aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-07-10 14:01:41 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-07-10 14:01:41 +0200
commitc66bb89be2b6e76a0926b19f9726c91067e5bbf3 (patch)
tree3f5d48114541e98ea4ab8e4795b76df2242e9de6
parenta964e8ad0cb285e5b3c13da37ffe567175263acc (diff)
update template system
-rw-r--r--Makefile12
-rw-r--r--collect-wireless-mac.capsman10
-rw-r--r--collect-wireless-mac.local10
-rw-r--r--collect-wireless-mac.template (renamed from collect-wireless-mac.in)13
-rw-r--r--dhcp-lease-comment.capsman2
-rw-r--r--dhcp-lease-comment.local2
-rw-r--r--dhcp-lease-comment.template (renamed from dhcp-lease-comment.in)4
7 files changed, 20 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 23169cf..2169170 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,12 @@ GENERATE = collect-wireless-mac.capsman collect-wireless-mac.local dhcp-lease-co
all: $(GENERATE)
-%.local: *.in Makefile
- sed -e 's/%PATH%/interface wireless/' -e '/^# !!/,/^# !!/c # !! Do not edit this file, it is generated from template!' < $(basename $@).in > $@
+%.local: *.template Makefile
+ sed -e '/\/ caps-man/d' -e 's|%PATH%|interface wireless|' -e 's|%TEMPL%|$(suffix $@)|' \
+ -e '/^# !!/,/^# !!/c # !! Do not edit this file, it is generated from template!' \
+ < $(basename $@).template > $@
-%.capsman: *.in Makefile
- sed -e 's/%PATH%/caps-man/' -e '/^# !!/,/^# !!/c # !! Do not edit this file, it is generated from template!' < $(basename $@).in > $@
+%.capsman: *.template Makefile
+ sed -e '/\/ interface wireless/d' -e 's/%PATH%/caps-man/' -e 's/%TEMPL%/$(suffix $@)/' \
+ -e '/^# !!/,/^# !!/c # !! Do not edit this file, it is generated from template!' \
+ < $(basename $@).template > $@
diff --git a/collect-wireless-mac.capsman b/collect-wireless-mac.capsman
index f6fabf3..6b1ad49 100644
--- a/collect-wireless-mac.capsman
+++ b/collect-wireless-mac.capsman
@@ -1,4 +1,4 @@
-# RouterOS script: collect-wireless-mac
+# RouterOS script: collect-wireless-mac.capsman
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# collect wireless mac adresses in access list
@@ -33,13 +33,7 @@
}
:local regentry [ / caps-man registration-table find where mac-address=$mac ];
:local interface [ / caps-man registration-table get $regentry interface ];
- :local ssid;
- :if ("caps-man" = ("caps" . "-man")) do={
- :set ssid [ / caps-man registration-table get $regentry ssid ];
- } else={
- # keep two spaces here to protect against replace!
- :set ssid [ / interface wireless get [ find where name=$interface ] ssid ];
- }
+ :local ssid [ / caps-man registration-table get $regentry ssid ];
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
:local message ("unknown MAC address " . $mac . " (" . $hostname . ") first seen on " . \
$datetime . " connected to SSID " . $ssid . ", interface " . $interface);
diff --git a/collect-wireless-mac.local b/collect-wireless-mac.local
index 4418c94..5bd544c 100644
--- a/collect-wireless-mac.local
+++ b/collect-wireless-mac.local
@@ -1,4 +1,4 @@
-# RouterOS script: collect-wireless-mac
+# RouterOS script: collect-wireless-mac.local
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# collect wireless mac adresses in access list
@@ -33,13 +33,7 @@
}
:local regentry [ / interface wireless registration-table find where mac-address=$mac ];
:local interface [ / interface wireless registration-table get $regentry interface ];
- :local ssid;
- :if ("interface wireless" = ("caps" . "-man")) do={
- :set ssid [ / interface wireless registration-table get $regentry ssid ];
- } else={
- # keep two spaces here to protect against replace!
- :set ssid [ / interface wireless get [ find where name=$interface ] ssid ];
- }
+ :local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
:local message ("unknown MAC address " . $mac . " (" . $hostname . ") first seen on " . \
$datetime . " connected to SSID " . $ssid . ", interface " . $interface);
diff --git a/collect-wireless-mac.in b/collect-wireless-mac.template
index 79cbeff..80109fe 100644
--- a/collect-wireless-mac.in
+++ b/collect-wireless-mac.template
@@ -1,9 +1,9 @@
-# RouterOS script: collect-wireless-mac
+# RouterOS script: collect-wireless-mac%TEMPL%
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# collect wireless mac adresses in access list
#
-# !! This is just a template! Replace '%PATH%' with 'capsman'
+# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
:global "identity";
@@ -34,13 +34,8 @@
}
:local regentry [ / %PATH% registration-table find where mac-address=$mac ];
:local interface [ / %PATH% registration-table get $regentry interface ];
- :local ssid;
- :if ("%PATH%" = ("caps" . "-man")) do={
- :set ssid [ / %PATH% registration-table get $regentry ssid ];
- } else={
- # keep two spaces here to protect against replace!
- :set ssid [ / interface wireless get [ find where name=$interface ] ssid ];
- }
+ :local ssid [ / caps-man registration-table get $regentry ssid ];
+ :local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
:local message ("unknown MAC address " . $mac . " (" . $hostname . ") first seen on " . \
$datetime . " connected to SSID " . $ssid . ", interface " . $interface);
diff --git a/dhcp-lease-comment.capsman b/dhcp-lease-comment.capsman
index 324a5d8..eb436eb 100644
--- a/dhcp-lease-comment.capsman
+++ b/dhcp-lease-comment.capsman
@@ -1,4 +1,4 @@
-# RouterOS script: dhcp-lease-comment
+# RouterOS script: dhcp-lease-comment.capsman
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# update dhcp-server lease comment with infos from access-list
diff --git a/dhcp-lease-comment.local b/dhcp-lease-comment.local
index ad4785b..2b22691 100644
--- a/dhcp-lease-comment.local
+++ b/dhcp-lease-comment.local
@@ -1,4 +1,4 @@
-# RouterOS script: dhcp-lease-comment
+# RouterOS script: dhcp-lease-comment.local
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# update dhcp-server lease comment with infos from access-list
diff --git a/dhcp-lease-comment.in b/dhcp-lease-comment.template
index 35f1b3d..b344955 100644
--- a/dhcp-lease-comment.in
+++ b/dhcp-lease-comment.template
@@ -1,9 +1,9 @@
-# RouterOS script: dhcp-lease-comment
+# RouterOS script: dhcp-lease-comment%TEMPL%
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# update dhcp-server lease comment with infos from access-list
#
-# !! This is just a template! Replace '%PATH%' with 'capsman'
+# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
:foreach lease in=[ / ip dhcp-server lease find where dynamic=yes ] do={