Add initial configuration files and scripts for NextCloud setup
This commit is contained in:
66
scripts/install-launchd-retrust.sh
Executable file
66
scripts/install-launchd-retrust.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
LABEL="com.nextcloud.collabora.retrust"
|
||||
PLIST_DIR="$HOME/Library/LaunchAgents"
|
||||
PLIST_PATH="$PLIST_DIR/$LABEL.plist"
|
||||
WORKDIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
SCRIPT_PATH="$WORKDIR/scripts/retrust-collabora-caddy-ca.sh"
|
||||
LOG_DIR="$WORKDIR/.logs"
|
||||
STDOUT_LOG="$LOG_DIR/$LABEL.out.log"
|
||||
STDERR_LOG="$LOG_DIR/$LABEL.err.log"
|
||||
|
||||
mkdir -p "$PLIST_DIR" "$LOG_DIR"
|
||||
|
||||
cat > "$PLIST_PATH" <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>$LABEL</string>
|
||||
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/bin/bash</string>
|
||||
<string>$SCRIPT_PATH</string>
|
||||
</array>
|
||||
|
||||
<key>WorkingDirectory</key>
|
||||
<string>$WORKDIR</string>
|
||||
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
||||
</dict>
|
||||
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
|
||||
<key>StartInterval</key>
|
||||
<integer>300</integer>
|
||||
|
||||
<key>StandardOutPath</key>
|
||||
<string>$STDOUT_LOG</string>
|
||||
|
||||
<key>StandardErrorPath</key>
|
||||
<string>$STDERR_LOG</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
|
||||
launchctl bootout "gui/$(id -u)/$LABEL" >/dev/null 2>&1 || true
|
||||
if launchctl bootstrap "gui/$(id -u)" "$PLIST_PATH" >/dev/null 2>&1; then
|
||||
launchctl enable "gui/$(id -u)/$LABEL" >/dev/null 2>&1 || true
|
||||
launchctl kickstart -k "gui/$(id -u)/$LABEL" >/dev/null 2>&1 || true
|
||||
MODE="bootstrap"
|
||||
else
|
||||
launchctl unload "$PLIST_PATH" >/dev/null 2>&1 || true
|
||||
launchctl load -w "$PLIST_PATH"
|
||||
MODE="load"
|
||||
fi
|
||||
|
||||
echo "Installed launchd job: $LABEL (mode: $MODE)"
|
||||
echo "Plist: $PLIST_PATH"
|
||||
echo "Logs: $STDOUT_LOG and $STDERR_LOG"
|
||||
Reference in New Issue
Block a user