#!/bin/bash set -e # handles package-based and from source (on slackware) ntp daemons # todo - add chronyd [[ -z $1 ]] && echo vendor? && exit 1 vendor=$1 if [[ $vendor = Debian || $vendor = Ubuntu ]]; then tmp=`dpkg -l | grep ntp | awk '{print $2}' | grep -vE '^sntp$'` elif [[ $vendor = slackware ]]; then tmp=`ls -1 /var/log/packages/*ntp* 2>/dev/null` || true # will show executable path if the daemon is installed from source # openntpd does not offer a version argument # the best we have would be ntpd -dnvf /etc/openntpd.conf [[ ! -n $tmp ]] && tmp=`which ntpd` else echo ERROR DONNO ABOUT $vendor DISTRO VENDOR exit 1 fi output_lines=`echo "$tmp" | wc -l` if [[ -z $tmp ]]; then echo ERROR THERE IS NO NTP PACKAGE INSTALLED echo "$tmp" exit 1 elif (( output_lines > 1 )); then echo ERROR THERE IS MORE THAN ONE NTP PACKAGE INSTALLED echo "$tmp" exit 1 else # we do print a carriage return at the end # this makes it compatible with both clusterit and ansible conditions against stdout|trim echo $tmp fi