File: init

package info (click to toggle)
htpdate 1.2.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 160 kB
  • sloc: ansic: 568; sh: 111; makefile: 27
file content (69 lines) | stat: -rw-r--r-- 1,563 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# Script for htpdate.
# C2014, Joao Eriberto Mota Filho
# Based on original upstream script, available at scripts/htpdate.init

### BEGIN INIT INFO
# Provides:        htpdate
# Required-Start:  $network $remote_fs $syslog
# Required-Stop:   $network $remote_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start htpdate daemon
# Description:       Starts and stops the htpdate daemon used to
#                    synchronize a computer time.
### END INIT INFO

test -x /usr/sbin/htpdate || exit 0

. /lib/lsb/init-functions || exit 0

if [ -f /etc/default/htpdate ]; then
    . /etc/default/htpdate
else
    exit 0
fi

if [ "$HTP_DAEMON" = "no" ]; then
    echo "htpdate is disabled. Please, see /etc/default/htpdate."
    exit 0
fi

HTPCOM="/usr/sbin/htpdate"
PIDFILE="/var/run/htpdate.pid"

case "$1" in
	start)
		echo "Starting HTTP Time Protocol daemon: htpdate"
		# Set the time first before daemonizing, because the time offset
		# might be too big for smooth time adjustment
		$HTPCOM $HTP_OPTIONS $HTP_PROXY -i $PIDFILE $HTP_SERVERS
		;;
	stop)
		echo "Stopping HTTP Time Protocol daemon: htpdate"
		if [ -f $PIDFILE ]
		then
			kill `cat $PIDFILE`
		else
			echo "$PIDFILE not found"
		fi
		rm -f $PIDFILE
		;;
	restart)
		$0 stop
		$0 start
		;;
	reload|force-reload)
		echo "Reloading htpdate"
		start-stop-daemon --stop --signal 1 --exec $HTPCOM
		;;
	status)
		status_of_proc -p $PIDFILE $HTPCOM htpdate
		;;
	*)
		echo "Usage: $0 {start|stop|restart|reload|force-reload|status}"
		exit 1
esac

exit 0