From ebb9c93e4728fc9365570f91f070ac90a2e0b297 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Fri, 1 Feb 2019 17:02:44 -0800 Subject: [PATCH] Fix env parsing for variables with spaces --- cron-exec.sh | 7 ++++--- start.sh | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cron-exec.sh b/cron-exec.sh index ed4667f..2812ca8 100755 --- a/cron-exec.sh +++ b/cron-exec.sh @@ -1,10 +1,11 @@ #! /bin/bash -ENV=/env +ENV=/env.sh LOG=/cron.log HEALTH_FILE=/unhealthy -test -f $ENV || echo NO_ENV=true > $ENV +touch $ENV +source $ENV # 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; } diff --git a/start.sh b/start.sh index b1e92cb..e4e3f73 100755 --- a/start.sh +++ b/start.sh @@ -26,9 +26,9 @@ fi if [ -n "$CRON_SCHEDULE" ]; then # 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 - sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env + sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env.sh # Use bash for cron echo "SHELL=/bin/bash" > /crontab.conf