Publishs ambient information to mqtt server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

__install__.py 954B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/python
  2. #
  3. import os
  4. import sys
  5. SERVICE_FILE = """
  6. [Unit]
  7. Description=Smarthome Ambient Information Service
  8. After=network-online.target
  9. Wants=network-online.target
  10. [Service]
  11. User=%(UID)d
  12. Group=%(GID)d
  13. ExecStart=%(MY_PATH)s/ambient_info.sh
  14. Type=simple
  15. [Install]
  16. WantedBy=default.target
  17. """
  18. def help():
  19. print("Usage: prog <UID> <GID> <TARGET_PATH>")
  20. if __name__ == "__main__":
  21. if len(sys.argv) == 4:
  22. try:
  23. uid = int(sys.argv[1])
  24. gid = int(sys.argv[2])
  25. except ValueError:
  26. help()
  27. else:
  28. if os.path.isdir(sys.argv[3]):
  29. with open(os.path.join(sys.argv[3], 'ambient_info.service'), "w") as fh:
  30. fh.write(SERVICE_FILE % {
  31. "MY_PATH": os.path.dirname(os.path.abspath(__file__)),
  32. "UID": uid,
  33. "GID": gid})
  34. else:
  35. help()
  36. else:
  37. help()