-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·65 lines (51 loc) · 1.5 KB
/
install.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
#!/bin/bash
set -e
install_package() {
if ! command -v sudo &> /dev/null; then
echo "sudo is not installed. Please manually install $1."
exit 1
fi
if command -v zypper &> /dev/null; then
sudo zypper install -y "$1"
elif command -v apt &> /dev/null; then
sudo apt install -y "$1"
elif command -v dnf &> /dev/null; then
sudo dnf install -y "$1"
elif command -v pacman &> /dev/null; then
sudo pacman -Sy --noconfirm "$1"
else
echo "Unable to install package. No supported package manager found."
exit 1
fi
}
# Check if Ansible is installed
if ! command -v ansible &> /dev/null; then
install_package ansible
fi
# Check if git is installed
if ! command -v git &> /dev/null; then
install_package git
fi
if [ -z $PS1 ]; then
echo "About to run ansible-pull -U https://github.com/claudio4/dotfiles.git --ask-become-pass $@"
read -p "Continue? (y/n) " -n 1 -r
echo # move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
ask_pass="--ask-become-pass"
else
echo "Running ansible-pull -U https://github.com/claudio4/dotfiles.git \"$@\""
ask_pass=""
fi
if [[ -n $TAGS ]]; then
# Split the TAGS variable by spaces and prepend each tag with -t
IFS=' ' read -ra ADDR <<< "$TAGS"
tags=""
for i in "${ADDR[@]}"; do
tags+=" -t $i"
done
fi
# Run Ansible playbook using ansible-pull
ansible-pull -U https://github.com/claudio4/dotfiles.git $ask_pass $tags