mirror of
https://github.com/Dichgrem/luci-app-nyn.git
synced 2025-12-18 14:42:00 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa3b2954cd | ||
|
|
c056ca8a4b | ||
|
|
69ff02fdbb | ||
|
|
e4d1f1b108 | ||
|
|
ef45a9414b | ||
|
|
cd7f41d7a7 | ||
|
|
e1e0f03143 | ||
|
|
9dd9806fd8 | ||
|
|
290d77183e |
138
.github/workflows/build-zzz.yml
vendored
Normal file
138
.github/workflows/build-zzz.yml
vendored
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
name: Build luci-app-zzz
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
sdk:
|
||||||
|
description: '选择架构'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- ramips
|
||||||
|
- filogic
|
||||||
|
- x86_64
|
||||||
|
default: filogic
|
||||||
|
|
||||||
|
env:
|
||||||
|
RAMIPS_SDK_URL: https://downloads.immortalwrt.org/releases/24.10.3/targets/ramips/mt7621/immortalwrt-sdk-24.10.3-ramips-mt7621_gcc-13.3.0_musl.Linux-x86_64.tar.zst
|
||||||
|
FILOGIC_SDK_URL: https://downloads.immortalwrt.org/releases/24.10.3/targets/mediatek/filogic/immortalwrt-sdk-24.10.3-mediatek-filogic_gcc-13.3.0_musl.Linux-x86_64.tar.zst
|
||||||
|
X86_SDK_URL: https://downloads.immortalwrt.org/releases/24.10.3/targets/x86/64/immortalwrt-sdk-24.10.3-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo "👉 正在下载依赖项"
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential git wget python3 rsync zstd g++ make libncurses-dev
|
||||||
|
echo "✅ 下载完毕"
|
||||||
|
|
||||||
|
- name: Resolve SDK choice
|
||||||
|
id: vars
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
if [ "${{ github.event.inputs.sdk }}" = "x86_64" ]; then
|
||||||
|
echo "SDK_URL=${X86_SDK_URL}" >> $GITHUB_ENV
|
||||||
|
echo "PACKAGE_ARCH=x86_64" >> $GITHUB_ENV
|
||||||
|
echo "👉 选择x86_64架构"
|
||||||
|
elif [ "${{ github.event.inputs.sdk }}" = "filogic" ]; then
|
||||||
|
echo "SDK_URL=${FILOGIC_SDK_URL}" >> $GITHUB_ENV
|
||||||
|
echo "PACKAGE_ARCH=aarch64_cortex-a53" >> $GITHUB_ENV
|
||||||
|
echo "👉 选择aarch64架构"
|
||||||
|
else
|
||||||
|
echo "SDK_URL=${RAMIPS_SDK_URL}" >> $GITHUB_ENV
|
||||||
|
echo "PACKAGE_ARCH=ramips" >> $GITHUB_ENV
|
||||||
|
echo "👉 选择ramips架构"
|
||||||
|
fi
|
||||||
|
echo "WORK_ROOT=$GITHUB_WORKSPACE/imwrt-sdk" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Download & extract SDK
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p "$WORK_ROOT"
|
||||||
|
cd "$WORK_ROOT"
|
||||||
|
|
||||||
|
SDK_TAR="$(basename "$SDK_URL")"
|
||||||
|
echo "👉 正在下载SDK:$SDK_TAR"
|
||||||
|
wget -q "$SDK_URL" -O "$SDK_TAR"
|
||||||
|
|
||||||
|
echo "📦 正在解压SDK..."
|
||||||
|
tar --use-compress-program="zstd -q -d" -xf "$SDK_TAR" >/dev/null 2>&1
|
||||||
|
|
||||||
|
echo "✅ SDK解压完成"
|
||||||
|
SDK_ROOT="$(find . -maxdepth 1 -type d -name 'immortalwrt-sdk*' | head -n 1)"
|
||||||
|
if [ -z "$SDK_ROOT" ]; then
|
||||||
|
echo "❌ 未找到SDK目录" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
SDK_ROOT="$(cd "$SDK_ROOT" && pwd)"
|
||||||
|
echo "SDK_ROOT=$SDK_ROOT" >> $GITHUB_ENV
|
||||||
|
echo "📁 SDK路径: $SDK_ROOT"
|
||||||
|
|
||||||
|
- name: Setup feeds & clone source
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$SDK_ROOT"
|
||||||
|
echo "👉 正在设置feeds"
|
||||||
|
./scripts/feeds update -a
|
||||||
|
./scripts/feeds update luci || true
|
||||||
|
./scripts/feeds install -a -p luci || ./scripts/feeds install luci || true
|
||||||
|
echo "✅ feeds下载完毕"
|
||||||
|
cd package
|
||||||
|
git clone https://github.com/Dichgrem/luci-app-nyn.git
|
||||||
|
cp -r luci-app-nyn/luci-app-zzz . 2>/dev/null || true
|
||||||
|
cp -r luci-app-nyn/zzz . 2>/dev/null || true
|
||||||
|
rm -rf luci-app-nyn
|
||||||
|
|
||||||
|
- name: Build luci-app-zzz
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$SDK_ROOT"
|
||||||
|
make defconfig
|
||||||
|
echo "👉 正在编译中"
|
||||||
|
make package/luci-app-zzz/compile V=s
|
||||||
|
echo "✅ 编译完成"
|
||||||
|
|
||||||
|
- name: Collect packages
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
SDK_ROOT="$SDK_ROOT"
|
||||||
|
OUT="$GITHUB_WORKSPACE/output"
|
||||||
|
mkdir -p "$OUT"
|
||||||
|
|
||||||
|
echo "🔍 自动检测 SDK 包架构目录..."
|
||||||
|
BASE_DIR=$(find "$SDK_ROOT/bin/packages" -type d -path "*/base" | head -n1 || true)
|
||||||
|
if [ -z "$BASE_DIR" ]; then
|
||||||
|
echo "❌ 未找到 base 目录" >&2
|
||||||
|
ls -R "$SDK_ROOT/bin/packages" || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📦 从: $BASE_DIR 收集 luci-app-zzz 与 zzz 包..."
|
||||||
|
ls -lah "$BASE_DIR" || true
|
||||||
|
|
||||||
|
cp -v "$BASE_DIR"/*luci-app-zzz*.ipk "$OUT"/ 2>/dev/null || true
|
||||||
|
cp -v "$BASE_DIR"/*zzz*.ipk "$OUT"/ 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "✅ 收集完成,输出目录内容:"
|
||||||
|
ls -lah "$OUT"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload package one
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: luci-app-zzz
|
||||||
|
path: output/*luci-app-zzz*.ipk
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Upload package two
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: zzz
|
||||||
|
path: output/*zzz*.ipk
|
||||||
|
if-no-files-found: error
|
||||||
38
.github/workflows/mirror-to-codeberg.yml
vendored
Normal file
38
.github/workflows/mirror-to-codeberg.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: Mirror to Codeberg
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
mirror:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Push to Codeberg
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_CODEBERG }}
|
||||||
|
REPO_URL_CODEBERG: ${{ secrets.REPO_URL_CODEBERG }}
|
||||||
|
run: |
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
cat >> ~/.ssh/config <<EOF
|
||||||
|
Host codeberg.org
|
||||||
|
IdentityFile ~/.ssh/id_ed25519
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git config --global user.name "GitHub Actions"
|
||||||
|
git config --global user.email "github-actions@github.com"
|
||||||
|
|
||||||
|
git remote add codeberg "$REPO_URL_CODEBERG"
|
||||||
|
git push --tags --force --prune codeberg "refs/remotes/origin/*:refs/heads/*"
|
||||||
34
README.md
34
README.md
@@ -6,6 +6,17 @@
|
|||||||
<img src="https://github.com/Dichgrem/luci-app-nyn/blob/main/screenshot.png" width="400">
|
<img src="https://github.com/Dichgrem/luci-app-nyn/blob/main/screenshot.png" width="400">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
> Attention ! The nyn project is archived and it is recommended to use the c language version of zzz instead of it ! In order to commemorate nyn, the name of this project is not modified.
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
- Step 0: Make sure you have an ``openwrt router``, ``download the ipk`` in Releases in this project, and ``upload and install`` it in the system-package of the Luci background.
|
||||||
|
- Step 1:Fill in the user name: Student ID@operator. For example, ``212306666@cucc``, China Unicom is cucc, mobile is cmcc, and telecom is ctcc.
|
||||||
|
- Step 2: Fill in the password. The ``initial password`` is the last six digits of the ID card by default. It can be modified in the official client.
|
||||||
|
- Step 3: Select your network card; generally speaking, you can use ``ip addr`` to view the network card that has been assigned an IP, such as eth1.
|
||||||
|
- Step 4: ``Start the service`` and observe whether you can access the Internet, and then enable ``scheduled startup``; because the campus network will be closed from 12:00 to 7:00 the next day.
|
||||||
|
- Finally,enjoy it!
|
||||||
|
|
||||||
## How to build
|
## How to build
|
||||||
|
|
||||||
- First clone this repository to the package directory of the openwrt you want to compile:
|
- First clone this repository to the package directory of the openwrt you want to compile:
|
||||||
@@ -13,32 +24,35 @@
|
|||||||
```
|
```
|
||||||
cd ./package
|
cd ./package
|
||||||
git clone https://github.com/Dichgrem/luci-app-nyn.git
|
git clone https://github.com/Dichgrem/luci-app-nyn.git
|
||||||
|
cp -r ./luci-app-nyn/luci-app-zzz ./
|
||||||
|
cp -r ./luci-app-nyn/zzz ./
|
||||||
|
rm -rf ./luci-app-nyn
|
||||||
```
|
```
|
||||||
- Then select ``Network->nyn`` and ``LuCI->Applications->luci-app-nyn`` in make menuconfig and change them to "M" state;
|
- Then select ``Network->zzz`` and ``LuCI->Applications->luci-app-zzz`` in make menuconfig and change them to "M" state;
|
||||||
|
|
||||||
- Finally, run
|
- Finally, run
|
||||||
```
|
```
|
||||||
make package/luci-app-nyn/clean V=s
|
make package/luci-app-zzz/clean V=s
|
||||||
make package/luci-app-nyn/compile V=s
|
make package/luci-app-zzz/compile V=s
|
||||||
```
|
```
|
||||||
and
|
and
|
||||||
```
|
```
|
||||||
make package/nyn/clean V=s
|
make package/zzz/clean V=s
|
||||||
make package/nyn/compile V=s
|
make package/zzz/compile V=s
|
||||||
```
|
```
|
||||||
to start build.
|
to start build.
|
||||||
|
|
||||||
- You can use this command to find the compiled ipk:
|
- You can use this command to find the compiled ipk:
|
||||||
|
|
||||||
```
|
```
|
||||||
❯ find bin/ -name "nyn*.ipk"
|
❯ find bin/ -name "zzz*.ipk"
|
||||||
bin/packages/x86_64/base/nyn_1.0.0-r1_x86_64.ipk
|
bin/packages/x86_64/base/zzz_1.0.0-r1_x86_64.ipk
|
||||||
❯ find bin/ -name "luci-app-nyn*.ipk"
|
❯ find bin/ -name "luci-app-zzz*.ipk"
|
||||||
bin/packages/x86_64/base/luci-app-nyn_0_all.ipk
|
bin/packages/x86_64/base/luci-app-zzz_0_all.ipk
|
||||||
```
|
```
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
|
|
||||||
|
- [diredocks/zzz](https://github.com/diredocks/zzz)
|
||||||
- [diredocks/nyn](https://github.com/diredocks/nyn)
|
- [diredocks/nyn](https://github.com/diredocks/nyn)
|
||||||
- [bitdust/njit8021xclient](https://github.com/bitdust/njit8021xclient)
|
- [bitdust/njit8021xclient](https://github.com/bitdust/njit8021xclient)
|
||||||
|
|
||||||
|
|||||||
@@ -2,72 +2,71 @@
|
|||||||
module("luci.controller.zzz", package.seeall)
|
module("luci.controller.zzz", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
if not nixio.fs.access("/etc/config/zzz") then
|
if not nixio.fs.access("/etc/config/zzz") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Menu
|
-- Menu
|
||||||
entry({"admin", "network", "zzz"}, cbi("zzz"), "ZZZ", 60).dependent = false
|
entry({ "admin", "network", "zzz" }, cbi("zzz"), "ZZZ", 60).dependent = false
|
||||||
|
|
||||||
-- Settings
|
-- Settings
|
||||||
entry({"admin", "network", "zzz", "service_control"}, call("service_control")).leaf = true
|
entry({ "admin", "network", "zzz", "service_control" }, call("service_control")).leaf = true
|
||||||
|
|
||||||
-- Status API
|
-- Status API
|
||||||
entry({"admin", "network", "zzz", "get_status"}, call("act_status")).leaf = true
|
entry({ "admin", "network", "zzz", "get_status" }, call("act_status")).leaf = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function service_control()
|
function service_control()
|
||||||
local sys = require "luci.sys"
|
local sys = require("luci.sys")
|
||||||
local action = luci.http.formvalue("action")
|
local action = luci.http.formvalue("action")
|
||||||
local result = { success = false, message = "" }
|
local result = { success = false, message = "" }
|
||||||
|
|
||||||
if action then
|
if action then
|
||||||
local cmd = ""
|
local cmd = ""
|
||||||
if action == "start" then
|
if action == "start" then
|
||||||
cmd = "/etc/rc.d/S99zzz start"
|
cmd = "/etc/rc.d/S99zzz start"
|
||||||
elseif action == "stop" then
|
elseif action == "stop" then
|
||||||
cmd = "/etc/rc.d/S99zzz stop"
|
cmd = "/etc/rc.d/S99zzz stop"
|
||||||
elseif action == "restart" then
|
elseif action == "restart" then
|
||||||
cmd = "/etc/rc.d/S99zzz stop && sleep 2 && /etc/rc.d/S99zzz start"
|
cmd = "/etc/rc.d/S99zzz stop && sleep 2 && /etc/rc.d/S99zzz start"
|
||||||
end
|
end
|
||||||
|
|
||||||
if cmd ~= "" then
|
if cmd ~= "" then
|
||||||
local ret = sys.call(cmd)
|
local ret = sys.call(cmd)
|
||||||
if ret == 0 then
|
if ret == 0 then
|
||||||
result.success = true
|
result.success = true
|
||||||
result.message = action .. " 成功"
|
result.message = action .. " 成功"
|
||||||
else
|
else
|
||||||
result.success = false
|
result.success = false
|
||||||
result.message = action .. " 失败"
|
result.message = action .. " 失败"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(result)
|
luci.http.write_json(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
function act_status()
|
function act_status()
|
||||||
local sys = require "luci.sys"
|
local sys = require("luci.sys")
|
||||||
local util = require "luci.util"
|
local util = require("luci.util")
|
||||||
local status = {}
|
local status = {}
|
||||||
|
|
||||||
-- Get status
|
-- Get status
|
||||||
status.running = (sys.call("pgrep -f zzz >/dev/null") == 0)
|
status.running = (sys.call("pgrep -f zzz >/dev/null") == 0)
|
||||||
|
|
||||||
-- Get process info
|
-- Get process info
|
||||||
if status.running then
|
if status.running then
|
||||||
status.process_info = util.trim(sys.exec("ps | grep -v grep | grep zzz"))
|
status.process_info = util.trim(sys.exec("ps | grep -v grep | grep zzz"))
|
||||||
end
|
end
|
||||||
|
-- Get log
|
||||||
|
local log_file = "/tmp/zzz.log"
|
||||||
|
if nixio.fs.access(log_file) then
|
||||||
|
status.log = util.trim(sys.exec("tail -20 " .. log_file))
|
||||||
|
else
|
||||||
|
status.log = util.trim(sys.exec("logread | grep zzz | tail -10"))
|
||||||
|
end
|
||||||
|
|
||||||
-- Get log
|
luci.http.prepare_content("application/json")
|
||||||
local log_file = "/tmp/zzz.log"
|
luci.http.write_json(status)
|
||||||
if nixio.fs.access(log_file) then
|
|
||||||
status.log = util.trim(sys.exec("tail -20 " .. log_file))
|
|
||||||
else
|
|
||||||
status.log = util.trim(sys.exec("logread | grep zzz | tail -10"))
|
|
||||||
end
|
|
||||||
|
|
||||||
luci.http.prepare_content("application/json")
|
|
||||||
luci.http.write_json(status)
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- /usr/lib/lua/luci/model/cbi/zzz.lua
|
-- /usr/lib/lua/luci/model/cbi/zzz.lua
|
||||||
local m, s, o
|
local m, s, o
|
||||||
local sys = require "luci.sys"
|
local sys = require("luci.sys")
|
||||||
|
|
||||||
-- control
|
-- control
|
||||||
local start_action = luci.http.formvalue("cbid.zzz.auth.start_service")
|
local start_action = luci.http.formvalue("cbid.zzz.auth.start_service")
|
||||||
@@ -8,15 +8,14 @@ local stop_action = luci.http.formvalue("cbid.zzz.auth.stop_service")
|
|||||||
local restart_action = luci.http.formvalue("cbid.zzz.auth.restart_service")
|
local restart_action = luci.http.formvalue("cbid.zzz.auth.restart_service")
|
||||||
|
|
||||||
if start_action then
|
if start_action then
|
||||||
sys.call("/etc/rc.d/S99zzz start")
|
sys.call("/etc/rc.d/S99zzz start")
|
||||||
elseif stop_action then
|
elseif stop_action then
|
||||||
sys.call("/etc/rc.d/S99zzz stop")
|
sys.call("/etc/rc.d/S99zzz stop")
|
||||||
elseif restart_action then
|
elseif restart_action then
|
||||||
sys.call("/etc/rc.d/S99zzz stop; sleep 2; /etc/rc.d/S99zzz start")
|
sys.call("/etc/rc.d/S99zzz stop; sleep 2; /etc/rc.d/S99zzz start")
|
||||||
end
|
end
|
||||||
|
|
||||||
m = Map("zzz", "ZZZ 802.1x 认证客户端",
|
m = Map("zzz", "ZZZ 802.1x 认证客户端", "配置使用 zzz 客户端进行网络访问的 802.1x 认证")
|
||||||
"配置使用 zzz 客户端进行网络访问的 802.1x 认证")
|
|
||||||
|
|
||||||
-- Authentication Settings
|
-- Authentication Settings
|
||||||
s = m:section(TypedSection, "auth", "认证设置")
|
s = m:section(TypedSection, "auth", "认证设置")
|
||||||
@@ -27,20 +26,20 @@ s.addremove = false
|
|||||||
o = s:option(DummyValue, "_status", "当前状态")
|
o = s:option(DummyValue, "_status", "当前状态")
|
||||||
o.rawhtml = true
|
o.rawhtml = true
|
||||||
o.cfgvalue = function()
|
o.cfgvalue = function()
|
||||||
local sys = require "luci.sys"
|
local sys = require("luci.sys")
|
||||||
local running = sys.call("pgrep zzz >/dev/null") == 0
|
local running = sys.call("pgrep zzz >/dev/null") == 0
|
||||||
if running then
|
if running then
|
||||||
return "<span style='color:green;font-weight:bold'>✔ 正在运行中</span>"
|
return "<span style='color:green;font-weight:bold'>✔ 正在运行中</span>"
|
||||||
else
|
else
|
||||||
return "<span style='color:red;font-weight:bold'>✘ 未运行</span>"
|
return "<span style='color:red;font-weight:bold'>✘ 未运行</span>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- control buttons
|
-- control buttons
|
||||||
control_buttons = s:option(DummyValue, "_control", "服务控制")
|
control_buttons = s:option(DummyValue, "_control", "服务控制")
|
||||||
control_buttons.rawhtml = true
|
control_buttons.rawhtml = true
|
||||||
control_buttons.cfgvalue = function()
|
control_buttons.cfgvalue = function()
|
||||||
return [[
|
return [[
|
||||||
<div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
|
<div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
|
||||||
<input type="submit" class="cbi-button cbi-button-apply"
|
<input type="submit" class="cbi-button cbi-button-apply"
|
||||||
name="cbid.zzz.auth.start_service" value="启动服务" />
|
name="cbid.zzz.auth.start_service" value="启动服务" />
|
||||||
@@ -53,17 +52,39 @@ control_buttons.cfgvalue = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Username
|
-- Username
|
||||||
o = s:option(Value, "user", "用户名", "802.1x 认证用户名")
|
o = s:option(
|
||||||
|
Value,
|
||||||
|
"username",
|
||||||
|
"用户名",
|
||||||
|
[[802.1x 认证用户名
|
||||||
|
<span style="cursor: help; color: #007bff; font-weight: bold;" title="用户名为学号@运营商,例如212306666@cucc;移动为cmcc,联通为cucc,电信为ctcc">?</span>]]
|
||||||
|
)
|
||||||
o.password = true
|
o.password = true
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
o.rawhtml = true
|
||||||
|
|
||||||
-- Password
|
-- Password
|
||||||
o = s:option(Value, "password", "密码", "802.1x 认证密码")
|
|
||||||
o.password = true
|
o.password = true
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
o = s:option(
|
||||||
|
Value,
|
||||||
|
"password",
|
||||||
|
"密码",
|
||||||
|
[[802.1x 认证密码
|
||||||
|
<span style="cursor: help; color: #007bff; font-weight: bold;" title="密码默认为身份证号后六位,可以在官方客户端inode中修改">?</span>]]
|
||||||
|
)
|
||||||
|
o.password = true
|
||||||
|
o.rmempty = false
|
||||||
|
o.rawhtml = true
|
||||||
|
|
||||||
-- Network Device
|
-- Network Device
|
||||||
o = s:option(ListValue, "device", "网络接口", "用于认证的网络接口")
|
o = s:option(
|
||||||
|
Value,
|
||||||
|
"device",
|
||||||
|
"网络接口",
|
||||||
|
[[用于认证的网络接口
|
||||||
|
<span style="cursor: help; color: #007bff; font-weight: bold;" title="可以用ip addr命令查看,有10.38开头ip的接口">?</span>]]
|
||||||
|
)
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
o:value("eth0", "eth0")
|
o:value("eth0", "eth0")
|
||||||
o:value("eth1", "eth1")
|
o:value("eth1", "eth1")
|
||||||
@@ -72,9 +93,9 @@ o:value("wan", "WAN")
|
|||||||
-- Add network interface
|
-- Add network interface
|
||||||
local interfaces = sys.net.devices()
|
local interfaces = sys.net.devices()
|
||||||
for _, iface in ipairs(interfaces) do
|
for _, iface in ipairs(interfaces) do
|
||||||
if iface ~= "lo" then
|
if iface ~= "lo" then
|
||||||
o:value(iface, iface)
|
o:value(iface, iface)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Auto start
|
-- Auto start
|
||||||
@@ -84,34 +105,42 @@ auto_start.rmempty = false
|
|||||||
|
|
||||||
-- Get Status
|
-- Get Status
|
||||||
auto_start.cfgvalue = function(self, section)
|
auto_start.cfgvalue = function(self, section)
|
||||||
local has_cron = sys.call("crontab -l 2>/dev/null | grep 'S99zzz' >/dev/null") == 0
|
local has_cron = sys.call("crontab -l 2>/dev/null | grep 'S99zzz' >/dev/null") == 0
|
||||||
return has_cron and "1" or "0"
|
return has_cron and "1" or "0"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Crontab
|
-- Crontab
|
||||||
auto_start.write = function(self, section, value)
|
auto_start.write = function(self, section, value)
|
||||||
if value == "1" then
|
if value == "1" then
|
||||||
-- 启用定时任务:每周一至周五 7:00 启动
|
-- 启用定时任务:每周一至周五 7:00 启动
|
||||||
sys.call("(crontab -l 2>/dev/null | grep -v 'S99zzz' | grep -v '# zzz auto') | crontab - 2>/dev/null")
|
sys.call("(crontab -l 2>/dev/null | grep -v 'S99zzz' | grep -v '# zzz auto') | crontab - 2>/dev/null")
|
||||||
sys.call("(crontab -l 2>/dev/null; echo '0 7 * * 1,2,3,4,5 /etc/rc.d/S99zzz start # zzz auto start') | crontab -")
|
sys.call(
|
||||||
sys.call("/etc/init.d/cron enable && /etc/init.d/cron restart")
|
"(crontab -l 2>/dev/null; echo '0 7 * * 1,2,3,4,5 /etc/rc.d/S99zzz start # zzz auto start') | crontab -"
|
||||||
else
|
)
|
||||||
-- 禁用定时任务
|
sys.call("/etc/init.d/cron enable && /etc/init.d/cron restart")
|
||||||
sys.call("(crontab -l 2>/dev/null | grep -v 'S99zzz' | grep -v '# zzz auto') | crontab - 2>/dev/null")
|
else
|
||||||
sys.call("/etc/init.d/cron restart")
|
-- 禁用定时任务
|
||||||
end
|
sys.call("(crontab -l 2>/dev/null | grep -v 'S99zzz' | grep -v '# zzz auto') | crontab - 2>/dev/null")
|
||||||
|
sys.call("/etc/init.d/cron restart")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Crontab Status
|
-- Crontab Status
|
||||||
timer_status_display = s:option(DummyValue, "_timer_status_display", "定时任务状态")
|
timer_status_display = s:option(DummyValue, "_timer_status_display", "定时任务状态")
|
||||||
timer_status_display.rawhtml = true
|
timer_status_display.rawhtml = true
|
||||||
timer_status_display.cfgvalue = function()
|
timer_status_display.cfgvalue = function()
|
||||||
local cron_output = sys.exec("crontab -l 2>/dev/null | grep 'S99zzz' || echo '未设置'")
|
local cron_output = sys.exec("crontab -l 2>/dev/null | grep 'S99zzz' || echo '未设置'")
|
||||||
if cron_output:match("S99zzz") then
|
if cron_output:match("S99zzz") then
|
||||||
return "<span style='color:green;font-weight:bold'>✔ 已启用 (每周一至周五 7:00 自动启动)</span>"
|
return "<span style='color:green;font-weight:bold'>✔ 已启用 (每周一至周五 7:00 自动启动)</span>"
|
||||||
else
|
else
|
||||||
return "<span style='color:red;font-weight:bold'>✘ 未启用</span>"
|
return "<span style='color:red;font-weight:bold'>✘ 未启用</span>"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 保存后自动重启 zzz 服务
|
||||||
|
m.on_commit = function(self)
|
||||||
|
local sys = require("luci.sys")
|
||||||
|
sys.call("/etc/rc.d/S99zzz restart >/dev/null 2>&1 &")
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|||||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 155 KiB |
Reference in New Issue
Block a user