diff --git a/__install__.py b/__install__.py new file mode 100644 index 0000000..9a9aa6d --- /dev/null +++ b/__install__.py @@ -0,0 +1,41 @@ +#!/bin/python +# +import os +import sys + +SERVICE_FILE = """ +[Unit] +Description=Exec Command Service +After=network-online.target +Wants=network-online.target +[Service] +User=%(UID)d +Group=%(GID)d +ExecStart=%(MY_PATH)s/exec_command.sh +Type=simple +[Install] +WantedBy=default.target +""" + + +def help(): + print("Usage: prog ") + +if __name__ == "__main__": + if len(sys.argv) == 4: + try: + uid = int(sys.argv[1]) + gid = int(sys.argv[2]) + except ValueError: + help() + else: + if os.path.isdir(sys.argv[3]): + with open(os.path.join(sys.argv[3], 'exec_command.service'), "w") as fh: + fh.write(SERVICE_FILE % { + "MY_PATH": os.path.dirname(os.path.abspath(__file__)), + "UID": uid, + "GID": gid}) + else: + help() + else: + help() diff --git a/example_config/config.py b/example_config/config.py index 0427260..668f0d1 100644 --- a/example_config/config.py +++ b/example_config/config.py @@ -11,7 +11,7 @@ MQTT_SERVER = "host" TOPIC = 'topic' PAYLOAD = b'payload' -COMMAND = "aplay ring.wav -D plughw:UACDemoV10,0" +COMMAND = "aplay %s/ring.wav -D plughw:UACDemoV10,0" % __BASEPATH__ # # Logging diff --git a/ring.wav b/ring.wav index 52a944f..0d2fdc0 120000 --- a/ring.wav +++ b/ring.wav @@ -1 +1 @@ -sounds/phone-incoming-call.wav \ No newline at end of file +sounds/door-bell.wav \ No newline at end of file diff --git a/sounds/door-bell.wav b/sounds/door-bell.wav new file mode 100644 index 0000000..37ae04c Binary files /dev/null and b/sounds/door-bell.wav differ