|
@@ -0,0 +1,30 @@
|
|
1
|
+#!/bin/python3
|
|
2
|
+#
|
|
3
|
+import re
|
|
4
|
+import sys
|
|
5
|
+
|
|
6
|
+try:
|
|
7
|
+ src_file = sys.argv[1]
|
|
8
|
+ dst_file = sys.argv[2]
|
|
9
|
+except IndexError:
|
|
10
|
+ print(sys.argv[0], "<src> <dst>")
|
|
11
|
+ sys.exit(17)
|
|
12
|
+
|
|
13
|
+try:
|
|
14
|
+ with open(src_file, 'r') as fh:
|
|
15
|
+ s = fh.read()
|
|
16
|
+except (PermissionError, FileNotFoundError) as e:
|
|
17
|
+ print("Unable to open", '"' + src_file + '"')
|
|
18
|
+ sys.exit(18)
|
|
19
|
+
|
|
20
|
+n = re.sub('^.*server: .*', ' server: mqtt://{{ smart_sat_zigbee2mqtt_hostname }}', s, flags=re.MULTILINE)
|
|
21
|
+n = re.sub('^.*user: .*', ' user: {{ smart_sat_zigbee2mqtt_username }}', n, flags=re.MULTILINE)
|
|
22
|
+n = re.sub('^.*password: .*', ' password: {{ smart_sat_zigbee2mqtt_password }}', n, flags=re.MULTILINE)
|
|
23
|
+n = re.sub('^.*auth_token: .*', ' auth_token: {{ smart_sat_zigbee2mqtt_auth_token }}', n, flags=re.MULTILINE)
|
|
24
|
+
|
|
25
|
+try:
|
|
26
|
+ with open(dst_file, 'w') as fh:
|
|
27
|
+ fh.write(n)
|
|
28
|
+except PermissionError:
|
|
29
|
+ print("Unable to write", '"' + dst_file + '"')
|
|
30
|
+ sys.exit(19)
|