@@ -21,6 +21,7 @@ class UpdateCommand extends Command {
2121 protected bool $ shouldStop = false ;
2222 protected bool $ skipBackup = false ;
2323 protected bool $ skipUpgrade = false ;
24+ protected string $ urlOverride = '' ;
2425
2526 /** @var list<string> strings of text for stages of updater */
2627 protected array $ checkTexts = [
@@ -45,7 +46,8 @@ protected function configure(): void {
4546 ->setDescription ('Updates the code of an Nextcloud instance ' )
4647 ->setHelp ("This command fetches the latest code that is announced via the updater server and safely replaces the existing code with the new one. " )
4748 ->addOption ('no-backup ' , null , InputOption::VALUE_NONE , 'Skip backup of current Nextcloud version ' )
48- ->addOption ('no-upgrade ' , null , InputOption::VALUE_NONE , "Don't automatically run occ upgrade " );
49+ ->addOption ('no-upgrade ' , null , InputOption::VALUE_NONE , "Don't automatically run occ upgrade " )
50+ ->addOption ('url ' , null , InputOption::VALUE_OPTIONAL , 'The URL of the Nextcloud release to download ' );
4951 }
5052
5153 public static function getUpdaterVersion (): string {
@@ -60,6 +62,7 @@ public static function getUpdaterVersion(): string {
6062 protected function execute (InputInterface $ input , OutputInterface $ output ) {
6163 $ this ->skipBackup = (bool )$ input ->getOption ('no-backup ' );
6264 $ this ->skipUpgrade = (bool )$ input ->getOption ('no-upgrade ' );
65+ $ this ->urlOverride = (string )$ input ->getOption ('url ' );
6366
6467 $ version = static ::getUpdaterVersion ();
6568 $ output ->writeln ('Nextcloud Updater - version: ' . $ version );
@@ -133,7 +136,12 @@ protected function execute(InputInterface $input, OutputInterface $output) {
133136 $ output ->writeln ('Current version is ' . $ this ->updater ->getCurrentVersion () . '. ' );
134137
135138 // needs to be called that early because otherwise updateAvailable() returns false
136- $ updateString = $ this ->updater ->checkForUpdate ();
139+ if ($ this ->urlOverride ) {
140+ $ this ->updater ->log ('[info] Using URL override: ' . $ this ->urlOverride );
141+ $ updateString = 'Update check forced with URL override: ' . $ this ->urlOverride ;
142+ } else {
143+ $ updateString = $ this ->updater ->checkForUpdate ();
144+ }
137145
138146 $ output ->writeln ('' );
139147
@@ -146,9 +154,11 @@ protected function execute(InputInterface $input, OutputInterface $output) {
146154
147155 $ output ->writeln ('' );
148156
149- if (!$ this ->updater ->updateAvailable () && $ stepNumber === 0 ) {
150- $ output ->writeln ('Nothing to do. ' );
151- return 0 ;
157+ if (!$ this ->urlOverride ) {
158+ if (!$ this ->updater ->updateAvailable () && $ stepNumber === 0 ) {
159+ $ output ->writeln ('Nothing to do. ' );
160+ return 0 ;
161+ }
152162 }
153163
154164 $ questionText = 'Start update ' ;
@@ -360,10 +370,10 @@ protected function executeStep(int $step): array {
360370 }
361371 break ;
362372 case 4 :
363- $ this ->updater ->downloadUpdate ();
373+ $ this ->updater ->downloadUpdate ($ this -> urlOverride );
364374 break ;
365375 case 5 :
366- $ this ->updater ->verifyIntegrity ();
376+ $ this ->updater ->verifyIntegrity ($ this -> urlOverride );
367377 break ;
368378 case 6 :
369379 $ this ->updater ->extractDownload ();
0 commit comments