diff --git a/install.sh b/install.sh index 925873e..6429b2c 100755 --- a/install.sh +++ b/install.sh @@ -149,7 +149,8 @@ uninstall_symlink() done } -install_crontab(){ +install_crontab() +{ if [[ -x $(command -v crontab) ]]; then fmt_note "installing \"$CRON_JOB\" to crontab ..." ( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - @@ -158,7 +159,8 @@ install_crontab(){ fi } -uninstall_crontab(){ +uninstall_crontab() +{ if [[ -x $(command -v crontab) ]]; then fmt_note "removing \"$CRON_JOB\" from crontab ..." ( crontab -l | grep -vxF "$CRON_JOB" ) | crontab - @@ -167,7 +169,8 @@ uninstall_crontab(){ fi } -install_tmux_tpm(){ +install_tmux_tpm() +{ TMUX_TPM="$HOME/.tmux/plugins/tpm" if [[ -x $(command -v tmux) && ! -d "$TMUX_TPM" ]]; then fmt_note "installing tmux tpm ..." @@ -186,7 +189,8 @@ install_tmux_tpm(){ fi } -install_vim_vundle(){ +install_vim_vundle() +{ VIM_VUNDLE="$HOME/.vim/bundle/Vundle.vim" if [[ -x $(command -v vim) && ! -d "$VIM_VUNDLE" ]]; then fmt_note "installing vim vundle ..." @@ -196,7 +200,8 @@ install_vim_vundle(){ fi } -install_update(){ +install_update() +{ fmt_note "installing update.sh ..." cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh" chmod +x "${DOTFILES}/update.sh" @@ -208,12 +213,14 @@ install_update(){ fi } -uninstall_update(){ +uninstall_update() +{ fmt_note "removing update.sh ..." rm "${DOTFILES}/update.sh" } -install(){ +install() +{ if [[ "$INSTALL_DEP" == "1" ]]; then install_dependencies; fi install_update preinstall_check @@ -227,7 +234,8 @@ install(){ fmt_note "done installing!" } -uninstall(){ +uninstall() +{ ask_for_yN "do you really want to uninstall?" if [[ $? != 1 ]]; then fmt_error "aborting this job ..." diff --git a/tools/alpine.sh b/tools/alpine.sh index 59d81c2..57f9b2e 100755 --- a/tools/alpine.sh +++ b/tools/alpine.sh @@ -1,20 +1,19 @@ #!/bin/bash - set -e +THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +source "$THIS_DIR/common.sh" set_mirror() { MIRROR=${1:-"mirrors.tuna.tsinghua.edu.cn"} - sed -i "s@dl-cdn.alpinelinux.org@$MIRROR@g" /etc/apk/repositories + sed -i "s@dl-cdn.alpinelinux.org@${MIRROR}@g" /etc/apk/repositories } apk_add() { apk update - # lite apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux - # full if [[ -z "$DFS_LITE" ]]; then apk add wget python3 py3-pip htop gcc g++ cmake make perl linux-headers bind-tools man-db diff --git a/tools/macos.sh b/tools/macos.sh index ff4e566..fca9e2a 100755 --- a/tools/macos.sh +++ b/tools/macos.sh @@ -1,6 +1,7 @@ #!/bin/bash - set -e +THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +source "$THIS_DIR/common.sh" brew_install() { diff --git a/tools/msys2.sh b/tools/msys2.sh index 00ed05d..350a789 100755 --- a/tools/msys2.sh +++ b/tools/msys2.sh @@ -1,6 +1,7 @@ #!/bin/bash - set -e +THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +source "$THIS_DIR/common.sh" set_mirror() { diff --git a/tools/ubuntu.sh b/tools/ubuntu.sh index ef753e4..88917b6 100755 --- a/tools/ubuntu.sh +++ b/tools/ubuntu.sh @@ -1,6 +1,7 @@ #!/bin/bash - set -e +THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +source "$THIS_DIR/common.sh" set_mirror() { @@ -12,10 +13,8 @@ set_mirror() apt_install() { apt-get update -y - # lite - apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils ca-certificates - + apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils # full 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