Skip to content

Commit

Permalink
fix for app location check
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham R Pugh committed Jul 14, 2020
1 parent 246efe8 commit 5411065
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 38 deletions.
81 changes: 58 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# CHANGELOG

## Version History
## [Untagged]

## 0.15.1
No date

- If there are any changes since the last tag, click [here][untagged] to see the changes.

## [0.15.2]

14.07.2020

- Fixed some failed logic around the check for whether there is already an installer in the `/Applications` folder which was erroneously also looking in other locations.

## [0.15.1]

23.06.2020

- Parameters can now be supplied as `--argument value` as an alternative to `--argument=value` to provide more consistency with the included tools (`installinstallmacos.py` and `softwareupdate`).

## 0.15.0
## [0.15.0]

09.06.2020

- Adds `--allowremoval` option to the `startosinstall` command by default. This is an undocumented flag which is required under certain circumstances where there are backup files on the system disk.

## 0.14.0
## [0.14.0]

06.05.2020

- Adds `--replace_invalid` option for the option to overwrite a cached installer if it is not valid for use with `--erase` or `--reinstall`.
- Adds `--update` option for the option to overwrite a cached installer if a newer installer is available.

## 0.13.0
## [0.13.0]

04.05.2020

Expand All @@ -30,39 +40,39 @@
- Fix for missing heading in the full screen display of the `--reinstall` option.
- Added a test script `tests/test-erase-install.sh` for testing out functionality.

## 0.12.1
## [0.12.1]

14.04.2020

