Commit 92bc0fe5 authored by Franco Fichtner's avatar Franco Fichtner

rc: rework halt/reboot and fix dhcplease/rrd persistency (#56)

I know, I know, backing up rrd and restoring it after reboot seems
like overkill, but the good thing is that if you ever decide to
install from a clean image the config import is able to pick up
your backups as well and you will not lose any history.
parent aea19e3f
#!/bin/sh
# $Id$
if ! /usr/bin/lockf -s -t 30 /tmp/config.lock /usr/bin/true; then
echo "Cannot halt at this moment, a config write operation is in progress and 30 seconds have passed."
exit -1
......@@ -9,4 +7,14 @@ fi
sleep 1
/sbin/shutdown -p now
/usr/local/etc/rc.backup_rrd
/usr/local/etc/rc.backup_dhcpleases
sleep 1
SHUTDOWN=/sbin/shutdown
if [ -f /sbin/shutdown.old ]; then
SHUTDOWN=/sbin/shutdown.old
fi
$SHUTDOWN -p now
......@@ -54,6 +54,8 @@ echo
# if we can update base, we'll do that as well
if opnsense-update -c; then
# apparently, this is for moving between amd64 <-> i386
cp -p /sbin/shutdown /sbin/shutdown.old
opnsense-update && /usr/local/etc/rc.reboot
else
opnsense-update
......
......@@ -7,21 +7,8 @@ fi
sleep 1
# If PLATFORM is pfSense then remove
# temporary files on shutdown from /tmp/
PLATFORM=`cat /usr/local/etc/platform`
if [ "$PLATFORM" = "pfSense" ]; then
rm -rf /tmp/*
fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /conf/config.xml`
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
if [ "${PLATFORM}" != "pfSense" ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = "md" ]; then
/usr/local/etc/rc.backup_rrd
/usr/local/etc/rc.backup_dhcpleases
fi
/usr/local/etc/rc.backup_rrd
/usr/local/etc/rc.backup_dhcpleases
sleep 1
......
#!/bin/sh
if ! /usr/bin/lockf -s -t 30 /tmp/config.lock /usr/bin/true; then
echo "Cannot shutdown at this moment, a config write operation is in progress and 30 seconds have passed."
exit -1
fi
product=`cat /usr/local/etc/inc/globals.inc | grep product_name | cut -d'"' -f4`
echo
echo "${product} is now shutting down ..."
echo
stty status '^T'
# Set shell to ignore SIGINT (2), but not children;
trap : 2
HOME=/; export HOME
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
# If PLATFORM is pfSense then remove
# temporary files on shutdown from /tmp/
PLATFORM=`cat /usr/local/etc/platform`
if [ "$PLATFORM" = "pfSense" ]; then
find -x /tmp/* -type f -exec rm -f {} \; >/dev/null 2>&1
fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /conf/config.xml`
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
if [ "${PLATFORM}" != "pfSense" ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = "md" ]; then
/usr/local/etc/rc.backup_rrd
/usr/local/etc/rc.backup_dhcpleases
fi
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