Script to change login background .jpg daily

Can anyone help me? I have no idea how I would do this via a script.

I’m trying to write a script to daily change my login page background.

The idea was to keep 30 small jpg files in \hotspot\img\background\ - The file names would be 1.jpg, 2.jpg - all the way to 30.jpg

Currently my hotspot login uses the file \hotspot\img\background.jpg as the background.

I would need a script that would copy \hotspot\img\background\1.jpg to \hotspot\img\background.jpg at a set time (maybe 5am) each day, but on the next day copy 2.jpg, next day 3.jpg, etc.

Could any point me in the right direction?

Cheers,
Cinders.

can’t you just create 3 directories with different login pages, and use the script to change “hotspot directory” parameter in the hotspot server settings?

Surely it would be easier just to change a single background image file each day?

it would not be, as routeros doesn’t have file operation functions, like rename.

Ah OK. :smiley:

Thanks for the info. I’ll start working on it. :smiley:

If you download the image from a server using “/tool fetch”, you can rename the file enroute.

/tool fetch mode=http address=1.2.3.4 src-path=background2.gif dst-path=/hotspot/img/background.gif

edit: Oops! Forgot to add the mode parameter.

Tim,

That’s a great idea!

Because the hotspot runs at http server, is it possible to download it from itself? i.e. 127.0.0.1 ?

That I have not tried, but an interesting concept. Give it a shot and see how it does. Let me know! :smiley:

No worries - I’ll drop an update on this thread, thanks again for the great idea! :smiley:

Tim,

Unfortunately it wouldn’t work with the image files in the hotspot folder and trying to grab them from local host.

No problem, I put them on my Radius server and it works perfectly! Thanks again for the idea. :slight_smile:

All the best,
Cinders.

Try using javascript on the page you wish to change background on.

You can easily modify this to your needs :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title></title>
</head>

<body>
<script  type="text/javascript">
/*<![CDATA[*/
var ToDay=new Date();
var Month=ToDay.getMonth();
var Date=ToDay.getDate();
var Image=false;

if (ToDay.getFullYear()==2010){
 if (Month==0){  // January
  if (Date>=20&&Date<=30){
   Image='One.gif';
  }
 }
 if (Month==1){  // Febuary
  if (Date>=20&&Date<=25){
   Image='Three.gif';
  }
 }

}

if (Image){
 document.body.style.backgroundImage='url(http://192.168.88.1/img/'+Image+')';
}

/*]]>*/
</script>
</body>

</html>

Many thanks for the script above. :smiley: