mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-06-25 23:48:36 +02:00
Re-arrange scripts
This commit is contained in:
parent
d9e962b537
commit
732a3adc66
3 changed files with 0 additions and 0 deletions
20
ap-scripts/wifi-button.rsc
Normal file
20
ap-scripts/wifi-button.rsc
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Ref: https://gist.github.com/sebastian13/47e788371474d73552593b621eeacd33
|
||||
|
||||
:log info message=("mode button was pressed");
|
||||
:local i
|
||||
|
||||
:if ( [/int wir get 0 disabled ] = true ) do={
|
||||
:foreach i in= [ /int wir find ] do={ :int wir enable $i };
|
||||
} else={
|
||||
:foreach i in= [ /int wir find ] do={ :int wir disable $i };
|
||||
}
|
||||
|
||||
# Wifi disable
|
||||
# :if ( [/int wir get 0 disabled ] = true ) do={} else={
|
||||
# :foreach i in= [ /int wir find ] do={ :int wir disable $i };
|
||||
# }
|
||||
|
||||
# Wifi enable
|
||||
# :if ( [/int wir get 0 disabled ] = true ) do={
|
||||
# :foreach i in= [ /int wir find ] do={ :int wir enable $i };
|
||||
# }
|
11
ap-scripts/wifi-disable.rsc
Normal file
11
ap-scripts/wifi-disable.rsc
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Disable WiFi interfaces at night via scheduler (cron).
|
||||
|
||||
# To avoid being locked out, make sure to run a script to enable wifi interfaces when you wake up.
|
||||
# Also, put the wifi-enabler script in a button of your choice. Mode button or reset button. Mode button is recommended.
|
||||
# See below...
|
||||
|
||||
/system scheduler
|
||||
add comment="Shutdown WiFi @night to avoid electronic interference!" interval=1d name="WiFi Disable" on-event=\
|
||||
"/int wifiwave2 disable [find]; /int wireless disable [find];" policy=ftp,reboot,read,write,policy,test start-date=mar/05/2022 start-time=00:04:00
|
||||
|
||||
# /system routerboard mode-button set enabled=yes on-event=":log info \"Mode button pressed\"; /int wifiwave2 enable [find]; /int wireless enable [find];"
|
39
ap-scripts/wifi-enable.rsc
Normal file
39
ap-scripts/wifi-enable.rsc
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Enable WiFi in the morning
|
||||
|
||||
# using mode button
|
||||
# /system routerboard mode-button set enabled=yes on-event=":log info \"Mode button pressed\"; /int wifiwave2 enable [find]; /int wireless enable [find];"
|
||||
|
||||
# as a cron event
|
||||
# /system scheduler
|
||||
# add comment="Enable WiFi @morning" interval=1d name="WiFi Enable" on-event="/int wifiwave2 enable [find]; /int wireless enable [find];" \
|
||||
# policy=read,write,policy,test start-date=jan/03/2022 start-time=05:30:00
|
||||
|
||||
# as a script to be used
|
||||
|
||||
# Enable wireless / wifiwav2 interfaces if disabled.
|
||||
|
||||
:local interfaces
|
||||
:local interface
|
||||
|
||||
/interface
|
||||
# :do { wifiwave2 enable [find]; } on-error={ :log info "Error enabling wifiwave2 interfaces" }
|
||||
:do {
|
||||
:set interfaces [wireless print as-value]
|
||||
|
||||
} on-error={
|
||||
|
||||
:log info "Wireless doesn't exist!";
|
||||
|
||||
:do {
|
||||
:set interfaces [wifiwave2 print as-value]
|
||||
} on-error={ :error "Wifiwave2 doesn't exist"; }
|
||||
|
||||
}
|
||||
|
||||
:foreach interface in=$interfaces do={
|
||||
:local wifiName ($interface->"name")
|
||||
:if ( [get $wifiName disabled] = true ) do={
|
||||
enable $wifiName
|
||||
:log info "$wifiName is enabled";
|
||||
} else={ :log info "$wifiName is already running" }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue