I have a python script (taken from the forums here) that reboots my RPI when a button is pressed.
It works great, no issues, except that it refuses to start automatically (either on boot, login, anything). I have tried various options listed here (rc.local, .bashrc, idit.d tab, systems, crontab) and nothing seems to work.
Is it something as simple as my script actually not being very good, and something in there is stopping it from working?
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import os
def button_callback(channel):
print("Button was pushed!")
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def Restart(channel):
os.system("sudo shutdown -r now")
GPIO.add_event_detect(16,GPIO.RISING,callback = Restart, bouncetime = 2000)
message = input()
GPIO.cleanup()