mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
"Wekan installed but is not visible in menu" - because the snap installs a SERVER: it starts a daemon and shipped no .desktop file, so nothing appeared in the menu and it looked like nothing had been installed. `wekan.open` is that entry. It reads the snap's OWN settings and opens the address WeKan is actually serving - ROOT_URL when there is one, otherwise localhost with the configured port - so `snap set wekan port=…` is followed without anyone editing a desktop file. The URL goes to snapd's xdg-open shim, which hands it to the session's browser (that is what the `desktop` plug is for); on a headless install, where there is no session, it prints the address instead of failing silently. Thanks to COOKIE-1816 and xet7 ! Fixes #6539.
45 lines
1.7 KiB
Bash
Executable File
45 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================================================
|
|
# Open the WeKan server running on this machine in the browser (#6539).
|
|
#
|
|
# The snap is a SERVER: installing it starts a daemon and there was nothing in
|
|
# the application menu, so it looked like nothing had been installed. This is the
|
|
# menu entry - it opens the address WeKan is actually serving, read from the
|
|
# snap's own settings, so `snap set wekan port=…` / `root-url=…` are followed.
|
|
# ============================================================================
|
|
|
|
if [[ "$PATH" != *"$SNAP_INSTANCE_NAME"* ]]; then
|
|
export PATH="${PATH/\/snap\/wekan\//\/snap\/$SNAP_INSTANCE_NAME\/}"
|
|
fi
|
|
|
|
# read wekan config (PORT, ROOT_URL, CADDY_*)
|
|
source $SNAP/bin/wekan-read-settings >/dev/null 2>&1
|
|
|
|
URL="$ROOT_URL"
|
|
|
|
# ROOT_URL is what WeKan tells clients it is; when it carries no port and WeKan
|
|
# does not listen on the default one, the port has to be added or the browser
|
|
# lands nowhere.
|
|
case "$URL" in
|
|
""|"http://localhost"|"http://localhost/"|"http://127.0.0.1"|"http://127.0.0.1/")
|
|
URL="http://localhost:${PORT:-8080}"
|
|
;;
|
|
*:[0-9]*) : ;; # already carries a port
|
|
http://*|https://*)
|
|
if [ -n "$PORT" ] && [ "$PORT" != "80" ] && [ "$PORT" != "443" ]; then
|
|
URL="${URL%/}:${PORT}"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
echo "Opening $URL"
|
|
|
|
# xdg-open inside a snap is snapd's shim, which asks the desktop session to open
|
|
# it - the snap itself never gets a browser. If there is no session (a headless
|
|
# server, an SSH shell), print the address instead of failing silently.
|
|
if command -v xdg-open >/dev/null 2>&1; then
|
|
exec xdg-open "$URL"
|
|
fi
|
|
|
|
echo "No xdg-open available. Open this address in a browser: $URL"
|