Update MDMAddigy CustomSoftware.sh

This commit is contained in:
Søren Theilgaard
2021-10-28 13:46:16 +02:00
parent 921ba0f79e
commit 77567cdf4e

View File

@@ -1,62 +1,89 @@
#!/bin/zsh #!/bin/zsh
# Specific settings in Addigy to configure Custom Software for installomator. # Specific settings in Addigy to configure Custom Software for installomator.
# Addigy has 3 parts to fill out for this, Installation script, Conditions, and Removal steps. # Addigy has 3 parts to fill out for this, Installation script, Condition, and Removal steps (see RemoveInstallomator.sh).
# Mark: Installation script # Mark: Installation script
# Just click “Add” to the autogenerated script by clicking the “Add”-button next to the Installer PKG. # Just click “Add” to autogenerate the installer script line by clicking the “Add”-button next to the Installer PKG, replace with first line below
/usr/sbin/installer -pkg "/Library/Addigy/ansible/packages/Installomator (0.7.0)/Installomator-0.7.0.pkg" -target /
# Mark: Conditions # Installation using Installomator
# Remember to fill out the correct “TARGET_VERSION” and click "Install on succes". what="supportapp xink textmate microsoftedge wwdc keka vlc " # enter the software to installed separated with spaces
TARGET_VERSION="0.7.0"
APP="/usr/local/Installomator/Installomator.sh" # To be used as a script sent out from a MDM.
if [ ! -f ${APP} ]; then # Fill the variable "what" above with labels separated by space " ".
echo "Does not exist: ${APP}" # Script will loop through these labels and exit with number of errors.
exit 0 ######################################################################
# Count errors
errorCount=0
# Verify that Installomator has been installed
destFile="/usr/local/Installomator/Installomator.sh"
if [ ! -e "${destFile}" ]; then
echo "Installomator not found here:"
echo "${destFile}"
echo "Exiting."
exit 99
fi fi
INSTALLED_VERSION="$(${APP} version | tail -1 | awk '{print $4}')" for item in $what; do
#echo $item
${destFile} ${item} LOGO=addigy NOTIFY=silent BLOCKING_PROCESS_ACTION=quit_kill #INSTALL=force
if [ $? != 0 ]; then
# Error handling
echo "[$(DATE)] Error installing ${item}. Exit code $?"
let errorCount++
# exit $?
fi
done
echo
echo "Errors: $errorCount"
echo "[$(DATE)][LOG-END]"
exit $errorCount
# Mark: Conditions
# Install on success
# Remember to fill out the correct “TARGET_VERSION” and “PKG_ID”, and click "Install on succes".
PKG_ID="com.scriptingosx.Installomator"
TARGET_VERSION="0.7.0"
vercomp () { vercomp () {
if [[ $1 == $2 ]] if [[ $1 == $2 ]]; then
then
return 0 return 0
fi fi
local IFS=. local IFS=.
local i ver1=($1) ver2=($2) local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros # fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
do
ver1[i]=0 ver1[i]=0
done done
for ((i=0; i<${#ver1[@]}; i++)) for ((i=0; i<${#ver1[@]}; i++)); do
do if [[ -z ${ver2[i]} ]]; then
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros # fill empty fields in ver2 with zeros
ver2[i]=0 ver2[i]=0
fi fi
if ((10#${ver1[i]} > 10#${ver2[i]})) if ((10#${ver1[i]} > 10#${ver2[i]})); then
then
return 1 return 1
fi fi
if ((10#${ver1[i]} < 10#${ver2[i]})) if ((10#${ver1[i]} < 10#${ver2[i]})); then
then
return 2 return 2
fi fi
done done
return 0 return 0
} }
INSTALLED_VERSION="$(pkgutil --pkg-info $PKG_ID | grep -i "^version" | awk '{print $2}')"
echo "Current Version: ${INSTALLED_VERSION}" echo "Current Version: ${INSTALLED_VERSION}"
vercomp ${TARGET_VERSION} ${INSTALLED_VERSION} vercomp ${TARGET_VERSION} ${INSTALLED_VERSION}
COMP=$? # 0 means the same, 1 means TARGET is newer, 2 means INSTALLED is newer COMP=$? # 0 means the same, 1 means TARGET is newer, 2 means INSTALLED is newer
echo "COMPARISON: ${COMP}" echo "COMPARISON: ${COMP}"
if [ "${COMP}" -eq 1 ] if [ "${COMP}" -eq 1 ]; then
then
echo "Installed version is older than ${TARGET_VERSION}." echo "Installed version is older than ${TARGET_VERSION}."
exit 0 exit 0
else else