diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2008-07-31 20:46:50 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2008-07-31 20:46:50 +0000 |
commit | ff33e21f1fe38cc4c40ac4e70aaf8f2d545f6026 (patch) | |
tree | 0dde301976fb87e72262fe2271695b00f28375d1 | |
parent | 18f081726f1d80f26d892f5a560556ceb34bf571 (diff) | |
download | pfsense-ff33e21f1fe38cc4c40ac4e70aaf8f2d545f6026.zip pfsense-ff33e21f1fe38cc4c40ac4e70aaf8f2d545f6026.tar.gz |
* Backup prior configuration before syncing. Tired of blowing up my
firewall and having to spend hours to get back online. This is not
exactly productive.
* Add a RESTORE option as a branch if we detect a previous CVSSYNC.
With these changes it should be easy as pie to revert to the last known
good working state.
-rw-r--r-- | etc/phpshellsessions/cvssync | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/etc/phpshellsessions/cvssync b/etc/phpshellsessions/cvssync index 2167e26..ca46f50 100644 --- a/etc/phpshellsessions/cvssync +++ b/etc/phpshellsessions/cvssync @@ -47,7 +47,11 @@ global $command_split; /* NOTE: Set branches here */ $branches = array("RELENG_1_MULTI_ANYTHING" => "Ermals multi interface branch", "RELENG_1" => "1.3 development branch", - "RELENG_1_2" => "1.2 release branch"); + "RELENG_1_2" => "1.2 release branch", + ); + +if(file_exists("/root/cvssync_backup.tgz")) + $branches[] = array("RESTORE" => "Restores prior CVSSync backup data."); if($command_split[2]) { $branch = $command_split[2]; @@ -79,6 +83,21 @@ if(!$found) { exit; } +if($branch == "RESTORE") { + if(!file_exists("/root/cvssync_backup.tgz")) { + echo "Sorry, we could not find a previous CVSSync backup file.\n"; + exit(); + } + echo "===> Restoring previous CVSSync backup... Please wait...\n"; + exec("tar xzPf /root/cvssync_backup.tgz -C /"); + post_cvssync_commands(); + exit(); +} + +echo "===> Backing up current pfSense information... Please wait...\n"; +exec("tar czPf /root/cvssync_backup.tgz --exclude /root --exclude /dev --exclude /tmp /"); +exec("ls -lah /root/cvssync_backup.tgz"); + echo "===> Checking out $branch\n"; exec("mkdir -p /home/pfsense/$branch"); system("cvsup /var/etc/pfSense-supfile"); @@ -114,27 +133,32 @@ exec("cd $CODIR/pfSense ; tar -cpf - . | (cd / ; tar -Uxpf -)"); echo "CVS Sync Complete\n"; -echo "Removing FAST-CGI temporary files...\n"; -exec("find /tmp -name \"*php*\" -exec rm -rf {} \;"); +post_cvssync_commands(); -exec("rm -rf /tmp/xcache/* 2>/dev/null"); +echo "===> Checkout complete. Your system is now sync'd. Scripting terminating.\n"; -echo "Upgrading configuration...\n"; +function post_cvssync_commands() { + echo "Removing FAST-CGI temporary files...\n"; + exec("find /tmp -name \"*php*\" -exec rm -rf {} \;"); -convert_config(); -sync_webgui_passwords(); + exec("rm -rf /tmp/xcache/* 2>/dev/null"); -echo "Restarting check_reload_status...\n"; -exec("killall check_reload_status"); -mwexec_bg("nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status"); + echo "Upgrading configuration...\n"; -echo "Configuring filter..."; -exec("/etc/rc.filter_configure_sync"); -exec("pfctl -f /tmp/rules.debug"); -echo "\n"; + convert_config(); + sync_webgui_passwords(); -echo "===> Checkout complete. Your system is now sync'd. Scripting terminating.\n"; + echo "Restarting check_reload_status...\n"; + exec("killall check_reload_status"); + mwexec_bg("nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status"); + + echo "Configuring filter..."; + exec("/etc/rc.filter_configure_sync"); + exec("pfctl -f /tmp/rules.debug"); -touch("/tmp/restart_webgui"); + echo "\n"; -exec("killall php"); + touch("/tmp/restart_webgui"); + + exec("killall php"); +} |