mirror of
https://cgit.krebsco.de/krops
synced 2024-11-23 03:29:48 +01:00
runShell/writeCommand: add allocateTTY argument
This commit is contained in:
parent
c1b24328c4
commit
d80cb74c74
2 changed files with 11 additions and 4 deletions
|
@ -185,6 +185,10 @@ pkgs.krops.writeCommand "deploy-with-swap" {
|
||||||
|
|
||||||
[see `writeDeploy`](#writeDeploy)
|
[see `writeDeploy`](#writeDeploy)
|
||||||
|
|
||||||
|
### `allocateTTY` (optional, defaults to false)
|
||||||
|
|
||||||
|
whether the ssh session should do a pseudo-terminal allocation.
|
||||||
|
sets `-t` on the ssh command.
|
||||||
|
|
||||||
## Source Types
|
## Source Types
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,13 @@ in
|
||||||
{ nix, openssh, populate, writers }: rec {
|
{ nix, openssh, populate, writers }: rec {
|
||||||
|
|
||||||
rebuild = args: target:
|
rebuild = args: target:
|
||||||
runShell target "nixos-rebuild -I ${lib.escapeShellArg target.path} ${
|
runShell target {} "nixos-rebuild -I ${lib.escapeShellArg target.path} ${
|
||||||
lib.concatMapStringsSep " " lib.escapeShellArg args
|
lib.concatMapStringsSep " " lib.escapeShellArg args
|
||||||
}";
|
}";
|
||||||
|
|
||||||
runShell = target: command:
|
runShell = target: {
|
||||||
|
allocateTTY ? false
|
||||||
|
}: command:
|
||||||
let
|
let
|
||||||
command' = if target.sudo then "sudo ${command}" else command;
|
command' = if target.sudo then "sudo ${command}" else command;
|
||||||
in
|
in
|
||||||
|
@ -20,7 +22,7 @@ in
|
||||||
exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [
|
exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [
|
||||||
(lib.optionals (target.user != "") ["-l" target.user])
|
(lib.optionals (target.user != "") ["-l" target.user])
|
||||||
"-p" target.port
|
"-p" target.port
|
||||||
"-T"
|
(if allocateTTY then "-t" else "-T")
|
||||||
target.extraOptions
|
target.extraOptions
|
||||||
target.host
|
target.host
|
||||||
command'])}
|
command'])}
|
||||||
|
@ -30,6 +32,7 @@ in
|
||||||
command ? (targetPath: "echo ${targetPath}"),
|
command ? (targetPath: "echo ${targetPath}"),
|
||||||
backup ? false,
|
backup ? false,
|
||||||
force ? false,
|
force ? false,
|
||||||
|
allocateTTY ? false,
|
||||||
source,
|
source,
|
||||||
target
|
target
|
||||||
}: let
|
}: let
|
||||||
|
@ -38,7 +41,7 @@ in
|
||||||
writers.writeDash name ''
|
writers.writeDash name ''
|
||||||
set -efu
|
set -efu
|
||||||
${populate { inherit backup force source; target = target'; }}
|
${populate { inherit backup force source; target = target'; }}
|
||||||
${runShell target' (command target'.path)}
|
${runShell target' { inherit allocateTTY; } (command target'.path)}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
writeDeploy = name: {
|
writeDeploy = name: {
|
||||||
|
|
Loading…
Reference in a new issue