Added service scripts and updated purple-helpers for the new app install script in P-MDMSCRIPTS.

This commit is contained in:
Michael
2022-09-21 16:34:29 +00:00
parent 0fb151cfc9
commit f19337aeac
7 changed files with 247 additions and 8 deletions

3
.nova/Configuration.json Normal file
View File

@@ -0,0 +1,3 @@
{
"editor.default_syntax" : "shell"
}

87
Helpers/add-to-dock.sh Normal file
View File

@@ -0,0 +1,87 @@
#!/bin/zsh
# add-to-dock.sh
# SERVICE SCRIPT CALLED BY OTHER SCRIPTS
prplappno=
prplappcount=
echo "*** BEGIN add-to-dock.SH ***"
chmod 777 /var/tmp/depnotify.log
whatDockList=$MDMAPPLABEL # RECEIVES VARIABLE FROM ENV
echo
echo THE BELOW ERROR IS NORMAL
while read line >> /dev/null
do
echo "$line"
done < "${1:-/dev/stdin}"
echo PLEASE IGNORE ABOVE ERROR
echo
# No sleeping keep device awake
/usr/bin/caffeinate -d -i -m -u &
caffeinatepid=$!
caffexit () {
kill "$caffeinatepid"
pkill caffeinate
exit $1
}
# Count errors
errorCount=0
# Count dock items
prplappno=$(echo "$whatDockList" | awk '{print gsub("[ \t]",""); exit}')
prplappcount=`expr $prplappno + 4`
prpltrueappcount=`expr $prplappno + 1`
echo "-- ADDING $prpltrueappcount APPS TO DOCK --"
echo Dock will appear in this order "$@"
# Verify that DockUtil has been installed, exit script and record error if not
dockdestFile="/usr/local/bin/dockutil"
if [ ! -e "${dockdestFile}" ]; then
echo "DockUtil not found here:"
echo "${dockdestFile}"
echo "Exiting."
caffexit 99
fi
#EMPTYDOCK - not used in this script
# /usr/local/bin/dockutil --remove all --allhomes
rm -rf /usr/local/bin/dockutil-labels.sh
curl -s -o /usr/local/bin/dockutil-labels.sh https://raw.githubusercontent.com/PurpleComputing/helpful-scripts/main/dockutil-labels.sh
chmod +x /usr/local/bin/dockutil-labels.sh
dockdestFile="/usr/local/bin/dockutil-labels.sh"
echo Started Dock Add Script
for what in $whatDockList; do
echo Running Dock Add for ${what}
# Looping using dockutil-labels.sh
cmdOutput="$(${dockdestFile} ${what} || true)"
# Check result
echo "Status: Dock addition for ${what} complete..." >> /var/tmp/depnotify.log
sleep 1
exitStatus="$( echo "${cmdOutput}" | grep --binary-files=text -i "exit" | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' || true )"
if [[ ${exitStatus} -ne 0 ]] ; then
echo "Error adding dock item ${what}. Exit code ${exitStatus}"
echo "Status: error adding ${what} to dock" >> /var/tmp/depnotify.log
#echo "$cmdOutput"
errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )"
echo "$errorOutput"
let errorCount++
fi
done
echo Finished Dock Add Script
echo
echo "Errors: $errorCount"
echo
echo "[$(DATE)][LOG-END]"
echo "Command: DeterminateManualStep: 1" >> /var/tmp/depnotify.log
caffexit $errorCount
echo "*** END add-to-dock.SH ***"

View File

