mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
cleaned up some DEBUG related code
This commit is contained in:
@@ -18,7 +18,7 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
|||||||
# set to 0 for production, 1 for debugging
|
# set to 0 for production, 1 for debugging
|
||||||
# while debugging, items will be downloaded to the parent directory of this script
|
# while debugging, items will be downloaded to the parent directory of this script
|
||||||
# also no actual installation will be performed
|
# also no actual installation will be performed
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
|
|
||||||
# behavior when blocking processes are found
|
# behavior when blocking processes are found
|
||||||
BLOCKING_PROCESS_ACTION=prompt_user
|
BLOCKING_PROCESS_ACTION=prompt_user
|
||||||
@@ -718,6 +718,12 @@ getAppVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkRunningProcesses() {
|
checkRunningProcesses() {
|
||||||
|
# don't check in DEBUG mode
|
||||||
|
if [[ $DEBUG -ne 0 ]]; then
|
||||||
|
echo "DEBUG mode, not checking for blocking processes"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# try at most 3 times
|
# try at most 3 times
|
||||||
for i in {1..3}; do
|
for i in {1..3}; do
|
||||||
countedProcesses=0
|
countedProcesses=0
|
||||||
@@ -809,7 +815,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
|
|
||||||
|
|
||||||
# set ownership to current user
|
# set ownership to current user
|
||||||
if [ -n "$currentUser" ]; then
|
if [ "$currentUser" != "loginwindow" ]; then
|
||||||
echo "Changing owner to $currentUser"
|
echo "Changing owner to $currentUser"
|
||||||
chown -R "$currentUser" "$targetDir/$appName"
|
chown -R "$currentUser" "$targetDir/$appName"
|
||||||
else
|
else
|
||||||
@@ -984,7 +990,7 @@ if [[ -z $blockingProcesses ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# determine tmp dir
|
# determine tmp dir
|
||||||
if [ "$DEBUG" -eq 1 ]; then
|
if [ "$DEBUG" -ne 0 ]; then
|
||||||
# for debugging use script dir as working directory
|
# for debugging use script dir as working directory
|
||||||
tmpDir=$(dirname "$0")
|
tmpDir=$(dirname "$0")
|
||||||
else
|
else
|
||||||
@@ -1003,7 +1009,7 @@ fi
|
|||||||
# check if this is an Update
|
# check if this is an Update
|
||||||
getAppVersion
|
getAppVersion
|
||||||
if [[ -n $appVersion ]]; then
|
if [[ -n $appVersion ]]; then
|
||||||
if [[ $DEBUG == 0 ]]; then
|
if [[ $DEBUG -eq 0 ]]; then
|
||||||
if runUpdateTool; then
|
if runUpdateTool; then
|
||||||
cleanupAndExit 0
|
cleanupAndExit 0
|
||||||
fi # otherwise continue
|
fi # otherwise continue
|
||||||
@@ -1028,7 +1034,7 @@ fi
|
|||||||
|
|
||||||
# download the archive
|
# download the archive
|
||||||
|
|
||||||
if [ -f "$archiveName" ] && [ "$DEBUG" -eq 1 ]; then
|
if [ -f "$archiveName" ] && [ "$DEBUG" -ne 0 ]; then
|
||||||
echo "$archiveName exists and DEBUG enabled, skipping download"
|
echo "$archiveName exists and DEBUG enabled, skipping download"
|
||||||
else
|
else
|
||||||
# download the dmg
|
# download the dmg
|
||||||
|
|||||||
54
README.md
54
README.md
@@ -103,8 +103,60 @@ The script started out as a pure `sh` script, and when I needed arrays I 'switch
|
|||||||
|
|
||||||
Keeping the script as a `zsh` allows you to paste it into your management system's interface (and disable the DEBUG mode) and use it without requiring any other installations.
|
Keeping the script as a `zsh` allows you to paste it into your management system's interface (and disable the DEBUG mode) and use it without requiring any other installations.
|
||||||
|
|
||||||
##
|
## How to use
|
||||||
|
|
||||||
|
### Interactively in the command line
|
||||||
|
|
||||||
|
The script will require at least one argument. If more than one argument is given, it will _ignore_ all but the last argument.
|
||||||
|
|
||||||
|
The argument can be `version` or `longversion` which will print the script's version.
|
||||||
|
|
||||||
|
```
|
||||||
|
> ./Installomator.sh version
|
||||||
|
0.1
|
||||||
|
> ./Installomator.sh longversion
|
||||||
|
Installomater: version 0.1 (20200506)
|
||||||
|
```
|
||||||
|
|
||||||
|
Other than the version arguments, the argument can be any of the labels listed in the Labels.txt file. Each of the labels will download and install the latest version of the application, or suite of applications. Since the script will have to run the `installer` command or copy the application to the `/Applications` folder, it will have to be run as root.
|
||||||
|
|
||||||
|
```
|
||||||
|
> sudo ./Installomator.sh desktoppr
|
||||||
|
```
|
||||||
|
|
||||||
|
### Debug mode
|
||||||
|
|
||||||
|
There is a variable named `DEBUG` which is set in line 21 of the script. When `DEBUG` is set to `1` (default) no actions that wousld actually modify the current system are taken. This is useful for testing most of the actions in the script, but obviously not all of them.
|
||||||
|
|
||||||
|
Also when the `DEBUG` variable is `1`, downloaded archives and extracted files will be written to the script's directory, rather than a temporary directory, which can make debugging easier.
|
||||||
|
|
||||||
|
_Always remember_ to change the `DEBUG` variable to `0` when deploying.
|
||||||
|
|
||||||
|
### Use Installomator with Jamf Pro
|
||||||
|
|
||||||
|
In Jamf Pro, create a new 'Script' and paste the contents of `Installomator.sh` into the 'Script Contents' area. Under 'Options' you can change the parameter label for argument 4 to 'Application Label.'
|
||||||
|
|
||||||
|
Then you can use the Installomator script in a policy and choose the application to install by setting the label for argument 4.
|
||||||
|
|
||||||
|
## What it does
|
||||||
|
|
||||||
|
When it runs with a known label, the script will perform the following:
|
||||||
|
|
||||||
|
- when the application is running, prompt the user to quit or cancel
|
||||||
|
- download the latest version from the vendor
|
||||||
|
- dmg or zip archives:
|
||||||
|
- extract the application and copy it to /Applications
|
||||||
|
- change the owner of the application to the current user
|
||||||
|
- pkg files:
|
||||||
|
- when necessary, extract the pkg from the enclosing archive
|
||||||
|
- install the pkg with the `installer` tool
|
||||||
|
- clean up the downloaded files
|
||||||
|
- notify the user
|
||||||
|
|
||||||
|
## Configuring the script
|
||||||
|
|
||||||
|
As of now there are two settings that are meant to configured when deploying the script.
|
||||||
|
|
||||||
|
### Debug mode
|
||||||
|
|
||||||
|
The first is the `DEBUG` variable. When this is set to `1` the script will _not_ perform any changes to the current system. In other words, no application will be copied to the target directory and no `installer` command be performed. This is useful to test the download and verification process
|
||||||
|
|||||||
Reference in New Issue
Block a user