Have a second directory with the alternative, internal pages. On the external server keep a small file to download as a test. Write a script that uses the fetch tool to download that file from the external server, then see if it exists in the file system. If it does, just delete it and set the html-directory property of the Hotspot profile to the directory that contains the redirect to external. If it does not, set the same property to the directory for internal fallback. Schedules the script to run every five minutes.
# change these five variables as necessary
:local testURL "http://example.com/test.txt";
:local localFile "connectivity-test";
:local HTMLdirForExternal "HotspotExternal";
:local HTMLdirForInternal "HotspotInternal";
:local HotspotProfileName "Hotspot";
# remove local file just in case something broke before
/file remove [/file find name=$localFile];
# try to fetch the tester URL
tool fetch url=$testURL dst-path=$localFile;
# check if it downloaded
:if ([:len [/file find name=$localFile]] > 0) do={
/ip hotspot profile set [/ip hotspot profile find name=$HotspotProfileName] html-directory=$HTMLdirForExternal;
} else={
/ip hotspot profile set [/ip hotspot profile find name=$HotspotProfileName] html-directory=$HTMLdirForInternal;
}
That’s as far as I got (though that isn’t much, it’s fairly obvious up to that point). What that needs is the equivalent of a try/catch block around the “tool fetch” command - when confronted with a failure the script just bombs out. I remember dssmiktik posting something to that regard but I was unable to find it when I tried searching for it.
I’m posting that as incomplete because I’m going on vacation tomorrow and hopefully someone else can help you deal with the error condition and finish it. I won’t have time until the second or third week of November. Sorry.
I found a good solution to solve this issue. I leave it here if someone need it:
1.- First of all I create a folder named ‘local’ with the login file ‘login.html’
login.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<center>Main Internet Feed is Down</center>
</body>
</html>
2.- Create a new Hotspot Server Profile copying the hotspot profile I use and change the html directory:
3.- Create a netwatch to some server [I use google dns 8.8.8.8 ] If is down I change the hotspot profile to the local one and remove all active users. If is up I turn it back the the normal hotspot profile:
/tool netwatch
add comment="DNS Google - Comprobacion conectividad" disabled=no down-script="\
:local dumplist [/ip hotspot active find]\r\
\n:foreach i in=\$dumplist do={\r\
\n\t/ip hotspot active remove \$i\r\
\n}\r\
\n/ip hotspot set hotspot1 profile=hsprof_local\r\
\n" host=8.8.8.8 interval=1m timeout=1s up-script=\
"/ip hotspot set hotspot1 profile=hsprof1\r\
\n"