2017-10-02 23:41:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2017-10-03 17:08:22 +02:00
|
|
|
# Tiny script to install BOSWatch-service via systemctl
|
2017-10-02 23:41:57 +02:00
|
|
|
# Just a few simple steps are required to (un)register your service
|
|
|
|
|
|
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
|
echo "This script must be run as root!" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
read -p"Do you want to install (i) or remove (r) the service? " action
|
|
|
|
|
|
|
|
|
|
if [ "$action" == "i" ]; then
|
|
|
|
|
|
|
|
|
|
# 1 Check whether the right data are in the service-file
|
2017-10-03 17:08:22 +02:00
|
|
|
|
2017-10-02 23:41:57 +02:00
|
|
|
read -p"Did you adapt the file boswatch.service (y/n)? " response
|
2017-10-03 17:08:22 +02:00
|
|
|
|
2017-10-02 23:41:57 +02:00
|
|
|
if [ "$response" == "y" ]; then
|
|
|
|
|
# 2 Copy the file
|
|
|
|
|
cp boswatch.service /etc/systemd/system
|
|
|
|
|
|
|
|
|
|
# 3 Enable the service and check status
|
|
|
|
|
systemctl enable boswatch.service
|
|
|
|
|
systemctl is-enabled boswatch.service
|
|
|
|
|
|
|
|
|
|
# 4 fire it up
|
|
|
|
|
systemctl start boswatch.service
|
|
|
|
|
|
|
|
|
|
# 5 post the status
|
|
|
|
|
systemctl status boswatch.service
|
2017-10-03 17:08:22 +02:00
|
|
|
elif [ "$response" == "n" ]; then
|
2017-10-02 23:41:57 +02:00
|
|
|
echo "Please adapt your personal boswatch.service-file"
|
|
|
|
|
exit 1
|
2017-10-03 17:08:22 +02:00
|
|
|
else
|
|
|
|
|
echo "Invalid input - please try again"
|
|
|
|
|
exit 1
|
2017-10-02 23:41:57 +02:00
|
|
|
fi
|
2017-10-03 17:08:22 +02:00
|
|
|
elif [ "$action" == "r" ]; then # we want to remove the service
|
2017-10-02 23:41:57 +02:00
|
|
|
# stop it...
|
|
|
|
|
systemctl stop boswatch.service
|
2017-10-03 17:08:22 +02:00
|
|
|
|
2017-10-02 23:41:57 +02:00
|
|
|
# disable it
|
|
|
|
|
systemctl disable boswatch.service
|
|
|
|
|
|
|
|
|
|
# and remove it
|
|
|
|
|
rm /etc/systemd/system/boswatch.service
|
2018-11-01 13:20:28 +01:00
|
|
|
echo "BosWatch service removed"
|
2017-10-03 17:08:22 +02:00
|
|
|
else # error handling
|
|
|
|
|
echo "Invalid input - please try again"
|
|
|
|
|
exit 1
|
2017-10-02 23:41:57 +02:00
|
|
|
fi
|