diff --git a/systemd/installservice.sh b/systemd/installservice.sh index d75d2f4..d2dd6a3 100755 --- a/systemd/installservice.sh +++ b/systemd/installservice.sh @@ -1,8 +1,14 @@ #!/bin/bash -sudo cp /home/livecam/LiveCam/systemd/livecam-chch.service /etc/systemd/system/livecam-chch.service -sudo chmod 664 /etc/systemd/system/livecam-chch.service -# service enablen - startet so automatisch -sudo systemctl enable livecam-chch +if [ "$(id -u)" -ne 0 ]; then + exec sudo /bin/bash "$0" "$@" +fi +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cp $SCRIPT_DIR/livecam-chch.service /etc/systemd/system/livecam-chch.service +chmod 664 /etc/systemd/system/livecam-chch.service +systemctl daemon-reload +# enable and start service +systemctl enable livecam-chch +systemctl start livecam-chch