From cb40c94d581474fea89e1bb647b7308bb863f8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=BE=20=D0=93=D0=BB=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D1=8C=D0=BA=D0=B8=D0=B9=20=28Danylo=20Hlynskyi=29?= Date: Wed, 25 Jan 2017 01:39:15 +0200 Subject: [PATCH] support Hetzner vServer This tweaks nixos-infect to be allow infecting some Hetzner servers. Also, add some fallbacks (useful for debugging new backends) --- nixos-infect | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nixos-infect b/nixos-infect index 4b7e7fd..4ef674a 100755 --- a/nixos-infect +++ b/nixos-infect @@ -47,6 +47,9 @@ set -ex +export disk=$( (>/dev/null ls -l /dev/vda && echo vda) \ + || (>/dev/null ls -l /dev/sda && echo sda) ) + makeConf() { # NB <<"EOF" quotes / $ ` in heredocs, < ]; - boot.loader.grub.device = "/dev/vda"; - fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; + boot.loader.grub.device = "/dev/$disk"; + fileSystems."/" = { device = "/dev/${disk}1"; fsType = "ext4"; }; } EOF @@ -150,13 +153,14 @@ makeConf makeSwap # smallest (512MB) droplet needs extra memory! which dnf && dnf install -y perl-Digest-SHA # Fedora 24 +which bzcat || (which yum && yum install -y bzip2) # CentOS # DigitalOcean doesn't seem to set USER while running user data export USER="root" export HOME="/root" -groupadd -r nixbld -g 30000 -seq 1 10 | xargs -I{} useradd -c "Nix build user {}" -d /var/empty -g nixbld -G nixbld -M -N -r -s `which nologin` nixbld{} +groupadd -r nixbld -g 30000 || true +seq 1 10 | xargs -I{} useradd -c "Nix build user {}" -d /var/empty -g nixbld -G nixbld -M -N -r -s `which nologin` nixbld{} || true curl https://nixos.org/nix/install | sh @@ -190,7 +194,7 @@ etc/resolv.conf root/.nix-defexpr/channels EOF -mv -v /boot /boot.bak && +rm -rf /boot.bak && mv -v /boot /boot.bak && /nix/var/nix/profiles/system/bin/switch-to-configuration boot reboot