mirror of
				https://github.com/eworm-de/routeros-scripts.git
				synced 2024-05-11 05:55:19 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
# RouterOS script: check-routeros-update
 | 
						|
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
 | 
						|
#
 | 
						|
# check for RouterOS update, send notification e-mails
 | 
						|
 | 
						|
:global "identity";
 | 
						|
:global "email-general-to";
 | 
						|
:global "email-general-cc";
 | 
						|
:global "sent-routeros-update-notification";
 | 
						|
 | 
						|
:if ([ :len [ / system package find where name="wireless" disabled=no ] ] > 0) do={
 | 
						|
  :if ([ / interface wireless cap get enabled ] = true && \
 | 
						|
      [ / caps-man manager get enabled ] = false) do={
 | 
						|
    :error "System is managed by CAPsMAN, not checking.";
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
:if ($"sent-routeros-update-notification" = true) do={
 | 
						|
  :error "Already sent the RouterOS update notification.";
 | 
						|
}
 | 
						|
 | 
						|
# get some information
 | 
						|
:local model [ / system routerboard get model ];
 | 
						|
:local serialnumber [ / system routerboard get serial-number ];
 | 
						|
 | 
						|
# check for RouterOS
 | 
						|
/ system package update check-for-updates without-paging;
 | 
						|
:local installedversion [ / system package update get installed-version ];
 | 
						|
:local latestversion [ / system package update get latest-version ];
 | 
						|
:local channel [ / system package update get channel ];
 | 
						|
 | 
						|
:if ($installedversion != $latestversion) do={
 | 
						|
  / tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
 | 
						|
    subject=("[" . $identity . "] RouterOS update notification") \
 | 
						|
    body=("There is a RouterOS update available\n\n" . \
 | 
						|
      "Routerboard:   " . $model . "\n" . \
 | 
						|
      "Serial number: " . $serialnumber . "\n" . \
 | 
						|
      "Hostname:      " . $identity . "\n" . \
 | 
						|
      "Channel:       " . $channel . "\n" . \
 | 
						|
      "Installed:     " . $installedversion . "\n" . \
 | 
						|
      "Available:     " . $latestversion);
 | 
						|
  :set "sent-routeros-update-notification" true;
 | 
						|
}
 |