mirror of
https://github.com/ViViDboarder/docker-restic-cron.git
synced 2024-12-04 02:46:55 +00:00
Fix env parsing for variables with spaces
This commit is contained in:
parent
8cc87d0a16
commit
ebb9c93e47
@ -1,10 +1,11 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
ENV=/env
|
ENV=/env.sh
|
||||||
LOG=/cron.log
|
LOG=/cron.log
|
||||||
HEALTH_FILE=/unhealthy
|
HEALTH_FILE=/unhealthy
|
||||||
|
|
||||||
test -f $ENV || echo NO_ENV=true > $ENV
|
touch $ENV
|
||||||
|
source $ENV
|
||||||
|
|
||||||
# Execute command and write output to log
|
# Execute command and write output to log
|
||||||
env `cat $ENV | xargs` $@ 2>> $LOG && rm -f $HEALTH_FILE || { touch $HEALTH_FILE; exit 1; }
|
$@ 2>> $LOG && rm -f $HEALTH_FILE || { touch $HEALTH_FILE; exit 1; }
|
||||||
|
4
start.sh
4
start.sh
@ -26,9 +26,9 @@ fi
|
|||||||
|
|
||||||
if [ -n "$CRON_SCHEDULE" ]; then
|
if [ -n "$CRON_SCHEDULE" ]; then
|
||||||
# Export the environment to a file so it can be loaded from cron
|
# Export the environment to a file so it can be loaded from cron
|
||||||
env > /env
|
env | sed 's/^\(.*\)=\(.*\)$/export \1="\2"/g' > /env.sh
|
||||||
# Remove some vars we don't want to keep
|
# Remove some vars we don't want to keep
|
||||||
sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env
|
sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env.sh
|
||||||
|
|
||||||
# Use bash for cron
|
# Use bash for cron
|
||||||
echo "SHELL=/bin/bash" > /crontab.conf
|
echo "SHELL=/bin/bash" > /crontab.conf
|
||||||
|
Loading…
Reference in New Issue
Block a user