does not download swiftui if it is already there

This commit is contained in:
Armin Briegel
2022-07-29 19:34:21 +02:00
parent 19e59fc36c
commit 720128f23a
3 changed files with 32 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ fakeInstallDelay=5
items=(
"firefoxpkg|Firefox"
"googlechromepkg|Google Chrome"
"microsoftoffice365|Microsoft Office 365"
)
# MARK: Constants
@@ -66,9 +67,6 @@ dialogActivate() {
progressUpdate() {
# $1: progress text (optional)
local text=$1
progressindex=$((progressindex + 1))
dialogUpdate "progress: $progressindex"
echo $progressindex > $progressIndexPath
if [[ -n $text ]]; then
dialogUpdate "progresstext: $text"
fi
@@ -78,7 +76,6 @@ startItem() {
local description=$1
echo "Starting Item: $description"
echo $description > $currentItemPath
dialogUpdate "listitem: $description: wait"
progressUpdate $description
}
@@ -88,7 +85,6 @@ completeItem() {
local itemStatus=$2
dialogUpdate "listitem: $description: $itemStatus"
echo "$description: $itemStatus" >> $completedItemsPath
echo "completed item $description: $itemStatus"
}
@@ -138,15 +134,10 @@ cleanupAndExit() {
rm -rf $tmpDir
fi
# remove dialog command file
if [[ -e $dialog_command_file ]]; then
rm $dialog_command_file
fi
# remove completed Items file
if [[ -e $completedItemsPath ]]; then
rm $completedItemsPath
fi
# # remove dialog command file
# if [[ -e $dialog_command_file ]]; then
# rm $dialog_command_file
# fi
}
checkInstallomator() {
@@ -199,6 +190,12 @@ checkInstallomator() {
fi
}
checkSwiftDialog() {
if [[ ! -x $dialog ]]; then
installomator swiftdialog "Swift Dialog"
fi
}
# MARK: sanity checks
@@ -217,7 +214,6 @@ fi
# MARK: Setup
# No sleeping
caffeinate -dimsu & caffeinatePID=$!
@@ -227,14 +223,8 @@ trap cleanupAndExit EXIT
# get a temp
tmpDir=$(mktemp -d)
completedItemsPath=$tmpDir/completedItems.txt
currentItemPath=$tmpDir/currentItem.txt
progressIndexPath=$tmpDir/progressIndexPath.txt
# setup first list
itemCount=${#items}
progressCount=$((item + 2))
progressindex=0
listitems=( "--listitem" "Configure Tools" )
@@ -250,7 +240,7 @@ checkInstallomator
# download and install Swift Dialog
echo "installing Swift Dialog"
installomator swiftdialog
checkSwiftDialog
# display first screen
$dialog --title "Configuring your Mac" \

View File

@@ -117,12 +117,12 @@ printlog(){
while IFS= read -r logmessage; do
if [[ "$(whoami)" == "root" ]]; then
echo "$timestamp" : "${log_priority}${space_char} : $label : ${logmessage}" | tee -a $log_location
updateDialogProgressText "${logmessage}" "$DIALOGCMDFILE"
updateDialogProgress "increment" "$DIALOGCMDFILE"
updateDialogProgressText "${logmessage}"
# updateDialogProgress "increment"
else
echo "$timestamp" : "${log_priority}${space_char} : $label : ${logmessage}"
updateDialogProgressText "${logmessage}" "$DIALOGCMDFILE"
updateDialogProgress "increment" "$DIALOGCMDFILE"
updateDialogProgressText "${logmessage}"
# updateDialogProgress "increment"
fi
done <<< "$log_message"
fi
@@ -830,7 +830,7 @@ runUpdateTool() {
finishing() {
printlog "Finishing..."
if [[ $DIALOG_PROGRESS == "main" || $DIALOG_PROGRESS == "list" ]]; then
updateDialogProgress "complete" "$DIALOGCMDFILE"
updateDialogProgress "complete"
fi
sleep 5 # wait a moment to let spotlight catch up
@@ -911,9 +911,20 @@ readDownloadPipe() {
local log=${2:-$DIALOG_CMD_FILE}
# set up read from pipe
while IFS= read -k 1 -u 0 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && updateDialogProgressText "Downloading - $progress%" $log && updateDialogProgress "$progress" $log && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
if [[ $char =~ [0-9] ]]; then
keep=1
fi
if [[ $char == % ]]; then
updateDialogProgressText "Downloading $name - $progress%"
updateDialogProgress "$progress"
progress=""
keep=0
fi
if [[ $keep == 1 ]]; then
progress="$progress$char"
fi
done < $pipe
}

View File

@@ -202,7 +202,7 @@ else
initNamedPipe create $pipe
# run the pipe read in the background
readDownloadPipe $pipe "$DIALOGCMDFILE" & downloadPipePID=$!
readDownloadPipe $pipe "$DIALOG_CMD_FILE" & downloadPipePID=$!
# curl (extract - line in "# MARK: download the archive" of Installomator.sh)
curlDownload=$(curl -fL -# --show-error ${curlOptions} "$downloadURL" -o "$archiveName" 2>&1 | tee $pipe)