Forrás

Wifi rádió tiltása adott időszakban
# Script to ensure wireless lan radio is ON or OFF #
# between user selected times #
# The radio ON/OFF operation will not be performed if the system #
# clock is not in sync with local time, unless so required #
# Remember router is set back to default time after a reboot #
# Schedule this script at required intervals #
# Written by Peter James 2012-07-19 #
# Tested on RB751U and RouterOS v5.19 #

#####################################
## Set the Radio ON and OFF times here ##
:local RadioOnTime "07:00";
:local RadioOffTime "17:00";

# set to "no" if clock is being set manually after each reboot #
# set to "yes" if clock is being set using NTP client #
:local UseNTPClientStatus "yes";
#####################################

:log info "RadioOnOff Script Starting";
# get the name of the wlan radio interface #
:local RadioName [/interface get [find type=wlan] name];
:log info "Radio Name = $RadioName";

# First check if system clock has been syncronized with local time #
:local NTPSyncState [/system ntp client get status];
:log info "NTP Client Status = $NTPSyncState";

# Don't perform radio On or Off operation, if current real time is unknown, unless required #
:if (($NTPSyncState="synchronized") or ($UseNTPClientStatus="no")) do {

:local CurrentTime [/system clock get time];
:log info "Current Time = $CurrentTime";

# Check current ON or OFF status of radio #
:local RadioDisabled [/interface get $RadioName disabled];
:log info "Radio Disabled = $RadioDisabled";


# Where the ON time is set earlier than the OFF time #
:if ($RadioOnTime < $RadioOffTime) do {

# Radio should be ON between these times #
:if (($CurrentTime > $RadioOnTime) and ($CurrentTime < $RadioOffTime)) do {

if ($RadioDisabled=true) do {
:log info "Radio was OFF, now switching ON";
/interface enable $RadioName;
}
} else {

if ($RadioDisabled=false) do {
:log info "Radio was ON, now switching OFF";
/interface disable $RadioName;
}

}

}

# Where the ON time is set later than the OFF time #
:if ($RadioOnTime > $RadioOffTime) do {

# Radio should be OFF between these times #
:if (($CurrentTime < $RadioOnTime) and ($CurrentTime > $RadioOffTime)) do {

if ($RadioDisabled=false) do {
:log info "Radio was ON, now switching OFF";
/interface disable $RadioName;
}
} else {

if ($RadioDisabled=true) do {
:log info "Radio was OFF, now switching ON";
/interface enable $RadioName;
}

}

}

 } else {

:log info "System clock may not be synchronized to local time, unable to perform operation";

}

:log info "RadioOnOff Script completed";


  • No labels