server-config/update.sh
Harsh Shandilya 8185fd7023
Update and streamline update script
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
2019-06-06 18:58:14 +05:30

29 lines
884 B
Bash
Executable file

#!/bin/bash
CL_RST="\033[0m"
CL_YLW="\033[01;33m"
function prettyPrint {
echo -e "${CL_YLW}${1}${CL_RST}"
}
# Grab all service names
declare -a services=('caddy' 'horbiswalls-bot' 'mirror-bot' 'uno-bot')
# Place the systemd unit files where they belong
prettyPrint "Copying systemd files to /etc/systemd/system"
for service in "${services[@]}"; do sudo cp -v "${service}.service" /etc/systemd/system/; done
# Reload systemctl so that it processes our changes
prettyPrint "Reloading systemctl daemon"
sudo systemctl daemon-reload
# Now loop through each service and restart it
for service in "${services[@]}"; do
prettyPrint "Restarting ${service}"
sudo service "${service}" restart
if [ ! -f "/etc/systemd/system/multi-user.target.wants/${service}.service" ]; then
prettyPrint "Enabling ${service}"
sudo systemctl enable "${service}"
fi
done