daily-psk-schedule 956 Bytes
Newer Older
1 2
#!rsc
# RouterOS script: daily-psk-schedule
3
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
4 5 6
#
# schedule daily-psk on startup

7
:local Scheduler [ / system scheduler find where name="daily-psk-schedule" ];
8

9 10
:if ([ / system scheduler get $Scheduler interval ] = 0s) do={
  / system scheduler set interval=15s $Scheduler;
11
} else={
12
  :if ([ / tool netwatch get [ find where comment=[ / tool e-mail get address ] ] status ] != "up") do={
13 14
    :log warning "Mail server is not up.";
    :error "Warning: See log for details.";
15 16 17
  }

  :if ([ / system ntp client get status ] != "synchronized") do={
18 19 20
    :if ([ / system resource get uptime ] > 5m) do={
      / system script run [ find where name="rotate-ntp" ];
    }
21 22
    :log warning "Time is not yet synchronized from ntp.";
    :error "Warning: See log for details.";
23 24
  }

25
  / system script run [ find where name~"^daily-psk\\.(capsman|local)\$" ];
26

27
  / system scheduler set interval=0s $Scheduler;
28
}