Revision f0ce6758
Added by Erik Fonnesbeck over 14 years ago
etc/phpshellsessions/gitsync | ||
---|---|---|
19 | 19 |
global $argv; |
20 | 20 |
global $command_split; |
21 | 21 |
|
22 |
// If this parameter is set, all interactive functions are disabled |
|
23 |
// and neither PHP nor the web gui will be killed or restarted. |
|
24 |
$upgrading = in_array("--upgrading", $argv); |
|
25 |
|
|
22 | 26 |
unlink_if_exists("/tmp/config.cache"); |
23 | 27 |
|
24 | 28 |
if(!file_exists("/usr/local/bin/git")) { |
... | ... | |
61 | 65 |
if($command_split[2]) { |
62 | 66 |
$branch = $command_split[2]; |
63 | 67 |
} else { |
64 |
if(!$argv[3]) { |
|
68 |
if(!$argv[3] && !$upgrading) {
|
|
65 | 69 |
echo "\nCurrent repository is $GIT_REPO\n"; |
66 | 70 |
echo "\nPlease select which branch you would like to sync against:\n\n"; |
67 | 71 |
foreach($branches as $branchname => $branchdesc) { |
... | ... | |
98 | 102 |
$found = true; |
99 | 103 |
} |
100 | 104 |
if(!$found) { |
101 |
if(isURL($branch)) { |
|
105 |
if(isURL($branch) && !$upgrading) {
|
|
102 | 106 |
echo "\n"; |
103 | 107 |
echo "NOTE: $branch was not found.\n\n"; |
104 | 108 |
$command = readline("Is this a custom GIT URL? [y]? "); |
... | ... | |
142 | 146 |
} |
143 | 147 |
} |
144 | 148 |
} |
145 |
if(!$command_split[2] && !$argv[3]) { |
|
149 |
if(!$command_split[2] && !$argv[3] && !$upgrading) {
|
|
146 | 150 |
do { |
147 | 151 |
echo "\nAdd a custom RCS branch URL (HTTP) to merge in or press enter if done.\n\n"; |
148 | 152 |
$merge_repo = readline("> "); |
... | ... | |
268 | 272 |
// Reset the repository to restore the deleted files |
269 | 273 |
exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard >/dev/null 2>/dev/null"); |
270 | 274 |
|
271 |
post_cvssync_commands(); |
|
275 |
if(!$upgrading) |
|
276 |
post_cvssync_commands(); |
|
272 | 277 |
|
273 | 278 |
echo "===> Checkout complete.\n"; |
274 | 279 |
echo "\n"; |
275 |
echo "Your system is now sync'd and PHP and Lighty will be restarted in 5 seconds.\n\n"; |
|
280 |
if(!$upgrading) |
|
281 |
echo "Your system is now sync'd and PHP and Lighty will be restarted in 5 seconds.\n\n"; |
|
282 |
else |
|
283 |
echo "Your system is now sync'd.\n\n"; |
|
276 | 284 |
|
277 | 285 |
function post_cvssync_commands() { |
278 | 286 |
echo "===> Removing FAST-CGI temporary files...\n"; |
tmp/post_upgrade_command.php | ||
---|---|---|
6 | 6 |
require_once("config.inc"); |
7 | 7 |
require_once("functions.inc"); |
8 | 8 |
|
9 |
if(file_exists("/usr/local/bin/git") && isset($config['system']['gitsync']['synconupgrade'])) { |
|
10 |
if(isset($config['system']['gitsync']['repositoryurl'])) |
|
11 |
exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url " . escapeshellarg($config['system']['gitsync']['repositoryurl'])); |
|
12 |
if(isset($config['system']['gitsync']['branch'])) |
|
13 |
system("pfSsh.php playback gitsync " . escapeshellarg($config['system']['gitsync']['branch']) . " --upgrading"); |
|
14 |
} |
|
15 |
|
|
9 | 16 |
if($g['platform'] == "embedded") { |
10 | 17 |
$config['system']['enableserial'] = true; |
11 | 18 |
write_config(); |
usr/local/www/system_firmware_settings.php | ||
---|---|---|
57 | 57 |
else |
58 | 58 |
unset($config['system']['firmware']['allowinvalidsig']); |
59 | 59 |
|
60 |
if($_POST['synconupgrade'] == "yes") |
|
61 |
$config['system']['gitsync']['synconupgrade'] = true; |
|
62 |
else |
|
63 |
unset($config['system']['gitsync']['synconupgrade']); |
|
64 |
$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl']; |
|
65 |
$config['system']['gitsync']['branch'] = $_POST['branch']; |
|
66 |
|
|
60 | 67 |
write_config(); |
61 | 68 |
} |
62 | 69 |
} |
63 | 70 |
|
64 | 71 |
$curcfg = $config['system']['firmware']; |
72 |
$gitcfg = $config['system']['gitsync']; |
|
65 | 73 |
|
66 | 74 |
$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings")); |
67 | 75 |
include("head.inc"); |
... | ... | |
156 | 164 |
<?=gettext("Allow updating the system with auto-updater and images with no signature."); ?> |
157 | 165 |
</td> |
158 | 166 |
</tr> |
167 |
<?php if(file_exists("/usr/local/bin/git")): ?> |
|
168 |
<tr> |
|
169 |
<td colspan="2" class="list" height="12"> </td> |
|
170 |
</tr> |
|
171 |
<tr> |
|
172 |
<td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td> |
|
173 |
</tr> |
|
174 |
<tr> |
|
175 |
<td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td> |
|
176 |
<td width="78%" class="vtable"> |
|
177 |
<input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked"; ?> /> |
|
178 |
<br /> |
|
179 |
<?=gettext("After updating, sync with the following repository/branch before reboot."); ?> |
|
180 |
</td> |
|
181 |
</tr> |
|
182 |
<tr> |
|
183 |
<td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td> |
|
184 |
<td width="78%" class="vtable"> |
|
185 |
<input name="repositoryurl" type="input" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>"> |
|
186 |
</td> |
|
187 |
</tr> |
|
188 |
<tr> |
|
189 |
<td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td> |
|
190 |
<td width="78%" class="vtable"> |
|
191 |
<input name="branch" type="input" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>"> |
|
192 |
<br /> |
|
193 |
<?=gettext("Sync will not be performed if a branch is not specified."); ?> |
|
194 |
</td> |
|
195 |
</tr> |
|
196 |
<?php endif; ?> |
|
159 | 197 |
<script>enable_altfirmwareurl();</script> |
160 | 198 |
<tr> |
161 | 199 |
<td width="22%" valign="top"> </td> |
Also available in: Unified diff
Add option to System: Firmware: Settings for running gitsync after installing an update, hidden/disabled if git has not been installed yet.