#!/bin/bash

# OFXC means you user directory - replace it in script 
# copy this script to /Users/ofxc/scripts/
# make it executable: chmod +x /Users/ofxc/scripts/startup/startup.sh
# you may need to edit the shudoers file

# this script must be added as LaunchDaemon so it can be executed without the need to login first
# copy the plist file com.autorestarter.plist to /Library/LaunchDaemons/ (with root user ofc (sudo command))
#    sudo cp com.autorestarter.plist /Library/LaunchDaemons/
# run sudo launchctl load -w /Library/LaunchDaemons/com.autorestarter.plist
# to remove it run sudo launchctl unload -w /Library/LaunchDaemons/com.autorestarter.plist

# restart and check if /Users/ofxc/restart.tmp exists
# if it exists, restart again to check if its gone and if yes, uncomment reboot (line 19, remove #)

FILE="/Users/ofxc/restart.tmp"
if test -f "$FILE"; then
  rm $FILE
else
  echo "test" >> $FILE
  #reboot
fi
