Commit graph

83 commits

Author SHA1 Message Date
Christian Hesse
7f96e5c966 global-functions: add $WaitForFile, wait for file on fetch
The fetch command is asynchronous, the file is not guaranteed to be
available when command terminates.

I opened an issue at Mikrotik support (Ticket#2019041722004999),
their answer:

> You should perform a check in a loop.
> :delay until file exist
>
> That can happen also with any configuration not just files.

So add a function to wait for a file with given name.

I have not seen this with other configuration, though.
2019-04-30 16:52:53 +02:00
Christian Hesse
5273efda21 check-certificates: make sure fingerprint is a string
This makes sure the condition below works for certificate templates,
which do not have a fingerprint.
2019-04-11 22:22:05 +02:00
Christian Hesse
20d7020fe3 check-certificates: do not send notification for templates 2019-04-11 10:19:46 +02:00
Christian Hesse
ea94b7598e check-certificates: always return a string in $GetIssuerCN 2019-04-11 09:57:20 +02:00
Christian Hesse
58c25c8cca check-certificates: add url encoding for certificate download 2019-04-10 14:47:20 +02:00
Christian Hesse
e562825bd9 check-certificates: try to fetch PEM and P12 file 2019-04-10 14:29:24 +02:00
Christian Hesse
5beebbe8e8 check-certificates: use full path...
... to make sure syntax does not break if package is not installed.
2019-04-10 14:29:24 +02:00
Christian Hesse
c0b73d6e92 check-certificates: just change certificates, no loop 2019-04-10 13:59:38 +02:00
Christian Hesse
b93d4d40bc drop deprecated mode= for fetch 2019-04-09 18:01:44 +02:00
Christian Hesse
b35c0b8a6f always write warnings and errors to log 2019-04-03 21:30:43 +02:00
Christian Hesse
594aef2aab check-certificates: support multiple passphrases 2019-04-01 22:45:38 +02:00
Christian Hesse
de602cba4f check-certificates: show remaining time 2019-03-28 13:32:08 +01:00
Christian Hesse
04b7b1f3b5 check-certificates: update certificates for ipsec identities 2019-03-25 16:49:26 +01:00
Christian Hesse
a66713d093 check-certificates: split loop for certificate renew and warning
This allows to have differnt time values.
2019-03-06 13:49:12 +01:00
Christian Hesse
afeab858d4 check-certificates: strip prefix from issuer CN 2019-01-12 00:47:53 +01:00
Christian Hesse
e62fbd2489 check-certificates: properly handle expired certificates 2019-01-12 00:04:53 +01:00
Christian Hesse
4ab9f9e7c8 check-certificates: move conditions to loop 2019-01-09 22:26:32 +01:00
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