From 3a2383a5241995c139ed3bb83ce62a1649aaf241 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sat, 18 Nov 2023 15:56:43 -0800 Subject: [PATCH] Simplify systemd service files --- enable-services.sh | 9 ++------- freehl-cstrike.service | 22 ---------------------- freehl-gearbox.service | 22 ---------------------- freehl-hunger.service | 22 ---------------------- freehl-rewolf.service | 22 ---------------------- freehl-scihunt.service | 22 ---------------------- freehl-tfc.service | 22 ---------------------- freehl-valve.service => freehl.service | 2 +- freehl-dmc.service => freehl@.service | 4 ++-- restart-services.sh | 9 +++++---- 10 files changed, 10 insertions(+), 146 deletions(-) mode change 100755 => 100644 enable-services.sh delete mode 100644 freehl-cstrike.service delete mode 100644 freehl-gearbox.service delete mode 100644 freehl-hunger.service delete mode 100644 freehl-rewolf.service delete mode 100644 freehl-scihunt.service delete mode 100644 freehl-tfc.service rename freehl-valve.service => freehl.service (94%) rename freehl-dmc.service => freehl@.service (81%) diff --git a/enable-services.sh b/enable-services.sh old mode 100755 new mode 100644 index 1ee5b82..edfd211 --- a/enable-services.sh +++ b/enable-services.sh @@ -1,9 +1,4 @@ #!/bin/sh -SERVICE_DIR="/etc/systemd/system" - -find ./ -type f -name '*.service' -print | while read LINE -do - FILE=$(basename "$LINE" | cut -d '.' -f 1) - systemctl enable "$FILE" -done \ No newline at end of file +systemctl enable freehl +systemctl enable freehl@ \ No newline at end of file diff --git a/freehl-cstrike.service b/freehl-cstrike.service deleted file mode 100644 index 393671b..0000000 --- a/freehl-cstrike.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=FreeHL-CStrike - -[Service] -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 cstrike - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/freehl-gearbox.service b/freehl-gearbox.service deleted file mode 100644 index 7acd1f7..0000000 --- a/freehl-gearbox.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=FreeHL-Gearbox - -[Service] -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 gearbox - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/freehl-hunger.service b/freehl-hunger.service deleted file mode 100644 index 865edfe..0000000 --- a/freehl-hunger.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=FreeHL-Hunger - -[Service] -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 hunger - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/freehl-rewolf.service b/freehl-rewolf.service deleted file mode 100644 index 3b820f0..0000000 --- a/freehl-rewolf.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=FreeHL-Rewolf - -[Service] -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 rewolf - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/freehl-scihunt.service b/freehl-scihunt.service deleted file mode 100644 index 150adcb..0000000 --- a/freehl-scihunt.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=FreeHL-Scihunt - -[Service] -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 scihunt - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/freehl-tfc.service b/freehl-tfc.service deleted file mode 100644 index 4abb055..0000000 --- a/freehl-tfc.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=FreeHL-TFC - -[Service] -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 tfc - -PrivateTmp=true -ProtectHome=false -ProtectSystem=full -PrivateDevices=false -CapabilityBoundingSet=~CAP_SYS_ADMIN - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/freehl-valve.service b/freehl.service similarity index 94% rename from freehl-valve.service rename to freehl.service index 029f0d1..cdb1818 100644 --- a/freehl-valve.service +++ b/freehl.service @@ -1,5 +1,5 @@ [Unit] -Description=FreeHL-Valve +Description=FreeHL [Service] ExecReload=/bin/kill $MAINPID diff --git a/freehl-dmc.service b/freehl@.service similarity index 81% rename from freehl-dmc.service rename to freehl@.service index 8a75003..18522e8 100644 --- a/freehl-dmc.service +++ b/freehl@.service @@ -1,5 +1,5 @@ [Unit] -Description=FreeHL-DMC +Description=FreeHL-%I [Service] ExecReload=/bin/kill $MAINPID @@ -10,7 +10,7 @@ Restart=on-failure User=debian Environment="HOME=/home/debian" WorkingDirectory=/home/debian/halflife/ -ExecStart=/home/debian/halflife/fteqw-sv64 -halflife -game dmc +ExecStart=/home/debian/halflife/fteqw-sv64 -halflife -game %i PrivateTmp=true ProtectHome=false diff --git a/restart-services.sh b/restart-services.sh index 4425a39..f1fb190 100755 --- a/restart-services.sh +++ b/restart-services.sh @@ -1,9 +1,10 @@ #!/bin/sh -SERVICE_DIR="/etc/systemd/system" +systemctl restart freehl -find ./ -type f -name '*.service' -print | while read LINE +find ./ -type f -name "server.cfg" -print | while read LINE do - FILE=$(basename "$LINE" | cut -d '.' -f 1) - systemctl restart "$FILE" + GAMEDIR=$(dirname "$LINE" | cut -d '/' -f 2) + echo systemctl restart freehl@$GAMEDIR + ##systemctl restart "$FILE" done \ No newline at end of file