Browse Source

mqtt_smarthome in tmux

master
Dirk Alders 1 year ago
parent
commit
d5f22f1a49
1 changed files with 13 additions and 1 deletions
  1. 13
    1
      mqtt_smarthome

+ 13
- 1
mqtt_smarthome View File

1
 #!/bin/sh
1
 #!/bin/sh
2
 clear
2
 clear
3
-/opt/mqtt_sniffer/venv/bin/python /opt/mqtt_sniffer/mqtt_sniffer.py -f mqtt.home
3
+
4
+#!/bin/sh
5
+#
6
+
7
+for s in $(tmux list-sessions -F '#{session_name}'); do
8
+    p=$(tmux list-panes -F '#{pane_tty}' -t "$s")
9
+    if [ "$p" = "$(tty)" ]; then
10
+        # Session already running
11
+        exit 0
12
+    fi
13
+done
14
+
15
+tmux attach-session -t mqtt_smarthome || tmux new-session -s mqtt_smarthome "/opt/mqtt_sniffer/venv/bin/python /opt/mqtt_sniffer/mqtt_sniffer.py -f mqtt.home"
4
 
16
 

Loading…
Cancel
Save