访脚本的主要功能是,wifi、hot-users、cap、vpn-users 等用户名及密码根据路由日期自动更改

方法如下;
1、在/System Script下添加如下脚本内容;

# months array
:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");

# get time
#:local ts [/system clock get time]
#:set ts ([:pick $ts 0 2].[:pick $ts 3 5])

# get date
:local ds [/system clock get date]

# convert name of month to number
:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set mm ("0" . $mm); }

# set $ds to format YYYY-MM-DD
:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6])

#remove pptp-server name 201*****
/inter pptp-server remove [/inte pptp-server find name~"201"]
#view pptp-server name 201*****
#:put [/inte pptp-server find name~"201"]

#remove l2tp-server name 201*****
/inter l2tp-server remove [/inte l2tp-server find name~"201"]
#view l2tp-server name 201*****
#:put [/inte l2tp-server find name~"201"]

# set wireless default password
#/inter wir secur set [/inter wireless secur find name="default"] wpa2=$ds
# view wireless default password
#:put [/inter wir secur get [/inter wireless secur find name="default"] wpa2]

# set hotspot user comment="dateuser" name&password
/ip hot user set [/ip hot user find comment="dateuser"] name=$ds
/ip hot user set [/ip hot user find comment="dateuser"] password=$ds
# view hotspot user comment="dateuser" name&password
#:put [/ip hot user get [/ip hot user find comment="dateuser"] name]
#:put [/ip hot user get [/ip hot user find comment="dateuser"] password]

# set capsman security1 password
#/cap security set  [/cap security find name="security1"] passphrase=$ds
# view capsman security1 password
#:put [/cap security get [/cap security find name="security1"] passphrase]

# set vpn users comment="dateuser" name&password
/ppp secre set [/ppp secre find comment="dateuser"] name=$ds
/ppp secre set [/ppp secre find comment="dateuser"] password=$ds
# view vpn users comment="dateuser" name&password
#:put [/ppp secre get [/ppp secre find comment="dateuser"] name]
#:put [/ppp secre get [/ppp secre find comment="dateuser"] password]

脚本名称命名为DateUser

2、在/System Scheduler下添加一个脚本定时,名称为DateUser,内容为DateUser,执行时间为24小时(时间可自定义)

注;根据自己需要的功能进行注释或启用

下面这段命令是半自动的,修改好相关参数,直接在WinBox的New Terminal下粘入如下命令即可

/system script
add name=DateUser owner=admin policy=
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source="# month
    s arrayr
    n:local months ("jan","feb","mar","apr","may","jun","jul",
    "aug","sep","oct","nov","dec");r
    nr
    n# get timer
    n#:local ts [/system clock get time]r
    n#:set ts ([:pick $ts 0 2].[:pick $ts 3 5])r
    nr
    n# get dater
    n:local ds [/system clock get date]r
    nr
    n# convert name of month to numberr
    n:local month [ :pick $ds 0 3 ];r
    n:local mm ([ :find $months $month -1 ] + 1);r
    n:if ($mm < 10) do={ :set mm ("0" . $mm); }r
    nr
    n# set $ds to format YYYY-MM-DDr
    n:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6])r
    nr
    n#remove pptp-server name 201*****r
    n/inter pptp-server remove [/inte pptp-server find name~"201"]r
    n#view pptp-server name 201*****r
    n#:put [/inte pptp-server find name~"201"]r
    nr
    n#remove l2tp-server name 201*****r
    n/inter l2tp-server remove [/inte l2tp-server find name~"201"]r
    n#view l2tp-server name 201*****r
    n#:put [/inte l2tp-server find name~"201"]r
    nr
    n# set wireless default passwordr
    n#/inter wir secur set [/inter wireless secur find name="default"] wpa2
    =$dsr
    n# view wireless default passwordr
    n#:put [/inter wir secur get [/inter wireless secur find name="default"
    ] wpa2]r
    nr
    n# set hotspot user comment="dateuser" name&passwordr
    n/ip hot user set [/ip hot user find comment="dateuser"] name=$dsr
    n/ip hot user set [/ip hot user find comment="dateuser"] password=$ds
    r
    n# view hotspot user comment="dateuser" name&passwordr
    n#:put [/ip hot user get [/ip hot user find comment="dateuser"] name]r
    n#:put [/ip hot user get [/ip hot user find comment="dateuser"] passwor
    d]r
    nr
    n# set capsman security1 passwordr
    n#/cap security set  [/cap security find name="security1"] passphrase=
    $dsr
    n# view capsman security1 passwordr
    n#:put [/cap security get [/cap security find name="security1"] passphr
    ase]r
    nr
    n# set vpn users comment="dateuser" name&passwordr
    n/ppp secre set [/ppp secre find comment="dateuser"] name=$dsr
    n/ppp secre set [/ppp secre find comment="dateuser"] password=$dsr
    n# view vpn users comment="dateuser" name&passwordr
    n#:put [/ppp secre get [/ppp secre find comment="dateuser"] name]r
    n#:put [/ppp secre get [/ppp secre find comment="dateuser"] password]"

/system scheduler
add interval=1d name=DateUser on-event=DateUser policy=
    ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=
    jan/20/2016 start-time=00:00:00

发表回复

后才能评论