applications/luci-splash: make it work with uhttpd

This commit is contained in:
Jo-Philipp Wich 2010-10-28 16:58:05 +00:00
parent 6a48025d68
commit 28b5b2b637
2 changed files with 24 additions and 25 deletions

View file

@ -0,0 +1,3 @@
#!/bin/sh
echo -en "Status: 302 Moved\r\n"
echo -en "Location: http://$SERVER_ADDR/cgi-bin/luci/splash\r\n\r\n"

View file

@ -24,29 +24,29 @@ ipt_log() {
iface_add() { iface_add() {
local cfg="$1" local cfg="$1"
config_get zone "$cfg" zone config_get zone "$cfg" zone
[ -n "$zone" ] || return 0 [ -n "$zone" ] || return 0
config_get net "$cfg" network config_get net "$cfg" network
[ -n "$net" ] || return 0 [ -n "$net" ] || return 0
config_get ifname "$net" ifname config_get ifname "$net" ifname
[ -n "$ifname" ] || return 0 [ -n "$ifname" ] || return 0
config_get ipaddr "$net" ipaddr config_get ipaddr "$net" ipaddr
[ -n "$ipaddr" ] || return 0 [ -n "$ipaddr" ] || return 0
config_get netmask "$net" netmask config_get netmask "$net" netmask
[ -n "$netmask" ] || return 0 [ -n "$netmask" ] || return 0
config_get parentiface "$net" interface config_get parentiface "$net" interface
[ -n "$parentiface" ] && { [ -n "$parentiface" ] && {
config_get parentproto "$parentiface" proto config_get parentproto "$parentiface" proto
config_get parentipaddr "$parentiface" ipaddr config_get parentipaddr "$parentiface" ipaddr
config_get parentnetmask "$parentiface" netmask config_get parentnetmask "$parentiface" netmask
} }
eval "$(ipcalc.sh $ipaddr $netmask)" eval "$(ipcalc.sh $ipaddr $netmask)"
### Add interface specific chain entry rules ### Add interface specific chain entry rules
@ -67,7 +67,7 @@ iface_add() {
} }
iface_del() { iface_del() {
config_get zone "$1" zone config_get zone "$1" zone
[ -n "$zone" ] || return 0 [ -n "$zone" ] || return 0
config_get net "$1" network config_get net "$1" network
@ -92,10 +92,10 @@ mac_add() {
subnet_add() { subnet_add() {
local cfg="$1" local cfg="$1"
config_get ipaddr "$cfg" ipaddr config_get ipaddr "$cfg" ipaddr
config_get netmask "$cfg" netmask config_get netmask "$cfg" netmask
[ -n "$ipaddr" ] && { [ -n "$ipaddr" ] && {
iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN
iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN
@ -134,7 +134,7 @@ qos_iface_add() {
# set client upload speed # set client upload speed
tc filter add dev "$iface" parent ffff: protocol ip prio 1 \ tc filter add dev "$iface" parent ffff: protocol ip prio 1 \
handle 79 fw police rate ${LIMIT_UP}kbit mtu 6k burst 6k drop handle 79 fw police rate ${LIMIT_UP}kbit mtu 6k burst 6k drop
fi fi
} }
qos_iface_del() { qos_iface_del() {
@ -147,20 +147,16 @@ qos_iface_del() {
boot() { boot() {
### Setup splash-relay ### Setup splash-relay
uci get lucid.splashr 2>/dev/null || { uci get uhttpd.splash 2>/dev/null || {
uci batch <<EOF uci batch <<EOF
set lucid.splashr=daemon set uhttpd.splash=uhttpd
set lucid.splashr.slave=httpd set uhttpd.splash.home="/www/cgi-bin/splash/"
add_list lucid.splashr.address=8082 set uhttpd.splash.interpreter=".sh=/bin/ash"
add_list lucid.splashr.publisher=splashredir set uhttpd.splash.listen_http="8082"
set lucid.splashr.enabled=1 set uhttpd.splash.index_page="splash.sh"
set uhttpd.splash.error_page="/splash.sh"
set lucid.splashredir=Redirector commit uhttpd
set lucid.splashredir.name=Splashd
set lucid.splashredir.virtual='/'
set lucid.splashredir.physical=':80/luci/splash'
commit lucid
EOF EOF
} }
@ -248,7 +244,7 @@ stop() {
silent iptables -t mangle -D PREROUTING -j luci_splash_mark_out silent iptables -t mangle -D PREROUTING -j luci_splash_mark_out
silent iptables -t mangle -D POSTROUTING -j luci_splash_mark_in silent iptables -t mangle -D POSTROUTING -j luci_splash_mark_in
### Clear subchains ### Clear subchains
silent iptables -t nat -F luci_splash_prerouting silent iptables -t nat -F luci_splash_prerouting
silent iptables -t nat -F luci_splash_leases silent iptables -t nat -F luci_splash_leases
@ -256,7 +252,7 @@ stop() {
silent iptables -t filter -F luci_splash_filter silent iptables -t filter -F luci_splash_filter
silent iptables -t mangle -F luci_splash_mark_out silent iptables -t mangle -F luci_splash_mark_out
silent iptables -t mangle -F luci_splash_mark_in silent iptables -t mangle -F luci_splash_mark_in
### Delete subchains ### Delete subchains
silent iptables -t nat -X luci_splash_prerouting silent iptables -t nat -X luci_splash_prerouting
silent iptables -t nat -X luci_splash_leases silent iptables -t nat -X luci_splash_leases
@ -264,7 +260,7 @@ stop() {
silent iptables -t filter -X luci_splash_filter silent iptables -t filter -X luci_splash_filter
silent iptables -t mangle -X luci_splash_mark_out silent iptables -t mangle -X luci_splash_mark_out
silent iptables -t mangle -X luci_splash_mark_in silent iptables -t mangle -X luci_splash_mark_in
sed -ie '/\/usr\/sbin\/luci-splash sync/d' /var/spool/cron/crontabs/root sed -ie '/\/usr\/sbin\/luci-splash sync/d' /var/spool/cron/crontabs/root
lock -u $LOCK lock -u $LOCK