Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:mskibbe
ntp-dev
conf.ntp-dev.init
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File conf.ntp-dev.init of Package ntp-dev
#! /bin/sh # Copyright (c) 1995-2003 SuSE Linux AG, Nuernberg, Germany. # All rights reserved. # # Author: Michael Andres # # /etc/init.d/ntp-dev # and its symbolic link # /usr/sbin/rcntp-dev # ### BEGIN INIT INFO # Provides: ntp-dev ntp-devd xntp-devd # Required-Start: $remote_fs $syslog $named # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 5 # Default-Stop: 0 1 6 # Description: Start network time protocol daemon (NTPD). ### END INIT INFO # First reset status of this service . /etc/rc.status rc_reset # Return values acc. to LSB for all commands but status: # 0 - success # 1 - generic or unspecified error # 2 - invalid or excess argument(s) # 3 - unimplemented feature (e.g. "reload") # 4 - insufficient privilege # 5 - program is not installed # 6 - program is not configured # 7 - program is not running # set default options NTP_CONF="/etc/ntp-dev.conf" if [ ! -f ${NTP_CONF} ]; then echo -n "Time server configuration file, ${NTP_CONF} does not exist." # Tell the user this has skipped rc_status -s exit 6 fi NTPD_BIN="/usr/sbin/ntp-devd" if [ ! -x ${NTPD_BIN} ]; then echo -n "Time server, ${NTPD_BIN} not installed!" rc_status -s exit 5 fi NTPD_OPTIONS="-g -u ntp-dev:ntp-dev" NTPD_RUN_CHROOTED="yes" NTPDATE_BIN="/usr/sbin/ntp-devdate" NTPDC_BIN="/usr/sbin/ntp-devdc" NTP_KEYS=$(awk '/^keys/ { print $2 }' $NTP_CONF) if test -z "$NTP_KEYS"; then echo -n "NTP key file does not exist" rc_status -s exit 5 fi NTP_KEYID=$(awk '/^requestkey[[:blank:]]/ { print $2 }' $NTP_CONF) if test -z "$NTP_KEYS"; then echo -n "NTP key id not defined" rc_status -s exit 5 fi NTP_PASSWD=$(awk '$0 ~ key { print $3 }' key="^[[:blank:]]*$NTP_KEYID[[:blank:]]" $NTP_KEYS) if test -z "$NTP_KEYS"; then echo -n "No password for requestkey set" return 1 fi # Override defaults, if we have the sysconfig file test -f /etc/sysconfig/ntp-dev && . /etc/sysconfig/ntp-dev # set Default CHROOT path if not set but wanted test "${NTPD_RUN_CHROOTED}" = "yes" && \ CHROOT_PREFIX="/var/lib/ntp-dev" || \ CHROOT_PREFIX="" # set default PID variables NTPD_PID="${CHROOT_PREFIX}/var/run/ntp-dev/ntp-devd.pid" NTPD_PID_NOPREFIX="/var/run/ntp-dev/ntp-devd.pid" function ntp-devd_is_running() { $0 status >/dev/null } function parse_symlink { if [ -c "$NTP_PARSE_DEVICE" ]; then if [ -n "$NTP_PARSE_LINK" ]; then ln -sf $NTP_PARSE_DEVICE $NTP_PARSE_LINK fi fi } function prepare_chroot { for configfile in /etc/{localtime,ntp-dev.keys} $NTP_CONF $NTPD_CHROOT_FILES; do test -d ${CHROOT_PREFIX}/${configfile%/*} || mkdir -p ${CHROOT_PREFIX}/${configfile%/*} cp -auL ${configfile} ${CHROOT_PREFIX}/${configfile%/*} done NTPD_OPTIONS="${NTPD_OPTIONS} -i ${CHROOT_PREFIX}" } function runtime_configuration { NTPC_CMD="keyid $NTP_KEYID\npasswd $NTP_PASSWD\n" for ntp-devserver in "$@"; do NTPC_CMD="${NTPC_CMD}addserver $ntp-devserver\n" done NTPDC_LOG=$(echo -e "${NTPC_CMD}quit" | $NTPDC_BIN) logger -t $0 "runtime configuration: $NTPDC_LOG" } function add_runtime_server { NTPC_CMD="keyid $NTP_KEYID\npasswd $NTP_PASSWD\naddserver $@\n" NTPDC_LOG=$(echo -e "${NTPC_CMD}quit" | $NTPDC_BIN) logger -t $0 "runtime configuration: $NTPDC_LOG" } function reloaddevices { NTPC_CMD="keyid $NTP_KEYID\npasswd $NTP_PASSWD\nifreload\n" NTPDC_LOG=$(echo -e "${NTPC_CMD}quit" | $NTPDC_BIN) logger -t $0 "runtime configuration: $NTPDC_LOG" } function adddhcpserver { if( test -r /var/run/ntp-dev/servers ) then . /var/run/ntp-dev/servers runtime_configuration $RUNTIME_SERVERS return 0 else return 1 fi } case "$1" in start) # get the initial date from the timeservers configured in ntp-dev.conf echo -n "Starting network time protocol daemon (NTPD)" # do we need a refclock symlink? parse_symlink # do we run chrooted? test "${NTPD_RUN_CHROOTED}" = "yes" && prepare_chroot grep -v "^server" $NTP_CONF > $NTP_CONF.tmp grep "^server.*127\.0\.0\.1" $NTP_CONF >> $NTP_CONF.tmp startproc $NTPD_BIN -p ${NTPD_PID_NOPREFIX} $NTPD_OPTIONS -c $NTP_CONF~ rm $NTP_CONF.tmp $0 readd $2 rc_status -v ;; stop) echo -n "Shutting down network time protocol daemon (NTPD)" killproc -p ${NTPD_PID} -TERM $NTPD_BIN rc_status -v rm -f ${NTPD_PID} ;; try-restart) $0 status if test $? = 0; then $0 restart $2 else rc_reset # Not running is not a failure. fi # Remember status and be quiet rc_status ;; restart) $0 stop $0 start $2 rc_status ;; try-restart-iburst) $0 status if test $? = 0; then $0 stop $0 start iburst else rc_reset # Not running is not a failure. fi # Remember status and be quiet rc_status ;; addserver) if test "${#@}" -lt "2"; then echo -n "No servers to add specified" rc_failed 3 fi shift $0 status 2>&1 >/dev/null if test $? = 0; then add_runtime_server $@ fi mv $NTP_CONF $NTP_CONF~ grep -vi "^server.*$1" < $NTP_CONF~ > $NTP_CONF echo "server $@" >> $NTP_CONF ;; force-reload) # Does not support signalling to reload $0 try-restart rc_status ;; readd) reloaddevices adddhcpserver # manage adding server at runtime grep "^server" $NTP_CONF | grep -v "127\.0\.0\.1" | sed -e "s/\n//" | sed -e "s/^server//" | sed -e "s/#.*$//" | while read SERV do # do we get the option iburst? if [ -z $2 ]; then true else case $2 in iburst) SERV="$SERV iburst" ;; *) echo "Unknown option $2" echo "options: {iburst}" exit 1 ;; esac fi add_runtime_server $SERV done rc_status ;; ntp-devtimeset) grep -v 127.127.1.0 /etc/ntp-dev.conf | grep ^server >/dev/null && startproc $NTPD_BIN -p ${NTPD_PID_NOPREFIX} $NTPD_OPTIONS -c $NTP_CONF -q || echo "no server configured" ;; reload) echo -n "Reload network time protocol daemon (NTPD)" # Does not support signalling to reload rc_failed 3 rc_status -v ;; status) checkproc -p ${NTPD_PID} $NTPD_BIN if( test $? -eq 0 ) then ntp-devq -p echo "" fi echo -n "Checking for network time protocol daemon (NTPD): " checkproc -p ${NTPD_PID} $NTPD_BIN rc_status -v ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart|try-restart-iburst|force-reload|reload|addserver|ntp-devtimeset|readd}" exit 1 ;; esac rc_exit
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor