add config entry for kai (#593)
Co-authored-by: jannson <jannon.wei@gmail.com>
diff --git a/applications/app-meta-kai/Makefile b/applications/app-meta-kai/Makefile
index 3a6d522..29ca805 100644
--- a/applications/app-meta-kai/Makefile
+++ b/applications/app-meta-kai/Makefile
@@ -2,8 +2,8 @@
include $(TOPDIR)/rules.mk
-PKG_VERSION:=1.0.0
-PKG_RELEASE:=7
+PKG_VERSION:=1.0.1
+PKG_RELEASE:=1
META_TITLE:=酷友社KAI
META_TITLE.en:=kai
META_DEPENDS:=+luci-app-kai +kai +kai_session
@@ -14,6 +14,8 @@ META_ARCH:=x86_64 aarch64
META_TAGS:=system ai
META_LUCI_ENTRY:=/cgi-bin/luci/admin/services/kai
META_WEBSITE:=https://www.koolcenter.com
+META_AUTOCONF:=path enable
+META_UCI:=kai
include ../../meta.mk
diff --git a/applications/app-meta-kai/config.sh b/applications/app-meta-kai/config.sh
new file mode 100755
index 0000000..ca3265a
--- /dev/null
+++ b/applications/app-meta-kai/config.sh
@@ -0,0 +1,19 @@
+
+[ -z "$ISTORE_CONF_DIR" ] && exit 1
+
+ENABLED=1
+ISTORE_ACTION=start
+if [ -n "$ISTORE_DONT_START" ]; then
+ ENABLED=0
+ ISTORE_ACTION=stop
+fi
+
+mkdir -p "$ISTORE_CONF_DIR/KAI" || exit 1
+
+uci -q batch <<-EOF >/dev/null || exit 1
+ set kai.@kai[0].enabled=$ENABLED
+ set kai.@kai[0].data_dir="$ISTORE_CONF_DIR/KAI"
+ commit kai
+EOF
+
+/etc/init.d/kai $ISTORE_ACTION || [ stop = $ISTORE_ACTION ]
diff --git a/applications/app-meta-kai/entry.sh b/applications/app-meta-kai/entry.sh
new file mode 100755
index 0000000..8013514
--- /dev/null
+++ b/applications/app-meta-kai/entry.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+status(){
+ local host="$1"
+ [ -n "$host" ] || host=127.0.0.1
+ . /usr/share/libubox/jshn.sh
+ json_init
+ json_add_string "app" "kai"
+ json_add_boolean "docker" "0"
+
+ local port
+ port="$(uci get kai.@kai[0].port 2>/dev/null)"
+ local portsec=${port:-8197}
+
+ if pidof kai_bin >/dev/null 2>&1; then
+ json_add_boolean "running" "1"
+ json_add_string "web" ":${portsec}"
+ json_add_string "href" "http://$host:${portsec}/"
+ json_add_string "protocol" http
+ json_add_string "port" "${portsec}"
+ json_add_boolean "deployed" "1"
+ else
+ json_add_boolean "running" "0"
+ if [ -x /etc/init.d/kai ]; then
+ json_add_boolean "deployed" "1"
+ else
+ json_add_boolean "deployed" "0"
+ fi
+ fi
+
+ json_dump
+ json_cleanup >/dev/null
+}
+
+start(){
+ /etc/init.d/kai start
+}
+
+stop(){
+ /etc/init.d/kai stop
+}
+
+ACTION=${1}
+shift 1
+[ -z "${ACTION}" ] && ACTION=help
+
+case ${ACTION} in
+ "status" | "start" | "stop")
+ ${ACTION} "$@"
+ ;;
+ *)
+ echo "Unknown Action" >&2
+ exit 1
+ ;;
+esac
+
GitHub
sha: c2272c4a9d8284b830b924be1163561823c8ddb6