Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,14 @@ install_service_linux() {
mkdir -p "$unit_dir"
local template="$INSTALL_DIR/templates/maestro-relay.service"
[ -f "$template" ] || { warn "Service template missing at $template"; return; }
local node_bin; node_bin="$(command -v node)"
local node_dir; node_dir="$(dirname "$node_bin")"
sed \
-e "s|@INSTALL_DIR@|$INSTALL_DIR|g" \
-e "s|@CONFIG_DIR@|$CONFIG_DIR|g" \
-e "s|@NODE_BIN@|$(command -v node)|g" \
-e "s|@NODE_BIN@|$node_bin|g" \
-e "s|@NODE_DIR@|$node_dir|g" \
-e "s|@HOME@|$HOME|g" \
"$template" > "$unit_dir/maestro-relay.service"
# Disable+remove a legacy maestro-discord unit if present so we don't leave
# two competing user services running on upgrade.
Expand All @@ -563,10 +567,14 @@ install_service_macos() {
mkdir -p "$INSTALL_DIR/logs"
local template="$INSTALL_DIR/templates/sh.maestro.relay.plist"
[ -f "$template" ] || { warn "Plist template missing at $template"; return; }
local node_bin; node_bin="$(command -v node)"
local node_dir; node_dir="$(dirname "$node_bin")"
sed \
-e "s|@INSTALL_DIR@|$INSTALL_DIR|g" \
-e "s|@CONFIG_DIR@|$CONFIG_DIR|g" \
-e "s|@NODE_BIN@|$(command -v node)|g" \
-e "s|@NODE_BIN@|$node_bin|g" \
-e "s|@NODE_DIR@|$node_dir|g" \
-e "s|@HOME@|$HOME|g" \
"$template" > "$plist_dir/sh.maestro.relay.plist"
# Unload+remove a legacy launchd plist if present.
if [ -f "$plist_dir/sh.maestro.discord.plist" ]; then
Expand Down
1 change: 1 addition & 0 deletions templates/maestro-relay.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ StartLimitBurst=5
Type=simple
WorkingDirectory=@INSTALL_DIR@
EnvironmentFile=@CONFIG_DIR@/.env
Environment=PATH=@HOME@/.local/bin:@NODE_DIR@:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStart=@NODE_BIN@ @INSTALL_DIR@/dist/index.js
Restart=on-failure
RestartSec=5
Expand Down
2 changes: 1 addition & 1 deletion templates/sh.maestro.relay.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>set -a; . "@CONFIG_DIR@/.env"; set +a; export PATH="/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin${PATH:+:$PATH}"; exec "@NODE_BIN@" "@INSTALL_DIR@/dist/index.js"</string>
<string>set -a; . "@CONFIG_DIR@/.env"; set +a; export PATH="@HOME@/.local/bin:@NODE_DIR@:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin${PATH:+:$PATH}"; exec "@NODE_BIN@" "@INSTALL_DIR@/dist/index.js"</string>
</array>
<key>RunAtLoad</key>
<true/>
Expand Down