Skip to content

Commit 0c815b5

Browse files
committed
add parameter-option to ispconfig_patch for unattended patches
1 parent 568b977 commit 0c815b5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

server/scripts/ispconfig_patch

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ function is_installed($appname) {
8787
}
8888
}
8989

90+
$cmd_opt = getopt('', array('patch_id::'));
91+
$auto = false;
92+
if(isset($cmd_opt['patch_id'])) {
93+
$patch_id = $cmd_opt['patch_id'];
94+
$auto = true;
95+
}
96+
9097
echo "\n\n".str_repeat('-',80)."\n";
9198
echo " _____ ___________ _____ __ _
9299
|_ _/ ___| ___ \ / __ \ / _(_)
@@ -98,14 +105,14 @@ echo " _____ ___________ _____ __ _
98105
|___/ ";
99106
echo "\n".str_repeat('-',80)."\n";
100107
echo "\n\n>> Patch tool \n\n";
101-
echo "Please enter the patch id that you want to be applied to your ISPConfig installation.\nPlease be aware that we take NO responsibility that this will work for you.\nOnly use patches if you know what you are doing.\n\n";
108+
if(!$auto) echo "Please enter the patch id that you want to be applied to your ISPConfig installation.\nPlease be aware that we take NO responsibility that this will work for you.\nOnly use patches if you know what you are doing.\n\n";
102109

103110
if(!is_installed('patch')) {
104111
swriteln("The program 'patch' is missing on your server. Please install it and try again.");
105112
exit;
106113
}
107114

108-
$patch_id = simple_query('Enter patch id', false, '');
115+
if(!$auto) $patch_id = simple_query('Enter patch id', false, '');
109116
if($patch_id == '') {
110117
swriteln("Patch terminated by user.\n");
111118
die();
@@ -122,7 +129,7 @@ if(!$patch_data) {
122129

123130
$patch_text = @file_get_contents('http://ispconfig.org/downloads/patches/' . $patch_id . '.txt');
124131
if($patch_text) {
125-
$ok = simple_query("Patch description:\n".str_repeat("-", 80)."\n".$patch_text."\n".str_repeat("-", 80)."\nDo you really want to apply this patch now?", array('y','n'), 'y');
132+
if($auto) $ok = 'y'; else $ok = simple_query("Patch description:\n".str_repeat("-", 80)."\n".$patch_text."\n".str_repeat("-", 80)."\nDo you really want to apply this patch now?", array('y','n'), 'y');
126133
if($ok != 'y') {
127134
swriteln("Patch terminated by user.\n");
128135
die();
@@ -140,4 +147,4 @@ unlink($temp_file);
140147

141148
exit;
142149

143-
?>
150+
?>

0 commit comments

Comments
 (0)