diff options
Diffstat (limited to 'projectroot/usr/bin/chrony_command')
-rwxr-xr-x | projectroot/usr/bin/chrony_command | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/projectroot/usr/bin/chrony_command b/projectroot/usr/bin/chrony_command new file mode 100755 index 000000000..03a18d0ae --- /dev/null +++ b/projectroot/usr/bin/chrony_command @@ -0,0 +1,27 @@ +#!/bin/sh +# This is a generic chrony command script which +# extracts the chrony access key from /etc/chrony/chrony.key +# and executes one given command +# some chronyc commands need prior autentication: extract keys from config +PREFIX="chrony command helper: " +command=$1 +if [ -z "$command" ] ; then + echo "Usage: $0 <command>" + exit 0 +fi +[ "$command" = "--help" ] && command="help" + +bailout(){ + echo "${PREFIX}ERROR --- $*" >&2 + exit 1 +} + +KEY=$(awk '$1 ~ /^commandkey$/ { print $2; exit}' /etc/chrony/chrony.conf) +PASSWORD=`awk '$1 ~ /^'$KEY'$/ {print $2; exit}' /etc/chrony/chrony.keys` + +/bin/pidof chronyd > /dev/null || bailout " chronyd is not running " +/usr/bin/chronyc <<-EOF +password $PASSWORD +$command +EOF + |