finish combination; get_os_name; macos.sh

This commit is contained in:
xiongdian.me 2022-12-03 16:26:50 +08:00
parent 104d1b1db3
commit df8eddf846
6 changed files with 57 additions and 30 deletions

View File

@ -29,30 +29,20 @@ HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2"
install_dependencies() install_dependencies()
{ {
fmt_note "installing dependencies ..." fmt_note "installing dependencies ..."
case $(get_os_type) in case $(get_os_name) in
"linux" ) "ubuntu"|"debian" )
case $(get_linux_dist) in DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/ubuntu.sh apt-install
"ubuntu"|"debian" ) ;;
$SUDO apt-get update "alpine" )
$SUDO apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/alpine.sh apk-add
;;
"alpine" )
$SUDO apk update
$SUDO apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux
;;
* ) fmt_error "dfs auto-install is not implemented on linux distribution: $(get_linux_dist)"
esac
;; ;;
"macos" ) "macos" )
$SUDO brew update DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/macos.sh brew-install
$SUDO brew install git zsh curl tmux vim util-linux
;; ;;
"msys" ) "msys" )
pacman -Syu DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/msys2.sh pacman-S
pacman -S tmux git zsh bash curl vim
SUDO=""
;; ;;
* ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_type)" * ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_name)"
esac esac
} }

View File

@ -12,9 +12,13 @@ apk_add()
{ {
apk update apk update
# mass installation # lite
apk add zsh git tmux vim curl wget bash python3 py3-pip htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils util-linux apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux
#for i in {fzf,ripgrep}; do apk add $i -y; done
# full
if [[ -z "$DFS_LITE" ]]; then
apk add wget python3 py3-pip htop gcc g++ cmake make perl linux-headers bind-tools man-db
fi
} }
set_timezone() set_timezone()

View File

@ -172,7 +172,8 @@ apost_beacon()
post_beacon "$@" 1>/dev/null & post_beacon "$@" 1>/dev/null &
} }
get_os_type() { get_os_type()
{
local ans="unknown" local ans="unknown"
case "$(uname -s)" in case "$(uname -s)" in
Darwin*) ans="MacOS";; Darwin*) ans="MacOS";;
@ -184,7 +185,8 @@ get_os_type() {
echo $ans | tr '[:upper:]' '[:lower:]' echo $ans | tr '[:upper:]' '[:lower:]'
} }
get_linux_dist() { get_linux_dist()
{
local ans="unknown" local ans="unknown"
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
@ -206,6 +208,15 @@ get_linux_dist() {
echo $ans | tr '[:upper:]' '[:lower:]' echo $ans | tr '[:upper:]' '[:lower:]'
} }
get_os_name()
{
local ans=$(get_os_type)
if [[ "$ans" == "linux" ]]; then
ans=$(get_linux_dist)
fi
echo $ans
}
# if bash-ed, else source-d # if bash-ed, else source-d
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
$1 "${@:2}" $1 "${@:2}"

19
tools/macos.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
brew_install()
{
brew update
brew install git zsh curl tmux vim util-linux
}
router()
{
case $1 in
brew_install ) brew_install ;;
* ) echo unknown command "$1". available: brew_install;;
esac
}
router $@

View File

@ -13,7 +13,12 @@ set_mirror()
pacman_S() pacman_S()
{ {
pacman -Syu pacman -Syu
pacman -S tmux git zsh curl vim wget base-devel mingw-w64-x86_64-toolchain make cmake gcc zip unzip python3 python3-pip man-pages-posix # lite
pacman -S tmux git zsh bash curl vim
# full
if [[ -z "$DFS_LITE" ]]; then
pacman -S wget base-devel mingw-w64-x86_64-toolchain make cmake gcc zip unzip python3 python3-pip man-pages-posix
fi
} }
router() router()

View File

@ -11,17 +11,15 @@ set_mirror()
apt_install() apt_install()
{ {
# basic packages apt-get update -y
apt-get update
for i in {man-db,vim,ca-certificates}; do apt-get install $i -y; done
# lite # lite
apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils ca-certificates
# full # full
if [[ -z "$DFS_LITE" ]]; then if [[ -z "$DFS_LITE" ]]; then
apt-get install wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron openssh-client openssh-server htop gcc g++ cmake make zip apt-get install wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron openssh-client openssh-server htop gcc g++ cmake make zip
for i in {fzf,ripgrep}; do apt-get install -y $i; done for i in {fzf,ripgrep,man-db}; do apt-get install -y $i; done
fi fi
} }