-
Notifications
You must be signed in to change notification settings - Fork 4
/
install
executable file
·93 lines (81 loc) · 3.21 KB
/
install
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
DEPENDENCIES_OK=true
declare -a MISSING
echo -n "Checking dependencies..."
command -v git >/dev/null 2>&1 \
|| DEPENDENCIES_OK=false MISSING=("${MISSING[@]}" "git")
command -v zsh >/dev/null 2>&1 \
|| DEPENDENCIES_OK=false MISSING=("${MISSING[@]}" "zsh")
command -v tmux >/dev/null 2>&1 \
|| DEPENDENCIES_OK=false MISSING=("${MISSING[@]}" "tmux")
command -v vim >/dev/null 2>&1 \
|| DEPENDENCIES_OK=false MISSING=("${MISSING[@]}" "vim")
if [[ "$DEPENDENCIES_OK" == "true" ]]; then
echo "passed."
else
echo "failed!"
echo "Missing dependencies: ${MISSING[@]}"
exit 1
fi
RELATIVE_PATH="$(dirname "$0")"
FULL_PATH="$(cd "$RELATIVE_PATH" && pwd)"
BACKUP_FOLDER="$FULL_PATH/install-backup/$(date +%Y%m%d%H%M%S)"
mkdir -p $BACKUP_FOLDER
mkdir -p $BACKUP_FOLDER/docker
echo -n "Backing up previous configuration files..."
mv $HOME/.bashrc $BACKUP_FOLDER || true
mv $HOME/.bash_aliases $BACKUP_FOLDER || true
mv $HOME/.zshrc $BACKUP_FOLDER || true
mv $HOME/.vim $BACKUP_FOLDER || true
mv $HOME/.vimrc $BACKUP_FOLDER || true
mv $HOME/.tmux.conf $BACKUP_FOLDER || true
mv $HOME/.gitconfig $BACKUP_FOLDER || true
mv $HOME/.gitattributes $BACKUP_FOLDER || true
mv $HOME/.terraformrc $BACKUP_FOLDER || true
cp $FULL_PATH/zsh/private.zsh $BACKUP_FOLDER || true
cp $FULL_PATH/git/user.inc $BACKUP_FOLDER || true
cp /etc/docker/daemon.json $BACKUP_FOLDER/docker || true
echo "done."
echo -n "Creating the symlinks..."
ln -sT $FULL_PATH $HOME/.myutilitybelt
ln -sT $FULL_PATH/vim $HOME/.vim
ln -s $FULL_PATH/bash/bashrc $HOME/.bashrc
ln -s $FULL_PATH/bash/bash_aliases $HOME/.bash_aliases
ln -s $FULL_PATH/zsh/zshrc $HOME/.zshrc
ln -s $FULL_PATH/vim/vimrc $HOME/.vimrc
ln -s $FULL_PATH/tmux/tmux.conf $HOME/.tmux.conf
ln -s $FULL_PATH/git/gitconfig $HOME/.gitconfig
ln -s $FULL_PATH/git/gitattributes $HOME/.gitattributes
ln -s $FULL_PATH/terraform/terraformrc $HOME/.terraformrc
ln -s $FULL_PATH/docker/daemon.json /etc/docker/daemon.json
echo "done."
echo "Collecting user data for private.zsh vars:"
read -e -p "GPGKEY [$GPGKEY]:" INPUT_GPGKEY
GPGKEY="${INPUT_GPGKEY:-${GPGKEY}}"
read -e -p "GITHUB_USERNAME [$GITHUB_USERNAME]:" INPUT_GITHUB_USERNAME
GITHUB_USERNAME="${INPUT_GITHUB_USERNAME:-${GITHUB_USERNAME}}"
read -e -p "GITHUB_ACCESS_TOKEN [$GITHUB_ACCESS_TOKEN]:" INPUT_GITHUB_ACCESS_TOKEN
GITHUB_ACCESS_TOKEN="${INPUT_GITHUB_ACCESS_TOKEN:-${GITHUB_ACCESS_TOKEN}}"
cat <<EOT > $FULL_PATH/zsh/private.zsh
export GPGKEY=$GPGKEY
export GITHUB_USERNAME=$GITHUB_USERNAME
export GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN
EOT
echo "Collecting user data for git config"
GIT_USER_NAME=$(git config user.name)
read -e -p "Git user.name [$GIT_USER_NAME]:" INPUT_GIT_USER_NAME
GIT_USER_NAME="${INPUT_GIT_USER_NAME:-${GIT_USER_NAME}}"
GIT_USER_EMAIL=$(git config user.email)
read -e -p "Git user.email [$GIT_USER_EMAIL]:" INPUT_GIT_USER_EMAIL
GIT_USER_EMAIL="${INPUT_GIT_USER_EMAIL:-${GIT_USER_EMAIL}}"
cat <<EOT > $FULL_PATH/git/user.inc
[user]
name = $GIT_USER_NAME
email = $GIT_USER_EMAIL
EOT
echo -n "Installing Vim plugins..."
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim -N -u $HOME/.vim/vundle.vim -c ':BundleCleanInstallQuit'
echo "done."
echo "--- Installation of myutilitybelt complete ---"
exit 0