This commit is contained in:
xiongdian.me 2022-12-03 20:28:16 +08:00
parent cefba82f1c
commit 4ab0472846
5 changed files with 26 additions and 18 deletions

View File

@ -149,7 +149,8 @@ uninstall_symlink()
done done
} }
install_crontab(){ install_crontab()
{
if [[ -x $(command -v crontab) ]]; then if [[ -x $(command -v crontab) ]]; then
fmt_note "installing \"$CRON_JOB\" to crontab ..." fmt_note "installing \"$CRON_JOB\" to crontab ..."
( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - ( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab -
@ -158,7 +159,8 @@ install_crontab(){
fi fi
} }
uninstall_crontab(){ uninstall_crontab()
{
if [[ -x $(command -v crontab) ]]; then if [[ -x $(command -v crontab) ]]; then
fmt_note "removing \"$CRON_JOB\" from crontab ..." fmt_note "removing \"$CRON_JOB\" from crontab ..."
( crontab -l | grep -vxF "$CRON_JOB" ) | crontab - ( crontab -l | grep -vxF "$CRON_JOB" ) | crontab -
@ -167,7 +169,8 @@ uninstall_crontab(){
fi fi
} }
install_tmux_tpm(){ install_tmux_tpm()
{
TMUX_TPM="$HOME/.tmux/plugins/tpm" TMUX_TPM="$HOME/.tmux/plugins/tpm"
if [[ -x $(command -v tmux) && ! -d "$TMUX_TPM" ]]; then if [[ -x $(command -v tmux) && ! -d "$TMUX_TPM" ]]; then
fmt_note "installing tmux tpm ..." fmt_note "installing tmux tpm ..."
@ -186,7 +189,8 @@ install_tmux_tpm(){
fi fi
} }
install_vim_vundle(){ install_vim_vundle()
{
VIM_VUNDLE="$HOME/.vim/bundle/Vundle.vim" VIM_VUNDLE="$HOME/.vim/bundle/Vundle.vim"
if [[ -x $(command -v vim) && ! -d "$VIM_VUNDLE" ]]; then if [[ -x $(command -v vim) && ! -d "$VIM_VUNDLE" ]]; then
fmt_note "installing vim vundle ..." fmt_note "installing vim vundle ..."
@ -196,7 +200,8 @@ install_vim_vundle(){
fi fi
} }
install_update(){ install_update()
{
fmt_note "installing update.sh ..." fmt_note "installing update.sh ..."
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh" cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
chmod +x "${DOTFILES}/update.sh" chmod +x "${DOTFILES}/update.sh"
@ -208,12 +213,14 @@ install_update(){
fi fi
} }
uninstall_update(){ uninstall_update()
{
fmt_note "removing update.sh ..." fmt_note "removing update.sh ..."
rm "${DOTFILES}/update.sh" rm "${DOTFILES}/update.sh"
} }
install(){ install()
{
if [[ "$INSTALL_DEP" == "1" ]]; then install_dependencies; fi if [[ "$INSTALL_DEP" == "1" ]]; then install_dependencies; fi
install_update install_update
preinstall_check preinstall_check
@ -227,7 +234,8 @@ install(){
fmt_note "done installing!" fmt_note "done installing!"
} }
uninstall(){ uninstall()
{
ask_for_yN "do you really want to uninstall?" ask_for_yN "do you really want to uninstall?"
if [[ $? != 1 ]]; then if [[ $? != 1 ]]; then
fmt_error "aborting this job ..." fmt_error "aborting this job ..."

View File

@ -1,20 +1,19 @@
#!/bin/bash #!/bin/bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh"
set_mirror() set_mirror()
{ {
MIRROR=${1:-"mirrors.tuna.tsinghua.edu.cn"} 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_add()
{ {
apk update apk update
# lite # lite
apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux
# full # full
if [[ -z "$DFS_LITE" ]]; then if [[ -z "$DFS_LITE" ]]; then
apk add wget python3 py3-pip htop gcc g++ cmake make perl linux-headers bind-tools man-db apk add wget python3 py3-pip htop gcc g++ cmake make perl linux-headers bind-tools man-db

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh"
brew_install() brew_install()
{ {

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh"
set_mirror() set_mirror()
{ {

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh"
set_mirror() set_mirror()
{ {
@ -12,10 +13,8 @@ set_mirror()
apt_install() apt_install()
{ {
apt-get update -y apt-get update -y
# lite # 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 # 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