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