-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·51 lines (43 loc) · 1.3 KB
/
main.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
#!/usr/bin/env bash
# Running this script will ensure that all dependencies
# are available and their services are running
# Define functions for missing dependencies
install_curl() {
echo "Installing curl..."
apt-get update
apt-get install -y curl
}
install_puppet() {
echo "Installing puppet..."
apt-get update
apt-get install -y puppet
}
# Check if the user is root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Check if the user has sudo privileges
if ! sudo -v; then
echo "This script must be run with sudo privileges"
exit 1
fi
# Check if the user has the required dependencies
for command in curl puppet; do
if ! command -v $command &> /dev/null; then
echo "Command $command is missing"
# Call the appropriate function to install the missing dependency
install_${command}
fi
done
# Check if the server is a load balancer
hostname="$(uname -n)"
if [[ "$hostname" == *lb* ]]; then
openssl enc -aes-256-cbc -iter 10000 -d -in ./load_balancer/config.cfg.enc -out ./load_balancer/config.cfg
./load_balancer/main.sh
fi
# Check if the server is a web server
if [[ "$hostname" == *web* ]]; then
openssl enc -aes-256-cbc -iter 10000 -d -in ./backend/default.enc -out ./backend/default
./backend/main.sh
fi