diff --git a/kdash_client/extensions/kdash/daemon.sh b/kdash_client/extensions/kdash/daemon.sh index e2a815f..0492f3a 100644 --- a/kdash_client/extensions/kdash/daemon.sh +++ b/kdash_client/extensions/kdash/daemon.sh @@ -14,6 +14,11 @@ PIDFILE="${DAEMON_PATH}/${DAEMON}.pid" # SCRIPTNAME="/etc/init.d/${NAME}" case "$1" in +set-gateway) + GATEWAY=$(ip route | grep default | grep "${NET}" | awk '{print $3}') + echo "$GATEWAY" + echo "$GATEWAY" >"${DAEMON_PATH}/gateway.txt" + ;; enable) touch "$DAEMON_ENABLED_FILE" ;; @@ -24,7 +29,7 @@ start) if [ -e "$DAEMON_ENABLED_FILE" ]; then printf "%-50s" "Starting $NAME..." cd "$DAEMON_PATH" || exit - . "$DAEMON_ENV_FILE" + . "$DAEMON_ENV_FILE" || exit PID=$( RUST_BACKTRACE=full RUST_LOG=debug $DAEMON "$DAEMONOPTS" >/dev/null 2>&1 & echo $! @@ -72,7 +77,7 @@ restart) ;; *) - echo "Usage: $0 {status|start|stop|restart}" + echo "Usage: $0 {set-gateway|enable|disable|status|start|stop|restart}" exit 1 ;; esac diff --git a/kdash_client/extensions/kdash/kdash.env b/kdash_client/extensions/kdash/kdash.env new file mode 100644 index 0000000..ca8f17e --- /dev/null +++ b/kdash_client/extensions/kdash/kdash.env @@ -0,0 +1,4 @@ +export KDASH_URL= +export KDASH_JWT= +export NET="wlan0" +export ROUTER_IP="$(cat "${DAEMON_PATH}/gateway.txt" | sed -e 's/^[ \t]*//' -e 's/\ *$//g')" diff --git a/kdash_client/extensions/kdash/menu.json b/kdash_client/extensions/kdash/menu.json index 1d7f18c..fae7806 100644 --- a/kdash_client/extensions/kdash/menu.json +++ b/kdash_client/extensions/kdash/menu.json @@ -3,6 +3,11 @@ { "name": "kdash", "items": [ + { + "name": "Set Gateway", + "priority": 0, + "action": "./daemon.sh set-gateway" + }, { "name": "Enable", "priority": 0, "action": "./daemon.sh enable" }, { "name": "Disable", "priority": 0, "action": "./daemon.sh disable" }, { "name": "Start", "priority": 0, "action": "./daemon.sh start" },