aboutsummaryrefslogblamecommitdiffstats
path: root/daily-psk-schedule
blob: 784b3362e0471d85b43e1e6c4d75b0b55828b8f5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                     
                                                         

                               
                                                                             
 
                                                              
        
                                                                                                        
                                           

                                                                 

                                                           
                                                          
   
                                                                           
 
                                                
 
#!rsc
# RouterOS script: daily-psk-schedule
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
#
# schedule daily-psk on startup

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

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

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

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

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