#!/bin/sh
# $Owl: Owl/packages/openntpd/openntpd.control,v 1.3 2005/11/16 13:21:53 solar Exp $

. /etc/control.d/functions

CONFIG=/etc/ntpd.conf
EXE=/etc/init.d/ntpd

# XXX: Actually we should uncomment only the first 'listen on' directive.
#      The way proposed below isn't reliable since it's bound to the
#      presence of the '# Addresses ...' comment line right before the
#      first 'listen on' directive.
#                                                             -- (GM)
new_subst server \
	'^[[:space:]]*listen[[:space:]]+on[[:space:]]' \
	'/# Addresses to/,+1 s,^#\([[:space:]]*listen[[:space:]]\+on[[:space:]]\),\1,'
new_subst client \
	'^#[[:space:]]*listen[[:space:]]+on[[:space:]]' \
	's,^\([[:space:]]*listen[[:space:]]\+on[[:space:]]\),#\1,'

new_help client "Comment out \"listen on\" directive, see ntpd.conf(5)"
new_help server "Uncomment \"listen on\" directive, see ntpd.conf(5)"

new_summary "Network Time Protocol daemon"

is_builtin_mode "$*" ||
	[ "$*" != "`control_subst "$CONFIG" status`" ] || exit 0

control_subst "$CONFIG" "$*" || exit 1

is_builtin_mode "$*" ||
	[ ! -x "$EXE" ] || "$EXE" condrestart || exit 0
