lgsm local mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
1.4 KiB

#!/bin/bash
# LinuxGSM command_install_init.sh function
# Author: legendofmiracles
# Website: https://linuxgsm.com
# Description: Installs the service files for systemd in the correct place.
commandname="INITSYSTEM"
commandaction="systemd service file"
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set
fn_install_systemd() {
file_c=$'[Unit]
Description=LinuxGSM gamename Server
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
User=whoami
ExecStart=path start
ExecStop=path stop
Restart=no
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target'
file_c=$(printf "$file_c" | sed s/'gamename'/$gamename/g | sed "s|path|$path|g" | sed s/'whoami'/$(whoami)/g)
fn_print_ok_nl "Generated the file contents"
fn_print_information_nl "Enter the password of root:"
su -c "echo \"$file_c\" > /etc/systemd/system/${selfname}-lgsm.service" || return 1 && return 0
}
fn_install_systemd
if [ $? -eq 1 ]
then
fn_print_error_nl "su exited with non 0 exit code.. something went wrong";
fn_script_log_fatal "su exited with non 0 exit code."
else
fn_print_complete_nl "Placed the file in /etc/systemd/system/ as ${selfname}-lgsm.service"
fn_print_information_nl "run \`systemctl enable ${selfname}-lgsm.service\` (as root), to enable the game on boot"
fn_script_log_pass "sucessfullly installed the systemd service file"
fi
core_exit.sh