-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-desktop.sh
More file actions
executable file
·195 lines (174 loc) · 5.67 KB
/
Copy pathinstall-desktop.sh
File metadata and controls
executable file
·195 lines (174 loc) · 5.67 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# install-desktop.sh — Install GSA desktop entry, icon, and launcher on Linux.
#
# Usage:
# ./scripts/install-desktop.sh # Install
# ./scripts/install-desktop.sh --remove # Remove
#
# Author: Jonathan D.A. Jewell
set -euo pipefail
APP_NAME="game-server-admin"
APP_DISPLAY="Game Server Admin"
APP_PORT="8090"
APP_DESC="Universal game server probe, config management, and administration"
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
DESKTOP_FILE="$REPO_DIR/${APP_NAME}.desktop"
ICON_DIR="$HOME/.local/share/icons/hicolor/256x256/apps"
APPS_DIR="$HOME/.local/share/applications"
BIN_DIR="$HOME/.local/bin"
LAUNCHER="$BIN_DIR/${APP_NAME}-launcher"
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/${APP_NAME}"
CONFIG_FILE="$CONFIG_DIR/install.conf"
# --- Remove mode ---
if [[ "${1:-}" == "--remove" ]]; then
echo "Removing ${APP_DISPLAY} desktop entry..."
rm -f "$APPS_DIR/${APP_NAME}.desktop"
rm -f "$ICON_DIR/${APP_NAME}.png"
rm -f "$LAUNCHER"
rm -f "$CONFIG_FILE"
update-desktop-database "$APPS_DIR" 2>/dev/null || true
echo "Done. ${APP_DISPLAY} desktop entry removed."
exit 0
fi
# --- Install mode ---
echo "Installing ${APP_DISPLAY}..."
mkdir -p "$APPS_DIR" "$ICON_DIR" "$BIN_DIR"
# Copy desktop file
if [[ -f "$DESKTOP_FILE" ]]; then
cp "$DESKTOP_FILE" "$APPS_DIR/${APP_NAME}.desktop"
echo " + Desktop entry -> $APPS_DIR/${APP_NAME}.desktop"
else
echo " ! Desktop file not found at $DESKTOP_FILE"
exit 1
fi
# Copy icon if available
if [[ -f "$REPO_DIR/assets/icon-256.png" ]]; then
cp "$REPO_DIR/assets/icon-256.png" "$ICON_DIR/${APP_NAME}.png"
echo " + Icon -> $ICON_DIR/${APP_NAME}.png"
elif [[ -f "$REPO_DIR/raw-assets/main/icon-256.png" ]]; then
cp "$REPO_DIR/raw-assets/main/icon-256.png" "$ICON_DIR/${APP_NAME}.png"
echo " + Icon -> $ICON_DIR/${APP_NAME}.png"
else
echo " ! No icon found (place icon-256.png in assets/)"
fi
# Create launcher wrapper
cat > "$LAUNCHER" << LAUNCHER_EOF
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later
# ${APP_DISPLAY} Launcher — Gossamer GUI for game server administration
set -euo pipefail
REPO_DIR="$REPO_DIR"
FFI_DIR="\$REPO_DIR/src/interface/ffi"
VERISIMDB_URL="\${GSA_VERISIMDB_URL:-http://[::1]:${APP_PORT}}"
PROFILES_DIR="\${GSA_PROFILES_DIR:-\$REPO_DIR/profiles}"
MODE="\${1:---auto}"
# Check VeriSimDB is running
check_verisimdb() {
if curl -sf "\$VERISIMDB_URL/health" >/dev/null 2>&1; then
return 0
else
echo "VeriSimDB not reachable at \$VERISIMDB_URL"
echo "Start it with: systemctl --user start gsa-verisimdb"
echo "Or: podman start gsa-verisimdb"
return 1
fi
}
# Build libgsa.so if not already built
build_ffi() {
if [[ ! -f "\$FFI_DIR/zig-out/lib/libgsa.so" ]]; then
echo "Building libgsa.so..."
cd "\$FFI_DIR"
zig build
echo "Built: \$FFI_DIR/zig-out/lib/libgsa.so"
fi
}
# Launch via Gossamer webview (native desktop)
launch_gossamer() {
build_ffi
export LD_LIBRARY_PATH="\$FFI_DIR/zig-out/lib:\${LD_LIBRARY_PATH:-}"
export GSA_VERISIMDB_URL="\$VERISIMDB_URL"
export GSA_PROFILES_DIR="\$PROFILES_DIR"
if command -v gossamer &>/dev/null; then
exec gossamer \\
--load "\$FFI_DIR/zig-out/lib/libgsa.so" \\
--html "\$REPO_DIR/src/gui/host.html" \\
--title "${APP_DISPLAY}" \\
--width 1400 --height 900
else
echo "gossamer binary not found in PATH"
echo "Falling back to browser mode..."
launch_web
fi
}
# Launch web interface (opens browser to panel host)
launch_web() {
echo "Opening ${APP_DISPLAY} in browser..."
local host_html="\$REPO_DIR/src/gui/host.html"
if [[ -f "\$host_html" ]]; then
xdg-open "file://\$host_html" 2>/dev/null || \\
echo "Open file://\$host_html in your browser"
else
echo "Panel host HTML not found at \$host_html"
exit 1
fi
}
# Stop VeriSimDB
stop_services() {
echo "Stopping ${APP_DISPLAY} services..."
systemctl --user stop gsa-verisimdb 2>/dev/null || \\
podman stop gsa-verisimdb 2>/dev/null || \\
echo "No running services found."
echo "Done."
}
case "\$MODE" in
--gossamer)
check_verisimdb || true
launch_gossamer
;;
--web)
check_verisimdb || true
launch_web
;;
--stop)
stop_services
;;
--auto|*)
check_verisimdb || true
launch_gossamer
;;
esac
LAUNCHER_EOF
chmod +x "$LAUNCHER"
echo " + Launcher -> $LAUNCHER"
# Write install config
mkdir -p "$CONFIG_DIR"
cat > "$CONFIG_FILE" << CONF_EOF
# ${APP_DISPLAY} install configuration
# Generated by install-desktop.sh — $(date -Iseconds)
install_dir=$REPO_DIR
install_type=user
os=linux
verisimdb_port=${APP_PORT}
installed_at=$(date -Iseconds)
CONF_EOF
echo " + Config -> $CONFIG_FILE"
# Update desktop database
update-desktop-database "$APPS_DIR" 2>/dev/null || true
gtk-update-icon-cache "$HOME/.local/share/icons/hicolor/" 2>/dev/null || true
echo ""
echo "Done! ${APP_DISPLAY} is now available in your application menu."
echo ""
echo "Prerequisites:"
echo " 1. Build Zig FFI: cd src/interface/ffi && zig build"
echo " 2. Start VeriSimDB: systemctl --user start gsa-verisimdb"
echo " 3. Install Gossamer for native desktop mode (optional)"
echo ""
echo "Commands:"
echo " ${APP_NAME}-launcher # Start (auto-detect Gossamer/browser)"
echo " ${APP_NAME}-launcher --web # Force browser mode"
echo " ${APP_NAME}-launcher --gossamer # Force Gossamer mode"
echo " ${APP_NAME}-launcher --stop # Stop services"
echo ""
echo "To remove: $0 --remove"