Actions
Architecture #4711
closedReplace complex cron one-liner with one script call
Status:
Released
Priority:
N/A
Assignee:
Jonathan CLARKE
Category:
System integration
Target version:
Pull Request:
Effort required:
Name check:
Fix check:
Regression:
Description
Please replace this:
$ tail -1 /etc/cron.d/rudder-agent 0,5,10,15,20,25,30,35,40,45,50,55 * * * * root . /etc/profile; if [ -e /opt/rudder/bin/check-rudder-agent ]; then /opt/rudder/bin/check-rudder-agent; else if [ ! -e /opt/rudder/etc/disable-agent -a `ps -efww | grep -E "(cf-execd|cf-agent)" | grep -E "/var/rudder/cfengine-community/bin/(cf-execd|cf-agent)" | grep -v grep | wc -l` -eq 0 ]; then /var/rudder/cfengine-community/bin/cf-agent -f failsafe.cf >/dev/null 2>&1 && /var/rudder/cfengine-community/bin/cf-agent >/dev/null 2>&1; if [ $? != 0 ]; then if [ -f /opt/rudder/etc/rudder-restart-message.txt ]; then cat /opt/rudder/etc/rudder-restart-message.txt; else echo "Rudder agent was unable to restart on $(hostname)."; fi; fi; fi; fi
with something more readable to prevent typos.
Like this:
$ tail -1 /etc/cron.d/rudder-agent 0,5,10,15,20,25,30,35,40,45,50,55 * * * * root /opt/rudder/bin/rudder-cron.sh $ cat /opt/rudder/bin/rudder-cron.sh #!/bin/bash # # Source profile file . /etc/profile # Do checks if [ -e /opt/rudder/bin/check-rudder-agent ]; then /opt/rudder/bin/check-rudder-agent elif [ ! -e /opt/rudder/etc/disable-agent -a `ps -efww | grep -E "(cf-execd|cf-agent)" | grep -E "/var/rudder/cfengine-community/bin/(cf-execd|cf-agent)" | grep -v grep | wc -l` -eq 0 ]; then /var/rudder/cfengine-community/bin/cf-agent -f failsafe.cf >/dev/null 2>&1 && /var/rudder/cfengine-community/bin/cf-agent >/dev/null 2>&1 if [ $? != 0 ]; then if [ -f /opt/rudder/etc/rudder-restart-message.txt ]; then cat /opt/rudder/etc/rudder-restart-message.txt else echo "Rudder agent was unable to restart on $(hostname)." fi fi fi
NOTE: I did not check the script for errors and I'm not sure what it should to. This is only an example. Have fun!
Actions