2014-02-04 01:52:58 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# PROVIDE: cbsdd
|
|
|
|
# REQUIRE: LOGIN FILESYSTEMS sshd
|
|
|
|
# KEYWORD: shutdown
|
|
|
|
#
|
|
|
|
# cbsdd_enable="YES"
|
|
|
|
#
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name=cbsdd
|
|
|
|
rcvar=cbsdd_enable
|
|
|
|
load_rc_config $name
|
|
|
|
|
|
|
|
: ${cbsdd_enable="NO"}
|
|
|
|
|
|
|
|
export workdir="${cbsd_workdir}"
|
2014-04-16 08:30:31 +02:00
|
|
|
export NO_CBSD_HISTORY=yes
|
2023-03-05 08:01:25 +01:00
|
|
|
# disable interactive question
|
|
|
|
export NOINTER=1
|
|
|
|
# always answer 'no'
|
|
|
|
export ALWAYS_NO=1
|
|
|
|
|
2019-04-01 23:09:06 +02:00
|
|
|
globalconf=${cbsd_globalconf:-"%%PREFIX%%/cbsd/cbsd.conf"}
|
2014-02-04 01:52:58 +01:00
|
|
|
|
|
|
|
if [ ! -f ${globalconf} ]; then
|
2014-07-13 13:38:47 +02:00
|
|
|
echo "cbsd: no such ${globalconf}";
|
|
|
|
exit 1
|
2014-02-04 01:52:58 +01:00
|
|
|
fi
|
|
|
|
|
2014-02-22 20:45:34 +01:00
|
|
|
if [ ! -f ${mdtools} ]; then
|
2014-07-13 13:38:47 +02:00
|
|
|
echo "cbsd: no such ${mdtools}";
|
|
|
|
exit 1
|
2014-02-22 20:45:34 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f ${subr} ]; then
|
2014-07-13 13:38:47 +02:00
|
|
|
echo "cbsd: no such ${subr}";
|
|
|
|
exit 1
|
2014-02-22 20:45:34 +01:00
|
|
|
fi
|
2014-02-04 01:52:58 +01:00
|
|
|
|
|
|
|
if [ ! -f ${localcbsdconf} ]; then
|
2014-07-13 13:38:47 +02:00
|
|
|
echo "cbsd: no such ${localcbsdconf}";
|
|
|
|
exit 1
|
2014-02-04 01:52:58 +01:00
|
|
|
fi
|
|
|
|
|
2014-02-22 20:45:34 +01:00
|
|
|
. ${globalconf}
|
|
|
|
. ${mdtools}
|
2023-03-05 08:01:25 +01:00
|
|
|
. ${subrdir}/nc.subr
|
2014-02-22 20:45:34 +01:00
|
|
|
|
2014-02-04 01:52:58 +01:00
|
|
|
. ${localcbsdconf}
|
|
|
|
|
|
|
|
start_precmd=${name}_prestart
|
|
|
|
stop_precmd=${name}_prestop
|
2014-07-13 13:38:47 +02:00
|
|
|
stop_cmd=${name}_stop
|
2016-10-30 10:22:15 +01:00
|
|
|
status_cmd="${name}_status"
|
2018-11-26 06:52:55 +01:00
|
|
|
restart_cmd=${name}_restart
|
|
|
|
extra_commands="restart"
|
2014-02-04 01:52:58 +01:00
|
|
|
|
2014-07-13 13:38:47 +02:00
|
|
|
command="${toolsdir}/cbsdd"
|
2019-07-04 18:49:34 +02:00
|
|
|
pidfile="${cbsd_workdir}/var/run/$name.pid"
|
2014-07-13 13:38:47 +02:00
|
|
|
command_args="&"
|
2014-02-04 01:52:58 +01:00
|
|
|
|
|
|
|
cbsdd_prestart() {
|
2014-08-16 16:39:58 +02:00
|
|
|
%%PREFIX%%/bin/cbsd task mode=flushall > /dev/null 2>&1
|
2021-07-12 15:59:13 +02:00
|
|
|
. ${subrdir}/initenv.subr
|
2014-07-13 13:38:47 +02:00
|
|
|
. ${inventory}
|
2014-02-04 01:52:58 +01:00
|
|
|
|
2016-09-24 20:03:43 +02:00
|
|
|
%%PREFIX%%/bin/cbsd sysinv mode=update
|
|
|
|
%%PREFIX%%/bin/cbsd netinv
|
|
|
|
update_netinfo
|
2017-01-24 17:11:00 +01:00
|
|
|
${miscdir}/sqlcli ${dbdir}/local.sqlite "UPDATE jails SET status='0' WHERE status='3'"
|
2018-11-26 06:52:55 +01:00
|
|
|
[ -n "${nat_enable}" ] && %%PREFIX%%/bin/cbsd naton
|
2014-08-16 16:39:58 +02:00
|
|
|
/usr/sbin/daemon -f ${rcddir}/jails-astart start
|
2014-02-04 01:52:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cbsdd_prestop()
|
|
|
|
{
|
2014-07-13 13:38:47 +02:00
|
|
|
${rcddir}/jails-astart stop
|
|
|
|
[ -n "${nat_enable}" ] && %%PREFIX%%/bin/cbsd natoff
|
|
|
|
}
|
|
|
|
|
|
|
|
cbsdd_stop()
|
|
|
|
{
|
2016-10-30 10:22:15 +01:00
|
|
|
if [ -f "${pidfile}" ]; then
|
2018-11-26 06:52:55 +01:00
|
|
|
pids=$( pgrep -F ${pidfile} 2>&1 )
|
|
|
|
_err=$?
|
|
|
|
if [ ${_err} -eq 0 ]; then
|
|
|
|
kill -9 ${pids} && /bin/rm -f ${pidfile}
|
|
|
|
else
|
|
|
|
echo "pgrep: ${pids}"
|
|
|
|
return ${_err}
|
|
|
|
fi
|
2016-10-30 10:22:15 +01:00
|
|
|
fi
|
2014-02-04 01:52:58 +01:00
|
|
|
}
|
|
|
|
|
2018-11-26 06:52:55 +01:00
|
|
|
cbsdd_restart()
|
2014-09-27 16:02:36 +02:00
|
|
|
{
|
2016-10-30 10:22:15 +01:00
|
|
|
if [ -f "${pidfile}" ]; then
|
2023-03-05 08:01:25 +01:00
|
|
|
pkill -9 -F ${pidfile} > /dev/null 2>&1
|
2016-10-30 10:22:15 +01:00
|
|
|
/bin/rm -f ${pidfile}
|
|
|
|
fi
|
2014-09-27 16:02:36 +02:00
|
|
|
run_rc_command "start"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2016-10-30 10:22:15 +01:00
|
|
|
cbsdd_status()
|
|
|
|
{
|
2018-11-26 06:52:55 +01:00
|
|
|
local _err
|
|
|
|
|
2016-10-30 10:22:15 +01:00
|
|
|
if [ -f "${pidfile}" ]; then
|
2018-11-26 06:52:55 +01:00
|
|
|
pids=$( pgrep -F ${pidfile} 2>&1 )
|
|
|
|
_err=$?
|
|
|
|
if [ ${_err} -eq 0 ]; then
|
|
|
|
echo "${name} is running as pid ${pids}."
|
|
|
|
else
|
|
|
|
echo "pgrep: ${pids}"
|
|
|
|
return ${_err}
|
|
|
|
fi
|
2016-10-30 10:22:15 +01:00
|
|
|
else
|
|
|
|
echo "${name} is not running."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-02-04 01:52:58 +01:00
|
|
|
run_rc_command "$1"
|