Created
January 2, 2016 02:15
-
-
Save vkhatri/1c3d9b287338ed0288c0 to your computer and use it in GitHub Desktop.
consul event ntpd service restart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response=$(cat -) | |
payload=$(echo $response | sed -e 's/^.*"Payload":"\([^"]*\)".*$/\1/') | |
# action string "runme" == byte "cnVubWU=" , replace "runme" with your payload data | |
if [ "$payload" == "cnVubWU=" ]; then | |
logger restarting ntpd, consul triggered by payload $payload | |
# /usr/bin/sudo /sbin/service ntpd restart | |
else | |
logger skipping ntpd restart, consul triggered by payload $payload | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add below lines | |
Defaults:consul !requiretty | |
consul ALL=(root) /sbin/service ntpd restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"watches": [ | |
{ | |
"name": "ntpd-restart", | |
"type": "event", | |
"handler": "/var/consul_scripts/handler-ntpd-restart.sh" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment