Update nixos-infect (#38)

Fix both issues cited in this [comment](https://github.com/elitak/nixos-infect/issues/18#issuecomment-508904427)
This commit is contained in:
le Duc Banal 2019-07-07 19:09:47 +02:00 committed by Eric Litak
parent 6c6e63594d
commit d28f8f9679
1 changed files with 3 additions and 2 deletions

View File

@ -9,7 +9,8 @@ makeConf() {
[[ -e /etc/nixos/configuration.nix ]] && return 0
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
mkdir -p /etc/nixos
local IFS=$'\n'; keys=($(grep -vE '^[[:space:]]*(#|$)' /root/.ssh/authorized_keys))
# Prevent grep for sending error code 1 (and halting execution) when no lines are selected : https://www.unix.com/man-page/posix/1P/grep
local IFS=$'\n'; keys=($(grep -vE '^[[:space:]]*(#|$)' /root/.ssh/authorized_keys || [[ $? == 1 ]]))
local network_import=""
[ "$PROVIDER" = "digitalocean" ] && network_import="./networking.nix # generated at runtime by nixos-infect"
@ -191,7 +192,7 @@ checkEnv() {
# Perform some easy fixups before checking
which dnf && dnf install -y perl-Digest-SHA # Fedora 24
which bzcat || (which yum && yum install -y bzip2) \
|| (which apt-get && apt-get install bzip2) \
|| (which apt-get && apt-get update && apt-get install -y bzip2) \
|| true
[[ "$(whoami)" == "root" ]] || { echo "ERROR: Must run as root"; return 1; }