feat(server,client): remote install mode, install survives missing systemd

This commit is contained in:
hh committed 2026-10-02 22:09:50 +00:00
1 parent c2e9284a63
commit e89cf7864a
6 files changed
+83 -18

No files matched your search

+21 -3
View File
@@ -1,6 +1,10 @@
#!/bin/sh
set -eu
url="{{URL}}"
code="{{CODE}}"
mode="{{MODE}}"
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m)
case "$arch" in
@@ -11,12 +15,26 @@ esac
bin="$HOME/.local/bin"
mkdir -p "$bin"
curl -fsSL "{{URL}}/dl/lodge-$os-$arch" -o "$bin/lodge.new"
curl -fsSL "$url/dl/lodge-$os-$arch" -o "$bin/lodge.new"
chmod +x "$bin/lodge.new"
mv "$bin/lodge.new" "$bin/lodge"
"$bin/lodge" login "{{URL}}" "{{CODE}}"
"$bin/lodge" install
if [ "$mode" = login ]; then
"$bin/lodge" login "$url" "$code"
"$bin/lodge" install
else
plist="$HOME/Library/LaunchAgents/com.kotikot.lodge.plist"
unit="$HOME/.config/systemd/user/lodge.service"
restarted=yes
if [ -f "$plist" ]; then
launchctl kickstart -k "gui/$(id -u)/com.kotikot.lodge" || restarted=no
elif [ -f "$unit" ]; then
systemctl --user restart lodge.service || restarted=no
fi
[ "$restarted" = yes ] || echo "lodge: restart the running daemon so it runs the new binary" >&2
(cd / && "$bin/lodge" remote "$url" "$code")
[ -f "$plist" ] || [ -f "$unit" ] || "$bin/lodge" install
fi
case ":$PATH:" in
*":$bin:"*) ;;