58 lines
2.0 KiB
Bash
Executable File
58 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
##########################################################################
|
|
# Shellscript : Ausführen der Skripte
|
|
# Autor : Andreas Vogel, macenterprise gmbh
|
|
# Copyright : macenterprise 2020
|
|
##########################################################################
|
|
####################### Variabel #########################################
|
|
|
|
User=$(stat -f '%u %Su' /dev/console | cut -d ' ' -f 2)
|
|
ScriptDir="/usr/local/Scripts/defaults"
|
|
Scripts=$(find "$ScriptDir" -name "*.sh")
|
|
Results="/Users/$User/Library/Logs/LoginScript.log"
|
|
AGENT=/Users/$User/Library/LaunchAgents/de.ing.config_defaults.plist
|
|
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
|
|
jss_check="$(/usr/local/bin/jamf checkJSSConnection -retry 1 > /dev/null; echo $?)"
|
|
WarningIcon="/Library/Application Support/JAMF/ING/France_road_sign_A14.svg.png"
|
|
FailMassage=$(printf '\xE2\x9D\x8C no connection to ING')
|
|
HeadingFailMassage="JAMF Server nicht erreichbar."
|
|
|
|
####################### alle Skripts ausführen ###########################
|
|
|
|
exec 2>&1
|
|
exec >> $Results
|
|
|
|
DATE=$(DATE)
|
|
echo "==== Start ${DATE} ===="
|
|
|
|
if [[ "$jss_check" -eq 0 ]]
|
|
then
|
|
echo "JAMF ist erreichbar."
|
|
|
|
if [[ "$Scripts" == "" ]]
|
|
then
|
|
DATE=$(DATE)
|
|
echo "$DATE - Es wurden keine Skripte am Ziel gefunden $ScriptDir"
|
|
else
|
|
for SCRIPT in $Scripts
|
|
do
|
|
DATE=$(DATE)
|
|
echo "$DATE - Skript $SCRIPT wird gestartet......"
|
|
# /bin/sh "$SCRIPT"
|
|
DATE=$(DATE)
|
|
echo "$DATE - Skript wurde ausgeführt"
|
|
done
|
|
fi
|
|
|
|
elif [[ "$jss_check" -gt 0 ]]
|
|
then
|
|
printf HELPER=$("$jamfHelper" -windowType utility -icon "$WarningIcon" -title "Check Fail" -heading "$HeadingFailMassage" -description "$FailMassage" -button1 "OK" -defaultButton 1)
|
|
echo "ERROR; JAMF ist nicht erreichbar."
|
|
fi
|
|
DATE=$(DATE)
|
|
echo "==== End ${DATE} ===="
|
|
|
|
|
|
####################### LauchAgent löschen ###############################
|
|
# rm $AGENT
|