- Use `--forcequitapps` when _using_ the macOS Catalina installer, rather than just when _running_ on a macOS Catalina client (issue #25).

## 0.12.0
## [0.12.0]

13.02.2020

- Removed downloaded OS validity check for modes where the installer is not required for reinstall or eraseinstall, to prevent unnecessary exit failures.
- Fixed a problem preveting `--move` from working when overwriting a valid installer.
- Other small bugfixes.

## 0.11.1
## [0.11.1]

03.02.2020

- Restricted the add forcequitapps install_args option to macOS 10.15 or greater, as this is not functional with older versions (#35). Thanks to '@ahousseini' for the contribution.

## 0.11.0
## [0.11.0]

22.01.2020

- Added the `--sameos` option, so you can have a single command which will always try to reinstall whatever macOS (major) version is currently installed on the host.

## 0.10.1
## [0.10.1]

11.12.2019

- Removed check that a user is logged in before proceeding with startosinstall - apparently not necessary after all, and caused at least one user's workflow to break (#33).

## 0.10.0
## [0.10.0]

27.11.2019

Expand All @@ -75,54 +85,54 @@

Thanks to '@ahousseini' for various contributions to this release

## 0.9.1
## [0.9.1]

15.11.2019

- Move a comment that states that --fetch-full-installer is available to the correct place (#31)

## 0.9.0
## [0.9.0]

07.10.2019

- Added support for `softwareupdate --fetch-full-installer` and `seedutil` for clients running macOS 10.15 or greater.

## 0.8.0
## [0.8.0]

27.09.2019

- Fixed caffeinate (forgot to make it a background process)
- Added 'Confirm' option for erasing. Thanks to '@ryan-alectrona' for the contribution.

## 0.7.1
## [0.7.1]

26.09.2019

- Added caffeinate to the script to prevent the computer going to sleep during long download phases etc.

## 0.7.0
## [0.7.0]

12.07.2019

- Added `--beta` option.
- Changed behaviour of `--os`, `--version` and auto (i.e. no flag) options to get the latest rather than earliest valid build.
- Removed `install-macos.sh` script. Use `erase-install.sh` with `--reinstall` option instead.

## 0.6.0
## [0.6.0]

19.06.2019

- Added `--reinstall` option, which obsoletes the `install-macos.sh` script.

## 0.5.0
## [0.5.0]

16.04.2019

- Bug fix for empty extra packages folder.
Thanks to '@Avartharian' for contributions
- Added `--catalogurl` and `--seedprogram` options

## 0.4.0
## [0.4.0]

02.04.2019

Expand All @@ -131,27 +141,27 @@ Thanks to '@ahousseini' for various contributions to this release
- Added `--os`, `--path`, `--extras`, `--list` options.
Thanks to '@mark lamont' for contributions

## 0.3.2
## [0.3.2]

13.12.2018

- Bug fix for `--build` option, and for exiting gracefully when nothing is downloaded.

## 0.3.1
## [0.3.1]

21.09.2018

- Added ability to specify a macOS version.
- Fixed the `--overwrite` flag.
- Added ability to specify a build in the parameters, and we now clear out the cached content.

## 0.3.0
## [0.3.0]

03.09.2018

- Additional and amended options for selecting non-standard builds.

## 0.2.0
## [0.2.0]

09.07.2018

Expand All @@ -162,3 +172,28 @@ Thanks to '@ahousseini' for various contributions to this release
29.03.2018

- Initial version. Expects a manual choice of installer from `installinstallmacos.py`.

[untagged]: https://github.com/grahampugh/erase-install/compare/v0.15.2...HEAD
[0.15.2]: https://github.com/grahampugh/erase-install/compare/v0.15.1...v0.15.2
[0.15.1]: https://github.com/grahampugh/erase-install/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/grahampugh/erase-install/compare/v0.14.0...v0.15.0
[0.14.0]: https://github.com/grahampugh/erase-install/compare/v0.13.0...v0.14.0
[0.13.0]: https://github.com/grahampugh/erase-install/compare/v0.12.1...v0.13.0
[0.12.1]: https://github.com/grahampugh/erase-install/compare/v0.12.0...v0.12.1
[0.12.0]: https://github.com/grahampugh/erase-install/compare/v0.11.1...v0.12.0
[0.11.1]: https://github.com/grahampugh/erase-install/compare/v0.11.0...v0.11.1
[0.11.0]: https://github.com/grahampugh/erase-install/compare/v0.10.1...v0.11.0
[0.10.1]: https://github.com/grahampugh/erase-install/compare/v0.10.0...v0.10.1
[0.10.0]: https://github.com/grahampugh/erase-install/compare/v0.9.1...v0.10.0
[0.9.1]: https://github.com/grahampugh/erase-install/compare/v0.9.0...v0.9.1
[0.9.0]: https://github.com/grahampugh/erase-install/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/grahampugh/erase-install/compare/v0.7.1...v0.8.0
[0.7.1]: https://github.com/grahampugh/erase-install/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/grahampugh/erase-install/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/grahampugh/erase-install/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/grahampugh/erase-install/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/grahampugh/erase-install/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/grahampugh/erase-install/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/grahampugh/erase-install/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/grahampugh/erase-install/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/grahampugh/erase-install/compare/v0.1.0...v0.2.0
10 changes: 3 additions & 7 deletions erase-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,28 @@ check_installer_is_valid() {
if [[ $installer_os_version -lt $installed_os_version ]]; then
echo " [check_installer_is_valid] $installer_version < $installed_version so not valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
invalid_installer_found="yes"
elif [[ $installer_os_version -eq $installed_os_version ]]; then
if [[ $installer_minor_version -lt $installed_minor_version ]]; then
echo " [check_installer_is_valid] $installer_version < $installed_version so not valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
invalid_installer_found="yes"
else
echo " [check_installer_is_valid] $installer_version >= $installed_version so valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
fi
else
echo " [check_installer_is_valid] $installer_version > $installed_version so valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
fi
}

find_existing_installer() {
installer_app=$( find "$installer_directory/"*macOS*.app -maxdepth 1 -type d -print -quit 2>/dev/null )
# Search for an existing download
# First let's see if this script has been run before and left an installer
macOSDMG=$( find $workdir/*.dmg -maxdepth 1 -type f -print -quit 2>/dev/null )
macOSSparseImage=$( find $workdir/*.sparseimage -maxdepth 1 -type f -print -quit 2>/dev/null )

# First let's see if this script has been run before and left an installer
installer_app=$( find "$installer_directory/"*macOS*.app -maxdepth 1 -type d -print -quit 2>/dev/null )
if [[ -f "$macOSDMG" ]]; then
echo " [find_existing_installer] Installer image found at $macOSDMG."
hdiutil attach "$macOSDMG"
Expand All @@ -223,6 +218,7 @@ find_existing_installer() {
check_installer_is_valid
elif [[ -d "$installer_app" ]]; then
echo " [find_existing_installer] Installer found at $installer_app."
app_is_in_applications_folder="yes"
check_installer_is_valid
else
echo " [find_existing_installer] No valid installer found."
Expand Down
45 changes: 37 additions & 8 deletions tests/test-erase-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,28 @@ check_installer_is_valid() {
if [[ $installer_os_version -lt $installed_os_version ]]; then
echo " [check_installer_is_valid] $installer_version < $installed_version so not valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
invalid_installer_found="yes"
elif [[ $installer_os_version -eq $installed_os_version ]]; then
if [[ $installer_minor_version -lt $installed_minor_version ]]; then
echo " [check_installer_is_valid] $installer_version < $installed_version so not valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
invalid_installer_found="yes"
else
echo " [check_installer_is_valid] $installer_version >= $installed_version so valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
fi
else
echo " [check_installer_is_valid] $installer_version > $installed_version so valid."
installmacOSApp="$installer_app"
app_is_in_applications_folder="yes"
fi
}

find_existing_installer() {
installer_app=$( find "$installer_directory/"*macOS*.app -maxdepth 1 -type d -print -quit 2>/dev/null )
# Search for an existing download
# First let's see if this script has been run before and left an installer
macOSDMG=$( find $workdir/*.dmg -maxdepth 1 -type f -print -quit 2>/dev/null )
macOSSparseImage=$( find $workdir/*.sparseimage -maxdepth 1 -type f -print -quit 2>/dev/null )

# First let's see if this script has been run before and left an installer
installer_app=$( find "$installer_directory/"*macOS*.app -maxdepth 1 -type d -print -quit 2>/dev/null )
if [[ -f "$macOSDMG" ]]; then
echo " [find_existing_installer] Installer image found at $macOSDMG."
hdiutil attach "$macOSDMG"
Expand All @@ -223,6 +218,7 @@ find_existing_installer() {
check_installer_is_valid
elif [[ -d "$installer_app" ]]; then
echo " [find_existing_installer] Installer found at $installer_app."
app_is_in_applications_folder="yes"
check_installer_is_valid
else
echo " [find_existing_installer] No valid installer found."
Expand Down Expand Up @@ -278,6 +274,7 @@ run_fetch_full_installer() {
if [[ $seedprogram ]]; then
echo " [run_fetch_full_installer] Non-standard seedprogram selected"
/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil enroll $seedprogram
/usr/sbin/softwareupdate -l -a
fi

softwareupdate_args=''
Expand Down Expand Up @@ -482,6 +479,38 @@ do
;;
-f|--fetch-full-installer) ffi="yes"
;;
--seedprogram)
shift
seedprogram="$1"
;;
--catalogurl)
shift
catalogurl="$1"
;;
--path)
shift
installer_directory="$1"
;;
--extras)
shift
extras_directory="$1"
;;
--os)
shift
prechosen_os="$1"
;;
--version)
shift
prechosen_version="$1"
;;
--build)
shift
prechosen_build="$1"
;;
--workdir)
shift
workdir="$1"
;;
--seedprogram*)
seedprogram=$(echo $1 | sed -e 's|^[^=]*=||g')
;;
Expand Down Expand Up @@ -697,7 +726,7 @@ fi
# run it!
# "$installmacOSApp/Contents/Resources/startosinstall" "${install_args[@]}" --agreetolicense --nointeraction "${install_package_list[@]}"

# kill Self Service if running
# # kill Self Service if running
# kill_process "Self Service"
# kill Jamf FUD if startosinstall ends before a reboot
kill_process "jamfHelper"

0 comments on commit 5411065

Please sign in to comment.