Created
July 17, 2022 23:29
-
-
Save nuvious/94824cf57bd1b11c1e583c549e99e1e4 to your computer and use it in GitHub Desktop.
LinuxGSM systemd configuraiton template for automatic server launching AND backup/update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NOTE: Before running this script, edit the templates and change the GAME_SERVER_NAME and | |
# GAME_SERVER_USER to the Linux gsm appropriate names/scripts. Also rename service | |
# and timer files to GAME_SERVER_USER(-backup/-update).(service/timer) | |
sudo cp *.service *.timer /lib/systemd/system | |
sudo systemctl daemon-reload | |
sudo systemctl enable GAME_SERVER | |
sudo systemctl enable GAME_SERVER-backup.timer | |
sudo systemctl enable GAME_SERVER-udpate.timer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=GAME_SERVER_NAME server backup | |
After=network-online.target | |
Wants=network-online.target | |
[Service] | |
Type=forking | |
User=GAME_SERVER_USER | |
Group=GAME_SERVER_USER | |
WorkingDirectory=/home/GAME_SERVER_USER | |
ExecStart=/home/GAME_SERVER_USER/GAME_SERVER_NAME backup | |
TimeoutSec=3600 # Backup may take a bit, so have a long timeout | |
Restart=no | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Run weekly backup | |
[Timer] | |
OnCalendar=Mon 05:00 # Replace with desired schedule | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=GAME_SERVER_NAME server update | |
After=network-online.target | |
Wants=network-online.target | |
[Service] | |
Type=forking | |
User=GAME_SERVER_USER | |
Group=GAME_SERVER_USER | |
WorkingDirectory=/home/GAME_SERVER_USER | |
ExecStart=/home/GAME_SERVER_USER/GAME_SERVER_NAME ul && /home/GAME_SERVER_USER/GAME_SERVER_NAME u | |
TimeoutSec=3600 # Updates may take a bit so have a long timeout | |
Restart=no | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Run weekly update | |
[Timer] | |
OnCalendar=Mon 06:00 # Replace with desired schedule | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=GAME_SERVER_NAME server | |
After=network-online.target | |
Wants=network-online.target | |
[Service] | |
Type=forking | |
User=GAME_SERVER_USER | |
Group=GAME_SERVER_USER | |
WorkingDirectory=/home/GAME_SERVER_USER | |
RemainAfterExit=yes #Assume that the service is running after main process exits with code 0 | |
ExecStart=/home/GAME_SERVER_USER/GAME_SERVER_NAME start | |
ExecStop=/home/GAME_SERVER_USER/GAME_SERVER_NAME stop | |
Restart=no | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment