#!/bin/sh
# yawarra_mfd.sh (make factory defaults)

# Written by Paul McGowan, (c) Yawarra Information Appliances Pty Ltd 2009
# enquiries@yawarra.com.au
# http://www.yawarra.com.au

# This script sets the current configuration to be the "factory default".
# Note: This is the opposite of menu item 4, which makes the factory defaults
# the current configuration.
# You would use this script when you have configured pfSense for a particular
# client or application, and want to to create a failsafe configuration that 
# you can go back to by selecting "reset to factory defaults" (menu item 4).

# To install this script:
# Select menu item 8 to get into the shell
# Run /etc/rc.conf_mount_rw to set the filesystem to 'read/write'
# Copy the script into the current directory
# (either using vi and pasting it, or by scp from another host)
# Set file to be executable using 'chmod +x yawarra_mfd.sh'
# Run /etc/rc.conf_mount_ro to set the filesystem to 'read only'
# Note: This script is already installed in pfSense images obtained from Yawarra

# To use this script:
# Select menu item 8 to get into the shell
# Run ./yawarra_mfd.sh
# Wait for 'Done' message
# Exit the shell

echo "Setting filesystem read/write..."
/etc/rc.conf_mount_rw

echo "Copying current config to default..."
cp /conf/config.xml /conf.default/config.xml

echo "Flushing to disk (CF)..."
sync

echo "Remounting filesystem read only..."
/etc/rc.conf_mount_ro

echo "Done. Current config is now the factory default"

# end script
