26 | | 5 name="http_get_5" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
27 | | dont-require-permissions=no last-started=feb/27/2021 00:36:10 run-count=10 source= |
| 26 | [admin@G02] /system script> print |
| 27 | Flags: I - invalid |
| 28 | 0 name="http_getvpn" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
| 29 | dont-require-permissions=no last-started=mar/02/2021 17:06:04 run-count=20 source= |
29 | | :local serialnum [/system routerboard get serial-number]; |
30 | | :put $serialnum; |
31 | | :local result [/tool fetch url="http://192.168.5.1/~krit/Tmp/$serialnum/out2.txt" as-value output=user]; |
32 | | :put $result; |
33 | | :local msg ($result->"data"); |
34 | | :put "---msg---"; |
35 | | :put $msg; |
36 | | :put "---msg 3 --"; |
37 | | :local myArray [:toarray [:pick $msg ([:find $msg ":"]) [:len $msg]]]; |
38 | | :local ipaddr [:pick $myArray 0]; |
39 | | :local uname [:pick $myArray 1]; |
40 | | :local passwd [:pick $myArray 2]; |
41 | | :local conn [:pick $myArray 3]; |
42 | | :put "ip: $ipaddr"; |
43 | | :put "user: $uname"; |
44 | | :put "passwd: $passwd"; |
45 | | :put "connect: $conn"; |
46 | | :put "------------"; |
47 | | :local serialnum [/system routerboard get serial-number]; |
48 | | :put $serialnum; |
49 | | :if ($result->"status" = "finished") do={ |
50 | | :if ( $conn = "0" ) do={ |
51 | | :log info "value is $conn disable l2tp-out1 for user $uname"; |
52 | | :put "value is $conn disable l2tp-out1 for user $uname"; |
53 | | /interface l2tp-client disable l2tp-out1; |
54 | | } else={ |
55 | | :put "edit user: $uname in l2tp"; |
56 | | :log info "edit user: $uname in l2tp"; |
57 | | /interface l2tp-client set connect-to=$ipaddr l2tp-out1; |
58 | | /interface l2tp-client set user=$uname l2tp-out1; |
59 | | /interface l2tp-client set password=$passwd l2tp-out1; |
60 | | /interface l2tp-client enable l2tp-out1; |
61 | | } |
62 | | } |
| 31 | :local serialnum [/system routerboard get serial-number]; |
| 32 | :put $serialnum; |
| 33 | :local result [/tool fetch url="http://trueiot.io/~pong/SF19/G02/cmd.txt" as-value output=user]; |
| 34 | :put $result; |
| 35 | :local msg ($result->"data"); |
| 36 | :put "---msg---"; |
| 37 | :put $msg; |
| 38 | :put "---msg 3 --"; |
| 39 | :local myArray [:toarray [:pick $msg ([:find $msg ":"]) [:len $msg]]]; |
| 40 | :local ipaddr [:pick $myArray 0]; |
| 41 | :local uname [:pick $myArray 1]; |
| 42 | :local passwd [:pick $myArray 2]; |
| 43 | :local conn [:pick $myArray 3]; |
| 44 | :put "ip: $ipaddr"; |
| 45 | :put "user: $uname"; |
| 46 | :put "passwd: $passwd"; |
| 47 | :put "connect: $conn"; |
| 48 | :put "------------"; |
| 49 | :local serialnum [/system routerboard get serial-number]; |
| 50 | :put $serialnum; |
| 51 | :if ($result->"status" = "finished") do={ |
| 52 | :if ( $conn = "0" ) do={ |
| 53 | :log info "value is $conn disable l2tp-out1 for user $uname"; |
| 54 | :put "value is $conn disable l2tp-out1 for user $uname"; |
| 55 | /interface l2tp-client disable l2tp-out1; |
| 56 | } else={ |
| 57 | :if ( [/ping 10.50.30.254 count=3 size=64 interval=2s]=0 ) do={ |
| 58 | :log error "----VPN didn't connect"; |
| 59 | :put "edit user: $uname in l2tp"; |
| 60 | :log info "edit user: $uname in l2tp"; |
| 61 | /interface l2tp-client set connect-to=$ipaddr l2tp-out1; |
| 62 | /interface l2tp-client set user=$uname l2tp-out1; |
| 63 | /interface l2tp-client set password=$passwd l2tp-out1; |
| 64 | /interface l2tp-client enable l2tp-out1; |
| 65 | } else={ |
| 66 | :log info "----VPN already connect"; |
| 67 | } |
| 68 | } |
| 69 | } |
| 71 | |
| 72 | 1 name="script_reboot" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
| 73 | dont-require-permissions=no run-count=0 source= |
| 74 | :if ([/ping 8.8.8.8 count=3 size=64 interval=2s]=0) do={ |
| 75 | :log error "LTE DOWN"; |
| 76 | /system reboot; |
| 77 | } else={ |
| 78 | :log info "LTE OK"; |
| 79 | } |
| 80 | |
| 81 | 2 name="check_internet" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
| 82 | dont-require-permissions=no run-count=0 source= |
| 83 | :if ([/ping 8.8.8.8 count=3 size=64 interval=2s]=0) do={ |
| 84 | :log error "----Internet DOWN"; |
| 85 | /interface lte set numbers=lte1 disabled=yes; |
| 86 | /system routerboard usb power-reset duration=1; |
| 87 | :log info "---Power USB DOWN ---"; |
| 88 | /delay 40s; |
| 89 | /interface lte set numbers=lte1 disabled=no; |
| 90 | :log info "---Enable lte1 "; |
| 91 | } else={ |
| 92 | :log info "----Internet OK"; |
| 93 | } |
| 94 | |