Browse Source

Fix env parsing for variables with spaces

ViViDboarder 3 weeks ago
parent
commit
53e306d884
2 changed files with 6 additions and 5 deletions
  1. 4
    3
      cron-exec.sh
  2. 2
    2
      start.sh

+ 4
- 3
cron-exec.sh View File

@@ -1,10 +1,11 @@
1 1
 #! /bin/bash
2 2
 
3
-ENV=/env
3
+ENV=/env.sh
4 4
 LOG=/cron.log
5 5
 HEALTH_FILE=/unhealthy
6 6
 
7
-test -f $ENV || echo NO_ENV=true > $ENV
7
+touch $ENV
8
+source $ENV
8 9
 
9 10
 # Execute command and write output to log
10
-env `cat $ENV | xargs` $@ 2>> $LOG && rm -f $HEALTH_FILE || { touch $HEALTH_FILE; exit 1; }
11
+$@ 2>> $LOG && rm -f $HEALTH_FILE || { touch $HEALTH_FILE; exit 1; }

+ 2
- 2
start.sh View File

@@ -28,9 +28,9 @@ fi
28 28
 
29 29
 if [ -n "$CRON_SCHEDULE" ]; then
30 30
     # Export the environment to a file so it can be loaded from cron
31
-    env > /env
31
+    env | sed 's/^\(.*\)=\(.*\)$/export \1="\2"/g' > /env.sh
32 32
     # Remove some vars we don't want to keep
33
-    sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env
33
+    sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env.sh
34 34
 
35 35
     # Use bash for cron
36 36
     echo "SHELL=/bin/bash" > /crontab.conf

Loading…
Cancel
Save