Browse Source

Merge branch 'dev'

Joachim M. Giæver 3 years ago
parent
commit
a357fa2805
4 changed files with 33 additions and 1 deletions
  1. 15 0
      scripts/config/plug-bin
  2. 3 0
      scripts/hooks/connect-plug-bin
  3. 3 0
      snap/hooks/disconnect-plug-bin
  4. 12 1
      snap/snapcraft.yaml

+ 15 - 0
scripts/config/plug-bin

@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+snapctl is-connected bin
+
+if [ $? -eq 0 ]; then
+    readarray -d '' PATHS < <(find $SNAP -maxdepth 2 -type d -name bin -path "$SNAP/shared-bin*" -print0)
+
+    if [ "${#PATHS[@]}" -ne 0 ]; then
+        for TPATH in "${PATHS[@]}"; do
+            PATH="${PATH}:${TPATH}"
+        done
+    fi
+fi
+
+eval $@

+ 3 - 0
scripts/hooks/connect-plug-bin

@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+snapctl restart "${SNAP_NAME}"

+ 3 - 0
snap/hooks/disconnect-plug-bin

@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+snapctl restart "${SNAP_NAME}"

+ 12 - 1
snap/snapcraft.yaml

@@ -18,6 +18,12 @@ layout:
   /etc/openzwave:
     bind: $SNAP/openzwave
 
+plugs:
+  bin:
+    interface: content
+    content: executables
+    target: $SNAP/shared-bin
+
 slots:
   components:
     interface: content
@@ -47,6 +53,8 @@ hooks:
 apps:
   home-assistant-snap:
     command: bin/hass --config $SNAP_DATA
+    command-chain:
+      - bin/plug-bin
     daemon: simple
     environment:
       PIP_USER: 1
@@ -56,7 +64,7 @@ apps:
       - network
       - network-bind
       - raw-usb
-      # GPIO devices etc.. (e.g RaZberry GPIO hat)
+      # GPIO devices etc.. (e.g RaZberry HAT)
       - physical-memory-control
     slots: 
       - components
@@ -146,6 +154,7 @@ parts:
       configure: snap/hooks/configure
       post-refresh: snap/hooks/post-refresh
       prepare-slot-certs: snap/hooks/prepare-slot-certs
+      connect-plug-bin: snap/hooks/connect-plug-bin
   bins:
     plugin: dump
     source: ./scripts/bin
@@ -157,3 +166,5 @@ parts:
     plugin: dump
     source: ./scripts/config
     source-type: local
+    organize:
+      plug-bin: bin/plug-bin