feat(install): add --update-only emergency deploy mode
Adds '--update-only' flag for crisis deployment — no questions, no Ollama, no config provisioning. Just find hermes dir, deploy all plugin files, clear __pycache__, restart gateway, verify. Flow: 1. find_hermes_dir() → resolve correct path (6-priority cascade) 2. create_backup() → tar.gz safety net 3. cp plugin/ → $HERMES_DIR/plugins/platforms/rocketchat/ 4. rm -rf __pycache__ 5. systemctl restart hermes-gateway 6. journalctl grep verification (15s timeout) Use case: Gateway loses plugin discovery after clean shutdown. Instead of manual cp + restart, one command: ./install.sh --update-only Language strings added for DE + EN. Help text updated.
This commit is contained in:
+100
-2
@@ -11,6 +11,7 @@ ARG_LANG=""
|
||||
NONINTERACTIVE=false
|
||||
CHECK_ONLY=false
|
||||
UPDATE_MODE=false
|
||||
UPDATE_ONLY=false
|
||||
UPDATE_AVAILABLE=false
|
||||
|
||||
# ─── Language packs ─────────────────────────────────────────
|
||||
@@ -57,7 +58,7 @@ load_lang() {
|
||||
[restarting]="🔄 Restarting gateway…"
|
||||
[done]="✅ Rocket.Chat Plugin installed successfully!\n After the gateway restarts, check for a pairing code\n in the gateway logs and enter it in your home channel."
|
||||
[dry_info]="ℹ️ Use --help for all options."
|
||||
[help_text]="USAGE: ./install.sh [OPTIONS]\n\nOPTIONS:\n --help Show this help\n --lang en|de Language (default: auto-detect from \$LANG)\n --non-interactive Batch mode — reads from env vars:\n RC_URL, RC_BOT_USER, RC_BOT_PASS, RC_HOME_CHANNEL\n --check Check for updates only\n --update Check for updates and install if available"
|
||||
[help_text]="USAGE: ./install.sh [OPTIONS]\n\nOPTIONS:\n --help Show this help\n --lang en|de Language (default: auto-detect from \$LANG)\n --non-interactive Batch mode — reads from env vars:\n RC_URL, RC_BOT_USER, RC_BOT_PASS, RC_HOME_CHANNEL\n --check Check for updates only\n --update Check for updates and install if available\n --update-only Emergency deploy: Only deploy plugin files +\n restart gateway. No questions, no config provisioning,\n no Ollama. Uses find_hermes_dir() for path discovery."
|
||||
[env_required]="❌ --non-interactive requires RC_URL, RC_BOT_USER, RC_BOT_PASS, RC_HOME_CHANNEL"
|
||||
[param_error]="❌ Unknown option: %s"
|
||||
[check_update]="🔍 Checking for updates…"
|
||||
@@ -69,6 +70,14 @@ load_lang() {
|
||||
[rollback]="⏪ Restoring backup: %s"
|
||||
[rollback_success]="✅ Backup successfully restored"
|
||||
[update_failed]="❌ Update failed. Error: %s"
|
||||
[update_only_banner]="━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n Hermes RC Plugin — Emergency Deploy\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
[deploying]="📦 Deploying plugin files (update-only, no questions)..."
|
||||
[deploy_done]="✅ %d files deployed to %s"
|
||||
[cache_cleared]="🧹 Cleared __pycache__"
|
||||
[verifying]="🔍 Verifying gateway..."
|
||||
[verify_ok]="✅ Gateway running with Rocket.Chat connected"
|
||||
[verify_fail]="⚠️ Gateway started but Rocket.Chat not detected in logs (check journalctl)"
|
||||
[verify_timeout]="⏳ Waiting for Rocket.Chat handshake..."
|
||||
)
|
||||
else
|
||||
# German (default)
|
||||
@@ -103,7 +112,7 @@ load_lang() {
|
||||
[restarting]="🔄 Starte Gateway neu…"
|
||||
[done]="✅ Rocket.Chat Plugin erfolgreich installiert!\n Nach dem Gateway-Neustart bitte den Pairing-Code\n aus den Gateway-Logs im Home-Channel eingeben."
|
||||
[dry_info]="ℹ️ Mit --help alle Optionen anzeigen."
|
||||
[help_text]="AUFRUF: ./install.sh [OPTIONEN]\n\nOPTIONEN:\n --help Diese Hilfe anzeigen\n --lang en|de Sprache (Standard: auto-Erkennung über \$LANG)\n --non-interactive Stapelverarbeitung — liest aus Umgebungsvariablen:\n RC_URL, RC_BOT_USER, RC_BOT_PASS, RC_HOME_CHANNEL\n --check Nur auf Updates prüfen\n --update Auf Updates prüfen und bei Bedarf installieren"
|
||||
[help_text]="AUFRUF: ./install.sh [OPTIONEN]\n\nOPTIONEN:\n --help Diese Hilfe anzeigen\n --lang en|de Sprache (Standard: auto-Erkennung über \$LANG)\n --non-interactive Stapelverarbeitung — liest aus Umgebungsvariablen:\n RC_URL, RC_BOT_USER, RC_BOT_PASS, RC_HOME_CHANNEL\n --check Nur auf Updates prüfen\n --update Auf Updates prüfen und bei Bedarf installieren\n --update-only Notfall-Deployment: Nur Plugin-Dateien deployen +\n Gateway-Neustart. Keine Fragen, kein Config-Provisioning,\n kein Ollama. Nutzt find_hermes_dir() für Pfad-Ermittlung."
|
||||
[env_required]="❌ --non-interactive benötigt RC_URL, RC_BOT_USER, RC_BOT_PASS, RC_HOME_CHANNEL"
|
||||
[param_error]="❌ Unbekannte Option: %s"
|
||||
[check_update]="🔍 Prüfe auf Updates…"
|
||||
@@ -115,6 +124,14 @@ load_lang() {
|
||||
[rollback]="⏪ Stelle Backup wieder her: %s"
|
||||
[rollback_success]="✅ Backup erfolgreich wiederhergestellt"
|
||||
[update_failed]="❌ Update fehlgeschlagen. Fehler: %s"
|
||||
[update_only_banner]="━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n Hermes RC Plugin — Notfall-Deployment\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
[deploying]="📦 Deploye Plugin-Dateien (update-only, ohne Rückfragen)..."
|
||||
[deploy_done]="✅ %d Dateien deployed nach %s"
|
||||
[cache_cleared]="🧹 __pycache__ gelöscht"
|
||||
[verifying]="🔍 Verifiziere Gateway..."
|
||||
[verify_ok]="✅ Gateway läuft mit Rocket.Chat verbunden"
|
||||
[verify_fail]="⚠️ Gateway gestartet, aber Rocket.Chat nicht im Log erkannt (prüfe journalctl)"
|
||||
[verify_timeout]="⏳ Warte auf Rocket.Chat-Handshake..."
|
||||
)
|
||||
fi
|
||||
}
|
||||
@@ -406,6 +423,82 @@ perform_update() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# ─── Emergency Deploy (update-only) ─────────────────────────
|
||||
perform_update_only() {
|
||||
local script_dir
|
||||
script_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
echo -e "\n${T[update_only_banner]}\n"
|
||||
|
||||
# 1. Find hermes directory
|
||||
local hermes_dir
|
||||
hermes_dir=$(find_hermes_dir 2>/dev/null || echo "")
|
||||
if [ -z "$hermes_dir" ]; then
|
||||
msg no_hermes; exit 1
|
||||
fi
|
||||
msg found_hermes "$hermes_dir"
|
||||
|
||||
# 2. Backup current state
|
||||
local backup_file="/tmp/hermes-rocketchat-backup-$(date +%s).tar.gz"
|
||||
local plugin_dir="$hermes_dir/plugins/platforms/rocketchat"
|
||||
if [ -d "$plugin_dir" ]; then
|
||||
create_backup "$backup_file" "$plugin_dir" \
|
||||
"$HOME/.hermes/config.yaml" \
|
||||
"$HOME/.config/hermes/rocketchat.env"
|
||||
fi
|
||||
|
||||
# 3. Deploy all plugin files
|
||||
msg deploying
|
||||
local PLUGIN_DST="$hermes_dir/plugins/platforms/rocketchat"
|
||||
mkdir -p "$PLUGIN_DST"
|
||||
|
||||
if [ -d "$script_dir/plugin" ]; then
|
||||
while read -r src; do
|
||||
rel="${src#$script_dir/plugin/}"
|
||||
dst="$PLUGIN_DST/$rel"
|
||||
mkdir -p "$(dirname "$dst")"
|
||||
cp "$src" "$dst"
|
||||
done < <(find "$script_dir/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc')
|
||||
local copied_count
|
||||
copied_count=$(find "$script_dir/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc' | wc -l)
|
||||
msg deploy_done "$copied_count" "$PLUGIN_DST"
|
||||
else
|
||||
msg update_failed "plugin/ directory not found in $script_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 4. Clear stale __pycache__
|
||||
find "$PLUGIN_DST" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
||||
msg cache_cleared
|
||||
|
||||
# 5. Restart gateway
|
||||
msg restarting
|
||||
systemctl --user daemon-reload 2>/dev/null || true
|
||||
systemctl --user restart hermes-gateway 2>/dev/null || true
|
||||
|
||||
# 6. Verify Rocket.Chat connected (wait up to 15s)
|
||||
msg verifying
|
||||
local verified=false
|
||||
for i in $(seq 1 6); do
|
||||
sleep 2.5
|
||||
if journalctl --user -u hermes-gateway --since "15 seconds ago" --no-pager 2>/dev/null \
|
||||
| grep -q "Subscribed to.*rocketchat\|Connecting to rocketchat"; then
|
||||
verified=true
|
||||
break
|
||||
fi
|
||||
msg verify_timeout
|
||||
done
|
||||
|
||||
if $verified; then
|
||||
msg verify_ok
|
||||
rm -f "$backup_file"
|
||||
else
|
||||
msg verify_fail
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# ─── Argument parsing ────────────────────────────────────
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -422,6 +515,8 @@ while [ $# -gt 0 ]; do
|
||||
CHECK_ONLY=true; shift ;;
|
||||
--update)
|
||||
UPDATE_MODE=true; shift ;;
|
||||
--update-only)
|
||||
UPDATE_ONLY=true; shift ;;
|
||||
*)
|
||||
load_lang "${ARG_LANG:-${LANG##*.}}"
|
||||
msg param_error "$1"; echo; exit 1 ;;
|
||||
@@ -449,6 +544,9 @@ elif $UPDATE_MODE; then
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
elif $UPDATE_ONLY; then
|
||||
perform_update_only
|
||||
exit $?
|
||||
fi
|
||||
|
||||
msg checking
|
||||
|
||||
Reference in New Issue
Block a user