summaryrefslogtreecommitdiffstats
path: root/src/etc/rc.backup_aliastables.sh
diff options
context:
space:
mode:
authorNOYB <Al_Stu@Frontier.com>2016-04-17 00:18:33 -0700
committerNOYB <Al_Stu@Frontier.com>2016-04-17 00:18:33 -0700
commit03afdafaab503af22ce5c98ad06b9f6bbc459974 (patch)
tree73e6ea94d27823d65e3b3547fdcb03b08edb036d /src/etc/rc.backup_aliastables.sh
parent34515250ca726f096071b139fcebd5d18601162a (diff)
downloadpfsense-03afdafaab503af22ce5c98ad06b9f6bbc459974.zip
pfsense-03afdafaab503af22ce5c98ad06b9f6bbc459974.tar.gz
Alias Tables RAM Disk Store
If ramdisk is enabled keep a copy of the alias tables to restore at boot time. Otherwise unpredictable behavior may occur due to some aliases not being available when the firewall rules load. Because alias tables are typically somewhat static, the following strategies are employed to keep write cycles to a minimum for SSD and flash drive type devices friendliness. 1) Back up during reboot/shutdown only if a backup copy of the alias table does not already exists. This is typically during the reboot when ramdisk is first enabled. 2) Update the backup copy only when the alias table is updated with a new download, typically 1 or more days, as configured in the firewall alias.
Diffstat (limited to 'src/etc/rc.backup_aliastables.sh')
-rw-r--r--src/etc/rc.backup_aliastables.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/etc/rc.backup_aliastables.sh b/src/etc/rc.backup_aliastables.sh
new file mode 100644
index 0000000..dfc8b72
--- /dev/null
+++ b/src/etc/rc.backup_aliastables.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+: ${DBPATH:=/var/db/aliastables}
+: ${CF_CONF_PATH:=/cf/conf}
+
+: ${RAM_Disk_Store:=${CF_CONF_PATH}/RAM_Disk_Store/${DBPATH}}
+
+# Save the alias tables database to the RAM disk store.
+if [ -d "${DBPATH}" ]; then
+ [ -z "$NO_REMOUNT" ] && /etc/rc.conf_mount_rw
+
+ if [ ! -d "${RAM_Disk_Store}" ]; then
+ mkdir -p "${RAM_Disk_Store}"
+ fi
+
+ for aliastablefile in "${DBPATH}"/* ; do
+ filename="$(basename ${aliastablefile})"
+ if [ ! -f "${RAM_Disk_Store}/${filename}.tgz" ]; then
+ cd / && /usr/bin/tar -czf "${RAM_Disk_Store}/${filename}.tgz" -C / "${DBPATH}/${filename}"
+ fi
+ done
+
+ [ -z "$NO_REMOUNT" ] && /etc/rc.conf_mount_ro
+fi
OpenPOWER on IntegriCloud