From 7b0b808c1838924e0b38f6aa216ee8e711d4196c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 12 Oct 2018 13:33:25 +0200 Subject: add script 'daily-psk-schedule' --- daily-psk | 12 ------------ daily-psk-schedule | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 daily-psk-schedule diff --git a/daily-psk b/daily-psk index 1ac2b09..0162ff7 100644 --- a/daily-psk +++ b/daily-psk @@ -53,16 +53,6 @@ :return $return; } -# check mail server -:if ([ / tool netwatch get [ find where comment=[ / tool e-mail get address ] ] status ] != "up" ) do={ - :error "Mail server is not up."; -} - -# check time -:if ([ / system ntp client get status ] != "synchronized") do={ - :error "Time is not yet synchronized from ntp."; -} - :local date [ / system clock get date ]; :local newpsk [ $GeneratePSK $date ]; @@ -111,5 +101,3 @@ } } } - -/ system scheduler set disabled=yes [ find where name=daily-psk disabled=no ]; diff --git a/daily-psk-schedule b/daily-psk-schedule new file mode 100644 index 0000000..7866dba --- /dev/null +++ b/daily-psk-schedule @@ -0,0 +1,23 @@ +#!rsc +# RouterOS script: daily-psk-schedule +# Copyright (c) 2013-2018 Christian Hesse +# +# schedule daily-psk on startup + +:local scheduler [ / system scheduler find where name=daily-psk-schedule ]; + +:if ([ / system scheduler get $scheduler interval ] = "00:00:00") do={ + / system scheduler set interval=15s $scheduler; +} else={ + :if ([ / tool netwatch get [ find where comment=[ / tool e-mail get address ] ] status ] != "up" ) do={ + :error "Mail server is not up."; + } + + :if ([ / system ntp client get status ] != "synchronized") do={ + :error "Time is not yet synchronized from ntp."; + } + + / system script run daily-psk; + + / system scheduler set interval=0s $scheduler; +} -- cgit v1.2.3-70-g09d2