File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ commandname=" INITSYSTEM"
3+ commandaction=" systemd service file"
4+ functionselfname=" $( basename " $( readlink -f " ${BASH_SOURCE[0]} " ) " ) "
5+ fn_firstcommand_set
6+
7+ fn_install_systemd () {
8+ file_c=$' [Unit]
9+ Description=LinuxGSM gamename Server
10+ After=network-online.target
11+ Wants=network-online.target
12+
13+ [Service]
14+ Type=forking
15+ User=whoami
16+ ExecStart=path start
17+ ExecStop=path stop
18+ Restart=no
19+ RemainAfterExit=yes
20+
21+ [Install]
22+ WantedBy=multi-user.target'
23+ file_c=$( printf " $file_c " | sed s/' gamename' /$gamename /g | sed " s|path|$path |g" | sed s/' whoami' /$( whoami) /g)
24+ fn_print_ok_nl " Generated the file contents"
25+ fn_print_information_nl " Enter the password of root:"
26+ su -c " echo \" $file_c \" > /usr/lib/systemd/system/${selfname} -lgsm.service" || return 1 && return 0
27+ }
28+
29+ fn_install_systemd
30+ if [ $? -eq 1 ]
31+ then
32+ fn_print_error_nl " su exited with non 0 exit code.. something went wrong" ;
33+ fn_script_log_fatal " su exited with non 0 exit code."
34+ else
35+ fn_print_complete_nl " Placed the file in /usr/lib/systemd/system/ as ${selfname} -lgsm.service"
36+ fn_print_information_nl " run \` systemctl enable ${selfname} -lgsm.service\` , to enable the game on boot"
37+ fn_script_log_pass " sucessfullly installed the systemd service file"
38+ fi
39+ core_exit.sh
Original file line number Diff line number Diff line change @@ -742,6 +742,11 @@ functionfile="${FUNCNAME[0]}"
742742fn_fetch_function
743743}
744744
745+ command_install_init.sh () {
746+ functionfile=" ${FUNCNAME[0]} "
747+ fn_fetch_function
748+ }
749+
745750# Calls code required for legacy servers
746751core_legacy.sh
747752
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ cmd_update_linuxgsm=( "ul;update-lgsm;uf;update-functions" "command_update_linux
2121cmd_test_alert=( " ta;test-alert" " command_test_alert.sh" " Send a test alert." )
2222cmd_monitor=( " m;monitor" " command_monitor.sh" " Check server status and restart if crashed." )
2323cmd_donate=( " do;donate" " command_donate.sh" " Donation options." )
24+ cmd_install_init=(" ii;install-init" " command_install_init.sh" " Puts the service file in the right place" )
2425# Console servers only.
2526cmd_console=( " c;console" " command_console.sh" " Access server console." )
2627cmd_debug=( " d;debug" " command_debug.sh" " Start server directly in your terminal." )
@@ -130,7 +131,7 @@ if [ "${engine}" == "source" ]||[ "${shortname}" == "rust" ]||[ "${shortname}" =
130131fi
131132
132133# # Installer.
133- currentopt+=( " ${cmd_install[@]} " " ${cmd_auto_install[@]} " )
134+ currentopt+=( " ${cmd_install[@]} " " ${cmd_auto_install[@]} " " ${cmd_install_init[@]} " )
134135
135136# # Developer commands.
136137currentopt+=( " ${cmd_dev_debug[@]} " )
Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ if [ "${shortname}" == "core" ]; then
368368
369369# LinuxGSM server mode.
370370else
371+ path=" $( dirname $( readlink -f $0 ) ) /$( basename $0 ) "
371372 core_functions.sh
372373 if [ " ${shortname} " != " core-dep" ]; then
373374 # Load LinuxGSM configs.
You can’t perform that action at this time.
0 commit comments