summaryrefslogtreecommitdiff
blob: 73d095c8717b60200d15c95edaf9040fc9d7b544 (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
#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/termpkg/files/termnetd.initd,v 1.1 2008/09/23 19:34:00 sbriesen Exp $

description="Terminal Server daemon (${RC_SVCNAME#*.})"
description_reload="Reread configuration file and make the appropriate changes"
extra_started_commands="reload"
command="/usr/sbin/termnetd"
name="termnetd"

depend() {
	use logger
	need net
}

config_check() {
	command_args="${EXTRA_OPTS}"
	CONFIG_FILE_DEFAULT="/etc/termnetd.conf"

	[ -z "${CONFIG_FILE}" ] && CONFIG_FILE="${CONFIG_FILE_DEFAULT}"
	[ -n "${CONTROL_PORT}" ] && command_args="${command_args} -s ${CONTROL_PORT}"
	[ "${CONFIG_FILE}" != "${CONFIG_FILE_DEFAULT}" ] && command_args="${command_args} -c ${CONFIG_FILE}"

	if [ ! -f "${CONFIG_FILE}" ]; then
		eerror "Please create ${CONFIG_FILE}"
		eerror "Sample conf: ${CONFIG_FILE_DEFAULT}.dist"
		return 1
	fi
	return 0
}

start() {
	config_check || return ${?}
	ebegin "Starting ${description}"
	start-stop-daemon --start --quiet --exec "${command}" -- ${command_args}
	eend ${?}
}

stop() {
	ebegin "Stopping ${description}"
	start-stop-daemon --stop --quiet --oknodo --exec "${command}" --name "${name}"
	eend ${?}
}

reload() {
	ebegin "Reloading ${description}"
	start-stop-daemon --stop --signal HUP --oknodo --exec "${command}" --name "${name}"
	eend ${?}
}