phase: 02-operations-maintenance
plan: 03
type: execute
wave: 1
depends_on: []
files_modified: [deploy_rkl.sh]
autonomous: true
requirements: [OPS-04]
must_haves:
truths:
- "deploy_rkl.sh runs without errors on macOS (no GNU-only flags)"
- "deploy_rkl.sh runs without errors on Linux (no macOS-only tools)"
- "Script detects the platform and adapts commands accordingly"
artifacts:
- path: "deploy_rkl.sh"
provides: "Cross-platform deployment script"
contains: "uname"
key_links:
- from: "deploy_rkl.sh"
to: "platform detection"
via: "uname -s check"
pattern: "uname"
Make deploy_rkl.sh portable across macOS and Linux by replacing platform-specific commands with cross-platform alternatives and adding OS detection.
Purpose: OPS-04 requires the deployment script to work on both macOS and Linux without manual edits.
Output: Updated deploy_rkl.sh that detects the OS and uses appropriate commands.
@$HOME/.claude/get-shit-done/workflows/execute-plan.md
@$HOME/.claude/get-shit-done/templates/summary.md
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
Rewrite deploy_rkl.sh to be cross-platform. The current script is entirely Linux/systemd-centric. Add these changes:
- OS detection block right after
set -euo pipefailand the color definitions:
OS="$(uname -s)"
case "$OS" in
Darwin) PLATFORM="macos" ;;
Linux) PLATFORM="linux" ;;
*) fail "Unsupported OS: $OS" ;;
esac
echo -e " Platform: ${BOLD}${PLATFORM}${NC} ($(uname -m))"
- Platform-adaptive helper functions after the detection block:
pg_cmd() {
if [ "$PLATFORM" = "linux" ]; then
sudo -u postgres psql "$@"
else
psql "$@"
fi
}
svc_restart() {
local svc="$1"
if [ "$PLATFORM" = "linux" ]; then
systemctl restart "$svc"
else
# macOS: use launchctl or just print manual instruction
warn "Bitte Service '$svc' manuell neustarten (kein systemd auf macOS)"
fi
}
svc_active() {
local svc="$1"
if [ "$PLATFORM" = "linux" ]; then
systemctl is-active --quiet "$svc"
else
# macOS: check via process or return true (manual restart assumed)
pgrep -f "$svc" >/dev/null 2>&1
fi
}
nginx_reload() {
if [ "$PLATFORM" = "linux" ]; then
nginx -t 2>&1 && ok "nginx config OK" || fail "nginx config fehlerhaft"
systemctl reload nginx
else
nginx -t 2>&1 && ok "nginx config OK" || fail "nginx config fehlerhaft"
sudo nginx -s reload 2>/dev/null || warn "nginx reload fehlgeschlagen — ggf. manuell"
fi
}
- Replace hardcoded commands throughout the script:
- Line 31: Replace
sudo -u postgres psql -d crumbforest_db -f ...withpg_cmd -d crumbforest_db -f /tmp/migrate_rkl.sql ... - Line 34-37: Replace
sudo -u postgres psql -d crumbforest_db -c ...withpg_cmd -d crumbforest_db -c ... - Line 66-67: Replace nginx block with call to
nginx_reload - Line 76: Replace
systemctl restart forest-apiwithsvc_restart forest-api - Line 79: Replace
systemctl is-active --quiet forest-apiwithsvc_active forest-api -
Line 83: Replace
journalctl -u forest-api --no-pager -n 15with:
bash if [ "$PLATFORM" = "linux" ]; then journalctl -u forest-api --no-pager -n 15 else warn "Logs: Check console output or log file manually" fi -
macOS nginx config path: On macOS, nginx config is typically in
/usr/local/etc/nginx/or/opt/homebrew/etc/nginx/. Add:
if [ "$PLATFORM" = "linux" ]; then
NGINX_SITES="/etc/nginx/sites-available"
else
NGINX_SITES="/opt/homebrew/etc/nginx/servers"
fi
Then replace /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/ references with the variable. On macOS, skip the symlink step (Homebrew nginx uses servers/ directly).
- pip path: The hardcoded
/opt/crumbforest/venv/bin/pipmay not exist on macOS dev setups. Make it configurable:
VENV_PIP="${VENV_PIP:-/opt/crumbforest/venv/bin/pip}"
if [ ! -f "$VENV_PIP" ]; then
warn "pip nicht gefunden: $VENV_PIP — bitte VENV_PIP setzen"
warn "Beispiel: VENV_PIP=./venv/bin/pip ./deploy_rkl.sh"
fi
- bash -n deploy_rkl.sh succeeds (valid bash syntax)
- grep "uname" deploy_rkl.sh returns a match (OS detection present)
- grep "PLATFORM" deploy_rkl.sh returns a match (platform variable used)
- grep "Darwin" deploy_rkl.sh returns a match (macOS case handled)
- grep "Linux" deploy_rkl.sh returns a match (Linux case handled)
- grep "pg_cmd" deploy_rkl.sh returns a match (PostgreSQL abstracted)
- bash -n deploy_rkl.sh passes (valid syntax)
- Script contains OS detection via uname -s
- Platform-specific commands (systemctl, sudo -u postgres) are wrapped in conditionals
deploy_rkl.sh runs without syntax errors on both macOS and Linux. Platform-specific commands are abstracted behind helper functions with OS detection.