Skip to content

Commit df52eb0

Browse files
committed
Removes non-functional --restart-policy flag from SoftwareUpdateCommand.php
1 parent aaec7e4 commit df52eb0

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,14 @@ Works with the built in `softwareupdate` command and your MDM to facilitate the
143143

144144
* Wait Condition Monitoring (similar to the Wait command documented below), including whether the SUS is available.
145145
* Can trigger a Jamf policy for the installation of updates rather than using `softwareupdate`
146-
* Can trigger a Jamf policy for the restart of a system, rather than using `softwareupdate` or `shutdown`.
147146
* Returns a non-zero exit code when a lack of disk space prevents installations.
148147
* Allows for Json output.
149148
* Can provide a simple count of updates to install.
150149
* Can provide a summary of relevant information to performing updates.
151150
* If running `softwareupdate` without user authentication is prevented, opens the Software Update Preference pane for the console user.
152151

152+
IMPORTANT NOTE: This command currently requires the `at` daemon for restart functionality.
153+
153154
### Installations (--install)
154155

155156
**Apple Silicon Macs**
@@ -160,8 +161,6 @@ If the computer is using Apple Silicon, the Software Update preference pane is o
160161

161162
If the `install-policy` option is provided, the Jamf Policy is used instead of running `softwareupdate` for the installations, otherwise the `softwareupdate` binary is utilized. When using the `softwareupdate` binary, all non-restart updates are installed individually, then any updates requiring a restart are installed in a batch. This allows us to provide the maximum amount of feedback on the success or failure of updates installed.
162163

163-
If the `restart-policy` option is provided, the Jamf Policy is sued instead of running `shutdown` for updates that require a restart or halt. This allows for an authenticated restart on FileVault 2 enabled Macs. If the `restart-policy` option is not provided, the `shutdown` binary is used to restart or halt the computer as needed for the updates that were installed.
164-
165164
|Flags | Purpose |
166165
|--|--|
167166
| install | Installs available updates |
@@ -176,7 +175,6 @@ If the `restart-policy` option is provided, the Jamf Policy is sued instead of r
176175
| skip-screen | Do not wait for screen availability |
177176
| wait | The number of seconds to wait for wait conditions. Defaults to 60 seconds. |
178177
| install-policy | The trigger or ID for a Jamf Pro policy that installs updates using the Software Update payload. |
179-
| restart-policy | The trigger or ID for a Jamf Pro policy with no payload that forces a FileVault 2 authenticated restart. |
180178
| json | Show any output in JSON format. |
181179
| timeout | The amount of time in seconds that is allowed for any one `softwareupdate` command to complete. Defaults to 7200 seconds (2 hours)
182180

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ $command[] = new DevCoding\Jss\Easy\Command\Preferences\CC\BackupCommand();
3131
$command[] = new DevCoding\Jss\Easy\Command\Preferences\CC\TransferCommand();
3232
// Other Commands
3333
$command[] = new DevCoding\Jss\Easy\Command\PrepCommand();
34-
$app = new Application('Jez', 'v4.0.5');
34+
$app = new Application('Jez', 'v4.0.6');
3535
$app->addCommands($command);
3636
$app->run();

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"prefer-stable": true,
1818
"minimum-stability": "dev",
19-
"version": "4.0.5",
19+
"version": "4.0.6",
2020
"require": {
2121
"php": ">=7.1",
2222
"ext-json": "*",

dist/jez.phar

-421 Bytes
Binary file not shown.

src/Command/Download/SoftwareUpdateCommand.php

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ protected function configure()
4747
if ($this->isJamf())
4848
{
4949
$this->addOption('install-policy', null, InputOption::VALUE_REQUIRED, 'Install Policy Trigger or ID');
50-
$this->addOption('restart-policy', null, InputOption::VALUE_REQUIRED, 'Restart Policy Trigger or ID');
5150
}
5251
}
5352

@@ -585,35 +584,24 @@ protected function executeInstall(InputInterface $input, OutputInterface $output
585584
*/
586585
protected function executeRestart(InputInterface $input, OutputInterface $output)
587586
{
588-
if ($this->isJamf() && $policy = $this->getRestartPolicy())
587+
if ($this->isHaltRequired())
589588
{
590-
// Run the restart policy
591-
$this->io()->msg('Triggering System Restart via Jamf', 60);
592-
$this->json()->append(['jamf_restart' => $policy, 'restart' => true]);
593-
$flag = is_numeric($policy) ? 'id' : 'trigger';
594-
$data = escapeshellarg($policy);
595-
$cmd = $this->getAtCommand(sprintf('/usr/local/bin/jamf policy --%s %s', $flag, $data));
589+
$this->json()->append(['halt' => true]);
590+
$this->io()->msg('Triggering System Shutdown', 60);
591+
// Trigger Restart w/ Delay to Finish & Log
592+
$cmd = $this->getAtCommand('shutdown -h +2m');
596593
}
597594
else
598595
{
599-
if ($this->isHaltRequired())
600-
{
601-
$this->json()->append(['halt' => true]);
602-
$this->io()->msg('Triggering System Shutdown', 60);
603-
// Trigger Restart w/ Delay to Finish & Log
604-
$cmd = $this->getAtCommand('shutdown -h +2m');
605-
}
606-
else
607-
{
608-
$this->json()->append(['restart' => true]);
609-
$this->io()->msg('Triggering System Restart', 60);
596+
$this->json()->append(['restart' => true]);
597+
$this->io()->msg('Triggering System Restart', 60);
610598

611-
// Trigger Restart w/ Delay to Finish & Log
612-
$cmd = $this->getAtCommand('shutdown -r +2m');
613-
}
599+
// Trigger Restart w/ Delay to Finish & Log
600+
$cmd = $this->getAtCommand('shutdown -r +2m');
614601
}
615602

616-
if ($this->getShellExec($cmd))
603+
exec($cmd, $output, $retval);
604+
if (0 === $retval)
617605
{
618606
$this->io()->successln('[SUCCESS]');
619607

@@ -715,6 +703,11 @@ protected function executeSoftwareUpdate(InputInterface $input, OutputInterface
715703
$this->io()->successln('[SUCCESS]');
716704
$this->json()->append(['install' => array_fill_keys($remains, true)]);
717705

706+
if (OutputInterface::VERBOSITY_VERBOSE === $this->io()->getVerbosity())
707+
{
708+
$this->io()->writeln($SU->getOutput(false));
709+
}
710+
718711
// Will continue to a restart
719712
$retval = self::CONTINUE;
720713
}
@@ -962,7 +955,7 @@ protected function getAtCommand($cmd)
962955
{
963956
if (file_exists('/usr/bin/at'))
964957
{
965-
return sprintf("%s now <<ENDBGCMD >/dev/null 2>&1\n%s\nENDBGCMD", '/usr/bin/at', $cmd);
958+
return sprintf('echo "%s" | %s now + 2 minutes >/dev/null 2>&1', $cmd, '/usr/bin/at');
966959
}
967960

968961
throw new \Exception('The AT binary was not found at /usr/bin/at');

0 commit comments

Comments
 (0)