xntp revision eb1a34638eba7c5add1421327f3eb225a8ea7518
#!/sbin/sh
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
. /lib/svc/share/smf_include.sh
. /lib/svc/share/ipf_include.sh
#
# For ipfilter method. Normal start method will 'ignore' this information.
#
port=`$SERVINFO -p -s ntp 2>/dev/null`
if [ "$1" = "ipfilter" ]; then
FMRI=$2
out=`fmri_to_file $FMRI $IPF_SUFFIX`
else
out=`fmri_to_file $SMF_FMRI $IPF_SUFFIX`
fi
if [ ! -f /etc/inet/ntp.conf ]; then
echo "Error: Configuration file '/etc/inet/ntp.conf' not found." \
" See xntpd(1M)."
exit $SMF_EXIT_ERR_CONFIG
fi
ARGS=`/usr/bin/nawk '
BEGIN {
first = 1
}
/^[ \t]*#/ {
next
}
/^multicastclient[ \t]+/ {
if (first) {
first = 0
printf("-s -m")
}
if (NF == 1) {
printf(" 224.0.1.1")
printf("pass in log quick from any to 224.0.1.1\n") > file
} else {
printf(" %s", $2)
printf("pass in log quick from any to %s\n", $2) > file
}
next
}
/^server 127.127/ {
printf("pass in log quick from any to 224.0.1.1\n") > file
next
}
/^server[ \t]+|^peer[ \t]+/ {
if (first) {
first = 0
printf("-s")
}
printf(" %s", $2)
printf("pass in quick from %s to any port = %d\n", $2, port) > file
next
}
' port="$port" file="$out" /etc/inet/ntp.conf`
#
# Create ipfilter rules
#
if [ -n "$1" -a "$1" = "ipfilter" ]; then
policy=`get_policy $FMRI`
echo "# $FMRI server rules" >>$out
tport=`$SERVINFO -p -t -s "ntp" 2>/dev/null`
if [ -n "$tport" ]; then
generate_rules $FMRI $policy "tcp" "any" $tport $out
fi
uport=`$SERVINFO -p -u -s "ntp" 2>/dev/null`
if [ -n "$uport" ]; then
generate_rules $FMRI $policy "udp" "any" $uport $out
fi
exit $SMF_EXIT_OK
fi
# Run ntpdate to sync system to peer before starting xntpd
[ -n "$ARGS" ] && /usr/sbin/ntpdate $ARGS
/usr/lib/inet/xntpd