Skip to content

Commit 675b292

Browse files
committed
Adds SUS server checks to most commands, as well as SUS server info and cache locator info to the summary command.
1 parent 3723698 commit 675b292

File tree

11 files changed

+138
-47
lines changed

11 files changed

+138
-47
lines changed

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ $command[] = new DevCoding\Mac\Update\Command\DownloadCommand();
1414
$command[] = new DevCoding\Mac\Update\Command\InstallCommand();
1515
$command[] = new DevCoding\Mac\Update\Command\SummaryCommand();
1616
$command[] = new DevCoding\Mac\Update\Command\WaitCommand();
17-
$app = new Application('MacUpdate', 'v1.7.7');
17+
$app = new Application('MacUpdate', 'v1.8');
1818
$app->addCommands($command);
1919
$app->run();

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"DevCoding\\Mac\\Update\\": "src"
1515
}
1616
},
17-
"version": "1.7.7",
17+
"version": "1.8",
1818
"require": {
1919
"php": "^7.0",
2020
"ext-json": "*",

composer.lock

Lines changed: 42 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/macupdate.phar

13.4 KB
Binary file not shown.

src/Command/AbstractUpdateConsole.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ protected function getSoftwareUpdate()
226226
* @param string[] $flags
227227
*
228228
* @return SoftwareUpdateDriver
229+
*
229230
* @throws \Exception
230231
*/
231232
protected function getSoftwareUpdateDriver($flags)
@@ -469,5 +470,25 @@ protected function isLoadHigh()
469470
return false;
470471
}
471472

473+
/**
474+
* @param string|null $sus
475+
*
476+
* @return bool
477+
*/
478+
protected function isSusAvailable($sus = '_NONE_')
479+
{
480+
$tSus = '_NONE_' === $sus ? $this->getOs()->getSoftwareUpdateCatalogUrl() : $sus;
481+
if (!empty($tSus))
482+
{
483+
$ua = sprintf('Darwin/%s', $this->getShellExec('uname -r'));
484+
if ($rs = $this->getShellExec(sprintf('curl --user-agent %s %s -I -s | grep 200', $ua, $sus)))
485+
{
486+
return false !== strpos($rs, '200');
487+
}
488+
}
489+
490+
return true;
491+
}
492+
472493
// endregion ///////////////////////////////////////////// End System Information Functions
473494
}

src/Command/CheckCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
1818
{
1919
$this->io()->blankln();
2020

21+
if (!$this->isNoScan() && !$this->isSusAvailable())
22+
{
23+
$this->io()->errorln('The Software Update Server is not available.');
24+
25+
return self::EXIT_ERROR;
26+
}
27+
2128
$this->io()->msg('Checking For Updates', 50);
2229
$Updates = $this->getValidUpdates();
2330
$this->io()->successln('[SUCCESS]');

src/Command/DownloadCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace DevCoding\Mac\Update\Command;
44

5-
use DevCoding\Mac\Update\Drivers\SoftwareUpdateDriver;
65
use Symfony\Component\Console\Input\InputInterface;
76
use Symfony\Component\Console\Output\OutputInterface;
87

@@ -22,6 +21,13 @@ protected function getDefaultTimeout()
2221

2322
protected function execute(InputInterface $input, OutputInterface $output)
2423
{
24+
if (!$this->isNoScan() && !$this->isSusAvailable())
25+
{
26+
$this->io()->errorln('The Software Update Server is not available.');
27+
28+
return self::EXIT_ERROR;
29+
}
30+
2531
$this->io()->blankln()->msg('Checking For Updates', 50);
2632
$Updates = $this->getValidUpdates();
2733
$this->io()->successln('[SUCCESS]');

src/Command/InstallCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ protected function getDefaultTimeout()
3232

3333
protected function execute(InputInterface $input, OutputInterface $output)
3434
{
35+
if (!$this->isNoScan() && !$this->isSusAvailable())
36+
{
37+
$this->io()->errorln('The Software Update Server is not available.');
38+
39+
return self::EXIT_ERROR;
40+
}
41+
3542
$errors = [];
3643
$cUser = $this->getConsoleUser();
3744
$Updates = $this->getValidUpdates();

src/Command/ListCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ protected function configure()
1818

1919
protected function execute(InputInterface $input, OutputInterface $output)
2020
{
21+
if (!$this->isNoScan() && !$this->isSusAvailable())
22+
{
23+
$this->io()->errorln('The Software Update Server is not available.');
24+
25+
return self::EXIT_ERROR;
26+
}
27+
2128
$isJson = $this->io()->getOption('json');
2229
if ($isJson)
2330
{

0 commit comments

Comments
 (0)