Quellcode durchsuchen

Ansible adaptions

master
Dirk Alders vor 1 Jahr
Ursprung
Commit
8d9508f4fb
6 geänderte Dateien mit 17 neuen und 50 gelöschten Zeilen
  1. 0
    41
      __install__.py
  2. 5
    5
      config_example/config.py
  3. 8
    0
      init_venv
  4. 0
    4
      mpd_monitor.sh
  5. 0
    0
      smart_mpd.py
  6. 4
    0
      smart_mpd.sh

+ 0
- 41
__install__.py Datei anzeigen

@@ -1,41 +0,0 @@
1
-#!/bin/python
2
-#
3
-import os
4
-import sys
5
-
6
-SERVICE_FILE = """
7
-[Unit]
8
-Description=MPD Monitor 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/mpd_monitor.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], 'mpd_monitor.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()

+ 5
- 5
config_example/config.py Datei anzeigen

@@ -3,10 +3,10 @@
3 3
 import os
4 4
 import report
5 5
 
6
-MQTT_USER = "user"
7
-MQTT_PASS = "pass"
8
-MQTT_SERVER = "localhost"
9
-MQTT_TOPIC = "hifi/mpd"
6
+MQTT_SERVER = "<mqtt_smarthome_hostname>"
7
+MQTT_USER = "<mqtt_smarthome_username>"
8
+MQTT_PASS = "<mqtt_smarthome_password>"
9
+MQTT_TOPIC = "<mqtt_mpd_topic>"
10 10
 
11 11
 #
12 12
 # Logging
@@ -14,7 +14,7 @@ MQTT_TOPIC = "hifi/mpd"
14 14
 __BASEPATH__ = os.path.abspath(os.path.dirname(__file__))
15 15
 APP_NAME = "mpd"
16 16
 LOGTARGET = 'stdout'   # possible choices are: 'logfile' or 'stdout'
17
-LOGLVL = 'DEBUG'
17
+LOGLVL = 'INFO'
18 18
 
19 19
 LOGHOST = 'cutelog'
20 20
 LOGPORT = 19996

+ 8
- 0
init_venv Datei anzeigen

@@ -0,0 +1,8 @@
1
+#!/bin/sh
2
+#
3
+BASEPATH=`realpath $(dirname $0)`
4
+
5
+python3 -m venv $BASEPATH/venv
6
+$BASEPATH/venv/bin/pip install --upgrade pip
7
+find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r
8
+$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U

+ 0
- 4
mpd_monitor.sh Datei anzeigen

@@ -1,4 +0,0 @@
1
-#!/bin/sh
2
-#
3
-BASEPATH=`dirname $0`
4
-$BASEPATH/venv/bin/python $BASEPATH/mpd_monitor.py

mpd_monitor.py → smart_mpd.py Datei anzeigen


+ 4
- 0
smart_mpd.sh Datei anzeigen

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+#
3
+BASEPATH=`dirname $0`
4
+$BASEPATH/venv/bin/python $BASEPATH/smart_mpd.py

Laden…
Abbrechen
Speichern