-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·77 lines (64 loc) · 1.84 KB
/
bootstrap
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
#!/usr/bin/env bash
set -o
set -e pipefail
# Check for .dotfilesrc. if it doesn't exist exit with return value 2
if test -f ~/.dotfilesrc; then
source "$HOME"/.dotfilesrc
else
echo "ERROR: ~/.dotfilesrc does not exist"
exit 2
fi
banner() {
echo "========================================================================"
echo " $1"
echo "========================================================================"
}
install_pre_requisites() {
banner "Installing pre-requisites"
sudo apt update &&
sudo apt install -y \
git \
curl \
software-properties-common \
build-essential
}
copy_ssh_keys() {
banner "Copying SSH keys"
rsync -avz --files-from=<(printf "%s\n" "${DOTFILES_SSH_KEYS// /$'\n'}") "${DOTFILES_SSH_KEYS_HOST}:.ssh/" "${HOME}/.ssh"
}
configure_ssh() {
banner "Configuring SSH"
echo "IdentityFile ~/.ssh/$DOTFILES_SSH_KEYS_PRIMARY" >>~/.ssh/config
}
clone_git_repo() {
banner "Cloning git repo"
if test -d ~/dotfiles; then
echo "${HOME}/dotfiles already exists"
else
git clone git@github.com:steveclarke/dotfiles ~/dotfiles
fi
}
# [[ Entry Point ]]
if tput colors >/dev/null 2>&1 && [[ $(tput colors) -gt 0 ]]; then
echo -e "\033[0;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!\033[0m"
echo -e "\033[0;31m!!!!!!!!! WARNING !!!!!!!!!\033[0m"
echo -e "\033[0;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!\033[0m"
else
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!!!!!!!! WARNING !!!!!!!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi
echo -e "This script is designed to boostrap a fresh system and may overwrite existing files."
echo -e "Are you sure you want to proceed?"
echo -n "Do you want to proceed? (y/N): "
read answer
# convert answer to lowercase
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
if [ "$answer" = "y" ] || [ "$answer" = "yes" ]; then
install_pre_requisites
copy_ssh_keys
configure_ssh
clone_git_repo
else
echo "Exiting..."
fi