76f6d4d3e41e240b4b9bb4df8cc05e3790c839f0
[project/luci.git] / applications / luci-app-splash / htdocs / cgi-bin / splash / splash.sh
1 #!/bin/sh
2
3 $(uci -q get luci_splash.general.redirect_url) || {
4         set -x
5         touch /var/state/luci_splash_locations
6         touch /etc/config/luci_splash_locations
7         MAC=$(grep "$REMOTE_HOST" /proc/net/arp | awk '{print $4}')
8         uci -P /var/state set luci_splash_locations.${MAC//:/}=redirect
9         uci -P /var/state set luci_splash_locations.${MAC//:/}.location="http://${HTTP_HOST}${REQUEST_URI}"
10         set +x
11 }
12
13 echo -en "Cache-Control: no-cache, max-age=0, no-store, must-revalidate\r\n"
14 echo -en "Pragma: no-cache\r\n"
15 echo -en "Expires: -1\r\n"
16 echo -en "Status: 307 Temporary Redirect\r\n"
17 echo -en "Location: http://$SERVER_ADDR/cgi-bin/luci/splash\r\n" 
18 echo -en "\r\n"
19
20 cat <<EOT
21 <?xml version="1.0" encoding="UTF-8"?>
22 <WISPAccessGatewayParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.wballiance.net/wispr_2_0.xsd">
23         <Redirect>
24                 <MessageType>100</MessageType>
25                 <ResponseCode>0</ResponseCode>
26                 <AccessProcedure>1.0</AccessProcedure>
27                 <AccessLocation>12</AccessLocation>
28                 <LocationName>$SERVER_ADDR</LocationName>
29                 <LoginURL>http://$SERVER_ADDR/cgi-bin/luci/splash?wispr=1</LoginURL>
30                 <AbortLoginURL>http://$SERVER_ADDR/</AbortLoginURL>
31         </Redirect>
32 </WISPAccessGatewayParam>
33 EOT
34
35