31 lines
1.4 KiB
Bash
31 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
FILE="src/SettingsPage.cpp"
|
|
|
|
if [[ ! -f "$FILE" ]]; then
|
|
echo "ERROR: $FILE not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "[ubuntu-lts-system-fix] Patching $FILE"
|
|
|
|
perl -0777 -i -pe '
|
|
s@if \(pw\) chown\(conf_file\.c_str\(\), pw->pw_uid, pw->pw_gid\);@if (pw) {\n const int chown_rc = chown(conf_file.c_str(), pw->pw_uid, pw->pw_gid);\n if (chown_rc != 0) {\n std::cerr << _("[SettingsPage] ⚠ chown fallita per ") << conf_file << std::endl;\n }\n }@g;
|
|
|
|
s@std::system\("systemctl --user restart BastionGuard-mailproxy\.service 2>/dev/null"\);@const int rc = std::system("systemctl --user restart BastionGuard-mailproxy.service 2>/dev/null");\n if (rc != 0) {\n std::cerr << _("[SettingsPage] ⚠ Impossibile riavviare BastionGuard-mailproxy.service") << std::endl;\n }@g;
|
|
' "$FILE"
|
|
|
|
echo "[ubuntu-lts-system-fix] Verifying patch"
|
|
|
|
if grep -Eq '^[[:space:]]*if \(pw\) chown\(conf_file\.c_str\(\), pw->pw_uid, pw->pw_gid\);[[:space:]]*$' "$FILE"; then
|
|
echo "ERROR: chown patch not applied" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if grep -Eq '^[[:space:]]*std::system\("systemctl --user restart BastionGuard-mailproxy\.service 2>/dev/null"\);[[:space:]]*$' "$FILE"; then
|
|
echo "ERROR: mailproxy restart patch not applied" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "[ubuntu-lts-system-fix] Patch applied successfully"
|