aboutsummaryrefslogtreecommitdiffstats
path: root/global-config
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-01-03 17:45:43 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-01-04 12:35:34 +0100
commit870f00bb36f5af3088344371764da48bbde9651a (patch)
tree4e41839d17515cf05cb563fbb4dee92970889941 /global-config
parent7d06a7e8c2b66a12db65130bddb3578b3f04468f (diff)
global: 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*
Diffstat (limited to 'global-config')
-rw-r--r--global-config78
1 files changed, 39 insertions, 39 deletions
diff --git a/global-config b/global-config
index 448fbea..85fc54b 100644
--- a/global-config
+++ b/global-config
@@ -6,45 +6,45 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
-:global GlobalConfigVersion 1;
+:global GlobalConfigVersion 2;
# This is used for DNS and backup file.
-:global "domain" "example.com";
-:global "hostname-in-zone" true;
+:global Domain "example.com";
+:global HostNameInZone true;
# These addresses are used to send e-mails to. The to-addresses need
# to be filled, cc-addresses can be empty, one address or a comma
# separated list of addresses.
-:global "email-general-to" "mail@example.com";
-:global "email-general-cc" "another@example.com";
-:global "email-backup-to" "mail@example.com";
-:global "email-backup-cc" "";
+:global EmailGeneralTo "mail@example.com";
+:global EmailGeneralCc "another@example.com";
+:global EmailBackupTo "mail@example.com";
+:global EmailBackupCc "";
# You can send Telegram notifications. Register a bot
# and add the token and chat ids here.
-:global "telegram-tokenid" "";
-:global "telegram-chatid" "";
-#:global "telegram-tokenid" "123456:ABCDEF-GHI";
-#:global "telegram-chatid" "12345678";
+:global TelegramTokenId "";
+:global TelegramChatId "";
+#:global TelegramTokenId "123456:ABCDEF-GHI";
+#:global TelegramChatId "12345678";
# This defines what backups to generate and what password to use.
-:global "backup-send-binary" false;
-:global "backup-send-export" true;
-:global "backup-cloud" false;
-:global "backup-password" "v3ry-s3cr3t";
+:global BackupSendBinary false;
+:global BackupSendExport true;
+:global BackupCloud false;
+:global BackupPassword "v3ry-s3cr3t";
# Specify an address to enable auto update to version assumed safe.
# The configured channel (bugfix, current, release-candidate) is appended.
-:global "safe-update-url" "";
-#:global "safe-update-url" "https://example.com/ros/safe-update/";
+:global SafeUpdateUrl "";
+#:global SafeUpdateUrl "https://example.com/ros/safe-update/";
# This controls what configuration is activated by bridge-port-to-default.
-:global "bridge-port-to" "default";
+:global BridgePortTo "default";
# Access-list entries matching this comment are updated
# with daily pseudo-random PSK.
-:global "daily-psk-match-comment" "Daily PSK";
-:global "daily-psk-secrets" {
+:global DailyPskMatchComment "Daily PSK";
+:global DailyPskSecrets {
{ "Abusive"; "Aggressive"; "Bored"; "Chemical"; "Cold";
"Cruel"; "Curved"; "Delightful"; "Discreet"; "Elite";
"Evasive"; "Faded"; "Flat"; "Future"; "Grandiose";
@@ -60,9 +60,9 @@
}
# Run different commands with multiple mode-button presses.
-:global "mode-button" {
+:global ModeButton {
1="/ system script run leds-toggle-mode;";
- 2=":global SendNotification; :global identity; \$SendNotification (\"Hello...\") (\"Hello world, \" . \$identity . \" calling!\");";
+ 2=":global SendNotification; :global Identity; \$SendNotification (\"Hello...\") (\"Hello world, \" . \$Identity . \" calling!\");";
3="/ system shutdown;";
4="/ system reboot;";
5="/ system script run bridge-port-toggle;";
@@ -70,7 +70,7 @@
};
# Run commands on SMS action.
-:global "sms-action" {
+:global SmsAction {
bridge-port-toggle="/ system script run bridge-port-toggle;";
reboot="/ system reboot;";
shutdown="/ system shutdown;";
@@ -79,29 +79,29 @@
# This address should resolve ntp servers and is used to update
# ntp settings. A pool can rotate servers.
-:global "ntp-pool" "pool.ntp.org";
+:global NtpPool "pool.ntp.org";
# This is the address used to send gps data to.
-:global "gps-track-url" "https://example.com/index.php";
+:global GpsTrackUrl "https://example.com/index.php";
# Enable this to fetch scripts from given url.
-:global "script-updates-fetch" true;
-:global "script-updates-baseurl" "https://git.eworm.de/cgit.cgi/routeros-scripts/plain/";
-#:global "script-updates-baseurl" "https://raw.githubusercontent.com/eworm-de/routeros-scripts/master/";
-#:global "script-updates-baseurl" "https://gitlab.com/eworm-de/routeros-scripts/raw/master/";
-:global "script-updates-urlsuffix" "";
-:global "script-updates-ignore" {
+:global ScriptUpdatesFetch true;
+:global ScriptUpdatesBaseUrl "https://git.eworm.de/cgit.cgi/routeros-scripts/plain/";
+#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/master/";
+#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/master/";
+:global ScriptUpdatesUrlSuffix "";
+:global ScriptUpdatesIgnore {
"global-config"
}
# Use this for certificate auto-renew
-:global "cert-renew-url" "";
-#:global "cert-renew-url" "https://example.com/certificates/";
-:global "cert-renew-pass" "v3ry-s3cr3t";
+:global CertRenewUrl "";
+#:global CertRenewUrl "https://example.com/certificates/";
+:global CertRenewPass "v3ry-s3cr3t";
# Configuration for update-tunnelbroker
-#:global tunnelurl "ipv4.tunnelbroker.net";
-#:global tunneluser "user";
-#:global tunnelpass "v3ry-s3cr3t";
-#:global tunnelid "user-XXX.tunnel.tserv6.fra1.ipv6.he.net";
-#:global tunnelint "tunnelbroker";
+#:global TunnelUrl "ipv4.tunnelbroker.net";
+#:global TunnelUser "user";
+#:global TunnelPass "v3ry-s3cr3t";
+#:global TunnelId "user-XXX.tunnel.tserv6.fra1.ipv6.he.net";
+#:global TunnelInt "tunnelbroker";