octoprint-klipper-docker/start.py

32 lines
668 B
Python
Raw Normal View History

2018-06-03 22:27:11 +00:00
#!/usr/bin/env python
import subprocess
import time
import os
import pwd
2022-06-06 14:47:40 +00:00
OCTOPRINT = ["/opt/octoprint/venv/bin/octoprint", "serve","--port","80"]
2018-06-03 22:27:11 +00:00
def main():
# Start klipper
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()