Created
September 4, 2013 16:02
-
-
Save hgdeoro/6439133 to your computer and use it in GitHub Desktop.
Init script for ntpd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
# ntpd-samba Control the NTP server | |
# | |
# chkconfig: - 90 10 | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
RETVAL=0 | |
PROCNAME=ntpd | |
USER=ntp | |
GROUP=ntp | |
CONFIG="/opt/ntp-4.2.6p5/etc/ntp.conf" | |
PIDFILE="/opt/ntp-4.2.6p5/var/lib/ntp/ntp.pid" | |
. /opt/ntp-4.2.6p5/settings | |
# See how we were called. | |
case "$1" in | |
start) | |
echo -n "Starting ntpd server for Samba 4: " | |
ntpd -c $CONFIG -u $USER:$GROUP -p $PIDFILE -g | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ] | |
then | |
echo_success | |
else | |
echo_failure | |
fi | |
echo | |
;; | |
stop) | |
echo -n "Stopping ntpd server for Samba 4: " | |
su -l -s /bin/bash -c "kill $(cat $PIDFILE) > /dev/null 2> /dev/null" $USER | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ] | |
then | |
echo_success | |
else | |
echo_failure | |
fi | |
echo | |
;; | |
status) | |
pids=$(pgrep -u $USER $PGREP) | |
if [ -z "$pids" ] ; then | |
echo "ntpd not running..." | |
RETVAL=1 | |
else | |
echo -n "ntpd running - Pids: " | |
for pid in $pids ; do | |
echo -n "$pid " | |
done | |
echo "" | |
RETVAL=0 | |
fi | |
;; | |
restart|reload) | |
$0 stop | |
$0 start | |
RETVAL=$? | |
;; | |
*) | |
echo "Usage: ntpd-samba {start|stop|status|restart}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment