-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
42 lines (32 loc) · 898 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
while [ ! -f /run/fcron.pid ]
do
echo "Waiting for fcron"
sleep 1
done
while true
do
env_vars=$(env | grep ".*_TUTUM_API_URL=" | cut -d= -f1 | tr '\n' ' ')
[ ! -f /tmp/cron.tmp ] || rm /tmp/cron.tmp
for env_var in $env_vars
do
# Set on the remote service
schedule_env_var=${env_var%_TUTUM_API_URL}_ENV_CRON_SCHEDULE
# Set on the cron service
schedule_var=${env_var%_TUTUM_API_URL}_CRON_SCHEDULE
if [[ -n $schedule_var ]]
then
schedule="${!schedule_var}"
else
schedule="${!schedule_env_var}"
fi
service_url=${!env_var}
cat <<EOF >> /tmp/cron.tmp
${schedule} curl -X POST -H "Authorization: $TUTUM_AUTH" -H "Accept: application/json" ${service_url}start/
EOF
done
echo "Installing new crontab"
cat /tmp/cron.tmp
fcrontab /tmp/cron.tmp
sleep 86400
done