Files
Alte_Skripte/aktuelle_Scripte/script_zum_Enforce_neustart.sh
2026-02-16 15:05:15 +01:00

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