Fixing minor issues with bash script
This commit is contained in:
parent
408d2d2cc3
commit
6091b87f96
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
# Logic for Password file required
|
# Logic for Password file required
|
||||||
# If PASSWORD_SECRET env var is defined, search for the /run/secrets/${PASSWORD_SECRET} and read the content
|
# If PASSWORD_SECRET env var is defined, search for the /run/secrets/${PASSWORD_SECRET} and read the content
|
||||||
@ -29,22 +29,25 @@ fi
|
|||||||
if [ "${CRON_SCHEDULE}" ]; then
|
if [ "${CRON_SCHEDULE}" ]; then
|
||||||
echo "Configuring a CUSTOM SCHEDULE in /etc/crontab for ${CRON_SCHEDULE} ..."
|
echo "Configuring a CUSTOM SCHEDULE in /etc/crontab for ${CRON_SCHEDULE} ..."
|
||||||
# Create the crontab file
|
# Create the crontab file
|
||||||
cat <<-EOF > /etc/crontab
|
cat <<-EOF > /etc/crontab
|
||||||
|
|
||||||
SHELL=/bin/sh
|
SHELL=/bin/sh
|
||||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
|
|
||||||
# m h dom mon dow user command
|
# m h dom mon dow user command
|
||||||
${CRON_SCHEDULE} /usr/sbin/autopostgresqlbackup
|
${CRON_SCHEDULE} /usr/sbin/autopostgresqlbackup
|
||||||
EOF
|
EOF
|
||||||
# the file should have the correct content
|
else
|
||||||
|
echo "Using cron.daily schedule..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the file
|
# Create the file
|
||||||
echo "Creating the password file..."
|
echo "Creating the password file..."
|
||||||
cat <<-EOF > ${HOME}/.pgpass
|
cat <<-EOF > ${HOME}/.pgpass
|
||||||
${DBHOST}:*:*:${USERNAME:-postgres}:${PASSPHRASE}
|
|
||||||
|
${DBHOST:-localhost}:*:*:${USERNAME:-postgres}:${PASSPHRASE}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Execute cron with parameters (autopostgresql script is under /etc/cron.daily)
|
# Execute cron with parameters (autopostgresql script is under /etc/cron.daily)
|
||||||
echo "Execute cron service..."
|
echo "Execute cron service..."
|
||||||
exec cron -f -l ${CRON_LOG_LEVEL:-8}
|
exec cron -f -l ${CRON_LOG_LEVEL:-8}
|
Loading…
Reference in New Issue
Block a user