I'm an absolute raspberry pi / phyton newbie so be patient with me.
Now for the problem (problem? more like a question). (I want to apologize before hand if such a request was already answered before, I just could not find something to useful.)
I have set up a raspberry pi rev2.1 with a mumble server which explicitely does not START on pi boot. I want to start / stop the mumble server service after the pi has booted and stabilized itself, manually via button presses. Also incase of a problem with the mumble service, I want to stop it via button press and start it again.
I have read some tutorials and codes now for reboot and shutdown button phyton scripts and I think my request is rather similar.
Here is the code I clobbered together so far. (Don't hit me to hard pls, this is my first phyton script..?)
#!/usr/bin/env python # import required modules import time import RPi.GPIO as GPIO # main function def main(): # use GPIO pin numbering convention GPIO.setmode(GPIO.BCM) # set up variable and GPIO pin for input MumbleStart = 2 GPIO.setup(MumbleStart, GPIO.IN, pull_up_down=GPIO.PUD_UP) MumbleStop = 3 GPIO.setup(MumbleStop, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: # button MumbleStart pressed, starting service if not GPIO.input(MumbleStart): sudo /etc/init.d/mumble-server start # button MumbleStop pressed, stoping service if not GPIO.input(MumbleStop): sudo /etc/init.d/mumble-server stop # wait 200ms time.sleep(0.2) GPIO.cleanup() if __name__ == '__main__': # call main function main()
Now I'm not certain if I can actually use it that way. I believe that the code for calling up the mumble-server, should be something else. But I can't find an explicit example of calling up a service via a phyton script. So if anybody has an idea, please help me.