-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mengeluarkan script ke folder terpisah
- Loading branch information
Showing
19 changed files
with
730 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
######################################################### | ||
# Wrapper for /tools fetch | ||
# Input: | ||
# mode | ||
# upload=yes/no | ||
# user | ||
# password | ||
# address | ||
# host | ||
# httpdata | ||
# httpmethod | ||
# check-certificate | ||
# src-path | ||
# dst-path | ||
# ascii=yes/no | ||
# url | ||
# resfile | ||
|
||
:local res "fetchresult.txt" | ||
:if ([:len $resfile]>0) do={:set res $resfile} | ||
#:put $res | ||
|
||
:local cmd "/tool fetch" | ||
:if ([:len $mode]>0) do={:set cmd "$cmd mode=$mode"} | ||
:if ([:len $upload]>0) do={:set cmd "$cmd upload=$upload"} | ||
:if ([:len $user]>0) do={:set cmd "$cmd user=\"$user\""} | ||
:if ([:len $password]>0) do={:set cmd "$cmd password=\"$password\""} | ||
:if ([:len $address]>0) do={:set cmd "$cmd address=\"$address\""} | ||
:if ([:len $host]>0) do={:set cmd "$cmd host=\"$host\""} | ||
:if ([:len $"http-data"]>0) do={:set cmd "$cmd http-data=\"$"http-data"\""} | ||
:if ([:len $"http-method"]>0) do={:set cmd "$cmd http-method=\"$"http-method"\""} | ||
:if ([:len $"check-certificate"]>0) do={:set cmd "$cmd check-certificate=\"$"check-certificate"\""} | ||
:if ([:len $"src-path"]>0) do={:set cmd "$cmd src-path=\"$"src-path"\""} | ||
:if ([:len $"dst-path"]>0) do={:set cmd "$cmd dst-path=\"$"dst-path"\""} | ||
:if ([:len $ascii]>0) do={:set cmd "$cmd ascii=\"$ascii\""} | ||
:if ([:len $url]>0) do={:set cmd "$cmd url=\"$url\""} | ||
|
||
:put ">> $cmd" | ||
|
||
:global FETCHRESULT | ||
:set FETCHRESULT "none" | ||
|
||
:local script "\ | ||
:global FETCHRESULT;\ | ||
:do {\ | ||
$cmd;\ | ||
:set FETCHRESULT \"success\";\ | ||
} on-error={\ | ||
:set FETCHRESULT \"failed\";\ | ||
}\ | ||
" | ||
:execute script=$script file=$res | ||
:local cnt 0 | ||
#:put "$cnt -> $FETCHRESULT" | ||
:while ($cnt<100 and $FETCHRESULT="none") do={ | ||
:delay 1s | ||
:set $cnt ($cnt+1) | ||
#:put "$cnt -> $FETCHRESULT" | ||
} | ||
:local content [/file get [find name=$res] content] | ||
#:put $content | ||
if ($content~"finished") do={:return "success"} | ||
:return $FETCHRESULT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local reportBody "" | ||
|
||
:local deviceName [/system identity get name] | ||
:local deviceDate [/system clock get date] | ||
:local deviceTime [/system clock get time] | ||
:local hwModel [/system routerboard get model] | ||
:local rosVersion [/system package get system version] | ||
:local currentFirmware [/system routerboard get current-firmware] | ||
:local upgradeFirmware [/system routerboard get upgrade-firmware] | ||
|
||
|
||
:set reportBody ($reportBody . "Router Reboot Report for $deviceName%0A") | ||
:set reportBody ($reportBody . "Report generated on $deviceDate at $deviceTime%0A%0A") | ||
|
||
:set reportBody ($reportBody . "Hardware Model: $hwModel%0A") | ||
:set reportBody ($reportBody . "RouterOS Version: $rosVersion%0A") | ||
:set reportBody ($reportBody . "Current Firmware: $currentFirmware%0A") | ||
:set reportBody ($reportBody . "Upgrade Firmware: $upgradeFirmware") | ||
if ( $currentFirmware < $upgradeFirmware) do={ | ||
:set reportBody ($reportBody . "NOTE: You should upgrade the RouterBOARD firmware!%0A") | ||
} | ||
|
||
:set reportBody ($reportBody . "%0A%0A=== Critical Log Events ===%0A" ) | ||
|
||
:local x | ||
:local ts | ||
:local msg | ||
foreach i in=([/log find where topics~"critical"]) do={ | ||
:set $ts [/log get $i time] | ||
:set $msg [/log get $i message] | ||
:set $reportBody ($reportBody . $ts . " " . $msg . "%0A" ) | ||
} | ||
|
||
:set reportBody ($reportBody . "%0A=== end of report ===%0A") | ||
$send chat=$chatid text=$reportBody mode="Markdown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:local hotspot [:len [/ip hotspot active find]] | ||
|
||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Router ID:* $[/system identity get name] * %0A\ | ||
Uptime: _$[/system resource get uptime]_%0A\ | ||
CPU Load: _$[/system resource get cpu-load]%_%0A\ | ||
RAM: _$(([/system resource get total-memory]-[/system resource get free-memory])/(1024*1024))M/$([/system resource get total-memory]/(1024*1024))M_" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
:return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:local param1 [:pick $params 0 [:find $params " "]] | ||
:local param2 [:pick $params ([:find $params " "]+1) [:len $params]] | ||
:local param3 [:pick [:pick $params ([:find $params " "]+1) [:len $params]] ([:find [:pick $params ([:find $params " "]+1) [:len $params]] " "]+1) [:len [:pick $params ([:find $params " "]+1) [:len $params]]]] | ||
:if ([:len [:find $param2 " "]]>0) do={ | ||
:set param2 [:pick [:pick $params ([:find $params " "]+1) [:len $params]] 0 [:find [:pick $params ([:find $params " "]+1) [:len $params]] " "]] | ||
} else={ | ||
:set param3 "" | ||
} | ||
|
||
:put $params | ||
:put $param1 | ||
:put $param2 | ||
:put $param3 | ||
:put $chatid | ||
:put $from | ||
|
||
:local getVendor false | ||
:if ((params = "lease") or (params = "LEASE") or (params = "Lease" | ||
local GetMacVendor do={ | ||
:do { | ||
return ([/tool fetch mode=https http-method=get url=("https://api.macvendors.com/".[:pick [:tostr $1] 0 8 ]) as-value output=user ]->"data") | ||
} on-error={ | ||
return "unknown vendor" | ||
} | ||
} | ||
:local text | ||
:local number (0) | ||
:set text ("*Router ID: ".[/system identity get value-name=name]."*%0A%0A") | ||
:foreach lease in=[/ip dhcp-server lease find] do={ | ||
:set number ($number + 1) | ||
set text ($text."====== \F0\9F\97\82 DHCP LEASE ($number) \F0\9F\97\82 ======%0A") | ||
:local addr [/ip dhcp-server lease get value-name=address $lease] | ||
:set text ($text."IP Address: $addr%0A") | ||
:local mac [/ip dhcp-server lease get value-name=mac-address $lease] | ||
:set text ($text."Mac Address: $mac%0A") | ||
:if ($getVendor = "true") do={ | ||
:local macvendor [$GetMacVendor $mac] | ||
:set text ($text."Mac Vendor: $macvendor%0A") | ||
} | ||
:local host [/ip dhcp-server lease get value-name=host-name $lease] | ||
:if ([:typeof $host] = "nil") do={set host ("Unknown Hostname")} | ||
:set text ($text."Hostname: $$host%0A") | ||
:local lastseen [/ip dhcp-server lease get value-name=last-seen $lease] | ||
:set text ($text."Uptime: $lastseen%0A") | ||
:local server [/ip dhcp-server lease get value-name=server $lease] | ||
:set text ($text."Server: $server%0A") | ||
} | ||
:set text ($text."=========== END REPORT ===========%0A") | ||
$send chat=$chatid text=("$text") mode="Markdown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "All hotspots disabled" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
/ip hotspot disable lantai1 | ||
/ip hotspot disable lantai2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "All hotspots enabled" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
/ip hotspot enable lantai1 | ||
/ip hotspot enable lantai2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Force Update DDNS" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
/ip cloud force-update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
|
||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Router ID:* $[/system identity get name] * %0A\ | ||
==================%0A\ | ||
MENU TERSEDIA%0A\ | ||
==================%0A\ | ||
/help%0A\ | ||
/start%0A\ | ||
/cpu%0A\ | ||
/interface%0A\ | ||
- show%0A\ | ||
/hotspot%0A\ | ||
- session%0A\ | ||
> count%0A\ | ||
> showall%0A\ | ||
> deauth-by-user <username>%0A\ | ||
> deauth-by-mac <mac address>%0A\ | ||
> deauth-by-ip <ip>%0A\ | ||
- add <username> <password>%0A\ | ||
- delete <username>%0A\ | ||
- disable <username>%0A\ | ||
- enable <username>%0A\ | ||
- setprofile <username> <profile>%0A\ | ||
- change-password <username> <password>%0A\ | ||
/ping to <ip>%0A\ | ||
/public%0A\ | ||
/enablehotspot%0A\ | ||
/disablehotspot%0A\ | ||
/forceupdateddns%0A\ | ||
/reboot" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
:return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
|
||
:put $params | ||
:put $chatid | ||
:put $from | ||
|
||
:local text "Router ID:* $[/system identity get name] * %0A\ | ||
==================%0A\ | ||
MENU TERSEDIA%0A\ | ||
==================%0A\ | ||
/help%0A\ | ||
/start%0A\ | ||
/cpu%0A\ | ||
/interface%0A\ | ||
- show%0A\ | ||
/hotspot%0A\ | ||
- session%0A\ | ||
> count%0A\ | ||
> showall%0A\ | ||
> deauth-by-user <username>%0A\ | ||
> deauth-by-mac <mac address>%0A\ | ||
> deauth-by-ip <ip>%0A\ | ||
- add <username> <password>%0A\ | ||
- delete <username>%0A\ | ||
- disable <username>%0A\ | ||
- enable <username>%0A\ | ||
- setprofile <username> <profile>%0A\ | ||
- change-password <username> <password>%0A\ | ||
/ping to <ip>%0A\ | ||
/public%0A\ | ||
/enablehotspot%0A\ | ||
/disablehotspot%0A\ | ||
/forceupdateddns%0A\ | ||
/reboot" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
:return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
:local send [:parse [/system script get tg_sendMessage source]] | ||
:local param1 [:pick $params 0 [:find $params " "]] | ||
:local param2 [:pick $params ([:find $params " "]+1) [:len $params]] | ||
:local param3 [:pick [:pick $params ([:find $params " "]+1) [:len $params]] ([:find [:pick $params ([:find $params " "]+1) [:len $params]] " "]+1) [:len [:pick $params ([:find $params " "]+1) [:len $params]]]] | ||
:if ([:len [:find $param2 " "]]>0) do={ | ||
:set param2 [:pick [:pick $params ([:find $params " "]+1) [:len $params]] 0 [:find [:pick $params ([:find $params " "]+1) [:len $params]] " "]] | ||
} else={ | ||
:set param3 "" | ||
} | ||
|
||
:put $params | ||
:put $param1 | ||
:put $param2 | ||
:put $param3 | ||
:put $chatid | ||
:put $from | ||
|
||
:if ($param1="session") do={ | ||
:if ($param2="count") do={ | ||
:local output | ||
:local hotspot [:len [/ip hotspot active find]] | ||
:local text "Router ID:* $[/system identity get name] * %0A\ | ||
Hotspot users: _$hotspot online_" | ||
|
||
$send chat=$chatid text=$text mode="Markdown" | ||
} | ||
:if ($param2="showall") do={ | ||
:local output | ||
:foreach activeIndex in=[/ip hotspot active find] do={ | ||
:local activeUser ("*Username*: ".[/ip hotspot active get value-name="user" $activeIndex]."%0A") | ||
:local activeAddress ("*IP*: ".[/ip hotspot active get value-name="address" $activeIndex]."%0A") | ||
:local activeMACAddr ("*MAC*: ".[/ip hotspot active get value-name="mac-address" $activeIndex]."%0A") | ||
:local activeLoginBy ("*Login Method*: ".[/ip hotspot active get value-name="login-by" $activeIndex]."%0A") | ||
:local activeUptime ("*Uptime*: ".[/ip hotspot active get value-name="uptime" $activeIndex]."%0A") | ||
:local idletime ("*Idle Time*: ".[/ip hotspot active get value-name="idle-time" $activeIndex]."%0A") | ||
:local serverIn ("*Server*: ".[/ip hotspot active get value-name="server" $activeIndex]."%0A") | ||
:set output ($output.$activeUser.$activeAddress.$activeMACAddr.$activeUptime.$idletime.$activeLoginBy.$serverIn."%0A") | ||
} | ||
$send chat=$chatid text=("$output") mode="Markdown" | ||
} | ||
:if ($param2="deauth-by-user") do={ | ||
/ip hotspot active remove [find user="$param3"] | ||
$send chat=$chatid text=("Sesi User $param3 berhasil dihapus") mode="Markdown" | ||
} | ||
:if ($param2="deauth-by-mac") do={ | ||
/ip hotspot active remove [find mac-address="$param3"] | ||
$send chat=$chatid text=("Sesi MAC $param3 berhasil dihapus") mode="Markdown" | ||
} | ||
:if ($param2="deauth-by-ip") do={ | ||
/ip hotspot active remove [find address="$param3"] | ||
$send chat=$chatid text=("Sesi IP $param3 berhasil dihapus") mode="Markdown" | ||
} | ||
} | ||
:if ($param1="add") do={ | ||
/ip hotspot user add name=$param2 password=$param3 profile=default | ||
$send chat=$chatid text=("Berhasil membuat user baru. Masuk ke hotspot dengan:%0A%0A*Username:* $param2%0A*Password:* $param3") mode="Markdown" | ||
} | ||
:if ($param1="delete") do={ | ||
/ip hotspot user remove [find name=$param2] | ||
$send chat=$chatid text=("Berhasil menghapus user $param2.") mode="Markdown" | ||
} | ||
:if ($param1="disable") do={ | ||
/ip hotspot user disable [find name=$param2] | ||
$send chat=$chatid text=("$param2 kini telah dinonaktifkan") mode="Markdown" | ||
} | ||
:if ($param1="enable") do={ | ||
/ip hotspot user enable [find name=$param2] | ||
$send chat=$chatid text=("$param2 kini telah diaktifkan") mode="Markdown" | ||
} | ||
:if ($param1="setprofile") do={ | ||
/ip hotspot user set password=$param3 [find name=$param2] | ||
/ip hotspot active remove [find name=$param2] | ||
$send chat=$chatid text=("Berhasil mengganti profile menjadi $param3.") mode="Markdown" | ||
} | ||
:if ($param1="change-password") do={ | ||
/ip hotspot user set password=$param3 [find name=$param2] | ||
/ip hotspot active remove [find name=$param2] | ||
$send chat=$chatid text=("Berhasil mengganti password untuk $param2.") mode="Markdown" | ||
} | ||
$send chat=$chatid text=("$output") mode="Markdown" | ||
} |
Oops, something went wrong.