diff --git a/tools/update-clawd.sh b/tools/update-clawd.sh index 8119e27..e6c537e 100644 --- a/tools/update-clawd.sh +++ b/tools/update-clawd.sh @@ -63,6 +63,21 @@ if [ "$NO_RESTART" = true ]; then exit 0 fi +# Patch service file if ReadWritePaths is missing /etc/hosts or /etc/hostname +SERVICE_FILE="/etc/systemd/system/$SERVICE" +if [ -f "$SERVICE_FILE" ]; then + if ! grep -q "/etc/hosts" "$SERVICE_FILE" || ! grep -q "/etc/hostname" "$SERVICE_FILE"; then + echo "==> Patching $SERVICE_FILE: adding /etc/hosts /etc/hostname to ReadWritePaths ..." + sed -i 's|ReadWritePaths=\(.*\)/tmp\(.*\)|ReadWritePaths=\1/tmp\2 /etc/hosts /etc/hostname|' "$SERVICE_FILE" + # If the pattern didn't match (different format), append directly + if ! grep -q "/etc/hosts" "$SERVICE_FILE"; then + sed -i 's|ReadWritePaths=.*|& /etc/hosts /etc/hostname|' "$SERVICE_FILE" + fi + systemctl daemon-reload + echo "==> daemon-reload done" + fi +fi + echo "==> Restarting service: $SERVICE" systemctl restart "$SERVICE"