From b2765dc3fa497b8670bf244ba48440c69226da29 Mon Sep 17 00:00:00 2001 From: celso Date: Wed, 18 Dec 2024 10:51:48 -0300 Subject: [PATCH] added systemd services --- systemd/cstrike1.6.service | 21 ++++++++ systemd/diskconnectbot.service | 17 ++++++ systemd/factorio.service | 17 ++++++ systemd/gitea.service | 87 +++++++++++++++++++++++++++++++ systemd/openttd.service | 17 ++++++ systemd/steam-tmux-master.service | 13 +++++ systemd/syncplay.service | 16 ++++++ systemd/terraria.service | 17 ++++++ systemd/tpdnsbot.service | 17 ++++++ 9 files changed, 222 insertions(+) create mode 100644 systemd/cstrike1.6.service create mode 100644 systemd/diskconnectbot.service create mode 100644 systemd/factorio.service create mode 100644 systemd/gitea.service create mode 100644 systemd/openttd.service create mode 100644 systemd/steam-tmux-master.service create mode 100644 systemd/syncplay.service create mode 100644 systemd/terraria.service create mode 100644 systemd/tpdnsbot.service diff --git a/systemd/cstrike1.6.service b/systemd/cstrike1.6.service new file mode 100644 index 0000000..aab1da8 --- /dev/null +++ b/systemd/cstrike1.6.service @@ -0,0 +1,21 @@ +[Unit] +Description=dedicated counter-strike 1.6 server +Wants=network.target +PartOf=steam-tmux-master.service +After=steam-tmux-master.service + +[Service] +Type=oneshot +WorkingDirectory=/home/steam/counter-strike1.6 +User=steam +Group=steam +Environment=STEAMOS=1 +Environment=STEAM_RUNTIME=1 +Environment="DBUS_FATAL_WARNINGS=0" +Environment="ADMIN=STEAM_[REDACTED]" +RemainAfterExit=yes +ExecStart=/usr/bin/tmux new-session -s cstrike -d /home/steam/counter-strike1.6/start-server.sh +ExecStop=/usr/bin/tmux send-keys -t cstrike "/quit" Enter + +[Install] +WantedBy=multi-user.target diff --git a/systemd/diskconnectbot.service b/systemd/diskconnectbot.service new file mode 100644 index 0000000..d6278b8 --- /dev/null +++ b/systemd/diskconnectbot.service @@ -0,0 +1,17 @@ +[Unit] +Description=telegram disk monitoring bot +Wants=network.target + +[Service] +Type=forking +WorkingDirectory=/home/diskconnectbot/diskconnectbot +User=diskconnectbot +Group=diskconnectbot +RemainAfterExit=yes +Environment="TELEGRAM_DSK_TOKEN=[REDACTED]" +ExecStart=/usr/bin/tmux new-session -s diskconnectbot -d /home/diskconnectbot/diskconnectbot/bot.sh start +ExecStop=/usr/bin/tmux kill-session -t diskconnectbot +KillMode=none + +[Install] +WantedBy=multi-user.target diff --git a/systemd/factorio.service b/systemd/factorio.service new file mode 100644 index 0000000..8ad20d8 --- /dev/null +++ b/systemd/factorio.service @@ -0,0 +1,17 @@ +[Unit] +Description=factorio game server +Wants=network.target +PartOf=steam-tmux-master.service +After=steam-tmux-master.service + +[Service] +Type=oneshot +WorkingDirectory=/home/steam/factorio +User=steam +Group=steam +RemainAfterExit=yes +ExecStart=/usr/bin/tmux new-session -s factorio -d /home/steam/factorio/start-server.sh +ExecStop=/usr/bin/tmux send-keys -t factorio "/quit" Enter + +[Install] +WantedBy=multi-user.target diff --git a/systemd/gitea.service b/systemd/gitea.service new file mode 100644 index 0000000..c0e1ef2 --- /dev/null +++ b/systemd/gitea.service @@ -0,0 +1,87 @@ +[Unit] +Description=Gitea (Git with a cup of tea) +After=syslog.target +After=network.target +### +# Don't forget to add the database service dependencies +### +# +#Wants=mysql.service +#After=mysql.service + +Wants=mariadb.service +After=mariadb.service + +#Wants=postgresql.service +#After=postgresql.service + +#Wants=memcached.service +#After=memcached.service + +Wants=redis.service +After=redis.service +# +### +# If using socket activation for main http/s +### +# +#After=gitea.main.socket +#Requires=gitea.main.socket +# +### +# (You can also provide gitea an http fallback and/or ssh socket too) +# +# An example of /etc/systemd/system/gitea.main.socket +### +## +## [Unit] +## Description=Gitea Web Socket +## PartOf=gitea.service +## +## [Socket] +## Service=gitea.service +## ListenStream= +## NoDelay=true +## +## [Install] +## WantedBy=sockets.target +## +### + +[Service] +# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that +# LimitNOFILE=524288:524288 +RestartSec=2s +Type=notify +User=git +Group=git +WorkingDirectory=/var/lib/gitea/ +# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file +# (manually creating /run/gitea doesn't work, because it would not persist across reboots) +#RuntimeDirectory=gitea +ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini -p 3002 +Restart=always +Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea +WatchdogSec=30s +# If you install Git to directory prefix other than default PATH (which happens +# for example if you install other versions of Git side-to-side with +# distribution version), uncomment below line and add that prefix to PATH +# Don't forget to place git-lfs binary on the PATH below if you want to enable +# Git LFS support +#Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin +# If you want to bind Gitea to a port below 1024, uncomment +# the two values below, or use socket activation to pass Gitea its ports as above +### +#CapabilityBoundingSet=CAP_NET_BIND_SERVICE +#AmbientCapabilities=CAP_NET_BIND_SERVICE +### +# In some cases, when using CapabilityBoundingSet and AmbientCapabilities option, you may want to +# set the following value to false to allow capabilities to be applied on gitea process. The following +# value if set to true sandboxes gitea service and prevent any processes from running with privileges +# in the host user namespace. +### +#PrivateUsers=false +### + +[Install] +WantedBy=multi-user.target diff --git a/systemd/openttd.service b/systemd/openttd.service new file mode 100644 index 0000000..b377d69 --- /dev/null +++ b/systemd/openttd.service @@ -0,0 +1,17 @@ +[Unit] +Description=openttd game server +Wants=network.target +PartOf=steam-tmux-master.service +After=steam-tmux-master.service + +[Service] +Type=oneshot +WorkingDirectory=/home/steam +User=steam +Group=steam +RemainAfterExit=yes +ExecStart=/usr/bin/tmux new-session -s openttd -d "/usr/local/games/openttd -D 192.168.1.11:3979 -c /home/steam/.config/openttd/openttd.cfg -g /home/steam/.local/share/openttd/save/save.sav" +ExecStop=/usr/bin/tmux send-keys -t openttd "quit" Enter + +[Install] +WantedBy=multi-user.target diff --git a/systemd/steam-tmux-master.service b/systemd/steam-tmux-master.service new file mode 100644 index 0000000..11a2e70 --- /dev/null +++ b/systemd/steam-tmux-master.service @@ -0,0 +1,13 @@ +[Unit] +Description=tmux master service for the steam user + +[Service] +Type=forking +User=steam +Group=steam +ExecStart=/usr/bin/tmux start-server \; set -g exit-empty off +ExecStop=/usr/bin/tmux kill-server + +[Install] +WantedBy=multi-user.target + diff --git a/systemd/syncplay.service b/systemd/syncplay.service new file mode 100644 index 0000000..5f3d7a3 --- /dev/null +++ b/systemd/syncplay.service @@ -0,0 +1,16 @@ +[Unit] +Description=syncplay server +Wants=network.target + +[Service] +Type=forking +WorkingDirectory=/srv/syncplay +User=syncplay +Group=syncplay +RemainAfterExit=yes +ExecStart=/usr/bin/tmux new-session -s syncplay -d /srv/syncplay/autorun.sh +ExecStop=/usr/bin/tmux kill-server +KillMode=none + +[Install] +WantedBy=multi-user.target diff --git a/systemd/terraria.service b/systemd/terraria.service new file mode 100644 index 0000000..c3aba86 --- /dev/null +++ b/systemd/terraria.service @@ -0,0 +1,17 @@ +[Unit] +Description=terraria game server +Wants=network.target +PartOf=steam-tmux-master.service +After=steam-tmux-master.service + +[Service] +Type=oneshot +WorkingDirectory=/home/steam/terraria +User=steam +Group=steam +RemainAfterExit=yes +ExecStart=/usr/bin/tmux new-session -s terraria -d "/home/steam/terraria/start-server.sh" +ExecStop=/usr/bin/tmux send-keys -t terraria "/exit" Enter + +[Install] +WantedBy=multi-user.target diff --git a/systemd/tpdnsbot.service b/systemd/tpdnsbot.service new file mode 100644 index 0000000..e2eac3e --- /dev/null +++ b/systemd/tpdnsbot.service @@ -0,0 +1,17 @@ +[Unit] +Description=telegram personal DNS bot +Wants=network.target + +[Service] +Type=forking +WorkingDirectory=/home/tpdnsbot/tpdnsbot +User=tpdnsbot +Group=tpdnsbot +RemainAfterExit=yes +Environment="TELEGRAM_DNS_TOKEN=[REDACTED]" +ExecStart=/usr/bin/tmux new-session -s tpdnsbot -d /home/tpdnsbot/tpdnsbot/bot.sh start +ExecStop=/usr/bin/tmux kill-session -t tpdnsbot +KillMode=none + +[Install] +WantedBy=multi-user.target