accesslist-duplicates.template 1.08 KB
Newer Older
1
#!rsc
2
# RouterOS script: accesslist-duplicates%TEMPL%
3
# Copyright (c) 2018-2019 Christian Hesse <mail@eworm.de>
4 5 6 7 8 9
#
# print duplicate antries in wireless access list
#
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!

10 11 12 13 14 15 16 17 18 19
:local Seen [ :toarray "" ];
:local Shown [ :toarray "" ];

:foreach AccList in=[ / %PATH% access-list find where mac-address!="00:00:00:00:00:00" ] do={
  :local Mac [ / %PATH% access-list get $AccList mac-address ];
  :foreach SeenMac in=$Seen do={
    :if ($SeenMac = $Mac) do={
      :local Skip 0;
      :foreach ShownMac in=$Shown do={
        :if ($ShownMac = $Mac) do={ :set Skip 1; }
20
      }
21 22 23
      :if ($Skip = 0) do={
        / %PATH% access-list print where mac-address=$Mac;
        :set Shown ($Shown, $Mac);
24

25 26 27
        :put "\nNumeric id to remove, any key to skip!";
        :local Remove ([ :terminal inkey ] - 48);
        :if ($Remove >= 0 && $Remove <= 9) do={
28 29
          :put ("Removing numeric id " . $Remove . "...\n");
          / %PATH% access-list remove $Remove;
30
        }
31 32 33
      }
    }
  }
34
  :set Seen ($Seen, $Mac);
35
}