fix: patch ReadWritePaths in clawd.service on upgrade if /etc/hosts missing
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -63,6 +63,21 @@ if [ "$NO_RESTART" = true ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
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"
|
echo "==> Restarting service: $SERVICE"
|
||||||
systemctl restart "$SERVICE"
|
systemctl restart "$SERVICE"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user