Just for sharing; a script witch is changing a hotspot user account password on a daily basis and sending an email to (for example) the reception.
Part 1:
A php scrip running on a simple webserver that generates a random character set, the password:
<?php
// http://www.yourwebserver.com/password.php
function randomPassword() {
$alphabet = "abcdefghijkmnopqrstuwxyzABCDEFGHJKLMNOPQRSTUWXYZ0123456789";
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass); //turn the array into a string
}
echo randomPassword();
?>
Part 2:
A ROS script witch sets the password for the hotspot user ‘guest’ and sends an email to the reception:
/tool fetch url=http://www.yourwebserver.com/password.php ;
:global password [/file get password.php contents] ;
/ip hotspot user set guest password=$password ;
/tool e-mail send to="reception@mycompany.com" from="Hotspot Password Changer <no-reply@mycompany.com>" \ subject="Hotspot password for $[/system clock get date]" \ body="Here do you receive the username and password for our hotspot.\nThese are valid on $[/system clock get date].\n\nUsername: guest\nPassword: $password\n\n" tls=yes ;
Put this script in the scheduler and when it runs it changing the password en sends the email out.
Dont forget to set the SMTP settings → /tool/e-mail
![]()