mirror of
https://github.com/msfjarvis/server-config
synced 2025-08-14 08:17:01 +05:30
Rewrite update script to fix shellcheck warnings
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
09cfd71230
commit
d4bcd98ea3
1 changed files with 11 additions and 11 deletions
22
update.sh
22
update.sh
|
@ -5,29 +5,29 @@ CL_YLW="\033[01;33m"
|
|||
|
||||
function reportWarning {
|
||||
echo -e ""
|
||||
echo -e ${CL_YLW}"${1}"${CL_RST}
|
||||
if [[ -z ${2} ]]; then
|
||||
echo -e "${CL_YLW}${1}${CL_RST}"
|
||||
if [[ -z "${2}" ]]; then
|
||||
echo -e ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Grab all service names
|
||||
services=$(ls *.service | cut -d '.' -f 1)
|
||||
declare -a services
|
||||
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
|
||||
reportWarning "Copying systemd files to /etc/systemd/system"
|
||||
sudo cp *.service /etc/systemd/system/
|
||||
for service in "${services[@]}"; do cp "${service}" /etc/systemd/system/; done
|
||||
|
||||
# Reload systemctl so that it processes our changes
|
||||
reportWarning "Reloading systemctl daemon"
|
||||
systemctl daemon-reload
|
||||
|
||||
# Sleep for 5 seconds to let systemctl get it's shit together
|
||||
sleep 5
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# Now loop through each service and restart it
|
||||
for service in ${services};do
|
||||
for service in "${services[@]}"; do
|
||||
reportWarning "Restarting ${service}"
|
||||
service ${service} restart
|
||||
[[ -f /etc/systemd/system/${service}.service ]] || systemctl enable ${service}
|
||||
service "${service}" restart
|
||||
[ -f "/etc/systemd/system/${service}.service" ] || systemctl enable "${service}"
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue