mirror of
https://github.com/Dichgrem/luci-app-nyn.git
synced 2025-12-16 13:42:00 -05:00
test:luci_app_zzz
This commit is contained in:
64
zzz/Makefile
Normal file
64
zzz/Makefile
Normal file
@@ -0,0 +1,64 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=zzz
|
||||
PKG_VERSION:=0.1.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Dichgrem <brcefy@gmail.com>
|
||||
PKG_LICENSE:=MIT
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/zzz
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=ZZZ 802.1x Authentication Client
|
||||
URL:=https://github.com/diredocks/zzz
|
||||
DEPENDS:=
|
||||
endef
|
||||
|
||||
define Package/zzz/description
|
||||
A 802.1x authentication client for OpenWrt routers.
|
||||
Cross-compiled C version for optimal performance and compatibility.
|
||||
endef
|
||||
|
||||
define Package/zzz/conffiles
|
||||
/etc/config/zzz
|
||||
/etc/zzz/config.ini
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/zzz/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/zzz
|
||||
|
||||
# Install precompiled binary based on architecture
|
||||
$(if $(CONFIG_TARGET_x86_64),$(INSTALL_BIN) ./files/bin/zzz-x86-linux-gnu $(1)/usr/bin/zzz)
|
||||
$(if $(CONFIG_TARGET_armvirt_64),$(INSTALL_BIN) ./files/bin/zzz-aarch64-linux-gnu $(1)/usr/bin/zzz)
|
||||
$(if $(CONFIG_TARGET_bcm27xx_bcm2711),$(INSTALL_BIN) ./files/bin/zzz-aarch64-linux-gnu $(1)/usr/bin/zzz)
|
||||
$(if $(CONFIG_TARGET_ath79_generic),$(INSTALL_BIN) ./files/bin/zzz-mipsel-linux-musleabi $(1)/usr/bin/zzz)
|
||||
$(if $(CONFIG_TARGET_ramips_mt7621),$(INSTALL_BIN) ./files/bin/zzz-mipsel-linux-musleabi $(1)/usr/bin/zzz)
|
||||
$(if $(CONFIG_TARGET_mediatek_mt7622),$(INSTALL_BIN) ./files/bin/zzz-aarch64-linux-gnu $(1)/usr/bin/zzz)
|
||||
$(if $(CONFIG_TARGET_rockchip_armv8),$(INSTALL_BIN) ./files/bin/zzz-aarch64-linux-gnu $(1)/usr/bin/zzz)
|
||||
# Fallback - try to detect architecture
|
||||
$(if $(findstring aarch64,$(ARCH)),$(INSTALL_BIN) ./files/bin/zzz-aarch64-linux-gnu $(1)/usr/bin/zzz)
|
||||
$(if $(findstring mips,$(ARCH)),$(INSTALL_BIN) ./files/bin/zzz-mipsel-linux-musleabi $(1)/usr/bin/zzz)
|
||||
$(if $(findstring x86,$(ARCH)),$(INSTALL_BIN) ./files/bin/zzz-x86-linux-gnu $(1)/usr/bin/zzz)
|
||||
|
||||
$(INSTALL_BIN) ./files/usr/bin/zzz-device-info $(1)/usr/bin/
|
||||
$(INSTALL_CONF) ./files/etc/config/zzz $(1)/etc/config/
|
||||
$(INSTALL_CONF) ./files/etc/zzz/config.ini $(1)/etc/zzz/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/zzz $(1)/etc/init.d/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,zzz))
|
||||
BIN
zzz/files/bin/zzz-aarch64-linux-gnu
Normal file
BIN
zzz/files/bin/zzz-aarch64-linux-gnu
Normal file
Binary file not shown.
BIN
zzz/files/bin/zzz-mipsel-linux-musleabi
Normal file
BIN
zzz/files/bin/zzz-mipsel-linux-musleabi
Normal file
Binary file not shown.
BIN
zzz/files/bin/zzz-x86-linux-gnu
Normal file
BIN
zzz/files/bin/zzz-x86-linux-gnu
Normal file
Binary file not shown.
7
zzz/files/etc/config/zzz
Normal file
7
zzz/files/etc/config/zzz
Normal file
@@ -0,0 +1,7 @@
|
||||
config general 'general'
|
||||
option enabled '0'
|
||||
|
||||
config auth 'auth'
|
||||
option username ''
|
||||
option password ''
|
||||
option device 'eth0'
|
||||
54
zzz/files/etc/init.d/zzz
Normal file
54
zzz/files/etc/init.d/zzz
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
CONFIG=/etc/zzz/config.ini
|
||||
|
||||
start_service() {
|
||||
# 检查是否启用
|
||||
local enabled=$(uci -q get zzz.general.enabled)
|
||||
[ "$enabled" = "1" ] || {
|
||||
echo "zzz is disabled"
|
||||
return 1
|
||||
}
|
||||
|
||||
generate_config
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/bin/zzz "$CONFIG"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
procd_kill zzz
|
||||
}
|
||||
|
||||
generate_config() {
|
||||
mkdir -p /etc/zzz
|
||||
|
||||
# 获取UCI配置
|
||||
local username=$(uci -q get zzz.auth.username)
|
||||
local password=$(uci -q get zzz.auth.password)
|
||||
local device=$(uci -q get zzz.auth.device)
|
||||
|
||||
# 检查必要参数
|
||||
[ -z "$username" ] && {
|
||||
logger -t zzz "Error: username not configured"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -z "$password" ] && {
|
||||
logger -t zzz "Error: password not configured"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 生成INI配置文件
|
||||
cat >"$CONFIG" <<EOF
|
||||
[auth]
|
||||
username = $username
|
||||
password = $password
|
||||
device = ${device:-eth0}
|
||||
EOF
|
||||
}
|
||||
7
zzz/files/etc/zzz/config.ini
Normal file
7
zzz/files/etc/zzz/config.ini
Normal file
@@ -0,0 +1,7 @@
|
||||
# Default configuration for zzz 802.1x client
|
||||
# This file will be generated by UCI system
|
||||
|
||||
[auth]
|
||||
username =
|
||||
password =
|
||||
device = eth0
|
||||
29
zzz/files/usr/bin/zzz-device-info
Normal file
29
zzz/files/usr/bin/zzz-device-info
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# /usr/bin/zzz-device-info
|
||||
# Helper script to get device information for zzz configuration
|
||||
|
||||
echo "Available network devices:"
|
||||
echo "=========================="
|
||||
|
||||
if command -v zzz >/dev/null 2>&1; then
|
||||
zzz -mode info 2>/dev/null | grep -E "(Found|device|hardware_description)" | while read line; do
|
||||
echo "$line"
|
||||
done
|
||||
else
|
||||
echo "zzz binary not found. Showing available network interfaces:"
|
||||
for dev in /sys/class/net/*; do
|
||||
if [ -d "$dev" ]; then
|
||||
iface=$(basename "$dev")
|
||||
if [ "$iface" != "lo" ]; then
|
||||
echo "Device: $iface"
|
||||
if [ -f "$dev/address" ]; then
|
||||
echo " MAC: $(cat "$dev/address")"
|
||||
fi
|
||||
if [ -f "$dev/operstate" ]; then
|
||||
echo " State: $(cat "$dev/operstate")"
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user