• Source
    1. #! /bin/sh
    2. # /etc/init.d/onofflog.sh
    3.  
    4. ### BEGIN INIT INFO
    5. # Provides: Mohamed Soubhi
    6. # Required-Start: $remote_fs $syslog
    7. # Required-Stop: $remote_fs $syslog
    8. # Default-Start: 2 3 4 5
    9. # Default-Stop: 0 1 6
    10. # Short-Description: Simple script to log power on and reboot and shut down
    11. # Description: A simple script from logging power on and pwoer of and reboot.
    12. ### END INIT INFO
    13.  
    14. # If you want a command to always run, put it here
    15.  
    16. # Carry out specific functions when asked to by the system
    17. ONOFF_LOG=/var/www/onoff.log
    18.  
    19. case "$1" in
    20. start)
    21. echo "Power on Log"
    22. # run application you want to start
    23.  
    24. bash /home/pi/ourscripts/poweron_script.sh
    25.  
    26.  
    27. ;;
    28. stop)
    29. echo "Shutdown Log"
    30. # kill application you want to stop
    31.  
    32. bash /home/pi/ourscripts/shutdown_script.sh
    33.  
    34.  
    35. ;;
    36. *)
    37. echo "No Log"
    38. exit 1
    39. ;;
    40. esac
    41.  
    42. exit 0