Commit graph

66 commits

Author SHA1 Message Date
Christian Hesse
df7cb1b88b check-certificates: shorten key for detailed infos 2019-01-09 17:38:55 +01:00
Christian Hesse
e51daf2761 check-certificates: show issuer CN only 2019-01-09 17:34:08 +01:00
Christian Hesse
fe34a80a3d check-certificates: include the issuer in notifications 2019-01-09 14:33:09 +01:00
Christian Hesse
1b9a277b47 check-certificates: update CommonName after renewal 2019-01-09 14:29:15 +01:00
Christian Hesse
1ee2491e66 check-certificates: use time functionality
No need to calculate that...
2019-01-09 11:43:30 +01:00
Christian Hesse
5539233417 check-certificates: send notification on renewal 2019-01-09 10:38:41 +01:00
Christian Hesse
6b6c3d5119 check-certificates: drop extra warning
A sent notification implies that renewal failed.
2019-01-09 10:31:54 +01:00
Christian Hesse
870f00bb36 global: variable names are CamelCase
___  _         ___     __
           / _ )(_)__ _   / _/__ _/ /_
          / _  / / _ `/  / _/ _ `/ __/
         /____/_/\_, /  /_/ \_,_/\__/
 _       __     /___/       _             __
| |     / /___ __________  (_)___  ____ _/ /
| | /| / / __ `/ ___/ __ \/ / __ \/ __ `/ /
| |/ |/ / /_/ / /  / / / / / / / / /_/ /_/
|__/|__/\__,_/_/  /_/ /_/_/_/ /_/\__, (_)
                                /____/

RouterOS has some odd behavior when it comes to variable names. Let's
have a look at the interfaces:

[admin@MikroTik] > / interface print where name=en1
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU
 0  RS en1                                 ether            1500  1598

That looks ok. Now we use a script:

{ :local interface "en1";
  / interface print where name=$interface; }

And the result...

[admin@MikroTik] > { :local interface "en1";
{...   / interface print where name=$interface; }
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU
 0  RS en1                                 ether            1500  1598

... still looks ok.
We make a little modification to the script:

{ :local name "en1";
  / interface print where name=$name; }

And the result:

[admin@MikroTik] > { :local name "en1";
{...   / interface print where name=$name; }
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU
 0  RS en1                                 ether            1500  1598
 1   S en2                                 ether            1500  1598
 2   S en3                                 ether            1500  1598
 3   S en4                                 ether            1500  1598
 4   S en5                                 ether            1500  1598
 5  R  br-local                            bridge           1500  1598

Ups! The filter has no effect!
That happens whenever the variable name ($name) matches the property
name (name=).

And another modification:

{ :local type "en1";
  / interface print where name=$type; }

And the result:

[admin@MikroTik] > { :local type "en1";
{...   / interface print where name=$type; }
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU

Ups! Nothing?
Even if the variable name ($type) matches whatever property name (type=)
things go wrong.

The answer from MikroTik support (in Ticket#2019010222000454):

> This is how scripting works in RouterOS and we will not fix it.

To get around this we use variable names in CamelCase. Let's hope
Mikrotik never ever introduces property names in CamelCase...

*fingers crossed*
2019-01-04 12:35:34 +01:00
Christian Hesse
472cd3d905 update copyright for 2019 2019-01-02 09:38:34 +01:00
Christian Hesse
44be3d8d07 check-certificates: support auto-renew of certificates 2018-12-20 15:55:40 +01:00
Christian Hesse
6e4d715937 global-functions: add identity tag in $SendNotification
... and send subject in telegram message.
2018-11-28 21:19:39 +01:00
Christian Hesse
1bbbe3a5a7 global: remove unused variables 2018-10-10 21:49:46 +02:00
Christian Hesse
e89779ff9f check-certificates: use function for notification 2018-10-09 15:57:53 +02:00
Christian Hesse
be673737d3 start scripts with a magic token / shebang 2018-09-27 00:18:43 +02:00
Christian Hesse
07e54dd88b add empty comment at first line...
... for better formatting in export.
2018-08-24 16:58:30 +02:00
Christian Hesse
e1f134ead5 add scripts 2018-07-05 15:34:08 +02:00