This commit is contained in:
committer@tuxwarrior
2025-03-29 05:22:10 -05:00
parent ede258f87c
commit 8cbc097390

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# klevstul :: 25.02
# switching owner of postgres' data director to and from 'poq' and 'postgres'
dir_psqdata=/home/poq/syncDir/quick/onedrive/swas/postgresql/dataLnx
if ! [ -d "${dir_psqdata}" ]; then
echo "error: non-existing directory '${dir_psqdata}'"
exit 1
else
echo "postgresql data directory: '${dir_psqdata}'"
fi
username=$(stat -c '%U' ${dir_psqdata})
if [[ ${username} == "postgres" ]]; then
echo "change owner to ${USER} (postgres ➔ ${USER})?"
echo "do you want to continue? (y/n)"
read user_input
if [[ ${user_input} != "y" ]]; then
echo "bye!"
exit 1
fi
sudo chown ${USER}:${USER} -R ${dir_psqdata}
elif [[ ${username} == "${USER}" ]]; then
echo "change owner to 'postgres' (${USER} ➔ postgres)?"
echo "do you want to continue? (y/n)"
read user_input
if [[ ${user_input} != "y" ]]; then
echo "bye!"
exit 1
fi
sudo chown postgres:postgres -R ${dir_psqdata}
else
echo "error: unknown username - not sure what to do in this case, except for quitting. bye!"
exit 1
fi