forked from MadByteDE/SPT-Linux-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch-server.sh
More file actions
executable file
·39 lines (32 loc) · 1.37 KB
/
launch-server.sh
File metadata and controls
executable file
·39 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# # # # # # # # # # # # # # # # # # # # # # # #
# SPT - Server pre-launch script #
# v2025.10-3 #
# # # # # # # # # # # # # # # # # # # # # # # #
ROOT_PATH="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &>/dev/null && pwd )"
TERMINALS=( "alacritty" "ghostty" "foot" "terminator" "ptyxis" "cosmic-terminal"
"kgx" "konsole" "gnome-terminal" "xfce4-terminal" "kitty" "xterm" )
err() {
local msg="${1}" status=${2:-1}
if [[ status != 0 ]]; then
echo "ERROR: $msg (Exit code: $status)"
exit $status
fi
}
# NOTE: `aspnetcore-runtime` on the host system is not available from a sandboxed environment.
# Theirfore we use `flatpak-spawn --host` to launch the server on the host system.
# This might not work with some Wayland desktop portals e.g. `cinnamon/xapp`
m_run() {
if [[ -z "${FLATPAK_SANDBOX_DIR}" ]]; then "$@"
else flatpak-spawn --host "$@" || err "Command \"flatpak-spawn --host $@\" failed"; fi
}
if [[ -n $( m_run pidof "SPT.Server.Linux" ) ]]; then
err "Another instance of the server is already running"
fi
for term in "${TERMINALS[@]}"; do
if ! m_run command -v $term &>/dev/null; then continue; fi
cd "${ROOT_PATH}/SPT"
m_run $term -e "./SPT.Server.Linux" || err "Failed to run \"SPT.Server.Linux\""
exit
done
err "Failed to find a terminal emulator"