69 lines
1.5 KiB
Bash
69 lines
1.5 KiB
Bash
#!/bin/bash
|
|
################################# Find last Reboot #################################
|
|
|
|
lastBootRaw=$(sysctl kern.boottime | awk '{print $5}' | tr -d ,)
|
|
lastBootFormat=$(date -jf "%s" "$lastBootRaw" +"%m-%d-%Y")
|
|
today=$(date +%s)
|
|
diffDays=$(( (today - lastBootRaw) ))
|
|
|
|
################################# Variablen #################################
|
|
|
|
listDaemons="
|
|
/Library/LaunchDaemons/de.ing.FiveMinWarningDaemon.plist
|
|
/Library/LaunchDaemons/de.ing.LastWarningDaemon.plist
|
|
"
|
|
|
|
listScripts="
|
|
LastWarningScript.sh
|
|
FiveMinWarningScript.sh
|
|
"
|
|
|
|
################################# Unload or Remove #################################
|
|
|
|
removeDaemon(){
|
|
for d in $listDaemons
|
|
do
|
|
if [ -f "$d" ]
|
|
then
|
|
echo $d
|
|
sudo launchctl unload $d
|
|
sudo rm $d
|
|
fi
|
|
done
|
|
}
|
|
|
|
removeScrpit(){
|
|
for s in $listScripts
|
|
do
|
|
if [ -f "/Library/Application Support/JAMF/ING/$s" ]
|
|
then
|
|
echo $s
|
|
rm -rf "/Library/Application Support/JAMF/ING/$s"
|
|
fi
|
|
done
|
|
}
|
|
|
|
################################# Ausführen #################################
|
|
|
|
if [ $diffDays -lt 600 ] && [ -f "/Library/LaunchDaemons/de.ing.LastWarningDaemon.plist" ]
|
|
then
|
|
echo "neustart innerhalb von 10 min "
|
|
#removeDaemon
|
|
#removeScrpit
|
|
# rm -rf /Library/LaunchDaemons/de.ing.EnforceRestat.plist
|
|
# shutdown -r +2
|
|
|
|
else
|
|
|
|
if [ $diffDays -gt 32400 ]
|
|
then
|
|
echo "letzter neustart über 7 stunden her also nestart"
|
|
#removeDaemon
|
|
#removeScrpit
|
|
# rm -rf /Library/LaunchDaemons/de.ing.EnforceRestat.plist
|
|
# shutdown -r +2
|
|
|
|
else
|
|
echo "neustart wird durch den LastWarningDaemon ausgeführt"
|
|
fi
|
|
fi |