mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
now shows verifying step, code cleanup
This commit is contained in:
@@ -44,7 +44,6 @@ repoDir=$(dirname $scriptDir)
|
|||||||
|
|
||||||
dialog="/usr/local/bin/dialog"
|
dialog="/usr/local/bin/dialog"
|
||||||
|
|
||||||
|
|
||||||
if [[ DEBUG -eq 0 ]]; then
|
if [[ DEBUG -eq 0 ]]; then
|
||||||
dialog_command_file="/var/tmp/dialog.log"
|
dialog_command_file="/var/tmp/dialog.log"
|
||||||
else
|
else
|
||||||
@@ -82,14 +81,6 @@ startItem() {
|
|||||||
progressUpdate $description
|
progressUpdate $description
|
||||||
}
|
}
|
||||||
|
|
||||||
completeItem() {
|
|
||||||
local description=$1
|
|
||||||
local itemStatus=$2
|
|
||||||
|
|
||||||
dialogUpdate "listitem: $description: $itemStatus"
|
|
||||||
echo "completed item $description: $itemStatus"
|
|
||||||
}
|
|
||||||
|
|
||||||
installomator() {
|
installomator() {
|
||||||
# $1: label
|
# $1: label
|
||||||
# $2: description
|
# $2: description
|
||||||
@@ -110,81 +101,13 @@ cleanupAndExit() {
|
|||||||
kill $caffeinatePID
|
kill $caffeinatePID
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# kill dialog process
|
|
||||||
# if [[ -n $dialogPID ]]; then
|
|
||||||
# dialogUpdate "quit:"
|
|
||||||
# kill $dialogPID
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# clean up tmp dir
|
# clean up tmp dir
|
||||||
if [[ -n $tmpDir && -d $tmpDir ]]; then
|
if [[ -n $tmpDir && -d $tmpDir ]]; then
|
||||||
echo "removing tmpDir $tmpDir"
|
echo "removing tmpDir $tmpDir"
|
||||||
rm -rf $tmpDir
|
rm -rf $tmpDir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# # remove dialog command file
|
|
||||||
# if [[ -e $dialog_command_file ]]; then
|
|
||||||
# rm $dialog_command_file
|
|
||||||
# fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInstallomator() {
|
|
||||||
if [[ ! -e $installomator ]]; then
|
|
||||||
echo "Installomator not found at path $installomator. Installing"
|
|
||||||
|
|
||||||
installomatorPkg="$tmpDir/Installomator.pkg"
|
|
||||||
|
|
||||||
# download Installomator pkg
|
|
||||||
if ! downloadURL=$(curl -L --silent --fail "https://api.github.com/repos/Installomator/Installomator/releases/latest" \
|
|
||||||
| awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }"); then
|
|
||||||
echo "could not get Installomator download url"
|
|
||||||
exit 96
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "downloading Installomator from $downloadURL"
|
|
||||||
if ! curl --fail --silent -L --show-error "$downloadURL" -o $installomatorPkg; then
|
|
||||||
echo "could not download Installomator"
|
|
||||||
exit 95
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "verifying Installomator"
|
|
||||||
# verify pkg
|
|
||||||
if ! spctlout=$(spctl -a -vv -t install "$installomatorPkg" 2>&1 ); then
|
|
||||||
echo "Error verifying $installomatorPkg"
|
|
||||||
exit 94
|
|
||||||
fi
|
|
||||||
teamID=$(echo $spctlout | awk -F '(' '/origin=/ {print $2 }' | tr -d '()' )
|
|
||||||
if [ "JME5BW3F3R" != "$teamID" ]; then
|
|
||||||
echo "Team IDs do not match!"
|
|
||||||
exit 93
|
|
||||||
fi
|
|
||||||
# Install pkg
|
|
||||||
|
|
||||||
echo "Installing Installomator"
|
|
||||||
if [[ DEBUG -eq 0 ]]; then
|
|
||||||
installer -pkg $installomatorPkg -tgt / -verbose
|
|
||||||
|
|
||||||
# check if Installomator is correctly installed
|
|
||||||
if [[ ! -x $installomator ]]; then
|
|
||||||
echo "failed to install Installomator"
|
|
||||||
exit 92
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "DEBUG enabled, skipping Installomator install"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# update installomator
|
|
||||||
# installomator installomator
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
checkSwiftDialog() {
|
|
||||||
if [[ ! -x $dialog ]]; then
|
|
||||||
installomator swiftdialog "Swift Dialog"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# MARK: sanity checks
|
# MARK: sanity checks
|
||||||
|
|
||||||
# check minimal macOS requirement
|
# check minimal macOS requirement
|
||||||
@@ -199,6 +122,19 @@ if [[ $DEBUG -eq 0 && $(id -u) -ne 0 ]]; then
|
|||||||
exit 97
|
exit 97
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check for installomator
|
||||||
|
if [[ ! -x $installomator ]]; then
|
||||||
|
echo "Cannot find Installomator at $installomator"
|
||||||
|
exit 96
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check for Swift Dialog
|
||||||
|
if [[ ! -x $dialog ]]; then
|
||||||
|
echo "Cannot find dialog at $dialog"
|
||||||
|
exit 95
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# MARK: Setup
|
# MARK: Setup
|
||||||
|
|
||||||
# No sleeping
|
# No sleeping
|
||||||
@@ -207,13 +143,10 @@ caffeinate -dimsu & caffeinatePID=$!
|
|||||||
# trap exit for cleanup
|
# trap exit for cleanup
|
||||||
trap cleanupAndExit EXIT
|
trap cleanupAndExit EXIT
|
||||||
|
|
||||||
# get a temp
|
|
||||||
tmpDir=$(mktemp -d)
|
|
||||||
|
|
||||||
# setup first list
|
# setup first list
|
||||||
itemCount=$((${#items} + 2))
|
itemCount=$((${#items} + 1))
|
||||||
|
|
||||||
listitems=( "--listitem" "Configure Tools" )
|
listitems=( )
|
||||||
|
|
||||||
for item in $items; do
|
for item in $items; do
|
||||||
label=$(cut -d '|' -f 1 <<< $item)
|
label=$(cut -d '|' -f 1 <<< $item)
|
||||||
@@ -221,14 +154,6 @@ for item in $items; do
|
|||||||
listitems+=( "--listitem" ${description} )
|
listitems+=( "--listitem" ${description} )
|
||||||
done
|
done
|
||||||
|
|
||||||
# download and install Installomator
|
|
||||||
startItem "Configure Tools"
|
|
||||||
checkInstallomator
|
|
||||||
|
|
||||||
# download and install Swift Dialog
|
|
||||||
echo "installing Swift Dialog"
|
|
||||||
checkSwiftDialog
|
|
||||||
|
|
||||||
# display first screen
|
# display first screen
|
||||||
$dialog --title "More Software" \
|
$dialog --title "More Software" \
|
||||||
--icon "SF=gear" \
|
--icon "SF=gear" \
|
||||||
@@ -244,9 +169,6 @@ $dialog --title "More Software" \
|
|||||||
sleep 0.1
|
sleep 0.1
|
||||||
|
|
||||||
itemCounter=0
|
itemCounter=0
|
||||||
progressUpdate "ConfigureTools"
|
|
||||||
|
|
||||||
completeItem "Configure Tools" "success"
|
|
||||||
|
|
||||||
for item in $items; do
|
for item in $items; do
|
||||||
label=$(cut -d '|' -f 1 <<< $item)
|
label=$(cut -d '|' -f 1 <<< $item)
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
|
|
||||||
# verify with spctl
|
# verify with spctl
|
||||||
printlog "Verifying: $appPath" INFO
|
printlog "Verifying: $appPath" INFO
|
||||||
|
updateDialog "wait" "Verifying..."
|
||||||
printlog "App size: $(du -sh "$appPath")" DEBUG
|
printlog "App size: $(du -sh "$appPath")" DEBUG
|
||||||
appVerify=$(spctl -a -vv "$appPath" 2>&1 )
|
appVerify=$(spctl -a -vv "$appPath" 2>&1 )
|
||||||
appVerifyStatus=$(echo $?)
|
appVerifyStatus=$(echo $?)
|
||||||
@@ -575,6 +576,7 @@ installFromDMG() {
|
|||||||
installFromPKG() {
|
installFromPKG() {
|
||||||
# verify with spctl
|
# verify with spctl
|
||||||
printlog "Verifying: $archiveName"
|
printlog "Verifying: $archiveName"
|
||||||
|
updateDialog "wait" "Verifying..."
|
||||||
printlog "File list: $(ls -lh "$archiveName")" DEBUG
|
printlog "File list: $(ls -lh "$archiveName")" DEBUG
|
||||||
printlog "File type: $(file "$archiveName")" DEBUG
|
printlog "File type: $(file "$archiveName")" DEBUG
|
||||||
spctlOut=$(spctl -a -vv -t install "$archiveName" 2>&1 )
|
spctlOut=$(spctl -a -vv -t install "$archiveName" 2>&1 )
|
||||||
@@ -954,7 +956,7 @@ readPKGInstallPipe() {
|
|||||||
progress="$progress$char"
|
progress="$progress$char"
|
||||||
fi
|
fi
|
||||||
if [[ $char == . && $keep == 1 ]]; then
|
if [[ $char == . && $keep == 1 ]]; then
|
||||||
updateDialog $progress "Installing $appname"
|
updateDialog $progress "Installing..."
|
||||||
progress=""
|
progress=""
|
||||||
keep=0
|
keep=0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -304,7 +304,5 @@ updateDialog "wait" "Finishing..."
|
|||||||
# MARK: Finishing — print installed application location and version
|
# MARK: Finishing — print installed application location and version
|
||||||
finishing
|
finishing
|
||||||
|
|
||||||
updateDialog "success" "$appversion"
|
|
||||||
|
|
||||||
# all done!
|
# all done!
|
||||||
cleanupAndExit 0 "All done!" REQ
|
cleanupAndExit 0 "All done!" REQ
|
||||||
|
|||||||
Reference in New Issue
Block a user