Add checks for super user exists

This commit is contained in:
2025-12-02 15:13:58 +09:00
parent 3a7251d84e
commit 0b3d47b5d4
2 changed files with 19 additions and 2 deletions

View File

@@ -71,6 +71,10 @@ if [ -z "${sudo_user}" ]; then
echo "sudo_user not set in the config file ${config_file}";
exit;
fi;
if ! id "${sudo_user}" &>/dev/null; then
echo "Sudo user ${sudo_user} does not exist, skipping stanza";
exit
fi;
if [ -z "${pgbackrest_config}" ] ||[ ! -f "${pgbackrest_config}" ]; then
echo "Missing pgbackrest default config file ${pgbackrest_config}";
exit;
@@ -218,6 +222,10 @@ while read -r stanza; do
fi;
# set override sudo user
if [ -n "${stanza_super_user}" ]; then
if ! id "${stanza_super_user}" &>/dev/null; then
echo "[!] Sudo user ${stanza_super_user} for stanza ${stanza_name} does not exist, skipping stanza";
continue;
fi;
sudo_user="${stanza_super_user}";
fi;
# build the call command