summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/phpshellsessions/gitsync18
-rwxr-xr-xtmp/post_upgrade_command.php7
-rwxr-xr-xusr/local/www/system_firmware_settings.php38
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) {
<?=gettext("Allow updating the system with auto-updater and images with no signature."); ?>
</td>
</tr>
+<?php if(file_exists("/usr/local/bin/git")): ?>
+ <tr>
+ <td colspan="2" class="list" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked"; ?> />
+ <br />
+ <?=gettext("After updating, sync with the following repository/branch before reboot."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="repositoryurl" type="input" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>">
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="branch" type="input" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>">
+ <br />
+ <?=gettext("Sync will not be performed if a branch is not specified."); ?>
+ </td>
+ </tr>
+<?php endif; ?>
<script>enable_altfirmwareurl();</script>
<tr>
<td width="22%" valign="top">&nbsp;</td>
OpenPOWER on IntegriCloud