11#! /usr/bin/env bash
22# SPDX-License-Identifier: PMPL-1.0-or-later
33#
4- # install-desktop.sh — Install Stapeln desktop entry, icon, and launcher on Linux.
4+ # install-desktop.sh — Install GSA desktop entry, icon, and launcher on Linux.
55#
66# Usage:
77# ./scripts/install-desktop.sh # Install
1111
1212set -euo pipefail
1313
14- APP_NAME=" gsa "
14+ APP_NAME=" game-server-admin "
1515APP_DISPLAY=" Game Server Admin"
16- APP_PORT=" 8080 "
17- APP_DESC=" Game Server Administration "
16+ APP_PORT=" 8090 "
17+ APP_DESC=" Universal game server probe, config management, and administration "
1818
1919REPO_DIR=" $( cd " $( dirname " $0 " ) /.." && pwd) "
2020DESKTOP_FILE=" $REPO_DIR /${APP_NAME} .desktop"
@@ -43,8 +43,13 @@ echo "Installing ${APP_DISPLAY}..."
4343mkdir -p " $APPS_DIR " " $ICON_DIR " " $BIN_DIR "
4444
4545# Copy desktop file
46- cp " $DESKTOP_FILE " " $APPS_DIR /${APP_NAME} .desktop"
47- echo " + Desktop entry -> $APPS_DIR /${APP_NAME} .desktop"
46+ if [[ -f " $DESKTOP_FILE " ]]; then
47+ cp " $DESKTOP_FILE " " $APPS_DIR /${APP_NAME} .desktop"
48+ echo " + Desktop entry -> $APPS_DIR /${APP_NAME} .desktop"
49+ else
50+ echo " ! Desktop file not found at $DESKTOP_FILE "
51+ exit 1
52+ fi
4853
4954# Copy icon if available
5055if [[ -f " $REPO_DIR /assets/icon-256.png" ]]; then
6166cat > " $LAUNCHER " << LAUNCHER_EOF
6267#!/usr/bin/env bash
6368# SPDX-License-Identifier: PMPL-1.0-or-later
64- # ${APP_DISPLAY} Launcher
69+ # ${APP_DISPLAY} Launcher — Gossamer GUI for game server administration
6570set -euo pipefail
6671
6772REPO_DIR="$REPO_DIR "
73+ FFI_DIR="\$ REPO_DIR/src/interface/ffi"
74+ VERISIMDB_URL="\$ {GSA_VERISIMDB_URL:-http://[::1]:${APP_PORT} }"
75+ PROFILES_DIR="\$ {GSA_PROFILES_DIR:-\$ REPO_DIR/profiles}"
6876MODE="\$ {1:---auto}"
6977
70- start_server() {
71- if ! curl -s http://localhost:${APP_PORT} >/dev/null 2>&1; then
72- echo "Starting ${APP_DISPLAY} server..."
73- cd "\$ REPO_DIR"
74- nohup deno task dev > /tmp/${APP_NAME} -server.log 2>&1 &
75- echo \$ ! > /tmp/${APP_NAME} -server.pid
76- for i in {1..30}; do
77- curl -s http://localhost:${APP_PORT} >/dev/null 2>&1 && break
78- sleep 0.5
79- done
78+ # Check VeriSimDB is running
79+ check_verisimdb() {
80+ if curl -sf "\$ VERISIMDB_URL/health" >/dev/null 2>&1; then
81+ return 0
82+ else
83+ echo "VeriSimDB not reachable at \$ VERISIMDB_URL"
84+ echo "Start it with: systemctl --user start gsa-verisimdb"
85+ echo "Or: podman start gsa-verisimdb"
86+ return 1
8087 fi
8188}
8289
83- open_client() {
84- xdg-open "http://localhost:${APP_PORT} " 2>/dev/null || \
85- echo "Open http://localhost:${APP_PORT} in your browser"
90+ # Build libgsa.so if not already built
91+ build_ffi() {
92+ if [[ ! -f "\$ FFI_DIR/zig-out/lib/libgsa.so" ]]; then
93+ echo "Building libgsa.so..."
94+ cd "\$ FFI_DIR"
95+ zig build
96+ echo "Built: \$ FFI_DIR/zig-out/lib/libgsa.so"
97+ fi
8698}
8799
88- stop_server() {
89- if [[ -f /tmp/${APP_NAME} -server.pid ]]; then
90- kill "\$ (cat /tmp/${APP_NAME} -server.pid)" 2>/dev/null || true
91- rm -f /tmp/${APP_NAME} -server.pid
92- echo "${APP_DISPLAY} server stopped."
100+ # Launch via Gossamer webview (native desktop)
101+ launch_gossamer() {
102+ build_ffi
103+ export LD_LIBRARY_PATH="\$ FFI_DIR/zig-out/lib:\$ {LD_LIBRARY_PATH:-}"
104+ export GSA_VERISIMDB_URL="\$ VERISIMDB_URL"
105+ export GSA_PROFILES_DIR="\$ PROFILES_DIR"
106+
107+ if command -v gossamer &>/dev/null; then
108+ exec gossamer \\
109+ --load "\$ FFI_DIR/zig-out/lib/libgsa.so" \\
110+ --html "\$ REPO_DIR/src/gui/host.html" \\
111+ --title "${APP_DISPLAY} " \\
112+ --width 1400 --height 900
113+ else
114+ echo "gossamer binary not found in PATH"
115+ echo "Falling back to browser mode..."
116+ launch_web
93117 fi
94118}
95119
120+ # Launch web interface (opens browser to panel host)
121+ launch_web() {
122+ echo "Opening ${APP_DISPLAY} in browser..."
123+ local host_html="\$ REPO_DIR/src/gui/host.html"
124+ if [[ -f "\$ host_html" ]]; then
125+ xdg-open "file://\$ host_html" 2>/dev/null || \\
126+ echo "Open file://\$ host_html in your browser"
127+ else
128+ echo "Panel host HTML not found at \$ host_html"
129+ exit 1
130+ fi
131+ }
132+
133+ # Stop VeriSimDB
134+ stop_services() {
135+ echo "Stopping ${APP_DISPLAY} services..."
136+ systemctl --user stop gsa-verisimdb 2>/dev/null || \\
137+ podman stop gsa-verisimdb 2>/dev/null || \\
138+ echo "No running services found."
139+ echo "Done."
140+ }
141+
96142case "\$ MODE" in
97143 --gossamer)
98- start_server
99- if command -v gossamer &>/dev/null; then
100- exec gossamer --url "http://localhost:${APP_PORT} " --title "${APP_DISPLAY} "
101- else
102- open_client
103- fi
144+ check_verisimdb || true
145+ launch_gossamer
104146 ;;
105147 --web)
106- start_server
107- open_client
148+ check_verisimdb || true
149+ launch_web
108150 ;;
109151 --stop)
110- stop_server
152+ stop_services
111153 ;;
112154 --auto|*)
113- start_server
114- if command -v gossamer &>/dev/null; then
115- exec gossamer --url "http://localhost:${APP_PORT} " --title "${APP_DISPLAY} "
116- else
117- open_client
118- fi
155+ check_verisimdb || true
156+ launch_gossamer
119157 ;;
120158esac
121159LAUNCHER_EOF
@@ -131,6 +169,7 @@ cat > "$CONFIG_FILE" << CONF_EOF
131169install_dir=$REPO_DIR
132170install_type=user
133171os=linux
172+ verisimdb_port=${APP_PORT}
134173installed_at=$( date -Iseconds)
135174CONF_EOF
136175echo " + Config -> $CONFIG_FILE "
@@ -142,10 +181,15 @@ gtk-update-icon-cache "$HOME/.local/share/icons/hicolor/" 2>/dev/null || true
142181echo " "
143182echo " Done! ${APP_DISPLAY} is now available in your application menu."
144183echo " "
184+ echo " Prerequisites:"
185+ echo " 1. Build Zig FFI: cd src/interface/ffi && zig build"
186+ echo " 2. Start VeriSimDB: systemctl --user start gsa-verisimdb"
187+ echo " 3. Install Gossamer for native desktop mode (optional)"
188+ echo " "
145189echo " Commands:"
146190echo " ${APP_NAME} -launcher # Start (auto-detect Gossamer/browser)"
147191echo " ${APP_NAME} -launcher --web # Force browser mode"
148192echo " ${APP_NAME} -launcher --gossamer # Force Gossamer mode"
149- echo " ${APP_NAME} -launcher --stop # Stop server "
193+ echo " ${APP_NAME} -launcher --stop # Stop services "
150194echo " "
151195echo " To remove: $0 --remove"
0 commit comments