configd 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: configd
# REQUIRE: LOGIN
# KEYWORD: shutdown
#

# load standard rc
. /etc/rc.subr

name=configd

15 16 17
start_precmd=configd_prestart
start_postcmd=configd_poststart
stop_cmd=configd_stop
18 19 20 21 22 23 24 25 26 27 28 29
stop_postcmd=configd_poststop

configd_load_rc_config()
{
	required_args=""
	required_dirs="/usr/local/opnsense/service/"
	required_files=""
	command_args="${required_args}"
	command=/usr/local/opnsense/service/configd.py
	command_interpreter=/usr/local/bin/python2.7
}

30
#
31 32
configd_prestart()
{
33
	# reset access rights on configd daemon script
34 35 36 37 38 39 40
	chmod 700 /usr/local/opnsense/service/configd.py
}

#
configd_poststart()
{
	# give the daemon some time to initilize it's configuration
41
	sleep 1
42
}
43 44

# kill configd
45
configd_stop()
46
{
47 48 49 50 51
	if [ -z "$rc_pid" ]; then
		[ -n "$rc_fast" ] && return 0
		_run_rc_notrunning
		return 1
	fi
52

53 54
	echo -n "Stopping ${name}."
	# first ask gently to exit
55
	kill -15 ${rc_pid}
56 57

	# wait max 2 seconds for gentle exit
58 59
	for i in $(seq 1 20);
	do
60 61
		if [ -z "`/bin/ps -ex | /usr/bin/awk '{print $1;}' | /usr/bin/grep "^${rc_pid}"`" ]; then
			break
62 63 64
		fi
		sleep 0.1
	done
65 66

	# kill if it's still running
67 68 69 70
	if [ ! -z "`/bin/ps -ex | /usr/bin/awk '{print $1;}' | /usr/bin/grep "^${rc_pid}"`" ]; then
		kill -9 ${rc_pid}
	fi
	echo  "..done"
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
}

# cleanup after stopping configd
configd_poststop()
{
	if [ -f /var/run/configd.pid ]; then
		rm /var/run/configd.pid
	fi
	if  [ -f /var/run/configd.socket ]; then
		rm /var/run/configd.socket
	fi
}


load_rc_config $name
configd_load_rc_config
run_rc_command $1