@@ -13,14 +13,18 @@
# #
# HISTORY # HISTORY
# #
# Version: 1.3 # Version: 1.4
# #
# - 1.1 Michael Tanner, 04.10.2021 # - 1.1 Michael Tanner, 04.10.2021
# - 1.2 Michael Tanner, 04.10.2021 # - 1.2 Michael Tanner, 04.10.2021
# - 1.3 Michael Tanner, 04.10.2021 - Fixed moved /tmp location for $appname # - 1.3 Michael Tanner, 04.10.2021 - Fixed moved /tmp location for $appname
# - 1.4 Michael Tanner, 04.10.2021 - Removed IF statement
# #
######################################################################### #########################################################################
# Script to brand DEPNotify with PurpleComputing for app installs. # Script to brand DEPNotify with PurpleComputing for app installs.
# SERVICE SCRIPT CALLED BY OTHER SCRIPTS
# #
cp -f /tmp/.appinstallname /Library/Caches/com.purplecomputing.mdm/Apps/.appinstallname cp -f /tmp/.appinstallname /Library/Caches/com.purplecomputing.mdm/Apps/.appinstallname
rm /tmp/.appinstallname rm /tmp/.appinstallname
@@ -33,11 +37,5 @@ echo 'Command: Image: /Library/Application Support/Purple/logo.png' >> /var/tmp/
echo Command: MainText: We are now installing the $appname application. >> /var/tmp/depnotify.log echo Command: MainText: We are now installing the $appname application. >> /var/tmp/depnotify.log
echo Command: WindowStyle: Activate >> /var/tmp/depnotify.log echo Command: WindowStyle: Activate >> /var/tmp/depnotify.log
if @1 != "NotificationOff" then
echo Command: NotificationOn: >> /var/tmp/depnotify.log
fi
done
## STARTING INSTALLS ### ## STARTING INSTALLS ###
sleep 2 sleep 1
## echo Status: Installing $appname in the background... >> /var/tmp/depnotify.log ## IGNORE DO NOT DELETE FOR NOW

View File

@@ -0,0 +1,80 @@
#!/bin/zsh
# install-app-loop.sh
# SERVICE SCRIPT CALLED BY OTHER SCRIPTS
prplappno=
prplappcount=
echo "*** BEGIN install-app-loop.SH ***"
chmod 777 /var/tmp/depnotify.log
######################################################################
# Installation using Installomator (enter the software to install separated with spaces in the "whatList"-variable)
LOGO="mosyleb" # or "mosylem"
######################################################################
whatList=$MDMAPPLABEL
echo
echo THE BELOW ERROR IS NORMAL
while read line >> /dev/null
do
echo "$line"
done < "${1:-/dev/stdin}"
echo PLEASE IGNORE ABOVE ERROR
echo
# No sleeping
/usr/bin/caffeinate -d -i -m -u &
caffeinatepid=$!
caffexit () {
kill "$caffeinatepid"
pkill caffeinate
exit $1
}
# Mark: Start Installomator label(s) installation
# Count errors
errorCount=0
echo "Command: DeterminateOff:" >> /var/tmp/depnotify.log
echo "Command: DeterminateOffReset:" >> /var/tmp/depnotify.log
prplappno=$(echo "$whatList" | awk '{print gsub("[ \t]",""); exit}')
prplappcount=`expr $prplappno + 4`
prpltrueappcount=`expr $prplappno + 1`
echo "Command: DeterminateManual: $prplappcount" >> /var/tmp/depnotify.log
echo "-- INSTALLING $prpltrueappcount APPS --"
echo Installs started for "$@"
# 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."
caffexit 99
fi
echo Started Installomator
for what in $whatList; do
echo Installing ${what}
echo "Status: installing ${what}" >> /var/tmp/depnotify.log
echo "Command: DeterminateManualStep: 1" >> /var/tmp/depnotify.log
# Install software using Installomator
cmdOutput="$(${destFile} ${what} LOGO=$LOGO NOTIFY=all BLOCKING_PROCESS_ACTION=kill || true)" # NOTIFY=silent BLOCKING_PROCESS_ACTION=quit_kill INSTALL=force
# Check result
echo "Status: installer for ${what} complete..." >> /var/tmp/depnotify.log
sleep 1
exitStatus="$( echo "${cmdOutput}" | grep --binary-files=text -i "exit" | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' || true )"
if [[ ${exitStatus} -ne 0 ]] ; then
echo "Error installing ${what}. Exit code ${exitStatus}"
echo "Status: error installing ${what}" >> /var/tmp/depnotify.log
#echo "$cmdOutput"
errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )"
echo "$errorOutput"
let errorCount++
fi
done
echo Finished Installomator
echo
echo "Errors: $errorCount"
echo
echo "[$(DATE)][LOG-END]"
caffexit $errorCount
echo "*** END install-app-loop.SH ***"

