summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMilan Pässler <me@pbb.lc>2019-11-29 12:34:31 +0100
committerMilan Pässler <me@pbb.lc>2019-11-29 12:56:03 +0100
commitcd215753338c9e077516deabac11735dfb624f06 (patch)
treea31a177d0c333b4144de0e6650a72ebc2a5c7101 /lib
parent2e94e6eb24eec23075e5925f8de7468b3489d4fb (diff)
ssh, rsync: support using sudo on remote
This allows deployment of remote hosts without having ssh access to the root user. Passwordless sudo is recommended since krops will use multiple ssh sessions and the password will not be remembered. Closes https://github.com/krebs/krops/issues/3
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 48e005e..bed284d 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -46,12 +46,13 @@ let {
default = defVal: val: if val != null then val else defVal;
parse = lib.match "(([^@]+)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;
elemAt' = xs: i: if lib.length xs > i then lib.elemAt xs i else null;
- in {
+ in if lib.isString s then {
user = default (lib.getEnv "LOGNAME") (elemAt' parse 1);
host = default (lib.maybeEnv "HOSTNAME" lib.getHostName) (elemAt' parse 3);
port = default "22" /* "ssh"? */ (elemAt' parse 5);
path = default "/var/src" /* no default? */ (elemAt' parse 6);
- };
+ sudo = false;
+ } else s;
shell = let
isSafeChar = lib.testString "[-+./0-9:=A-Z_a-z]";