-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·138 lines (121 loc) · 2.5 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
set -e -u -o pipefail
# Vars
scriptname="$0"
orange='\033[1;33m'
NC='\033[0m'
ansible_flags=("")
export DEBIAN_FRONTEND="noninteractive"
if [[ $(whoami) == "root" ]]; then
echo "Don't run this script as root. Thank you."
exit 2
fi
msg() {
echo -e "${orange}${*}${NC}"
}
deps() {
msg "Updating"
sudo apt update -y
msg "Installing python-debs"
#shellcheck disable=1091
source /etc/os-release
if [[ ${ID} == "kali" ]]; then
sudo apt install -y python3.11-venv
else
sudo apt install -y python3-venv
fi
workdir=$(mktemp -d)
python3 -m venv "${workdir}/venv"
# shellcheck source=/dev/null
source "${workdir}/venv/bin/activate"
python_version="$(python3 -V | cut -d ' ' -f 2 )"
pip3 install ansible
ansible-galaxy collection install community.general ansible.posix
}
help() {
echo "${scriptname} [-d] [module]
A wrapper for my ansible setup scripts. Currently supported modules are:
- admin
- dev
- kali
Commands:
-h Help"
}
run() {
if [[ ! -d "./ansible/roles/base" ]]; then
msg "Could not find the necessary role, cloning into the temporary directory"
git clone --depth 1 --single-branch https://github.com/IamLunchbox/ansible-setup "${workdir}/setup"
cd "${workdir}/setup/ansible"
else
cd ./ansible
fi
msg "Running ansible now. You will be prompted for your sudo password"
if command -v ansible-playbook &>/dev/null; then
#shellcheck disable=2086,2048
ansible-playbook ${ansible_flags[*]} -K ${1}.yaml
elif [[ -x ${HOME}/.local/bin/ansible-playbook ]]; then
#shellcheck disable=2086,2048
${HOME}/.local/bin/ansible-playbook ${ansible_flags[*]} -K ${1}.yaml
else
msg "I could not find the ansible-playbook. Exiting."
exit 5
fi
}
#cleanup() {
#for part in ${@}; do
#case $part in
# "ansible")
# pip3 remove ansible
# ;;
# "pip")
# sudo apt remove -y python3-pip python3-venv
# ;;
#esac
#done
#}
if [[ $# == 0 ]] || [[ $# -gt 2 ]]; then
help
exit 1
fi
while [[ $# -gt 1 ]]; do
case "${1}" in
"-d"|"--debug")
ansible_flags+=("-v")
;;
*)
echo "An Unkown parameter was provided: ${1}"
;;
esac
shift
done
case "${1}" in
"dev")
deps
run "dev"
exit 0
;;
"admin")
deps
run "admin"
exit 0
;;
"kali")
deps
run "kali"
exit 0
;;
"core")
echo "Core is not supported yet"
exit 6
#run "core"
#cleanup "ansible" "pip"
;;
"-h"|"--help"|"help")
help
exit 0
;;
*)
help
exit 3
;;
esac