-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-old.sh
executable file
·72 lines (62 loc) · 1.87 KB
/
install-old.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
#!/usr/bin/env bash
set -euo pipefail
ANSIBLE_URL="https://github.com/Oogy/replicator.git"
REPLICATOR_CONFIG_DIR="/opt/replicator"
if [ $# -eq 0 ]; then
BRANCH="main"
else
BRANCH=$1
fi
os_family(){
uname -s
}
safe_apt(){
while fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1 ; do
echo "+ Waiting for apt lock..."
sleep 1
done
apt "$@"
}
linux_dependencies(){
echo "+ doing linux things"
safe_apt -y update
safe_apt -y install python3-pip git
pip3 install ansible
echo "+ creating replicator config dir"
sudo mkdir -p ${REPLICATOR_CONFIG_DIR}
echo "+ Setting Ansible Vault Password"
read -s -p "Enter Ansible Vault Password: " VAULT_PASSWORD
echo ${VAULT_PASSWORD} > ${REPLICATOR_CONFIG_DIR}/vault-password
chmod 0600 $REPLICATOR_CONFIG_DIR/vault-password
}
mac_dependencies(){
echo "+ doing mac things"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install python git flock
python -m pip install ansible
}
dependencies(){
case $(os_family) in
Linux)
linux_dependencies
;;
Darwin)
mac_dependencies
;;
esac
}
install(){
case $(os_family) in
Linux)
sudo flock -n /tmp/replicator.lock -c "PYTHONUNBUFFERED=1 ANSIBLE_LOG_PATH=/var/log/ansible-workstation.log ANSIBLE_VAULT_PASSWORD_FILE=/opt/replicator/vault-password /usr/local/bin/ansible-pull -i ansible/hosts -U https://github.com/oogy/replicator.git ansible/main.yaml -C $BRANCH"
;;
Darwin)
flock -n /tmp/replicator.lock -c "PYTHONUNBUFFERED=1 ANSIBLE_LOG_PATH=/var/log/ansible-workstation.log /usr/local/bin/ansible-pull -i ansible/hosts -U https://github.com/oogy/replicator.git ansible/main.yaml -C $BRANCH"
;;
esac
}
main(){
dependencies
install
}
main