forked from rasendubi/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·44 lines (36 loc) · 1.07 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
FILES=".vimrc .vim .nvimrc .nvim .gitconfig .zshrc .zsh .tmux.conf .xxkbrc .Xresources .config/awesome .config/nvim .config/xxkb .nethackrc .emacs.d .ssh bin .config/zathura .irssi"
DEST=$1
if [ -z "$DEST" ]; then
DEST="$HOME"
fi
BASE=$(cd "$(dirname "$0")" && pwd)
ask_install() {
FILENAME=$1
LINK="$DEST/$FILENAME"
TARGET="$BASE/$FILENAME"
if [ -e $LINK ]; then
echo "$LINK exists. Skipping..."
else
read -r -p "Link $LINK to $TARGET? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
ln -v -s "$TARGET" "$LINK"
;;
esac
fi
}
for FILE in $FILES; do
ask_install $FILE
done
if [ ! -f "$BASE/.ssh/id_rsa" ]; then
read -r -p "$BASE/.ssh/id_rsa doesn't exist. Decrypt file? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
install -m 600 /dev/null "$BASE/.ssh/id_rsa"
gpg2 --output "$BASE/.ssh/id_rsa" --yes --decrypt "$BASE/.ssh/id_rsa.gpg"
;;
esac
else
echo "$BASE/.ssh/id_rsa exists. Skipping..."
fi