View File

@@ -0,0 +1,40 @@
#!/bin/zsh
# launch-app-installo.sh
# SERVICE SCRIPT CALLED BY OTHER SCRIPTS
cd /Library/Application\ Support/Purple/
# CHECKS FOR DIALOG AND PRESENTS IF REQUESTED
if [ "$SHOWDIALOG" == "Y" ]; then
echo "Dialog will open"
curl -s https://raw.githubusercontent.com/PurpleComputing/mdmscripts/main/Helpers/show-dialog-depnotify.sh | bash &
else
echo "Dialog will not open"
echo Continuing...
fi
# INSTALLS APPLICATION
curl -s https://raw.githubusercontent.com/PurpleComputing/mdmscripts/main/Helpers/install-app-loop.sh | bash
# CHECKS TO ADD TO DOCK OR NOT
if [ "$MDMADDTODOCK" == "Y" ]; then
echo "SCRIPT WILL TRY TO ADD TO DOCK"
curl -s https://raw.githubusercontent.com/PurpleComputing/mdmscripts/main/Helpers/add-to-dock.sh | bash
else
echo "SCRIPT WILL NOT TRY TO ADD TO DOCK"
echo Continuing...
fi
if [ "$SHOWDIALOG" == "Y" ]; then
# MOVES DEPNOTIFY STATUS BAR
echo "Command: DeterminateManualStep: 1" >> /var/tmp/depnotify.log
echo 'Command: WindowStyle: Activate' >> /var/tmp/depnotify.log
echo 'Command: ContinueButton: Finish' >> /var/tmp/depnotify.log
echo "Status: Installed or Updated $MDMAPPNAME, click Finish!" >> /var/tmp/depnotify.log
else
echo "Final message will not send"
echo Continuing...
fi

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# SERVICE SCRIPT CALLED BY OTHER SCRIPTS
# Remove Old Files # Remove Old Files
echo Making App Support Directories echo Making App Support Directories
mkdir -p /Library/Application\ Support/Purple/ mkdir -p /Library/Application\ Support/Purple/
@@ -46,3 +48,6 @@ chmod 777 /var/tmp/depnotify.log
rm -rf /Library/Caches/com.purplecomputing.mdm/Scripts/* rm -rf /Library/Caches/com.purplecomputing.mdm/Scripts/*
rm -rf /Library/Caches/com.purplecomputing.mdm/Apps/.appinstallname rm -rf /Library/Caches/com.purplecomputing.mdm/Apps/.appinstallname
rm -rf /Library/Caches/com.purplecomputing.mdm/Apps/pkg rm -rf /Library/Caches/com.purplecomputing.mdm/Apps/pkg
mkdir -p /Library/Caches/com.purplecomputing.mdm/Scripts/
rm -rf /Library/Caches/com.purplecomputing.mdm/Scripts/$SCRIPTNAME
rm -rf /Library/Caches/com.purplecomputing.mdm/Scripts/brandDEPinstall.sh

View File

@@ -0,0 +1,26 @@
#!/bin/sh
#########################################################################
# SERVICE SCRIPT CALLED BY OTHER SCRIPTS
#
APPNAME=$MDMAPPNAME
INSTALLAPP=googleearth
ILOGO=mosyleb
LOGLOCAL=/Library/Logs/com.purplecomputing.mdm/
# UPDATE PURPLE HELPERS
curl -s -L https://prpl.it/helperscript | bash
##-------------------------------##
## DEPNOTIFY WINDOW ##
##-------------------------------##
# SET APP TITLE TO APPNAME
echo "$APPNAME" >> /Library/Caches/com.purplecomputing.mdm/Apps/.appinstallname
# SET DEP NOTIFY FOR REINSTALL
curl -s -L https://prpl.it/brandDEPinstall | bash
# START DEPNOTIFY
sudo -u $(stat -f "%Su" /dev/console) /Library/Application\ Support/Purple/launch-dep.sh