mirror of
https://github.com/Dichgrem/luci-app-nyn.git
synced 2025-12-17 14:11:59 -05:00
test:luci_app_zzz
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user