-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c9b5dd9
Showing
9 changed files
with
874 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Brief | ||
--- | ||
OpenWrt feeds and LuCI UI for [H3C 802.1X client](https://github.com/haswelliris/h3c) | ||
|
||
Compile | ||
--- | ||
|
||
Compile with OpenWrt SDK | ||
|
||
```bash | ||
# Download OpenWrt SDK for your current platform architecture, such as ar71xx | ||
tar xjf OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2 | ||
cd OpenWrt-SDK-ar71xx-* | ||
# Clone this repo | ||
git clone https://github.com/LGA1150/openwrt-sysuh3c.git package/openwrt-sysuh3c | ||
# Select LuCI -> Applications -> luci-app-sysuh3c | ||
make menuconfig | ||
# Compile | ||
make package/luci-app-sysuh3c/compile V=s | ||
``` | ||
|
||
Install | ||
--- | ||
One can locate the compiled ipk files at `bin/packages/<architecture>/base` | ||
Upload `sysuh3c-<ver>.ipk` and `luci-app-sysuh3c-<ver>.ipk` to your router's /tmp folder, then install via opkg | ||
|
||
Download prebuilt ipks | ||
--- | ||
See [releases](https://github.com/LGA1150/openwrt-sysuh3c/releases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
LUCI_TITLE:=SYSU H3C 802.1X Client for LuCI | ||
LUCI_DEPENDS:=+sysuh3c | ||
LUCI_DESCRIPTION:=This package contains LuCI configuration pages for SYSU H3C. | ||
LUCI_PKGARCH:=all | ||
PKG_VERSION:=1.0 | ||
PKG_RELEASE:=3 | ||
PKG_LICENSE:=GPL-3.0 | ||
PKG_LICENSE_FILES:=LICENSE | ||
|
||
include $(TOPDIR)/feeds/luci/luci.mk | ||
|
||
# call BuildPackage - OpenWrt buildroot signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module("luci.controller.sysuh3c", package.seeall) | ||
|
||
function index() | ||
entry({"admin", "network", "sysuh3c"}, cbi("sysuh3c"), _("SYSU H3C Client"), 100) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--[[ | ||
LuCI - Lua Configuration Interface | ||
Copyright 2010 Jo-Philipp Wich <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
]]-- | ||
|
||
local sys = require "luci.sys" | ||
local nixio = require "nixio" | ||
|
||
m = Map("sysuh3c", translate("SYSU H3C Client"), translate("Configure H3C 802.1x client.")) | ||
|
||
s = m:section(TypedSection, "login", "") | ||
s.addremove = true | ||
s.anonymous = true | ||
|
||
enable = s:option(Flag, "enable", translate("Enable")) | ||
blockstartup = s:option(Flag, "blockstartup", translate("Block Startup Sequence"), | ||
"If enabled, the client will block startup sequence until authenticated") | ||
name = s:option(Value, "username", translate("Username")) | ||
pass = s:option(Value, "password", translate("Password")) | ||
pass.password = true | ||
|
||
method = s:option(ListValue, "method", translate("EAP Method")) | ||
method:value("xor") | ||
method:value("md5") | ||
|
||
ifname = s:option(ListValue, "ifname", translate("Interface")) | ||
for k, v in ipairs(nixio.getifaddrs()) do | ||
if v.flags["up"] and not v.flags["noarp"] and not v.flags["loopback"] then | ||
ifname:value(v.name) | ||
end | ||
end | ||
|
||
--[[ | ||
getwanif = s:option(Button, "_getwanif", translate("Get WAN interface")) | ||
getwanif.inputstyle = "apply" | ||
getwanif.write = function(self, section) | ||
local ifname = sys.exec("uci get network.wan.ifname") | ||
if ifname ~= nil then | ||
self.map:set(section, "ifname", ifname) | ||
end | ||
end | ||
]]-- | ||
--[[ | ||
local apply = luci.http.formvalue("cbi.apply") | ||
if apply then | ||
io.popen("/etc/init.d/sysuh3c restart") | ||
end | ||
]]-- | ||
return m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=sysuh3c | ||
PKG_VERSION:=1.0 | ||
PKG_RELEASE:=1 | ||
|
||
PKG_SOURCE_PROTO:=git | ||
PKG_SOURCE_URL:=https://github.com/haswelliris/h3c.git | ||
PKG_SOURCE_VERSION:=fdf66c3 | ||
|
||
PKG_LICENSE:=GPL-3.0 | ||
PKG_LICENSE_FILES:=LICENSE | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/$(PKG_NAME) | ||
SECTION:=net | ||
CATEGORY:=Network | ||
TITLE:=H3C client | ||
endef | ||
|
||
define Build/Configure | ||
$(call Build/Configure/Default) | ||
endef | ||
|
||
define Package/$(PKG_NAME)/install | ||
$(INSTALL_DIR) $(1)/usr/sbin | ||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/h3c $(1)/usr/sbin/sysuh3c | ||
$(INSTALL_DIR) $(1)/etc/config | ||
$(INSTALL_CONF) ./files/sysuh3c.config $(1)/etc/config/sysuh3c | ||
$(INSTALL_DIR) $(1)/etc/init.d | ||
$(INSTALL_BIN) ./files/sysuh3c.init $(1)/etc/init.d/sysuh3c | ||
endef | ||
|
||
$(eval $(call BuildPackage,$(PKG_NAME))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
config login | ||
option blockstartup '1' | ||
option enable '0' | ||
option method 'xor' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
uci -q batch <<-EOF >/dev/null | ||
delete ucitrack.@sysuh3c[-1] | ||
add ucitrack sysuh3c | ||
set ucitrack.@sysuh3c[-1].init=sysuh3c | ||
commit ucitrack | ||
EOF | ||
|
||
rm -f /tmp/luci-indexcache | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh /etc/rc.common | ||
START=70 | ||
|
||
run_h3c() | ||
{ | ||
local enable | ||
config_get_bool enable $1 enable | ||
|
||
if [ "$enable" == 1 ]; then | ||
local username | ||
local password | ||
local method | ||
local ifname | ||
local blockstartup | ||
|
||
config_get username $1 username | ||
config_get password $1 password | ||
config_get method $1 method | ||
config_get ifname $1 ifname | ||
config_get_bool blockstartup $1 blockstartup | ||
|
||
if [ "$blockstartup" == 1 ]; then | ||
while ! sysuh3c -u $username -p $password -i $ifname -m $method ; do | ||
echo sysuh3c: process exited unexpectedly, restarting.. | ||
sleep 1 | ||
done | ||
else | ||
sleep 5 | ||
sysuh3c -u $username -p $password -i $ifname -m $method & | ||
fi | ||
fi | ||
} | ||
|
||
start() | ||
{ | ||
config_load sysuh3c | ||
config_foreach run_h3c login | ||
} | ||
|
||
stop() | ||
{ | ||
killall sysuh3c >/dev/null 2>&1 | ||
} |