aboutsummaryrefslogblamecommitdiffstats
path: root/accesslist-duplicates.template
blob: 3b6a22ac9bba196c2dd3f556867dafee4daab8f2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
     
                                               
                                                         







                                                              
             








                                                                                             
                                     





                                                            

       
                             
 
#!rsc
# RouterOS script: accesslist-duplicates%TEMPL%
# Copyright (c) 2018-2019 Christian Hesse <mail@eworm.de>
#
# print duplicate antries in wireless access list
#
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!

:local seen [ :toarray "" ];
:local shown [ :toarray "" ];

:global Read;

: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 "seen-mac" in=$seen do={
    :if ($"seen-mac" = $mac) do={
      :local skip 0;
      :foreach "shown-mac" in=$shown do={
        :if ($"shown-mac" = $mac) do={ :set skip 1; }
      }
      :if ($skip = 0) do={
        / %PATH% access-list print where mac-address=$mac;
        :set shown ( $shown , $mac );

        :put "\nEnter to skip, numeric id to remove!";
        :local remove [ $Read ];
        :if ($remove != "") do={
          :put ("Removing numeric id " . $remove . "...\n");
          / %PATH% access-list remove $remove;
        }
      }
    }
  }
  :set seen ( $seen , $mac );
}