#!/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 " 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