mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
script-updates: add donation hint in configuration warning notification
This commit is contained in:
parent
c7563d4ffd
commit
166bbffe1d
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
:global GlobalConfigVersion 7;
|
:global GlobalConfigVersion 8;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
@ -107,7 +107,14 @@
|
||||||
:global ScriptUpdatesIgnore {
|
:global ScriptUpdatesIgnore {
|
||||||
"global-config"
|
"global-config"
|
||||||
}
|
}
|
||||||
|
# Enable this to silence all configuration warnings.
|
||||||
:global ScriptUpdatesConfigChangesIgnore false;
|
:global ScriptUpdatesConfigChangesIgnore false;
|
||||||
|
# This project is developed in private spare time and usage is free of charge
|
||||||
|
# for you. If you like the scripts and think this is of value for you or your
|
||||||
|
# business please consider a donation:
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/#donate
|
||||||
|
# Enable this to silence donation hint.
|
||||||
|
:global IDonate false;
|
||||||
|
|
||||||
# Use this for certificate auto-renew
|
# Use this for certificate auto-renew
|
||||||
:global CertRenewUrl "";
|
:global CertRenewUrl "";
|
||||||
|
|
|
@ -10,4 +10,5 @@
|
||||||
5="split off new script 'cloud-backup' from 'email-backup'";
|
5="split off new script 'cloud-backup' from 'email-backup'";
|
||||||
6="introduced script 'upload-backup' with new configuration parameters";
|
6="introduced script 'upload-backup' with new configuration parameters";
|
||||||
7="introduced script 'check-health' with new configuration parameters";
|
7="introduced script 'check-health' with new configuration parameters";
|
||||||
|
8="added donation hint and option to silence it";
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# global functions
|
# global functions
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 7;
|
:global ExpectedConfigVersion 8;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global SentConfigChangesNotification "-";
|
:global SentConfigChangesNotification "-";
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
:global ExpectedConfigVersion;
|
:global ExpectedConfigVersion;
|
||||||
:global GlobalConfigVersion;
|
:global GlobalConfigVersion;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
:global IDonate;
|
||||||
:global SentConfigChangesNotification;
|
:global SentConfigChangesNotification;
|
||||||
:global ScriptUpdatesFetch;
|
:global ScriptUpdatesFetch;
|
||||||
:global ScriptUpdatesBaseUrl;
|
:global ScriptUpdatesBaseUrl;
|
||||||
|
@ -81,7 +82,10 @@
|
||||||
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
||||||
:global GlobalConfigChanges;
|
:global GlobalConfigChanges;
|
||||||
:local ChangeLogCode;
|
:local ChangeLogCode;
|
||||||
:local Changes;
|
:local NotificationMessage ("Current configuration on " . $Identity . \
|
||||||
|
" is out of date. Please update global-config, then increase " . \
|
||||||
|
"variable GlobalConfigVersion (currently " . $GlobalConfigVersion . \
|
||||||
|
") to " . $ExpectedConfigVersion . " and re-run global-config.");
|
||||||
|
|
||||||
:log debug ("Fetching changelog.");
|
:log debug ("Fetching changelog.");
|
||||||
:do {
|
:do {
|
||||||
|
@ -91,20 +95,28 @@
|
||||||
:if ($Result->"status" = "finished") do={
|
:if ($Result->"status" = "finished") do={
|
||||||
:set ChangeLogCode ($Result->"data");
|
:set ChangeLogCode ($Result->"data");
|
||||||
}
|
}
|
||||||
|
:set NotificationMessage ($NotificationMessage . "\n\nChanges:");
|
||||||
|
[ :parse $ChangeLogCode ];
|
||||||
|
:for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={
|
||||||
|
:set NotificationMessage ($NotificationMessage . \
|
||||||
|
"\n * " . $GlobalConfigChanges->[ :tostr $I ]);
|
||||||
|
}
|
||||||
|
:set GlobalConfigChanges;
|
||||||
} on-error={
|
} on-error={
|
||||||
:log info ("Failed fetching changes!");
|
:log info ("Failed fetching changes!");
|
||||||
|
:set NotificationMessage ($NotificationMessage . \
|
||||||
|
"\n\nChanges are not available.");
|
||||||
}
|
}
|
||||||
[ :parse $ChangeLogCode ];
|
|
||||||
:for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={
|
|
||||||
:set Changes ( $Changes . "\n * " . $GlobalConfigChanges->[ :tostr $I ] );
|
|
||||||
}
|
|
||||||
:set GlobalConfigChanges;
|
|
||||||
|
|
||||||
$SendNotification "Configuration warning!" \
|
:if ($IDonate != true) do={
|
||||||
("Current configuration on " . $Identity . " is out of date. " . \
|
:set NotificationMessage ($NotificationMessage . \
|
||||||
"Please update global-config, then increase variable " . \
|
"\n\n==== donation hint ====\n" . \
|
||||||
"GlobalConfigVersion (currently " . $GlobalConfigVersion . \
|
"This project is developed in private spare time and usage is " . \
|
||||||
") to " . $ExpectedConfigVersion . " and re-run global-config.\n\n" . \
|
"free of charge for you. If you like the scripts and think this is " . \
|
||||||
"Changes:" . $Changes);
|
"of value for you or your business please consider a donation:\n" . \
|
||||||
|
"https://git.eworm.de/cgit/routeros-scripts/about/#donate");
|
||||||
|
}
|
||||||
|
|
||||||
|
$SendNotification "Configuration warning!" $NotificationMessage;
|
||||||
:set SentConfigChangesNotification $ExpectedConfigVersion;
|
:set SentConfigChangesNotification $ExpectedConfigVersion;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue