Skip to content

Commit

Permalink
fix reference to obsolete jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Jan 10, 2016
1 parent c187e87 commit 49824e2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
8 changes: 3 additions & 5 deletions nix/ssh-tunnel.nix
Expand Up @@ -69,15 +69,13 @@ with lib;
wantedBy = [ "network.target" ];
};

jobs = flip mapAttrs' config.networking.p2pTunnels.ssh (n: v: nameValuePair "ssh-tunnel-${n}" {
systemd.services = flip mapAttrs' config.networking.p2pTunnels.ssh (n: v: nameValuePair "ssh-tunnel-${n}" {
wantedBy = [ "multi-user.target" "encrypted-links.target" ];
partOf = [ "encrypted-links.target" ];
startOn = "started network-interfaces";
stopOn = "stopping network-interfaces";
after = [ "network-interfaces.target" ];
path = [ pkgs.nettools pkgs.openssh ];
preStart = "sleep 1"; # FIXME: hack to work around Upstart
# FIXME: ensure that the remote tunnel device is free
exec =
script =
"ssh -i ${v.privateKey} -x"
+ " -o StrictHostKeyChecking=no -o PermitLocalCommand=yes -o ServerAliveInterval=20"
+ " -o LocalCommand='ifconfig tun${toString v.localTunnel} ${v.localIPv4} pointopoint ${v.remoteIPv4} netmask 255.255.255.255; route add ${v.remoteIPv4}/32 dev tun${toString v.localTunnel}'"
Expand Down
39 changes: 19 additions & 20 deletions nix/virtualbox-image-nixops.nix
Expand Up @@ -10,26 +10,25 @@ in

services.openssh.enable = true;

jobs.get-vbox-nixops-client-key =
{ description = "Get NixOps SSH Key";
wantedBy = [ "multi-user.target" ];
before = [ "sshd.service" ];
requires = [ "dev-vboxguest.device" ];
after = [ "dev-vboxguest.device" ];
path = [ config.boot.kernelPackages.virtualboxGuestAdditions ];
preStart =
''
set -o pipefail
VBoxControl -nologo guestproperty get /VirtualBox/GuestInfo/Charon/ClientPublicKey | sed 's/Value: //' > ${clientKeyPath}.tmp
mv ${clientKeyPath}.tmp ${clientKeyPath}
if [[ ! -f /etc/ssh/ssh_host_ed25519_key ]]; then
VBoxControl -nologo guestproperty get /VirtualBox/GuestInfo/NixOps/PrivateHostEd25519Key | sed 's/Value: //' > /etc/ssh/ssh_host_ed25519_key.tmp
mv /etc/ssh/ssh_host_ed25519_key.tmp /etc/ssh/ssh_host_ed25519_key
chmod 0600 /etc/ssh/ssh_host_ed25519_key
fi
'';
};
systemd.services.get-vbox-nixops-client-key = {
description = "Get NixOps SSH Key";
wantedBy = [ "multi-user.target" ];
before = [ "sshd.service" ];
requires = [ "dev-vboxguest.device" ];
after = [ "dev-vboxguest.device" ];
path = [ config.boot.kernelPackages.virtualboxGuestAdditions ];
preStart = ''
set -o pipefail
VBoxControl -nologo guestproperty get /VirtualBox/GuestInfo/Charon/ClientPublicKey | sed 's/Value: //' > ${clientKeyPath}.tmp
mv ${clientKeyPath}.tmp ${clientKeyPath}
if [[ ! -f /etc/ssh/ssh_host_ed25519_key ]]; then
VBoxControl -nologo guestproperty get /VirtualBox/GuestInfo/NixOps/PrivateHostEd25519Key | sed 's/Value: //' > /etc/ssh/ssh_host_ed25519_key.tmp
mv /etc/ssh/ssh_host_ed25519_key.tmp /etc/ssh/ssh_host_ed25519_key
chmod 0600 /etc/ssh/ssh_host_ed25519_key
fi
'';
};

services.openssh.authorizedKeysFiles = [ ".vbox-nixops-client-key" ];

Expand Down

0 comments on commit 49824e2

Please sign in to comment.