aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/bridge-port-to.rsc19
-rw-r--r--mod/bridge-port-vlan.rsc22
-rw-r--r--mod/notification-email.rsc12
-rw-r--r--mod/notification-matrix.rsc41
-rw-r--r--mod/notification-ntfy.rsc15
-rw-r--r--mod/notification-telegram.rsc15
-rw-r--r--mod/scriptrunonce.rsc13
-rw-r--r--mod/ssh-keys-import.rsc37
8 files changed, 96 insertions, 78 deletions
diff --git a/mod/bridge-port-to.rsc b/mod/bridge-port-to.rsc
index a78f31b..441094f 100644
--- a/mod/bridge-port-to.rsc
+++ b/mod/bridge-port-to.rsc
@@ -12,7 +12,7 @@
:local BridgePortTo [ :tostr $1 ];
:global IfThenElse;
- :global LogPrintExit2;
+ :global LogPrint;
:global ParseKeyValueStore;
:local InterfaceReEnable ({});
@@ -24,21 +24,22 @@
:if ($BridgeDefault = "dhcp-client") do={
:if ([ :len $DHCPClient ] != 1) do={
- $LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
- " dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true;
+ $LogPrint warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
+ " dhcp client configuration for interface " . $BridgePortVal->"interface" . "!");
+ :error false;
}
:local DHCPClientDisabled [ /ip/dhcp-client/get $DHCPClient disabled ];
:if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={
- $LogPrintExit2 info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false;
+ $LogPrint info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.");
/interface/bridge/port/disable $BridgePort;
:delay 200ms;
/ip/dhcp-client/enable $DHCPClient;
}
} else={
:if ($BridgePortVal->"disabled" = true || $BridgeDefault != $BridgePortVal->"bridge") do={
- $LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $BridgePortTo . \
- " bridge " . $BridgeDefault . ", disabling dhcp client.") false;
+ $LogPrint info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $BridgePortTo . \
+ " bridge " . $BridgeDefault . ", disabling dhcp client.");
:if ([ :len $DHCPClient ] = 1) do={
/ip/dhcp-client/disable $DHCPClient;
:delay 200ms;
@@ -50,8 +51,8 @@
}
/interface/bridge/port/set disabled=no bridge=$BridgeDefault $BridgePort;
} else={
- $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \
- " bridge " . $BridgeDefault . ".") false;
+ $LogPrint debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \
+ " bridge " . $BridgeDefault . ".");
}
}
}
@@ -59,7 +60,7 @@
}
:if ([ :len $InterfaceReEnable ] > 0) do={
:delay 5s;
- $LogPrintExit2 info $0 ("Re-enabling interfaces...") false;
+ $LogPrint info $0 ("Re-enabling interfaces...");
/interface/ethernet/enable $InterfaceReEnable;
}
}
diff --git a/mod/bridge-port-vlan.rsc b/mod/bridge-port-vlan.rsc
index 72cf772..522e9a6 100644
--- a/mod/bridge-port-vlan.rsc
+++ b/mod/bridge-port-vlan.rsc
@@ -12,7 +12,7 @@
:local ConfigTo [ :tostr $1 ];
:global IfThenElse;
- :global LogPrintExit2;
+ :global LogPrint;
:global ParseKeyValueStore;
:local InterfaceReEnable ({});
@@ -24,13 +24,14 @@
:if ($Vlan = "dhcp-client") do={
:if ([ :len $DHCPClient ] != 1) do={
- $LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
- " dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true;
+ $LogPrint warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
+ " dhcp client configuration for interface " . $BridgePortVal->"interface" . "!");
+ :error false;
}
:local DHCPClientDisabled [ /ip/dhcp-client/get $DHCPClient disabled ];
:if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={
- $LogPrintExit2 info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false;
+ $LogPrint info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.");
/interface/bridge/port/disable $BridgePort;
:delay 200ms;
/ip/dhcp-client/enable $DHCPClient;
@@ -41,12 +42,13 @@
:do {
:set $Vlan ([ /interface/bridge/vlan/get [ find where comment=$Vlan ] vlan-ids ]->0);
} on-error={
- $LogPrintExit2 warning $0 ("Could not find VLAN '" . $Vlan . "' for interface " . $BridgePortVal->"interface" . "!") true;
+ $LogPrint warning $0 ("Could not find VLAN '" . $Vlan . "' for interface " . $BridgePortVal->"interface" . "!");
+ :error false;
}
}
:if ($BridgePortVal->"disabled" = true || $Vlan != $BridgePortVal->"pvid") do={
- $LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $ConfigTo . \
- " vlan " . $Vlan . [ $IfThenElse ($Vlan != $VlanName) (" (" . $VlanName . ")") ] . ", disabling dhcp client.") false;
+ $LogPrint info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $ConfigTo . \
+ " vlan " . $Vlan . [ $IfThenElse ($Vlan != $VlanName) (" (" . $VlanName . ")") ] . ", disabling dhcp client.");
:if ([ :len $DHCPClient ] = 1) do={
/ip/dhcp-client/disable $DHCPClient;
:delay 200ms;
@@ -58,8 +60,8 @@
}
/interface/bridge/port/set disabled=no pvid=$Vlan $BridgePort;
} else={
- $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $ConfigTo . \
- " vlan " . $Vlan . ".") false;
+ $LogPrint debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $ConfigTo . \
+ " vlan " . $Vlan . ".");
}
}
}
@@ -67,7 +69,7 @@
}
:if ([ :len $InterfaceReEnable ] > 0) do={
:delay 5s;
- $LogPrintExit2 info $0 ("Re-enabling interfaces...") false;
+ $LogPrint info $0 ("Re-enabling interfaces...");
/interface/ethernet/enable $InterfaceReEnable;
}
}
diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc
index 88bfdac..78192f3 100644
--- a/mod/notification-email.rsc
+++ b/mod/notification-email.rsc
@@ -24,7 +24,7 @@
:global EitherOr;
:global IsDNSResolving;
:global IsTimeSync;
- :global LogPrintExit2;
+ :global LogPrint;
:local AllDone true;
:local QueueLen [ :len $EmailQueue ];
@@ -35,23 +35,23 @@
}
:if ([ /tool/e-mail/get last-status ] = "in-progress") do={
- $LogPrintExit2 debug $0 ("Sending mail is currently in progress, not flushing.") false;
+ $LogPrint debug $0 ("Sending mail is currently in progress, not flushing.");
:return false;
}
:if ([ $IsTimeSync ] = false) do={
- $LogPrintExit2 debug $0 ("Time is not synced, not flushing.") false;
+ $LogPrint debug $0 ("Time is not synced, not flushing.");
:return false;
}
:local EMailSettings [ /tool/e-mail/get ];
:if ([ :typeof [ :toip ($EMailSettings->"server") ] ] != "ip" && [ $IsDNSResolving ] = false) do={
- $LogPrintExit2 debug $0 ("Server address is a DNS name and resolving fails, not flushing.") false;
+ $LogPrint debug $0 ("Server address is a DNS name and resolving fails, not flushing.");
:return false;
}
:if ([ :len $Scheduler ] > 0 && $QueueLen = 0) do={
- $LogPrintExit2 warning $0 ("Flushing E-Mail messages from scheduler, but queue is empty.") false;
+ $LogPrint warning $0 ("Flushing E-Mail messages from scheduler, but queue is empty.");
}
/system/scheduler/set interval=([ $EitherOr $QueueLen 1 ] . "m") comment="Sending..." $Scheduler;
@@ -64,7 +64,7 @@
:if ([ :len [ /file/find where name=$File ] ] = 1) do={
:set Attach ($Attach, $File);
} else={
- $LogPrintExit2 warning $0 ("File '" . $File . "' does not exist, can not attach.") false;
+ $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach.");
}
}
/tool/e-mail/send to=($Message->"to") cc=($Message->"cc") subject=($Message->"subject") \
diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc
index 8884b08..c4fe100 100644
--- a/mod/notification-matrix.rsc
+++ b/mod/notification-matrix.rsc
@@ -20,10 +20,10 @@
:global MatrixQueue;
:global IsFullyConnected;
- :global LogPrintExit2;
+ :global LogPrint;
:if ([ $IsFullyConnected ] = false) do={
- $LogPrintExit2 debug $0 ("System is not fully connected, not flushing.") false;
+ $LogPrint debug $0 ("System is not fully connected, not flushing.");
:return false;
}
@@ -31,7 +31,7 @@
:local QueueLen [ :len $MatrixQueue ];
:if ([ :len [ /system/scheduler/find where name="_FlushMatrixQueue" ] ] > 0 && $QueueLen = 0) do={
- $LogPrintExit2 warning $0 ("Flushing Matrix messages from scheduler, but queue is empty.") false;
+ $LogPrint warning $0 ("Flushing Matrix messages from scheduler, but queue is empty.");
}
:foreach Id,Message in=$MatrixQueue do={
@@ -45,7 +45,7 @@
$Message->"formatted" . "\" }") as-value;
:set ($MatrixQueue->$Id);
} on-error={
- $LogPrintExit2 debug $0 ("Sending queued Matrix message failed.") false;
+ $LogPrint debug $0 ("Sending queued Matrix message failed.");
:set AllDone false;
}
}
@@ -72,7 +72,7 @@
:global MatrixRoomOverride;
:global EitherOr;
- :global LogPrintExit2;
+ :global LogPrint;
:global SymbolForNotification;
:local PrepareText do={
@@ -134,7 +134,7 @@
"\"format\": \"org.matrix.custom.html\", \"formatted_body\": \"" . \
$Formatted . "\" }") as-value;
} on-error={
- $LogPrintExit2 info $0 ("Failed sending Matrix notification! Queuing...") false;
+ $LogPrint info $0 ("Failed sending Matrix notification! Queuing...");
:if ([ :typeof $MatrixQueue ] = "nothing") do={
:set MatrixQueue ({});
@@ -184,7 +184,7 @@
:local Pass [ :tostr $2 ];
:global CharacterReplace;
- :global LogPrintExit2;
+ :global LogPrint;
:global ParseJson;
:global MatrixAccessToken;
@@ -195,9 +195,10 @@
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
("https://" . $Domain . "/.well-known/matrix/client") as-value ]->"data");
:set MatrixHomeServer ([ $ParseJson ([ $ParseJson [ $CharacterReplace $Data " " "" ] ]->"m.homeserver") ]->"base_url");
- $LogPrintExit2 debug $0 ("Home server is: " . $MatrixHomeServer) false;
+ $LogPrint debug $0 ("Home server is: " . $MatrixHomeServer);
} on-error={
- $LogPrintExit2 error $0 ("Failed getting home server!") true;
+ $LogPrint error $0 ("Failed getting home server!");
+ :error false;
}
:if ([ :pick $MatrixHomeServer 0 8 ] = "https://") do={
@@ -209,18 +210,20 @@
http-method=post http-data=("{\"type\":\"m.login.password\", \"user\":\"" . $User . "\", \"password\":\"" . $Pass . "\"}") \
("https://" . $MatrixHomeServer . "/_matrix/client/r0/login") as-value ]->"data");
:set MatrixAccessToken ([ $ParseJson $Data ]->"access_token");
- $LogPrintExit2 debug $0 ("Access token is: " . $MatrixAccessToken) false;
+ $LogPrint debug $0 ("Access token is: " . $MatrixAccessToken);
} on-error={
- $LogPrintExit2 error $0 ("Failed logging in (and getting access token)!") true;
+ $LogPrint error $0 ("Failed logging in (and getting access token)!");
+ :error false;
}
:do {
/system/script/set global-config-overlay source=([ get global-config-overlay source ] . "\n" . \
":global MatrixHomeServer \"" . $MatrixHomeServer . "\";\n" . \
":global MatrixAccessToken \"" . $MatrixAccessToken . "\";\n");
- $LogPrintExit2 info $0 ("Appended configuration to global-config-overlay. Now create and join a room, please!") false;
+ $LogPrint info $0 ("Appended configuration to global-config-overlay. Now create and join a room, please!");
} on-error={
- $LogPrintExit2 error $0 ("Failed appending configuration to global-config-overlay!") true;
+ $LogPrint error $0 ("Failed appending configuration to global-config-overlay!");
+ :error false;
}
}
@@ -228,7 +231,7 @@
:set SetupMatrixJoinRoom do={
:global MatrixRoom [ :tostr $1 ];
- :global LogPrintExit2;
+ :global LogPrint;
:global UrlEncode;
:global MatrixAccessToken;
@@ -240,16 +243,18 @@
http-method=post http-data="" \
("https://" . $MatrixHomeServer . "/_matrix/client/r0/rooms/" . [ $UrlEncode $MatrixRoom ] . \
"/join?access_token=" . [ $UrlEncode $MatrixAccessToken ]) as-value;
- $LogPrintExit2 debug $0 ("Joined the room.") false;
+ $LogPrint debug $0 ("Joined the room.");
} on-error={
- $LogPrintExit2 error $0 ("Failed joining the room!") true;
+ $LogPrint error $0 ("Failed joining the room!");
+ :error false;
}
:do {
/system/script/set global-config-overlay source=([ get global-config-overlay source ] . "\n" . \
":global MatrixRoom \"" . $MatrixRoom . "\";\n");
- $LogPrintExit2 info $0 ("Appended configuration to global-config-overlay. Please review and cleanup!") false;
+ $LogPrint info $0 ("Appended configuration to global-config-overlay. Please review and cleanup!");
} on-error={
- $LogPrintExit2 error $0 ("Failed appending configuration to global-config-overlay!") true;
+ $LogPrint error $0 ("Failed appending configuration to global-config-overlay!");
+ :error false;
}
}
diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc
index 4dc6d84..6d48a59 100644
--- a/mod/notification-ntfy.rsc
+++ b/mod/notification-ntfy.rsc
@@ -18,10 +18,10 @@
:global NtfyMessageIDs;
:global IsFullyConnected;
- :global LogPrintExit2;
+ :global LogPrint;
:if ([ $IsFullyConnected ] = false) do={
- $LogPrintExit2 debug $0 ("System is not fully connected, not flushing.") false;
+ $LogPrint debug $0 ("System is not fully connected, not flushing.");
:return false;
}
@@ -29,7 +29,7 @@
:local QueueLen [ :len $NtfyQueue ];
:if ([ :len [ /system/scheduler/find where name="_FlushNtfyQueue" ] ] > 0 && $QueueLen = 0) do={
- $LogPrintExit2 warning $0 ("Flushing Ntfy messages from scheduler, but queue is empty.") false;
+ $LogPrint warning $0 ("Flushing Ntfy messages from scheduler, but queue is empty.");
}
:foreach Id,Message in=$NtfyQueue do={
@@ -39,7 +39,7 @@
($Message->"url") http-header-field=($Message->"headers") http-data=($Message->"text") as-value;
:set ($NtfyQueue->$Id);
} on-error={
- $LogPrintExit2 debug $0 ("Sending queued Ntfy message failed.") false;
+ $LogPrint debug $0 ("Sending queued Ntfy message failed.");
:set AllDone false;
}
}
@@ -66,7 +66,7 @@
:global CertificateAvailable;
:global EitherOr;
:global IfThenElse;
- :global LogPrintExit2;
+ :global LogPrint;
:global SymbolForNotification;
:global UrlEncode;
@@ -88,13 +88,14 @@
:do {
:if ($NtfyServer = "ntfy.sh") do={
:if ([ $CertificateAvailable "R3" ] = false) do={
- $LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
+ $LogPrint warning $0 ("Downloading required certificate failed.");
+ :error false;
}
}
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
$Url http-header-field=$Headers http-data=$Text as-value;
} on-error={
- $LogPrintExit2 info $0 ("Failed sending ntfy notification! Queuing...") false;
+ $LogPrint info $0 ("Failed sending ntfy notification! Queuing...");
:if ([ :typeof $NtfyQueue ] = "nothing") do={
:set NtfyQueue ({});
diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc
index 5b79135..506ec80 100644
--- a/mod/notification-telegram.rsc
+++ b/mod/notification-telegram.rsc
@@ -18,12 +18,12 @@
:global TelegramMessageIDs;
:global IsFullyConnected;
- :global LogPrintExit2;
+ :global LogPrint;
:global ParseJson;
:global UrlEncode;
:if ([ $IsFullyConnected ] = false) do={
- $LogPrintExit2 debug $0 ("System is not fully connected, not flushing.") false;
+ $LogPrint debug $0 ("System is not fully connected, not flushing.");
:return false;
}
@@ -31,7 +31,7 @@
:local QueueLen [ :len $TelegramQueue ];
:if ([ :len [ /system/scheduler/find where name="_FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={
- $LogPrintExit2 warning $0 ("Flushing Telegram messages from scheduler, but queue is empty.") false;
+ $LogPrint warning $0 ("Flushing Telegram messages from scheduler, but queue is empty.");
}
:foreach Id,Message in=$TelegramQueue do={
@@ -45,7 +45,7 @@
:set ($TelegramQueue->$Id);
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
} on-error={
- $LogPrintExit2 debug $0 ("Sending queued Telegram message failed.") false;
+ $LogPrint debug $0 ("Sending queued Telegram message failed.");
:set AllDone false;
}
}
@@ -74,7 +74,7 @@
:global CharacterReplace;
:global EitherOr;
:global IfThenElse;
- :global LogPrintExit2;
+ :global LogPrint;
:global ParseJson;
:global SymbolForNotification;
:global UrlEncode;
@@ -136,7 +136,8 @@
:do {
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={
- $LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
+ $LogPrint warning $0 ("Downloading required certificate failed.");
+ :error false;
}
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user http-method=post \
("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \
@@ -145,7 +146,7 @@
"&parse_mode=MarkdownV2&text=" . [ $UrlEncode $Text ]) as-value ]->"data");
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
} on-error={
- $LogPrintExit2 info $0 ("Failed sending telegram notification! Queuing...") false;
+ $LogPrint info $0 ("Failed sending telegram notification! Queuing...");
:if ([ :typeof $TelegramQueue ] = "nothing") do={
:set TelegramQueue ({});
diff --git a/mod/scriptrunonce.rsc b/mod/scriptrunonce.rsc
index 38348a0..ffb1aff 100644
--- a/mod/scriptrunonce.rsc
+++ b/mod/scriptrunonce.rsc
@@ -15,13 +15,14 @@
:global ScriptRunOnceBaseUrl;
:global ScriptRunOnceUrlSuffix;
- :global LogPrintExit2;
+ :global LogPrint;
:global ValidateSyntax;
:foreach Script in=$Scripts do={
:if (!($Script ~ "^(ftp|https?|sftp)://")) do={
:if ([ :len $ScriptRunOnceBaseUrl ] = 0) do={
- $LogPrintExit2 warning $0 ("Script '" . $Script . "' is not an url and base url is not available.") true;
+ $LogPrint warning $0 ("Script '" . $Script . "' is not an url and base url is not available.");
+ :error false;
}
:set Script ($ScriptRunOnceBaseUrl . $Script . ".rsc" . $ScriptRunOnceUrlSuffix);
}
@@ -30,19 +31,19 @@
:do {
:set Source ([ /tool/fetch check-certificate=yes-without-crl $Script output=user as-value ]->"data");
} on-error={
- $LogPrintExit2 warning $0 ("Failed fetching script '" . $Script . "'!") false;
+ $LogPrint warning $0 ("Failed fetching script '" . $Script . "'!");
}
:if ([ :len $Source ] > 0) do={
:if ([ $ValidateSyntax $Source ] = true) do={
:do {
- $LogPrintExit2 info $0 ("Running script '" . $Script . "' now.") false;
+ $LogPrint info $0 ("Running script '" . $Script . "' now.");
[ :parse $Source ];
} on-error={
- $LogPrintExit2 warning $0 ("The script '" . $Script . "' failed to run!") false;
+ $LogPrint warning $0 ("The script '" . $Script . "' failed to run!");
}
} else={
- $LogPrintExit2 warning $0 ("The script '" . $Script . "' failed syntax validation!") false;
+ $LogPrint warning $0 ("The script '" . $Script . "' failed syntax validation!");
}
}
}
diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc
index b88ef9a..fbc667e 100644
--- a/mod/ssh-keys-import.rsc
+++ b/mod/ssh-keys-import.rsc
@@ -18,32 +18,36 @@
:global CharacterReplace;
:global GetRandom20CharAlNum;
- :global LogPrintExit2;
+ :global LogPrint;
:global MkDir;
:global WaitForFile;
:if ([ :len $Key ] = 0 || [ :len $User ] = 0) do={
- $LogPrintExit2 warning $0 ("Missing argument(s), please pass key and user!") true;
+ $LogPrint warning $0 ("Missing argument(s), please pass key and user!");
+ :error false;
}
:if ([ :len [ /user/find where name=$User ] ] = 0) do={
- $LogPrintExit2 warning $0 ("User '" . $User . "' does not exist.") true;
+ $LogPrint warning $0 ("User '" . $User . "' does not exist.");
+ :error false;
}
:local KeyVal [ :toarray [ $CharacterReplace $Key " " "," ] ];
:if (!($KeyVal->0 = "ssh-ed25519" || $KeyVal->0 = "ssh-rsa")) do={
- $LogPrintExit2 warning $0 ("SSH key of type '" . $KeyVal->0 . "' is not supported.") true;
+ $LogPrint warning $0 ("SSH key of type '" . $KeyVal->0 . "' is not supported.");
+ :error false;
}
:if ([ $MkDir "tmpfs/ssh-keys-import" ] = false) do={
- $LogPrintExit2 warning $0 ("Creating directory 'tmpfs/ssh-keys-import' failed!") true;
+ $LogPrint warning $0 ("Creating directory 'tmpfs/ssh-keys-import' failed!");
+ :error false;
}
:local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex ($KeyVal->1) ];
:if ([ :len [ /user/ssh-keys/find where user=$User key-owner~("\\bmd5=" . $FingerPrintMD5 . "\\b") ] ] > 0) do={
- $LogPrintExit2 warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \
- ") is already available for user '" . $User . "'.") false;
+ $LogPrint warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \
+ ") is already available for user '" . $User . "'.");
:return false;
}
@@ -53,10 +57,11 @@
:do {
/user/ssh-keys/import public-key-file=$FileName user=$User;
- $LogPrintExit2 info $0 ("Imported ssh public key (" . $KeyVal->2 . ", " . $KeyVal->0 . ", " . \
- "MD5:" . $FingerPrintMD5 . ") for user '" . $User . "'.") false;
+ $LogPrint info $0 ("Imported ssh public key (" . $KeyVal->2 . ", " . $KeyVal->0 . ", " . \
+ "MD5:" . $FingerPrintMD5 . ") for user '" . $User . "'.");
} on-error={
- $LogPrintExit2 warning $0 ("Failed importing key.") true;
+ $LogPrint warning $0 ("Failed importing key.");
+ :error false;
}
}
@@ -67,17 +72,19 @@
:global CharacterReplace;
:global EitherOr;
- :global LogPrintExit2;
+ :global LogPrint;
:global ParseKeyValueStore;
:global SSHKeysImport;
:if ([ :len $FileName ] = 0 || [ :len $User ] = 0) do={
- $LogPrintExit2 warning $0 ("Missing argument(s), please pass file name and user!") true;
+ $LogPrint warning $0 ("Missing argument(s), please pass file name and user!");
+ :error false;
}
:local File [ /file/find where name=$FileName ];
:if ([ :len $File ] = 0) do={
- $LogPrintExit2 warning $0 ("File '" . $FileName . "' does not exist.") true;
+ $LogPrint warning $0 ("File '" . $FileName . "' does not exist.");
+ :error false;
}
:local Keys ([ /file/get $FileName contents ] . "\n");
@@ -90,7 +97,7 @@
:do {
$SSHKeysImport $Line $User;
} on-error={
- $LogPrintExit2 warning $0 ("Failed importing key for user '" . $User . "'.") false;
+ $LogPrint warning $0 ("Failed importing key for user '" . $User . "'.");
}
:set Continue true;
}
@@ -99,7 +106,7 @@
:set Continue true;
}
:if ($Continue = false && [ :len ($KeyVal->0) ] > 0) do={
- $LogPrintExit2 warning $0 ("SSH key of type '" . $KeyVal->0 . "' is not supported.") false;
+ $LogPrint warning $0 ("SSH key of type '" . $KeyVal->0 . "' is not supported.");
}
} while=([ :len $Keys ] > 0);
}