2018-06-03 22:27:11 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
import os
|
|
|
|
import pwd
|
|
|
|
|
|
|
|
|
|
|
|
OCTOPRINT = ["/opt/octoprint/venv/bin/octoprint", "serve"]
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
# Start klipper
|
2019-03-30 13:04:02 +00:00
|
|
|
klipper = subprocess.Popen(['sudo', '-u', 'octoprint', '/runklipper.py'])
|
2018-06-03 22:27:11 +00:00
|
|
|
|
|
|
|
os.setgid(
|
|
|
|
1000
|
|
|
|
) # Drop privileges, https://stackoverflow.com/questions/2699907/dropping-root-permissions-in-python#2699996
|
|
|
|
os.setuid(1000)
|
|
|
|
os.environ['HOME'] = '/home/octoprint'
|
|
|
|
# subprocess.Popen('env', shell=True).wait()
|
|
|
|
while 1:
|
|
|
|
Poctoprint = subprocess.Popen(OCTOPRINT)
|
|
|
|
Poctoprint.wait()
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
|