Add set gateway entry to KUAL

This commit is contained in:
Dominic Grimm 2024-11-22 16:06:29 +01:00
parent 220a446fb6
commit 926b15949d
3 changed files with 16 additions and 2 deletions

View file

@ -14,6 +14,11 @@ PIDFILE="${DAEMON_PATH}/${DAEMON}.pid"
# SCRIPTNAME="/etc/init.d/${NAME}" # SCRIPTNAME="/etc/init.d/${NAME}"
case "$1" in case "$1" in
set-gateway)
GATEWAY=$(ip route | grep default | grep "${NET}" | awk '{print $3}')
echo "$GATEWAY"
echo "$GATEWAY" >"${DAEMON_PATH}/gateway.txt"
;;
enable) enable)
touch "$DAEMON_ENABLED_FILE" touch "$DAEMON_ENABLED_FILE"
;; ;;
@ -24,7 +29,7 @@ start)
if [ -e "$DAEMON_ENABLED_FILE" ]; then if [ -e "$DAEMON_ENABLED_FILE" ]; then
printf "%-50s" "Starting $NAME..." printf "%-50s" "Starting $NAME..."
cd "$DAEMON_PATH" || exit cd "$DAEMON_PATH" || exit
. "$DAEMON_ENV_FILE" . "$DAEMON_ENV_FILE" || exit
PID=$( PID=$(
RUST_BACKTRACE=full RUST_LOG=debug $DAEMON "$DAEMONOPTS" >/dev/null 2>&1 & RUST_BACKTRACE=full RUST_LOG=debug $DAEMON "$DAEMONOPTS" >/dev/null 2>&1 &
echo $! 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 exit 1
;; ;;
esac esac

View file

@ -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')"

View file

@ -3,6 +3,11 @@
{ {
"name": "kdash", "name": "kdash",
"items": [ "items": [
{
"name": "Set Gateway",
"priority": 0,
"action": "./daemon.sh set-gateway"
},
{ "name": "Enable", "priority": 0, "action": "./daemon.sh enable" }, { "name": "Enable", "priority": 0, "action": "./daemon.sh enable" },
{ "name": "Disable", "priority": 0, "action": "./daemon.sh disable" }, { "name": "Disable", "priority": 0, "action": "./daemon.sh disable" },
{ "name": "Start", "priority": 0, "action": "./daemon.sh start" }, { "name": "Start", "priority": 0, "action": "./daemon.sh start" },