-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup-linux.sh
executable file
·93 lines (65 loc) · 1.91 KB
/
setup-linux.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
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
#!/usr/bin/env bash
SECONDS=0
# DEFAULTS
DO_MAS=${DO_MAS:-false}
ASK_PASS=${ASK_PASS:-true}
DO_POST_INSTALL=${DO_POST_INSTALL:-true}
DEBUG=${DEBUG:-false}
if [ -z "$DOTFILES_VERSION" ]; then
DOTFILES_VERSION=${1:-master}
fi
ANSIBLE_TAGS=${ANSIBLE_TAGS:-all,do_pacman,do_packages}
ANSIBLE_FLAGS=-v
if [[ "$DO_MAS" == true ]]; then
ANSIBLE_TAGS="${ANSIBLE_TAGS},do_mas"
fi
if [[ "$ASK_PASS" == true ]]; then
# Ask for sudo password (possibly required for homebrew role)
ANSIBLE_FLAGS="${ANSIBLE_FLAGS} -K"
fi
if [[ "$DEBUG" == true ]]; then
set -x
fi
set -eo pipefail
export DOTFILES_REPO="https://github.com/eliasnorrby/dotfiles"
export TARBALL_URL="$DOTFILES_REPO/tarball/$DOTFILES_VERSION"
export DOTFILES=~/.dotfiles
function _msg() { printf "\r\033[2K\033[0;32m[ SETUP ] %s\033[0m\n" "$*"; }
function _prompt() {
_msg "$1"
read -p "[ ..... ] Press Enter to continue"
}
function get_repo_snapshot() {
_msg "Downloading repository snapshot from eliasnorrby/dotfiles@$DOTFILES_VERSION..."
curl -sL "$TARBALL_URL" | tar xz
}
function install_ansible_and_roles() {
_msg "Installing ansible and required roles..."
sudo pacman -S ansible
ansible-galaxy install -r requirements.yml
_msg "Done!"
}
function run_playbook() {
_msg "Running the playbook..."
ansible-playbook playbook.yml --tags "$ANSIBLE_TAGS" $ANSIBLE_FLAGS
}
function print_duration() {
ELAPSED="$((SECONDS / 3600))hrs $(((SECONDS / 60) % 60))min $((SECONDS % 60))sec"
_mg "Setup completed in $ELAPSED"
}
_prompt "Next step: downloading repo"
cd "$(mktemp -d)"
get_repo_snapshot
cd eliasnorrby-dotfiles*
cd _provision
_prompt "Next step: installing ansible and roles"
install_ansible_and_roles
_prompt "Next step: running playbook"
run_playbook
_prompt "Next step: running post-install script"
if [[ "$DO_POST_INSTALL" == true ]]; then
_msg "Running post-install script..."
cd "$DOTFILES"
./post-install.zsh
fi
_msg "Done!"