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