You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This script serves two purposes: (OUTDATED; INCORRECT; CHANGEME PLEASE)
4
+
# 1. Installation: Creates and configures a systemd service (ssui.service) to run the StationeersServerControl (StationeersServerUI) application.
5
+
# 2. Runtime: When executed and Service already installed, finds and runs the latest StationeersServerControl binary (matching StationeersServerControlv*).
6
+
# The systemd service uses ExecStart=$SCRIPT_PATH to run this script, which then dynamically selects the latest binary version of SSUI to run.
7
+
# Check if running as root to prevent installing a service as root
8
+
9
+
if [[ $(id -u)= 0 ]];then
10
+
echo"For security reasons, it is not recommended to run this service as a root user."
11
+
exit 10
12
+
fi
13
+
14
+
# Check if systemd is available
15
+
if [[ !-d /run/systemd/system ]];then
16
+
echo"Error: systemd is not the active init system."
17
+
exit 2
18
+
fi
19
+
20
+
# Determine the full path of this script
21
+
SCRIPT_PATH=$(readlink -f "$0")
22
+
23
+
# Determine the base directory
24
+
BASEDIR=$(dirname "$SCRIPT_PATH")
25
+
if [[ -z"$BASEDIR"||!-d"$BASEDIR" ]];then
26
+
echo"Error: Could not determine base directory from SCRIPT_PATH: '$SCRIPT_PATH'."
27
+
exit 3
28
+
fi
29
+
30
+
31
+
USERNAME=$(whoami)
32
+
33
+
# Create the systemd service file pointing to this script
34
+
sudo tee /etc/systemd/system/stationeersserverui.service > /dev/null <<EOF
35
+
[Unit]
36
+
Description=Stationeers Server UI
37
+
After=network.target
38
+
39
+
[Service]
40
+
Type=simple
41
+
Restart=always
42
+
RestartSec=5s
43
+
User=$USERNAME
44
+
WorkingDirectory=$BASEDIR
45
+
ExecStart=$BASEDIR/StationeersServerUI
46
+
47
+
[Install]
48
+
WantedBy=multi-user.target
49
+
EOF
50
+
51
+
sudo chmod 0644 /etc/systemd/system/ssui.service
52
+
if [[ $?-ne 0 ]];then
53
+
echo"Error: Failed to set permissions on /etc/systemd/system/ssui.service."
54
+
exit 6
55
+
fi
56
+
57
+
# Reload systemd daemon
58
+
sudo systemctl daemon-reload
59
+
if [[ $?-ne 0 ]];then
60
+
echo"Error: Failed to reload systemd daemon."
61
+
exit 7
62
+
fi
63
+
64
+
# Enable the service
65
+
sudo systemctl enable ssui.service
66
+
if [[ $?-ne 0 ]];then
67
+
echo"Error: Failed to enable ssui.service."
68
+
exit 8
69
+
fi
70
+
71
+
# Start the service
72
+
sudo systemctl start ssui.service
73
+
if [[ $?-ne 0 ]];then
74
+
echo"Error: Failed to start ssui.service."
75
+
exit 9
76
+
fi
77
+
78
+
echo"Success! Service installed in '/etc/systemd/system/ssui.service'"
0 commit comments