Support openwrt
This commit is contained in:
8
package/luci/control/control
Normal file
8
package/luci/control/control
Normal file
@@ -0,0 +1,8 @@
|
||||
Package: luci-app-smartdns
|
||||
Version: git-18.201.27126-7bf0367-1
|
||||
Depends: libc, smartdns
|
||||
Source: feeds/luci/applications/luci-app-smartdns
|
||||
Section: luci
|
||||
Architecture: all
|
||||
Installed-Size: 1040
|
||||
Description: A smartdns server module
|
||||
5
package/luci/control/postinst
Normal file
5
package/luci/control/postinst
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0
|
||||
[ -x ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
default_postinst $0 $@
|
||||
4
package/luci/control/postinst-pkg
Normal file
4
package/luci/control/postinst-pkg
Normal file
@@ -0,0 +1,4 @@
|
||||
[ -n "${IPKG_INSTROOT}" ] || {
|
||||
(. /etc/uci-defaults/50_luci-smartdns) && rm -f /etc/uci-defaults/50_luci-smartdns
|
||||
exit 0
|
||||
}
|
||||
4
package/luci/control/prerm
Normal file
4
package/luci/control/prerm
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
[ -x ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
default_prerm $0 $@
|
||||
1
package/luci/debian-binary
Normal file
1
package/luci/debian-binary
Normal file
@@ -0,0 +1 @@
|
||||
2.0
|
||||
11
package/luci/files/etc/uci-defaults/50_luci-smartdns
Normal file
11
package/luci/files/etc/uci-defaults/50_luci-smartdns
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@smartdns[-1]
|
||||
add ucitrack smartdns
|
||||
set ucitrack.@smartdns[-1].init=smartdns
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
14
package/luci/files/luci/controller/smartdns.lua
Normal file
14
package/luci/files/luci/controller/smartdns.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- Copyright 2018 Nick Peng (pymumu@gmail.com)
|
||||
|
||||
module("luci.controller.smartdns", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/smartdns") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
|
||||
page = entry({"admin", "services", "smartdns"}, cbi("smartdns"), _("SmartDNS"), 60)
|
||||
page.dependent = true
|
||||
end
|
||||
120
package/luci/files/luci/model/cbi/smartdns.lua
Normal file
120
package/luci/files/luci/model/cbi/smartdns.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
-- Copyright 2018 Nick Peng (pymumu@gmail.com)
|
||||
|
||||
require("nixio.fs")
|
||||
require("luci.http")
|
||||
|
||||
m = Map("smartdns", translate("SmartDNS"),
|
||||
translate("SmartDNS is a local dns server to find fastest ip."))
|
||||
|
||||
if luci.sys.call("pidof smartdns >/dev/null") == 0 then
|
||||
m = Map("smartdns", translate("SmartDNS"), "%s - %s" %{translate("SmartDNS"), translate("RUNNING")})
|
||||
else
|
||||
m = Map("smartdns", translate("SmartDNS"), "%s - %s" %{translate("SmartDNS"), translate("NOT RUNNING")})
|
||||
end
|
||||
|
||||
-- Basic
|
||||
s = m:section(TypedSection, "smartdns", translate("SmartDNS Server"))
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("settings", translate("Settings"))
|
||||
s:tab("help", translate("Technical Support"))
|
||||
|
||||
---- Eanble
|
||||
o = s:taboption("settings", Flag, "enabled", translate("Enable"), translate("Enable or disable smartdns server"))
|
||||
o.rempty = false
|
||||
|
||||
---- Port
|
||||
o = s:taboption("settings", Value, "port", translate("Local Port"), translate("Smartdns local server port"))
|
||||
o.placeholder = 5353
|
||||
o.default = 5353
|
||||
o.datatype = "port"
|
||||
o.rempty = false
|
||||
|
||||
o = s:taboption("settings", Flag, "redirect", translate("redirect"), translate("redirect standard dns query from 53 to smartdns"))
|
||||
o.default = true
|
||||
o.rempty = false
|
||||
|
||||
---- cache-size
|
||||
o = s:taboption("settings", Value, "cache_size", translate("Cache Size"), translate("DNS domain result cache size"))
|
||||
o.rempty = true
|
||||
|
||||
---- rr-ttl
|
||||
o = s:taboption("settings", Value, "rr_ttl", translate("Domain TTL"), translate("TTL for all domain result."))
|
||||
o.rempty = true
|
||||
|
||||
---- rr-ttl-min
|
||||
o = s:taboption("settings", Value, "rr_ttl_min", translate("Domain TTL Min"), translate("Minimum TTL for all domain result."))
|
||||
o.rempty = true
|
||||
|
||||
---- rr-ttl-max
|
||||
o = s:taboption("settings", Value, "rr_ttl_min", translate("Domain TTL Max"), translate("Maximum TTL for all domain result."))
|
||||
o.rempty = true
|
||||
|
||||
o = s:taboption("help", Button, "web")
|
||||
o.title = translate("SmartDNS official website")
|
||||
o.inputtitle = translate("open website")
|
||||
o.inputstyle = "apply"
|
||||
o.write = function()
|
||||
luci.http.redirect("https://pymumu.github.io/")
|
||||
end
|
||||
|
||||
o = s:taboption("help", Button, "Donate")
|
||||
o.title = translate("Donate to smartdns")
|
||||
o.inputtitle = translate("Donate")
|
||||
o.inputstyle = "apply"
|
||||
o.write = function()
|
||||
luci.http.redirect("https://pymumu.github.io/smartdns")
|
||||
end
|
||||
|
||||
-- Upstream servers
|
||||
s = m:section(TypedSection, "server", translate("Upstream Servers"), translate("Upstream Servers, support UDP, TCP protocol"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
---- name
|
||||
s:option(Value, "name", translate("Name"), translate("DNS Server name"))
|
||||
---- IP address
|
||||
o = s:option(Value, "ip", translate("ip"), translate("DNS Server ip"))
|
||||
o.datatype = "ipaddr"
|
||||
o.rmempty = false
|
||||
---- port
|
||||
o = s:option(Value, "port", translate("port"), translate("DNS Server port"))
|
||||
o.placeholder = 53
|
||||
o.default = 53
|
||||
o.datatype = "port"
|
||||
o.rempty = false
|
||||
---- type
|
||||
o = s:option(ListValue, "type", translate("type"), translate("DNS Server type"))
|
||||
o.placeholder = "udp"
|
||||
o:value("udp", translate("udp"))
|
||||
o:value("tcp", translate("tcp"))
|
||||
o.default = "udp"
|
||||
o.rempty = false
|
||||
|
||||
-- Doman addresss
|
||||
s = m:section(TypedSection, "smartdns", translate("Domain Address"),
|
||||
translate("DNS Server name"))
|
||||
s.anonymous = true
|
||||
|
||||
---- address
|
||||
addr = s:option(Value, "address",
|
||||
translate(""),
|
||||
translate("Specify an IP address to return for any host in the given domains " ..
|
||||
"Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6. " ..
|
||||
""))
|
||||
|
||||
addr.template = "cbi/tvalue"
|
||||
addr.rows = 20
|
||||
|
||||
function addr.cfgvalue(self, section)
|
||||
return nixio.fs.readfile("/etc/smartdns/address.conf")
|
||||
end
|
||||
|
||||
function addr.write(self, section, value)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
nixio.fs.writefile("/etc/smartdns/address.conf", value)
|
||||
end
|
||||
|
||||
return m
|
||||
|
||||
88
package/luci/make.sh
Normal file
88
package/luci/make.sh
Normal file
@@ -0,0 +1,88 @@
|
||||
#/bin/sh
|
||||
|
||||
CURR_DIR=$(cd $(dirname $0);pwd)
|
||||
|
||||
VER="`date +"1.%Y.%m.%d-%H%M"`"
|
||||
SMARTDNS_DIR=$CURR_DIR/../../
|
||||
|
||||
showhelp()
|
||||
{
|
||||
echo "Usage: make [OPTION]"
|
||||
echo "Options:"
|
||||
echo " -o output directory."
|
||||
echo " --arch archtecture."
|
||||
echo " --ver version."
|
||||
echo " -h show this message."
|
||||
}
|
||||
|
||||
build()
|
||||
{
|
||||
ROOT=/tmp/luci-app-smartdns
|
||||
rm -fr $ROOT
|
||||
|
||||
mkdir -p $ROOT
|
||||
cp $CURR_DIR/* $ROOT/ -af
|
||||
cd $ROOT/
|
||||
mkdir $ROOT/root/usr/lib/lua/ -p
|
||||
cp $ROOT/files/luci $ROOT/root/usr/lib/lua/ -af
|
||||
cp $ROOT/files/etc $ROOT/root/ -af
|
||||
|
||||
sed -i "s/^Architecture.*/Architecture: $ARCH/g" $ROOT/control/control
|
||||
sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control
|
||||
|
||||
cd $ROOT/control
|
||||
chmod +x *
|
||||
tar zcf ../control.tar.gz ./
|
||||
cd $ROOT
|
||||
|
||||
tar zcf $ROOT/data.tar.gz -C root .
|
||||
tar zcf $OUTPUTDIR/luci-app-smartdns.$VER.$ARCH.ipk control.tar.gz data.tar.gz debian-binary
|
||||
rm -fr $ROOT/
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
OPTS=`getopt -o o:h --long arch:,ver: \
|
||||
-n "" -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "$OPTS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--arch)
|
||||
ARCH="$2"
|
||||
shift 2;;
|
||||
--ver)
|
||||
VER="$2"
|
||||
shift 2;;
|
||||
-o )
|
||||
OUTPUTDIR="$2"
|
||||
shift 2;;
|
||||
-h | --help )
|
||||
showhelp
|
||||
return 0
|
||||
shift ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARCH" ]; then
|
||||
echo "please input arch."
|
||||
return 1;
|
||||
fi
|
||||
|
||||
if [ -z "$OUTPUTDIR" ]; then
|
||||
OUTPUTDIR=$CURR_DIR;
|
||||
fi
|
||||
|
||||
build
|
||||
}
|
||||
|
||||
main $@
|
||||
exit $?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user