machines install: fix installation via tor
This commit is contained in:
@@ -38,6 +38,7 @@ class InstallOptions:
|
|||||||
update_hardware_config: HardwareConfig = HardwareConfig.NONE
|
update_hardware_config: HardwareConfig = HardwareConfig.NONE
|
||||||
password: str | None = None
|
password: str | None = None
|
||||||
identity_file: Path | None = None
|
identity_file: Path | None = None
|
||||||
|
use_tor: bool = False
|
||||||
|
|
||||||
|
|
||||||
@API.register
|
@API.register
|
||||||
@@ -135,22 +136,35 @@ def install_machine(opts: InstallOptions) -> None:
|
|||||||
if opts.debug:
|
if opts.debug:
|
||||||
cmd.append("--debug")
|
cmd.append("--debug")
|
||||||
cmd.append(target_host)
|
cmd.append(target_host)
|
||||||
|
if opts.use_tor:
|
||||||
run(
|
# nix copy does not support tor socks proxy
|
||||||
nix_shell(
|
# cmd.append("--ssh-option")
|
||||||
["nixpkgs#nixos-anywhere"],
|
# cmd.append("ProxyCommand=nc -x 127.0.0.1:9050 -X 5 %h %p")
|
||||||
cmd,
|
run(
|
||||||
),
|
nix_shell(
|
||||||
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
|
["nixpkgs#nixos-anywhere", "nixpkgs#tor"],
|
||||||
)
|
["torify", *cmd],
|
||||||
|
),
|
||||||
|
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
run(
|
||||||
|
nix_shell(
|
||||||
|
["nixpkgs#nixos-anywhere"],
|
||||||
|
cmd,
|
||||||
|
),
|
||||||
|
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def install_command(args: argparse.Namespace) -> None:
|
def install_command(args: argparse.Namespace) -> None:
|
||||||
host_key_check = HostKeyCheck.from_str(args.host_key_check)
|
host_key_check = HostKeyCheck.from_str(args.host_key_check)
|
||||||
try:
|
try:
|
||||||
machine = Machine(name=args.machine, flake=args.flake, nix_options=args.option)
|
machine = Machine(name=args.machine, flake=args.flake, nix_options=args.option)
|
||||||
|
use_tor = False
|
||||||
|
|
||||||
if args.flake is None:
|
if args.flake is None:
|
||||||
|
#
|
||||||
msg = "Could not find clan flake toplevel directory"
|
msg = "Could not find clan flake toplevel directory"
|
||||||
raise ClanError(msg)
|
raise ClanError(msg)
|
||||||
|
|
||||||
@@ -161,9 +175,10 @@ def install_command(args: argparse.Namespace) -> None:
|
|||||||
elif deploy_info:
|
elif deploy_info:
|
||||||
host = find_reachable_host(deploy_info, host_key_check)
|
host = find_reachable_host(deploy_info, host_key_check)
|
||||||
if host is None:
|
if host is None:
|
||||||
msg = f"Couldn't reach any host address: {deploy_info.addrs}"
|
use_tor = True
|
||||||
raise ClanError(msg)
|
target_host = f"root@{deploy_info.tor}"
|
||||||
target_host = host.target
|
else:
|
||||||
|
target_host = host.target
|
||||||
password = deploy_info.pwd
|
password = deploy_info.pwd
|
||||||
else:
|
else:
|
||||||
target_host = machine.target_host.target
|
target_host = machine.target_host.target
|
||||||
@@ -197,6 +212,7 @@ def install_command(args: argparse.Namespace) -> None:
|
|||||||
update_hardware_config=HardwareConfig(args.update_hardware_config),
|
update_hardware_config=HardwareConfig(args.update_hardware_config),
|
||||||
password=password,
|
password=password,
|
||||||
identity_file=args.identity_file,
|
identity_file=args.identity_file,
|
||||||
|
use_tor=use_tor,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
Reference in New Issue
Block a user