Browse Source

Add missing filed

Joachim M. Giæver 3 years ago
parent
commit
ae4f32858d
3 changed files with 34 additions and 0 deletions
  1. 22 0
      src/bin/daemonize
  2. 9 0
      src/bin/de-daemonize
  3. 3 0
      src/bin/restart

+ 22 - 0
src/bin/daemonize

@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+if ! snapctl is-connected raw-usb; then
+    echo "Failed to enable ${SNAP_NAME} service!"
+    echo ""
+    echo "Consult the help command:"
+    echo "${SNAP_NAME}.exec --help"
+    echo ""
+    echo "Ensure ${SNAP_NAME} is booting successfully before daemonize it"
+    echo "by running the app manually (remove the --help flag)."
+    exit 1
+fi
+
+snapctl start "${SNAP_NAME}.${SNAP_NAME}" --enable
+if [ $? -eq 0 ]; then
+    echo "Service enabled! Follow logs with"
+    echo "$ snap logs ${SNAP_NAME}"
+    exit 0
+fi
+
+echo "Failed enabling service"
+exit 1

+ 9 - 0
src/bin/de-daemonize

@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+snapctl stop --disable "${SNAP_NAME}.${SNAP_NAME}"
+
+if [ $? -eq 0 ]; then
+    echo "Service ${SNAP_NAME} disabled."
+    exit 0
+fi
+echo "Failed disabling ${SNAP_NAME} service"
+exit 1

+ 3 - 0
src/bin/restart

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