From 0207013b81316b25b71aaa3956b07a3ea912441d Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sat, 18 Nov 2023 16:07:09 -0800 Subject: [PATCH] Change to user service files --- disable-services.sh | 2 +- enable-services.sh | 9 +++++++-- freehl.service | 16 ++++------------ freehl@.service | 16 ++++------------ install-services.sh | 2 +- restart-services.sh | 5 ++--- stop-services.sh | 13 +++++++++++++ 7 files changed, 32 insertions(+), 31 deletions(-) create mode 100755 stop-services.sh diff --git a/disable-services.sh b/disable-services.sh index c22f6b1..a811ddc 100755 --- a/disable-services.sh +++ b/disable-services.sh @@ -5,5 +5,5 @@ systemctl disable freehl find ./ -type f -name "server.cfg" -print | while read LINE do GAMEDIR=$(dirname "$LINE" | cut -d '/' -f 2) - echo systemctl disable freehl@$GAMEDIR + systemctl --user disable freehl@$GAMEDIR done \ No newline at end of file diff --git a/enable-services.sh b/enable-services.sh index edfd211..e68e894 100755 --- a/enable-services.sh +++ b/enable-services.sh @@ -1,4 +1,9 @@ #!/bin/sh -systemctl enable freehl -systemctl enable freehl@ \ No newline at end of file +systemctl --user enable freehl + +find ./ -type f -name "server.cfg" -print | while read LINE +do + GAMEDIR=$(dirname "$LINE" | cut -d '/' -f 2) + systemctl --user enable freehl@$GAMEDIR +done \ No newline at end of file diff --git a/freehl.service b/freehl.service index cdb1818..31746a1 100644 --- a/freehl.service +++ b/freehl.service @@ -6,17 +6,9 @@ ExecReload=/bin/kill $MAINPID KillMode=process Restart=on-failure -; You want to adjust these for your user, this example assumes debian -User=debian -Environment="HOME=/home/debian" -WorkingDirectory=/home/debian/halflife/ -ExecStart=/home/debian/halflife/fteqw-sv64 -halflife - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN +; You want to adjust these for your setup +WorkingDirectory=%h/halflife/ +ExecStart=%h/halflife/fteqw-sv64 -halflife [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=default.target \ No newline at end of file diff --git a/freehl@.service b/freehl@.service index 18522e8..57a79b4 100644 --- a/freehl@.service +++ b/freehl@.service @@ -6,17 +6,9 @@ ExecReload=/bin/kill $MAINPID KillMode=process Restart=on-failure -; You want to adjust these for your user, this example assumes debian -User=debian -Environment="HOME=/home/debian" -WorkingDirectory=/home/debian/halflife/ -ExecStart=/home/debian/halflife/fteqw-sv64 -halflife -game %i - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN +; You want to adjust these for your setup +WorkingDirectory=%h/halflife/ +ExecStart=%h/halflife/fteqw-sv64 -halflife -game %i [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=default.target \ No newline at end of file diff --git a/install-services.sh b/install-services.sh index 0b90514..cd111f5 100755 --- a/install-services.sh +++ b/install-services.sh @@ -1,6 +1,6 @@ #!/bin/sh -SERVICE_DIR="/etc/systemd/system" +SERVICE_DIR="/etc/systemd/user" find ./ -type f -name '*.service' -print | while read LINE do diff --git a/restart-services.sh b/restart-services.sh index f1fb190..53aca0d 100755 --- a/restart-services.sh +++ b/restart-services.sh @@ -1,10 +1,9 @@ #!/bin/sh -systemctl restart freehl +systemctl --user restart freehl find ./ -type f -name "server.cfg" -print | while read LINE do GAMEDIR=$(dirname "$LINE" | cut -d '/' -f 2) - echo systemctl restart freehl@$GAMEDIR - ##systemctl restart "$FILE" + systemctl --user restart freehl@$GAMEDIR done \ No newline at end of file diff --git a/stop-services.sh b/stop-services.sh new file mode 100755 index 0000000..370c8c6 --- /dev/null +++ b/stop-services.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +systemctl --user restart freehl + +find ./ -type f -name "server.cfg" -print | while read LINE +do + GAMEDIR=$(dirname "$LINE" | cut -d '/' -f 2) + + if [ "$GAMEDIR" != "valve" ] + then + systemctl --user restart freehl@$GAMEDIR + fi +done \ No newline at end of file