-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·118 lines (102 loc) · 2.62 KB
/
setup.sh
File metadata and controls
executable file
·118 lines (102 loc) · 2.62 KB
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
#!/bin/bash
#
# Title: setup.sh
# Author: Pelochus
# Version: 1.0
# Brief: Configures my personal homelab calling Ansible playbooks
#############
### Functions
#############
menu() {
echo "-------------------------------------------------------------------------------------------------"
echo
echo " ### MENU - Choose an option"
echo
echo " [1] Do everything"
echo " [2] Config OS"
echo " [3] Deploy Software"
echo " [4] Exit"
echo
echo "-------------------------------------------------------------------------------------------------"
}
options() {
case $1 in
# Do something
2 | 1)
ansible-playbook -K os-config.yml
;;&
# This "&" makes it possible to execute following options
# Do something 2
3 | 1)
ansible-playbook -K software-deploy.yml
;;
# Exit
4)
echo
echo "-----------"
echo "Exiting now"
echo "-----------"
echo
exit
;;
esac
}
########
### Main
########
clear
# Run with parameters
if [ $# -gt 0 ]
then
if [ $1 == '-h' ] || [ $1 == '--help' ]
then
echo
echo "pelochus-homelab Template Script Help"
echo
echo "-a / --auto: Runs all options that don't require user's help. Needs root privileges"
echo "-h / --help: Shows this help screen"
echo
echo "For more information visit https://github.com/Pelochus/pelochus-homelab"
echo
exit
elif [ $1 == '-a' ] || [ $1 == '--auto' ]
then
options 1
echo
echo "//////////////////////////////"
echo "Finished automatic deployment!"
echo "//////////////////////////////"
echo
exit
fi
fi
echo
echo "-------------------------------------------------------------------------------------"
echo "This script calls the Ansible playbooks responsible for deploying the homelab"
echo "You should not need to run this as sudo, but it will ask the sudo password"
echo "Continue? [Y/N]"
echo "-------------------------------------------------------------------------------------"
echo
read continue
if [ $continue == 'Y' ] || [ $continue == 'y' ]
then
clear
echo "-----------------------------------"
echo "Checking if Ansible is installed..."
echo "-----------------------------------"
apt install ansible -y
clear
cd ansible
while true
do
menu
read chosen
options $chosen
done
else
echo
echo "-----------"
echo "Exiting now"
echo "-----------"
echo
fi