sulu: support dynamic QR

This commit is contained in:
Vivek Kumar Dutta 2025-07-11 18:27:56 +05:30 committed by Vivek Dutta
parent 6bec3c159c
commit 6cca837500
3 changed files with 2 additions and 55 deletions

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-builder
PKG_VERSION:=5.0.4
PKG_VERSION:=5.0.5
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
@ -28,7 +28,7 @@ define Package/sulu/default
CATEGORY:=Utilities
SUBMENU:=SULU
TITLE:=SULU-CE
DEPENDS:=+mosquitto-auth-shadow +usermngr +jq +userinterface +obuspa +qrencode
DEPENDS:=+mosquitto-auth-shadow +usermngr +jq +userinterface +obuspa
EXTRA_DEPENDS:=nginx
endef

View file

@ -33,7 +33,6 @@ start_service() {
log "Reloading related services"
/etc/sulu/sulu.sh -r
fi
/etc/sulu/sulu.sh -q
procd_close_instance
}

View file

@ -215,54 +215,6 @@ function update_obuspa_config() {
fi
}
generate_qr_code() {
local NA="UNKNOWN"
local TMP="/tmp/wifi_qr.svg"
local QR="/sulu/assets/QR.svg"
local SSID=""
local KEY=""
which qrencode || return
local PASS="$(get_user_password)"
if [ -z "$PASS" ]; then
PASS="$NA"
fi
get_ssid_and_key() {
local sec="$1"
local filter_vid="$2"
if [ "$SSID" != "" ]; then
return
fi
config_get type "$sec" type
if [ "$type" != "fronthaul" ]; then
return
fi
if [ "$filter_vid" = "1" ]; then
config_get vid "$sec" vid
if [ "$vid" != "1" ]; then
return
fi
fi
config_get ssid "$sec" ssid
config_get key "$sec" key
SSID="$ssid"
KEY="$key"
}
config_load mapcontroller
config_foreach get_ssid_and_key "ap" "0"
if [ "$SSID" == "" ]; then
config_foreach get_ssid_and_key "ap" "1"
fi
SSID=${SSID:-$NA}
KEY=${KEY:-$NA}
PASS=${PASS:-$NA}
qrencode -t svg -m 0 -o "$TMP" "WIFI:S:$SSID;T:WPA;P:$KEY;;GNX:U:user;Q:$PASS;;"
if [ "$(sha256sum "$TMP" | cut -d ' ' -f1)" != "$(sha256sum "$QR" | cut -d ' ' -f1)" ]; then
mv "$TMP" "$QR"
else
rm "$TMP"
fi
}
function configure_sulu() {
_create_mosquitto_acl
update_obuspa_config
@ -274,10 +226,6 @@ while getopts ":rq" opt; do
r)
_RESTART_SERVICES="1"
;;
q)
generate_qr_code
exit 0
;;
*)
slog "Invalid option: ${OPTARG}"
exit 1