summaryrefslogtreecommitdiff
blob: bf8e1433229894bf4fc69b60b26aceea07820a7c (plain)
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
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

PTPD_CONFIGFILE=${PTPD_CONFIGFILE:-/etc/${RC_SVCNAME}.conf}
PTPD_STATEFILE_DIR=${PTPD_STATEFILE_DIR:-/var/run}
PTPD_STATEFILE=${PTPD_STATEFILE:-${PTPD_STATEFILE_DIR}/${RC_SVCNAME}.status}
PTPD_PIDFILE_DIR=${PTPD_PIDFILE_DIR:-/var/run}
PTPD_PIDFILE=${PTPD_PIDFILE:-${PTPD_PIDFILE_DIR}/${RC_SVCNAME}.pid}

extra_commands="checkconfig"
extra_started_commands="reload"
command="/usr/sbin/ptpd2"
command_args="--global:lock_file=$PTPD_PIDFILE --global:status_file=$PTPD_STATEFILE -c $PTPD_CONFIGFILE $PTPD_OPTS"
pidfile="${PTPD_PIDFILE}"
description="Precise Time Protocol daemon"


depend() {
	use net dns logger
}

checkconfig() {
	ebegin "Checking ${SVCNAME} configuration"
	msgout="$($command -k $command_args 2>&1)"
	RETVAL=$?

	# colorize output
	echo "$msgout" | while read ln; do
		if [[ "$ln" == *ignored* ]]; then
			ewarn "$ln"
		elif [[ "$ln" != "Configuration OK" ]]; then
			eerror "$ln"
		fi
	done

	eend $RETVAL
}

start() {
	checkconfig || return 1

	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --start --exec ${command} \
		--pidfile ${pidfile} \
		-- ${command_args}
	eend $?
}

reload() {
	checkconfig || return 1

	ebegin "Reloading ${SVCNAME} configuration"
	start-stop-daemon --signal HUP --pidfile "${pidfile}"
	eend $?
}