mirror of
https://github.com/msfjarvis/server-config
synced 2025-08-15 01:37:01 +05:30
Update and streamline update script
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
88c78f686d
commit
8185fd7023
1 changed files with 10 additions and 15 deletions
25
update.sh
25
update.sh
|
@ -3,32 +3,27 @@
|
||||||
CL_RST="\033[0m"
|
CL_RST="\033[0m"
|
||||||
CL_YLW="\033[01;33m"
|
CL_YLW="\033[01;33m"
|
||||||
|
|
||||||
function reportWarning {
|
function prettyPrint {
|
||||||
echo -e ""
|
|
||||||
echo -e "${CL_YLW}${1}${CL_RST}"
|
echo -e "${CL_YLW}${1}${CL_RST}"
|
||||||
if [[ -z "${2}" ]]; then
|
|
||||||
echo -e ""
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grab all service names
|
# Grab all service names
|
||||||
declare -a services
|
declare -a services=('caddy' 'horbiswalls-bot' 'mirror-bot' 'uno-bot')
|
||||||
while IFS= read -r -d $'\0'; do
|
|
||||||
services+=("$REPLY")
|
|
||||||
done < <(find . -name '*.service' -print0 | sed 's/\.\///g')
|
|
||||||
|
|
||||||
# Place the systemd unit files where they belong
|
# Place the systemd unit files where they belong
|
||||||
reportWarning "Copying systemd files to /etc/systemd/system"
|
prettyPrint "Copying systemd files to /etc/systemd/system"
|
||||||
for service in "${services[@]}"; do sudo cp "${service}" /etc/systemd/system/; done
|
for service in "${services[@]}"; do sudo cp -v "${service}.service" /etc/systemd/system/; done
|
||||||
|
|
||||||
# Reload systemctl so that it processes our changes
|
# Reload systemctl so that it processes our changes
|
||||||
reportWarning "Reloading systemctl daemon"
|
prettyPrint "Reloading systemctl daemon"
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
# Now loop through each service and restart it
|
# Now loop through each service and restart it
|
||||||
for service in "${services[@]}"; do
|
for service in "${services[@]}"; do
|
||||||
service="${service/.service/}"
|
prettyPrint "Restarting ${service}"
|
||||||
reportWarning "Restarting ${service}"
|
|
||||||
sudo service "${service}" restart
|
sudo service "${service}" restart
|
||||||
[ -f "/etc/systemd/system/multi-user.target.wants/${service}.service" ] && sudo systemctl enable "${service}"
|
if [ ! -f "/etc/systemd/system/multi-user.target.wants/${service}.service" ]; then
|
||||||
|
prettyPrint "Enabling ${service}"
|
||||||
|
sudo systemctl enable "${service}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue