From f0ce6758e81a036a6eee144549cbe9e4c72bbe8e Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Wed, 10 Nov 2010 03:03:00 -0700 Subject: Add option to System: Firmware: Settings for running gitsync after installing an update, hidden/disabled if git has not been installed yet. --- etc/phpshellsessions/gitsync | 18 ++++++++++---- tmp/post_upgrade_command.php | 7 ++++++ usr/local/www/system_firmware_settings.php | 38 ++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/etc/phpshellsessions/gitsync b/etc/phpshellsessions/gitsync index 6f7a53f..9fa7079 100644 --- a/etc/phpshellsessions/gitsync +++ b/etc/phpshellsessions/gitsync @@ -19,6 +19,10 @@ $CODIR = "/root/pfsense/"; global $argv; global $command_split; +// If this parameter is set, all interactive functions are disabled +// and neither PHP nor the web gui will be killed or restarted. +$upgrading = in_array("--upgrading", $argv); + unlink_if_exists("/tmp/config.cache"); if(!file_exists("/usr/local/bin/git")) { @@ -61,7 +65,7 @@ if(is_dir("$CODIR/pfSenseGITREPO/pfSenseGITREPO")) { if($command_split[2]) { $branch = $command_split[2]; } else { - if(!$argv[3]) { + if(!$argv[3] && !$upgrading) { echo "\nCurrent repository is $GIT_REPO\n"; echo "\nPlease select which branch you would like to sync against:\n\n"; foreach($branches as $branchname => $branchdesc) { @@ -98,7 +102,7 @@ foreach($branches as $branchname => $branchdesc) { $found = true; } if(!$found) { - if(isURL($branch)) { + if(isURL($branch) && !$upgrading) { echo "\n"; echo "NOTE: $branch was not found.\n\n"; $command = readline("Is this a custom GIT URL? [y]? "); @@ -142,7 +146,7 @@ if(file_exists("/root/.gitsync_merge")) { } } } -if(!$command_split[2] && !$argv[3]) { +if(!$command_split[2] && !$argv[3] && !$upgrading) { do { echo "\nAdd a custom RCS branch URL (HTTP) to merge in or press enter if done.\n\n"; $merge_repo = readline("> "); @@ -268,11 +272,15 @@ exec("mv $CODIR/pfSenseGITREPO/gitsync_temp.git $CODIR/pfSenseGITREPO/pfSenseGIT // Reset the repository to restore the deleted files exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard >/dev/null 2>/dev/null"); -post_cvssync_commands(); +if(!$upgrading) + post_cvssync_commands(); echo "===> Checkout complete.\n"; echo "\n"; -echo "Your system is now sync'd and PHP and Lighty will be restarted in 5 seconds.\n\n"; +if(!$upgrading) + echo "Your system is now sync'd and PHP and Lighty will be restarted in 5 seconds.\n\n"; +else + echo "Your system is now sync'd.\n\n"; function post_cvssync_commands() { echo "===> Removing FAST-CGI temporary files...\n"; diff --git a/tmp/post_upgrade_command.php b/tmp/post_upgrade_command.php index 907e3ab..dfe9342 100755 --- a/tmp/post_upgrade_command.php +++ b/tmp/post_upgrade_command.php @@ -6,6 +6,13 @@ require_once("config.inc"); require_once("functions.inc"); + if(file_exists("/usr/local/bin/git") && isset($config['system']['gitsync']['synconupgrade'])) { + if(isset($config['system']['gitsync']['repositoryurl'])) + exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url " . escapeshellarg($config['system']['gitsync']['repositoryurl'])); + if(isset($config['system']['gitsync']['branch'])) + system("pfSsh.php playback gitsync " . escapeshellarg($config['system']['gitsync']['branch']) . " --upgrading"); + } + if($g['platform'] == "embedded") { $config['system']['enableserial'] = true; write_config(); diff --git a/usr/local/www/system_firmware_settings.php b/usr/local/www/system_firmware_settings.php index 216604a..ea3c215 100755 --- a/usr/local/www/system_firmware_settings.php +++ b/usr/local/www/system_firmware_settings.php @@ -57,11 +57,19 @@ if ($_POST) { else unset($config['system']['firmware']['allowinvalidsig']); + if($_POST['synconupgrade'] == "yes") + $config['system']['gitsync']['synconupgrade'] = true; + else + unset($config['system']['gitsync']['synconupgrade']); + $config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl']; + $config['system']['gitsync']['branch'] = $_POST['branch']; + write_config(); } } $curcfg = $config['system']['firmware']; +$gitcfg = $config['system']['gitsync']; $pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings")); include("head.inc"); @@ -156,6 +164,36 @@ function enable_altfirmwareurl(enable_over) { + + +   + + + + + + + + /> +
+ + + + + + + + + + + + + +
+ + + +   -- cgit v1.1