Skip to content

Commit

Permalink
Move all conffile to `sysuh3c'
Browse files Browse the repository at this point in the history
  • Loading branch information
LGA1150 committed Jul 9, 2018
0 parents commit c9b5dd9
Show file tree
Hide file tree
Showing 9 changed files with 874 additions and 0 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions README.md
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)
15 changes: 15 additions & 0 deletions luci-app-sysuh3c/Makefile
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
5 changes: 5 additions & 0 deletions luci-app-sysuh3c/luasrc/controller/sysuh3c.lua
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
56 changes: 56 additions & 0 deletions luci-app-sysuh3c/luasrc/model/cbi/sysuh3c.lua
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
35 changes: 35 additions & 0 deletions sysuh3c/Makefile
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)))
6 changes: 6 additions & 0 deletions sysuh3c/files/sysuh3c.config
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'

11 changes: 11 additions & 0 deletions sysuh3c/files/sysuh3c.defaults
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
43 changes: 43 additions & 0 deletions sysuh3c/files/sysuh3c.init
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
}

0 comments on commit c9b5dd9

Please sign in to comment.