Commit ecf405ad authored by Franco Fichtner's avatar Franco Fichtner

rc: add rc.syshook with early, start and stop hooks; closes #409

parent 18e1e7bb
...@@ -202,6 +202,9 @@ echo "done." ...@@ -202,6 +202,9 @@ echo "done."
# startup configd # startup configd
/usr/local/etc/rc.d/configd start /usr/local/etc/rc.d/configd start
# Execute the early syshook / plugin commands
/usr/local/etc/rc.syshook early
# let the PHP-based configuration subsystem set up the system now # let the PHP-based configuration subsystem set up the system now
echo -n "Launching the init system..." echo -n "Launching the init system..."
rm -f /root/lighttpd* rm -f /root/lighttpd*
...@@ -216,6 +219,9 @@ if [ -f "/tmp/donotbootup" ]; then ...@@ -216,6 +219,9 @@ if [ -f "/tmp/donotbootup" ]; then
exit 0 exit 0
fi fi
# Execute the normal syshook / plugin commands
/usr/local/etc/rc.syshook start
echo -n "Starting CRON... " echo -n "Starting CRON... "
cd /tmp && /usr/sbin/cron -s 2>/dev/null cd /tmp && /usr/sbin/cron -s 2>/dev/null
echo "done." echo "done."
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
# run beep sequence if enabled # run beep sequence if enabled
/usr/local/sbin/beep.sh stop /usr/local/sbin/beep.sh stop
# shutdown syshook / plugin scripts
/usr/local/etc/rc.syshook stop
# shutdown rc scripts # shutdown rc scripts
/usr/local/etc/rc.opnsense stop /usr/local/etc/rc.opnsense stop
......
#!/bin/sh
# Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
SYSDIR="/usr/local/etc/rc.syshook.d"
SYSLEVEL="${1}"
if [ -z "${SYSLEVEL}" ]; then
# we don't know of a default
exit 1;
fi
if [ ! -d ${SYSDIR} ]; then
# no dir no fun
exit 0;
fi
# collect all matching scripts
SYSHOOKS=$(find ${SYSDIR} -type f -name "*.${SYSLEVEL}")
for SYSHOOK in ${SYSHOOKS}; do
# extract syshook origin
SYSHOOK=${SYSHOOK##"${SYSDIR}/"}
SYSHOOK=${SYSHOOK%%".${SYSLEVEL}"}
echo "rc.syshook: launching ${SYSHOOK}.${SYSLEVEL}"
if ! ${SYSDIR}/${SYSHOOK}.${SYSLEVEL}; then
echo "rc.syshook: error in ${SYSHOOK}.${SYSLEVEL}"
fi
done
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment