Fixing minor issues with bash script

This commit is contained in:
Paulino Padial 2018-01-23 18:58:37 +01:00
parent 408d2d2cc3
commit 6091b87f96

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Logic for Password file required
# If PASSWORD_SECRET env var is defined, search for the /run/secrets/${PASSWORD_SECRET} and read the content
@ -30,19 +30,22 @@ if [ "${CRON_SCHEDULE}" ]; then
echo "Configuring a CUSTOM SCHEDULE in /etc/crontab for ${CRON_SCHEDULE} ..."
# Create the crontab file
cat <<-EOF > /etc/crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
${CRON_SCHEDULE} /usr/sbin/autopostgresqlbackup
EOF
# the file should have the correct content
else
echo "Using cron.daily schedule..."
fi
# Create the file
echo "Creating the password file..."
cat <<-EOF > ${HOME}/.pgpass
${DBHOST}:*:*:${USERNAME:-postgres}:${PASSPHRASE}
${DBHOST:-localhost}:*:*:${USERNAME:-postgres}:${PASSPHRASE}
EOF
# Execute cron with parameters (autopostgresql script is under /etc/cron.daily)