aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2021-11-18 23:21:06 +0800
committerGuangxiong Lin <[email protected]>2021-11-18 23:21:06 +0800
commitc60297e6481019fb3d936b561596ba3bfda7db70 (patch)
tree67b3546ea4a33d8bd0c9755510b068a7855cc85e /scripts
parentaeba95ae383270b2c272ae6dde635b6d91999054 (diff)
downloaddotfiles-c60297e6481019fb3d936b561596ba3bfda7db70.tar.gz
dotfiles-c60297e6481019fb3d936b561596ba3bfda7db70.tar.bz2
dotfiles-c60297e6481019fb3d936b561596ba3bfda7db70.zip
Add backup scripts
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/backup.sh17
-rwxr-xr-xscripts/bootstrap.sh63
2 files changed, 80 insertions, 0 deletions
diff --git a/scripts/backup.sh b/scripts/backup.sh
new file mode 100755
index 0000000..51ab218
--- /dev/null
+++ b/scripts/backup.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+OPT="-aPh"
+EXCLUDE="--exclude-from=$HOME/.backup-exclude-list.txt"
+LINK="--link-dest=/snapshots/$USER/latest"
+SRC="/home/$USER/"
+SNAP="/snapshots/$USER/"
+LATEST="/snapshots/$USER/latest"
+date=$(date "+%Y-%b-%d:_%T")
+
+[ ! -d $SNAP ] && mkdir -p $SNAP
+
+
+rsync $OPT $LINK $EXCLUDE $SRC ${SNAP}$date
+
+rm -f $LATEST
+ln -s ${SNAP}$date $LATEST
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh
new file mode 100755
index 0000000..fdc8003
--- /dev/null
+++ b/scripts/bootstrap.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+
+dotfiles_dir=$(cd -- "$(dirname ${BASH_SOURCE})" > /dev/null 2>&1; pwd -P)
+
+remove_and_link () {
+ for var in $@
+ do
+ if [ -L $HOME/$var ] && [ -e $HOME/$var ] && \
+ [ "$(readlink -- $HOME/$var)" = "$dotfiles_dir/$var" ]; then
+ continue
+ fi
+
+ rm -rf $HOME/$var
+ ln -s $dotfiles_dir/$var $HOME/$var
+ echo "Linked: $HOME/$var -> $dotfiles_dir/$var"
+ done
+}
+
+link_all () {
+ remove_and_link .ctags.d .mutt bin .aliases .macos \
+ .mbsyncrc .msmtprc .tmux.conf .urlview .zshrc \
+ .vimrc .vim .path .functions .emacs.d .gitconfig \
+ .config/i3 .config/polybar .xinitrc .pam_environment \
+ .zprofile .newsboat .ledgerrc .nnnrc
+}
+
+main () {
+ if [ $# -eq 0 ] || [ $1 = 'all' ]; then
+ link_all
+ return
+ fi
+
+ if [ $1 = 'install' ]; then
+ install
+ return
+ fi
+
+ remove_and_link $@
+}
+
+install () {
+ if [ -f '/etc/arch-release' ]; then
+ arch_install
+ else
+ echo "No script for this OS"
+ fi
+}
+
+arch_install () {
+ sudo pacman -Syu git xorg-server xorg-xinit networkmanager alsa-utils \
+ openssh keepassxc bluez bluez-utils \
+ adobe-source-han-serif-cn-fonts adobe-source-han-sans-cn-fonts \
+ wqy-zenhei wqy-microhei wqy-microhei-lite wqy-bitmapfont \
+ noto-fonts-cjk noto-fonts-emoji noto-fonts-extra \
+ firefox steam \
+ fcitx5-im fcitx5-chinese-addons fcitx5-anthy fcitx5-pinyin-zhwiki \
+ i3-wm
+
+ echo 'Please remember to install GPU driver'
+}
+
+main $@
+