aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
AgeCommit message (Expand)AuthorFilesLines
2020-03-12add script 'global-wait'•••Run this in schedulers that fire on startup without interval. Schedulers should look something like this: / system scheduler { add name=global-scripts on-event="/ system script { run global-config; run global-config-overlay; run global-functions; }" start-time=startup; add name=bridge-port-to-default on-event="/ system script { run global-wait; run bridge-port-to-default; }" start-time=startup; } Gravatar Christian Hesse1-0/+4
2020-03-09global-functions: $DeviceInfo: more indentionGravatar Christian Hesse1-5/+5
2020-03-05global-functions: $SendEMail: invert conditionGravatar Christian Hesse1-11/+13
2020-03-05global-functions: $SendTelegram: invert conditionGravatar Christian Hesse1-10/+12
2020-03-05global-functions: $SendTelegram: allow to override chatid•••This allows to send Telegram messages to different contact or group. Use something like this: /system scheduler add name=netwatch-notify interval=1m start-time=startup \ on-event=":global TelegramChatIdOverride \"-1234\"; / system script run netwatch-notify; :set TelegramChatIdOverride;" Gravatar Christian Hesse1-2/+8
2020-03-05always use severity 'warning', not just 'warn'Gravatar Christian Hesse1-2/+2
2020-03-05global-functions: $LogPrintExit: add debugging optionGravatar Christian Hesse1-7/+12
2020-03-03bridge-port-to-default: use $ParseKeyValueStore...•••... and unbreak last commit removing delay (69352c90). This requires a change in configuration syntax. Change this... comment="default:br-local, alt:br-guest" to... comment="default=br-local, alt=br-guest" change-13Gravatar Christian Hesse1-1/+1
2020-02-28global-functions: sort alphabeticallyGravatar Christian Hesse1-281/+280
2020-02-27global-functions: $ScriptLock: use $LogPrintExitGravatar Christian Hesse1-2/+3
2020-02-26global-functions: merge $LogAnd{Error,Put} to $LogPrintExit ...•••... and fix logging. Logging with severity from variable (:log $severity ...) is not possible, this is considered a syntax error. Also the 'workaround' with parsing code failed with missing message in log. The reliable code is a lot longer, so merge the two functions to save a lot of duplicate code. Gravatar Christian Hesse1-16/+17
2020-02-26global-functions: introduce $LogAndPutGravatar Christian Hesse1-0/+10
2020-02-26global-functions: $LogAndError: add severityGravatar Christian Hesse1-3/+4
2020-02-24global-functions: introduce $LogAndErrorGravatar Christian Hesse1-0/+9
2020-02-24global-functions: $WaitTimeSync: rotate ntp servers minutely•••Signed-off-by: Christian Hesse <mail@eworm.de> Gravatar Christian Hesse1-0/+4
2020-02-24global-functions: introduce $WaitTimeSyncGravatar Christian Hesse1-0/+10
2020-02-24global-functions: introduce $TimeIsSyncGravatar Christian Hesse1-0/+16
2020-02-24global-functions: introduce $MailServerIsUpGravatar Christian Hesse1-0/+22
2020-02-06global-functions: introduce and use $CertificateNameByCNGravatar Christian Hesse1-2/+13
2020-02-04global-config: drop $ScriptUpdatesConfigChangesIgnore•••Comment or remove $GlobalConfigVersion in global-config-overlay to disable change notifications. change-12Gravatar Christian Hesse1-1/+1
2020-02-03global-functions: $CharacterReplace: do not limit string length•••I've tried something like this to update a device: / system script set source=[ $CharacterReplace [ get global-config-overlay source ] "GlobalConfigVersion 10" "GlobalConfigVersion 11" ] global-config-overlay; This broke with global-config-overlay longer than 999 characters. So makes sure there is no limit for string length. Gravatar Christian Hesse1-2/+1
2020-02-02global-functions: $CertificateAvailable: simplify loopGravatar Christian Hesse1-4/+4
2020-01-29README: update instructions to use $ScriptInstallUpdatechange-11Gravatar Christian Hesse1-1/+1
2020-01-29global-functions: add $ScriptInstallUpdate•••Just call without parameters to update scripts: [admin@MikroTik] > $InstallAndUpdate Add comma separated list of scripts to install and update: [admin@MikroTik] > $InstallAndUpdate cloud-backup[,upload-backup][,...] Gravatar Christian Hesse1-0/+14
2020-01-29global-functions: $CertificateAvailable: check whole chain•••The root certificate is a self-signed certificate. Check for the issue certificate until we find the self-signed one. Gravatar Christian Hesse1-0/+12
2020-01-29global-functions: $CertificateAvailable: warn about crl download to flash•••Downloading certificate crls to flash can fill up all available space. So warn about it! Gravatar Christian Hesse1-0/+6
2020-01-28global-functions: replace deprecated keep-result=no with output=noneGravatar Christian Hesse1-1/+1
2020-01-06global-functions: $CertificateDownload: properly name new certificatesGravatar Christian Hesse1-0/+5
2020-01-03global-functions: do not encode dash, dot, slash and underscoreGravatar Christian Hesse1-4/+3
2020-01-03global-functions: $Certificate*: add quoting around CNGravatar Christian Hesse1-2/+2
2020-01-03global-functions: split $CertificateAvailable to $CertificateDownload•••This allows to force download even if certificate is available. We need this for a clean update path with Let's Encrypt. Gravatar Christian Hesse1-17/+28
2020-01-01update copyright for 2020Gravatar Christian Hesse1-1/+1
2019-12-10global-functions: define first, set laterGravatar Christian Hesse1-16/+34
2019-12-05global-functions: $DownloadPackage: retry on errorGravatar Christian Hesse1-12/+17
2019-12-03global-functions: introduce $ScriptFromTerminal•••Checking whether or not started from terminal is tricky... We have to find the job for the script, find its top most parent and get its type. Gravatar Christian Hesse1-0/+18
2019-11-28global-functions: $DeviceInfo: append revision to modelGravatar Christian Hesse1-1/+5
2019-10-28global-functions: add architecture in device infoGravatar Christian Hesse1-2/+3
2019-10-14check-health: make threshold for voltage configurablechange-10Gravatar Christian Hesse1-1/+1
2019-09-12introduce global-config-overlaychange-9Gravatar Christian Hesse1-1/+1
2019-09-12global-functions: $DeviceInfo: handle configuration versionGravatar Michael Gisbers1-0/+10
2019-09-12global-functions: introduce and use $DeviceInfoGravatar Christian Hesse1-0/+29
2019-08-30script-updates: add donation hint in configuration warning notificationchange-8Gravatar Christian Hesse1-1/+1
2019-08-27add script 'check-health'•••This may be incomplete... Please report if you have missing PSUs, ttemperature sensors, whatever. change-7Gravatar Christian Hesse1-1/+1
2019-08-18global-functions: support sending silent telegram notificationsGravatar Christian Hesse1-4/+6
2019-08-18global-functions: split off $SendEMail and $SendTelegramGravatar Christian Hesse1-9/+31
2019-08-01global-functions: $DownloadPackage: re-introduce check for valid package•••Even if fetch tool does its job right now... Chances are that the download servers have corrupted or empty files. Gravatar Christian Hesse1-0/+5
2019-07-26global-functions: add $RandomDelayGravatar Christian Hesse1-0/+7
2019-07-26global-functions: add $GetRandomGravatar Christian Hesse1-0/+13
2019-07-19global-functions: $DownloadPackage: fix downloading for CHR / x86_64Gravatar Christian Hesse1-0/+3
2019-07-19add script 'upload-backup'change-6Gravatar Christian Hesse1-1/+1
2019-07-17global-functions: add $ParseKeyValueStoreGravatar Christian Hesse1-0/+16
2019-07-16global-functions: $CharacterReplace: use same condition in loopGravatar Christian Hesse1-1/+1
2019-07-16global-functions: append system note in e-mail signatureGravatar Christian Hesse1-1/+6
2019-06-14backup: split off cloud-backup•••Currently backup to MikroTik cloud is pretty unreliable and script can not catch errors at runtime. Looks like this does not change any time soon (Ticket#2019052022003204). So let's just split off the cloud backup to make sure email backup works as expected. change-5Gravatar Christian Hesse1-1/+1
2019-04-30global-functions: $CertificateAvailable: fetch by CommonName•••Now that we have a proper $UrlEncode function... Fetch certificates by CommonName. Also remove the PEM after import. Gravatar Christian Hesse1-8/+11
2019-04-30global-functions: add $WaitForFile, wait for file on fetch•••The fetch command is asynchronous, the file is not guaranteed to be available when command terminates. I opened an issue at Mikrotik support (Ticket#2019041722004999), their answer: > You should perform a check in a loop. > :delay until file exist > > That can happen also with any configuration not just files. So add a function to wait for a file with given name. I have not seen this with other configuration, though. Gravatar Christian Hesse1-0/+22
2019-04-09drop deprecated mode= for fetchGravatar Christian Hesse1-2/+2
2019-04-03script-updates: send global-config changes notification just onceGravatar Christian Hesse1-0/+1
2019-04-02script-updates: add option to ignore global-config changeschange-4Gravatar Christian Hesse1-1/+1
2019-04-01check-certificates: support multiple passphraseschange-3Gravatar Christian Hesse1-1/+1
2019-03-28global-functions: prevent infinite loopGravatar Christian Hesse1-2/+4
2019-03-20global-functions: encode all non-alphanumeric charactersGravatar Christian Hesse1-2/+5
2019-02-28global-functions: remove extra check in $DownloadPackage•••Should be fixed in RouterOS 6.44rc1 with changelog: *) fetch - improved file downloading to slow memory; routeros-6.44rc1Gravatar Christian Hesse1-7/+0
2019-02-21global-functions: add $ScriptLockGravatar Christian Hesse1-0/+10
2019-02-21global-functions: drop $Read, use :return directlyGravatar Christian Hesse1-5/+0
2019-02-14global-functions: detect failed package downloadsGravatar Christian Hesse1-1/+9
2019-02-13global-functions: introduce and use $CleanFilePathGravatar Christian Hesse1-4/+21
2019-02-13global-functions: remove file on failed downloadGravatar Christian Hesse1-3/+9
2019-02-11global-functions: add missing colonGravatar Christian Hesse1-1/+1
2019-02-08global-functions: prevent infinite loop in $CharacterReplaceGravatar Christian Hesse1-0/+4
2019-02-08global-functions: add $CharacterReplaceGravatar Christian Hesse1-0/+15
2019-01-04global: variable names are CamelCase••• ___ _ ___ __ / _ )(_)__ _ / _/__ _/ /_ / _ / / _ `/ / _/ _ `/ __/ /____/_/\_, / /_/ \_,_/\__/ _ __ /___/ _ __ | | / /___ __________ (_)___ ____ _/ / | | /| / / __ `/ ___/ __ \/ / __ \/ __ `/ / | |/ |/ / /_/ / / / / / / / / / / /_/ /_/ |__/|__/\__,_/_/ /_/ /_/_/_/ /_/\__, (_) /____/ RouterOS has some odd behavior when it comes to variable names. Let's have a look at the interfaces: [admin@MikroTik] > / interface print where name=en1 Flags: D - dynamic, X - disabled, R - running, S - slave # NAME TYPE ACTUAL-MTU L2MTU 0 RS en1 ether 1500 1598 That looks ok. Now we use a script: { :local interface "en1"; / interface print where name=$interface; } And the result... [admin@MikroTik] > { :local interface "en1"; {... / interface print where name=$interface; } Flags: D - dynamic, X - disabled, R - running, S - slave # NAME TYPE ACTUAL-MTU L2MTU 0 RS en1 ether 1500 1598 ... still looks ok. We make a little modification to the script: { :local name "en1"; / interface print where name=$name; } And the result: [admin@MikroTik] > { :local name "en1"; {... / interface print where name=$name; } Flags: D - dynamic, X - disabled, R - running, S - slave # NAME TYPE ACTUAL-MTU L2MTU 0 RS en1 ether 1500 1598 1 S en2 ether 1500 1598 2 S en3 ether 1500 1598 3 S en4 ether 1500 1598 4 S en5 ether 1500 1598 5 R br-local bridge 1500 1598 Ups! The filter has no effect! That happens whenever the variable name ($name) matches the property name (name=). And another modification: { :local type "en1"; / interface print where name=$type; } And the result: [admin@MikroTik] > { :local type "en1"; {... / interface print where name=$type; } Flags: D - dynamic, X - disabled, R - running, S - slave # NAME TYPE ACTUAL-MTU L2MTU Ups! Nothing? Even if the variable name ($type) matches whatever property name (type=) things go wrong. The answer from MikroTik support (in Ticket#2019010222000454): > This is how scripting works in RouterOS and we will not fix it. To get around this we use variable names in CamelCase. Let's hope Mikrotik never ever introduces property names in CamelCase... *fingers crossed* Gravatar Christian Hesse1-58/+58
2019-01-03global-{config,functions}: move variables, make independentGravatar Christian Hesse1-1/+6
2019-01-03script-updates: add configuration versioningGravatar Christian Hesse1-0/+3
2019-01-02update copyright for 2019Gravatar Christian Hesse1-1/+1
2018-12-28global-functions: properly define global functionsGravatar Christian Hesse1-0/+2
2018-12-28global-functions: update comment in $SendNotificationGravatar Christian Hesse1-1/+1
2018-12-28global-functions: add $DownloadPackage•••... and make script 'capsman-download-packages' use it. Gravatar Christian Hesse1-0/+25
2018-12-27global-functions: add $GetMacVendorGravatar Christian Hesse1-0/+15
2018-12-20global-functions: make $CertificateAvailable work on CommonName•••This should prevent endless certificate switching for Let's Encrypt cross-signed intermediate certificates. Gravatar Christian Hesse1-7/+8
2018-12-12remove extra dollar signGravatar Christian Hesse1-2/+2
2018-11-28global-functions: add identity tag in $SendNotification•••... and send subject in telegram message. Gravatar Christian Hesse1-2/+4
2018-11-09global-functions: use 'print count-only'Gravatar Christian Hesse1-1/+1
2018-11-09global-functions: add function to read user inputGravatar Christian Hesse1-0/+5
2018-10-16global-functions: import certificates if required•••Signed-off-by: Christian Hesse <mail@eworm.de> Gravatar Christian Hesse1-3/+24
2018-10-15global-functions: fix missing colonGravatar Christian Hesse1-2/+2
2018-10-12global-functions: make sure parameters are stringsGravatar Christian Hesse1-6/+7
2018-10-10daily-psk: move function GeneratePSK from global-functionsGravatar Christian Hesse1-42/+0
2018-10-09global-functions: add UrlEncode and use in SendNotificationGravatar Christian Hesse1-1/+25
2018-10-09global-functions: add function to notify via e-mail and telegramGravatar Christian Hesse1-0/+35
2018-10-09global-functions: move daily psk secrets to global-configGravatar Christian Hesse1-15/+4
2018-10-09make GeneratePSK a global functionGravatar Christian Hesse1-0/+52
2018-10-09add global-functionsGravatar Christian Hesse1-0/+6