mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
rc: pluggable backup via rc.syshook
To achieve this pass additional arguments and also parse a subdirectory to find the appropriate scripts. Eventually it should make exclusive use of the directories.
This commit is contained in:
parent
f9f896533c
commit
43966ce7b7
10
plist
10
plist
@ -72,11 +72,6 @@
|
||||
/usr/local/etc/pkg/fingerprints/OPNsense/trusted/opnsense-update.deciso.com.20170721
|
||||
/usr/local/etc/pkg/fingerprints/OPNsense/trusted/pkg.opnsense.org.20171219
|
||||
/usr/local/etc/rc
|
||||
/usr/local/etc/rc.backup_captiveportal
|
||||
/usr/local/etc/rc.backup_dhcpleases
|
||||
/usr/local/etc/rc.backup_duid
|
||||
/usr/local/etc/rc.backup_netflow
|
||||
/usr/local/etc/rc.backup_rrd
|
||||
/usr/local/etc/rc.bootup
|
||||
/usr/local/etc/rc.carp
|
||||
/usr/local/etc/rc.configure_firmware
|
||||
@ -135,6 +130,11 @@
|
||||
/usr/local/etc/rc.syshook.d/90-carp.start
|
||||
/usr/local/etc/rc.syshook.d/90-cron.start
|
||||
/usr/local/etc/rc.syshook.d/95-beep.start
|
||||
/usr/local/etc/rc.syshook.d/backup/20-captiveportal
|
||||
/usr/local/etc/rc.syshook.d/backup/20-dhcpleases
|
||||
/usr/local/etc/rc.syshook.d/backup/20-duid
|
||||
/usr/local/etc/rc.syshook.d/backup/20-netflow
|
||||
/usr/local/etc/rc.syshook.d/backup/20-rrd
|
||||
/usr/local/etc/rc.update_bogons
|
||||
/usr/local/etc/ssl/opnsense.cnf
|
||||
/usr/local/opnsense/contrib/IXR/IXR_Library.php
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2015-2017 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2015-2018 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@ -33,32 +33,49 @@
|
||||
# It could be useful for the user to order scripts
|
||||
# or set a higher/lower priority in case some
|
||||
# use case requires a slightly different setup.
|
||||
#
|
||||
# Arguments beyond the syshook level are passed on to
|
||||
# the to be executed scripts.
|
||||
#
|
||||
# The syshook level can be given as a suffix or is implied
|
||||
# via the subdirectory used. For backwards compat the
|
||||
# subdirectory given is used, otherwise the old format
|
||||
# is used.
|
||||
|
||||
SYSDIR="/usr/local/etc/rc.syshook.d"
|
||||
SYSLEVEL="${1}"
|
||||
|
||||
shift
|
||||
|
||||
if [ -z "${SYSLEVEL}" ]; then
|
||||
# we don't know of a default
|
||||
exit 1;
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d ${SYSDIR} ]; then
|
||||
# no dir no fun
|
||||
exit 0;
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# collect all matching scripts
|
||||
SYSHOOKS=$(find -s ${SYSDIR} -type f -name "*.${SYSLEVEL}")
|
||||
|
||||
for SYSHOOK in ${SYSHOOKS}; do
|
||||
if [ -d ${SYSDIR}/${SYSLEVEL} ]; then
|
||||
# in the subdir all files match
|
||||
SYSHOOKS="$(find -s ${SYSDIR}/${SYSLEVEL} -type f})"
|
||||
fi
|
||||
|
||||
# XXX pre-18.7 compat: collect all matching root scripts
|
||||
SYSHOOKS="${SYSHOOKS} $(find -s ${SYSDIR} -type f -depth 1 -name "*.${SYSLEVEL}")"
|
||||
|
||||
for _SYSHOOK in ${SYSHOOKS}; do
|
||||
# extract syshook origin
|
||||
SYSHOOK=${SYSHOOK##"${SYSDIR}/"}
|
||||
SYSHOOK=${_SYSHOOK##"${SYSDIR}/"}
|
||||
SYSHOOK=${SYSHOOK##"${SYSLEVEL}/"}
|
||||
SYSHOOK=${SYSHOOK%%".${SYSLEVEL}"}
|
||||
SYSNAME=${SYSHOOK#??-}
|
||||
|
||||
echo ">>> Invoking ${SYSLEVEL} script '${SYSNAME}'"
|
||||
|
||||
if ! ${SYSDIR}/${SYSHOOK}.${SYSLEVEL}; then
|
||||
if ! ${_SYSHOOK} "${@}"; then
|
||||
echo ">>> Error in ${SYSLEVEL} script '${SYSNAME}'"
|
||||
fi
|
||||
done
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Restore backups from previous shutdown
|
||||
for BACKUP in captiveportal dhcpleases duid netflow rrd; do
|
||||
/usr/local/etc/rc.backup_${BACKUP} restore
|
||||
done
|
||||
/usr/local/etc/rc.syshook backup restore
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Backup volatile internals
|
||||
for BACKUP in captiveportal dhcpleases duid netflow rrd; do
|
||||
/usr/local/etc/rc.backup_${BACKUP}
|
||||
done
|
||||
/usr/local/etc/rc.syshook backup
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user