File tree 4 files changed +47
-1
lines changed
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]}"
742
742
fn_fetch_function
743
743
}
744
744
745
+ command_install_init.sh () {
746
+ functionfile=" ${FUNCNAME[0]} "
747
+ fn_fetch_function
748
+ }
749
+
745
750
# Calls code required for legacy servers
746
751
core_legacy.sh
747
752
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
21
21
cmd_test_alert=( " ta;test-alert" " command_test_alert.sh" " Send a test alert." )
22
22
cmd_monitor=( " m;monitor" " command_monitor.sh" " Check server status and restart if crashed." )
23
23
cmd_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" )
24
25
# Console servers only.
25
26
cmd_console=( " c;console" " command_console.sh" " Access server console." )
26
27
cmd_debug=( " d;debug" " command_debug.sh" " Start server directly in your terminal." )
@@ -130,7 +131,7 @@ if [ "${engine}" == "source" ]||[ "${shortname}" == "rust" ]||[ "${shortname}" =
130
131
fi
131
132
132
133
# # Installer.
133
- currentopt+=( " ${cmd_install[@]} " " ${cmd_auto_install[@]} " )
134
+ currentopt+=( " ${cmd_install[@]} " " ${cmd_auto_install[@]} " " ${cmd_install_init[@]} " )
134
135
135
136
# # Developer commands.
136
137
currentopt+=( " ${cmd_dev_debug[@]} " )
Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ if [ "${shortname}" == "core" ]; then
368
368
369
369
# LinuxGSM server mode.
370
370
else
371
+ path=" $( dirname $( readlink -f $0 ) ) /$( basename $0 ) "
371
372
core_functions.sh
372
373
if [ " ${shortname} " != " core-dep" ]; then
373
374
# Load LinuxGSM configs.
You can’t perform that action at this time.
0 commit comments