Skip to content

Instantly share code, notes, and snippets.

@vkhatri
Created January 2, 2016 02:15
Show Gist options
  • Save vkhatri/1c3d9b287338ed0288c0 to your computer and use it in GitHub Desktop.
Save vkhatri/1c3d9b287338ed0288c0 to your computer and use it in GitHub Desktop.
consul event ntpd service restart
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
# Add below lines
Defaults:consul !requiretty
consul ALL=(root) /sbin/service ntpd restart
{
"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