Guest User

Untitled

a guest
Jun 18th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import RPi.GPIO as GPIO
  5. import subprocess
  6.  
  7. GPIO.setmode(GPIO.BCM)
  8. GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  9. GPIO.wait_for_edge(21, GPIO.FALLING)
  10.  
  11. subprocess.call(['shutdown', '-h', 'now'], shell=False)
  12.  
  13. #! /bin/sh
  14.  
  15. ### BEGIN INIT INFO
  16. # Provides: shutdown.py
  17. # Required-Start: $remote_fs $syslog
  18. # Required-Stop: $remote_fs $syslog
  19. # Default-Start: 2 3 4 5
  20. # Default-Stop: 0 1 6
  21. ### END INIT INFO
  22.  
  23. # If you want a command to always run, put it here
  24.  
  25. # Carry out specific functions when asked to by the system
  26. case "$1" in
  27. start)
  28. echo "Starting shutdown.py"
  29. /usr/local/bin/shutdown.py &
  30. ;;
  31. stop)
  32. echo "Stopping shutdown.py"
  33. pkill -f /usr/local/bin/shutdown.py
  34. ;;
  35. *)
  36. echo "Usage: /etc/init.d/shutdown.sh {start|stop}"
  37. exit 1
  38. ;;
  39. esac
  40.  
  41. exit 0
Add Comment
Please, Sign In to add comment