mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-18 10:35:27 +00:00
88 lines
1.5 KiB
Bash
Executable File
88 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# PROVIDE: configd
|
|
# REQUIRE: SERVERS
|
|
# KEYWORD: shutdown
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="configd"
|
|
rcvar="configd_enable"
|
|
: ${configd_enable="YES"}
|
|
pidfile="/var/run/${name}.pid"
|
|
|
|
start_precmd=configd_prestart
|
|
start_postcmd=configd_poststart
|
|
stop_cmd=configd_stop
|
|
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
|
|
}
|
|
|
|
#
|
|
configd_prestart()
|
|
{
|
|
# reset access rights on configd daemon script
|
|
chmod 700 /usr/local/opnsense/service/configd.py
|
|
}
|
|
|
|
#
|
|
configd_poststart()
|
|
{
|
|
# give the daemon some time to initilize it's configuration
|
|
sleep 1
|
|
}
|
|
|
|
# kill configd
|
|
configd_stop()
|
|
{
|
|
if [ -z "$rc_pid" ]; then
|
|
[ -n "$rc_fast" ] && return 0
|
|
_run_rc_notrunning
|
|
return 1
|
|
fi
|
|
|
|
echo -n "Stopping ${name}."
|
|
# first ask gently to exit
|
|
kill -15 ${rc_pid}
|
|
|
|
# wait max 2 seconds for gentle exit
|
|
for i in $(seq 1 20);
|
|
do
|
|
if [ -z "`/bin/ps -ex | /usr/bin/awk '{print $1;}' | /usr/bin/grep "^${rc_pid}"`" ]; then
|
|
break
|
|
fi
|
|
sleep 0.1
|
|
done
|
|
|
|
# kill any remaining configd processes (if still running)
|
|
for configd_pid in `/bin/ps -ex | grep 'configd.py' | /usr/bin/awk '{print $1;}' `
|
|
do
|
|
kill -9 $configd_pid >/dev/null 2>&1
|
|
done
|
|
|
|
echo "..done"
|
|
}
|
|
|
|
# cleanup after stopping configd
|
|
configd_poststop()
|
|
{
|
|
if [ -S /var/run/configd.socket ]; then
|
|
rm /var/run/configd.socket
|
|
fi
|
|
}
|
|
|
|
load_rc_config $name
|
|
configd_load_rc_config
|
|
run_rc_command $1
|