Merge pull request #34 from SUNET/feature-ft-cron_wrapper_improvements
cron wrapper improvements
This commit is contained in:
commit
0db8d1fd9a
|
@ -1,4 +1,6 @@
|
||||||
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
|
||||||
|
|
||||||
*/15 * * * * root test -f /etc/no-automatic-cosmos || /usr/local/libexec/cosmos-cron-wrapper
|
*/15 * * * * root /usr/local/libexec/cosmos-cron-wrapper
|
||||||
|
|
||||||
|
@reboot root sleep 30; /usr/local/libexec/cosmos-cron-wrapper
|
||||||
|
|
|
@ -16,29 +16,29 @@ lock() {
|
||||||
eval "exec $fd>$lock_file"
|
eval "exec $fd>$lock_file"
|
||||||
|
|
||||||
# acquier the lock
|
# acquier the lock
|
||||||
flock -n $fd \
|
flock -n "$fd" \
|
||||||
&& return 0 \
|
&& return 0 \
|
||||||
|| return 1
|
|| return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
eexit() {
|
eexit() {
|
||||||
local error_str="$@"
|
local error_str="$*"
|
||||||
|
|
||||||
echo $error_str
|
echo "$error_str"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
lock $PROGNAME || eexit "Only one instance of $PROGNAME can run at one time."
|
lock "$PROGNAME" || eexit "Only one instance of $PROGNAME can run at one time."
|
||||||
cosmos $* update
|
cosmos "$@" update
|
||||||
cosmos $* apply
|
cosmos "$@" apply
|
||||||
|
|
||||||
touch /var/run/last-cosmos-ok.stamp
|
touch /var/run/last-cosmos-ok.stamp
|
||||||
|
|
||||||
find /var/lib/puppet/reports/ -type f -mtime +10 | xargs rm -f
|
find /var/lib/puppet/reports/ -type f -mtime +10 -print0 | xargs -0 rm -f
|
||||||
}
|
}
|
||||||
|
|
||||||
main $*
|
main "$@"
|
||||||
|
|
||||||
if [ -f /cosmos-reboot ]; then
|
if [ -f /cosmos-reboot ]; then
|
||||||
rm -f /cosmos-reboot
|
rm -f /cosmos-reboot
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
RUN_COSMOS=/usr/local/bin/run-cosmos
|
test -f /etc/no-automatic-cosmos && exit 0
|
||||||
|
|
||||||
|
RUN_COSMOS='/usr/local/bin/run-cosmos'
|
||||||
SCRIPTHERDER_CMD=''
|
SCRIPTHERDER_CMD=''
|
||||||
|
|
||||||
if [ -f /usr/local/bin/scriptherder ]; then
|
if [ -x /usr/local/bin/scriptherder ]; then
|
||||||
SCRIPTHERDER_CMD='/usr/local/bin/scriptherder --mode wrap --syslog --name cosmos --'
|
SCRIPTHERDER_CMD='/usr/local/bin/scriptherder --mode wrap --syslog --name cosmos --'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${SCRIPTHERDER_CMD} ${RUN_COSMOS}
|
exec ${SCRIPTHERDER_CMD} ${RUN_COSMOS} "$@"
|
||||||
|
|
Loading…
Reference in a new issue