mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect.git
synced 2024-11-22 12:01:27 +00:00
optional variables: NIXOS_CONFIG_ID and VOLUME_DEV_PATH
This commit is contained in:
parent
91073a50a3
commit
374711f324
35
nixos-infect
35
nixos-infect
|
@ -4,6 +4,7 @@
|
||||||
# - https://github.com/elitak/nixos-infect
|
# - https://github.com/elitak/nixos-infect
|
||||||
# - https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect
|
# - https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect
|
||||||
|
|
||||||
|
# mandatory variables
|
||||||
: "${API_TOKEN:?API_TOKEN variable is not set}"
|
: "${API_TOKEN:?API_TOKEN variable is not set}"
|
||||||
: "${CONFIG_URL:?CONFIG_URL variable is not set}"
|
: "${CONFIG_URL:?CONFIG_URL variable is not set}"
|
||||||
: "${DNS_PROVIDER_TOKEN:?DNS_PROVIDER_TOKEN variable is not set}"
|
: "${DNS_PROVIDER_TOKEN:?DNS_PROVIDER_TOKEN variable is not set}"
|
||||||
|
@ -12,12 +13,14 @@
|
||||||
: "${ENCODED_PASSWORD:?ENCODED_PASSWORD variable is not set}"
|
: "${ENCODED_PASSWORD:?ENCODED_PASSWORD variable is not set}"
|
||||||
: "${HOSTNAME:?HOSTNAME variable is not set}"
|
: "${HOSTNAME:?HOSTNAME variable is not set}"
|
||||||
: "${LUSER:?LUSER variable is not set}"
|
: "${LUSER:?LUSER variable is not set}"
|
||||||
: "${NIXOS_CONFIG_ID:?NIXOS_CONFIG_ID variable is not set}"
|
|
||||||
: "${NIX_VERSION:?NIX_VERSION variable is not set}"
|
: "${NIX_VERSION:?NIX_VERSION variable is not set}"
|
||||||
: "${PROVIDER:?PROVIDER variable is not set}"
|
: "${PROVIDER:?PROVIDER variable is not set}"
|
||||||
: "${STAGING_ACME:?STAGING_ACME variable is not set}"
|
: "${STAGING_ACME:?STAGING_ACME variable is not set}"
|
||||||
|
|
||||||
|
# optional variables
|
||||||
|
: "${NIXOS_CONFIG_ID:=default}"
|
||||||
: "${SSH_AUTHORIZED_KEY:=}"
|
: "${SSH_AUTHORIZED_KEY:=}"
|
||||||
|
: "${VOLUME_DEV_PATH:=}"
|
||||||
|
|
||||||
readonly NL=$'\n'
|
readonly NL=$'\n'
|
||||||
readonly LOCAL_FLAKE_DIR="/etc/nixos"
|
readonly LOCAL_FLAKE_DIR="/etc/nixos"
|
||||||
|
@ -34,20 +37,24 @@ EOF
|
||||||
|
|
||||||
# TODO receive disk device path from outside
|
# TODO receive disk device path from outside
|
||||||
determine2ndDisk() {
|
determine2ndDisk() {
|
||||||
local guess rootFsDev
|
local volDevPath rootFsDev
|
||||||
case "$PROVIDER" in
|
if [ -n "$VOLUME_DEV_PATH" ]; then
|
||||||
hetzner)
|
volDevPath="$VOLUME_DEV_PATH"
|
||||||
guess="/dev/sdb"
|
else
|
||||||
;;
|
case "$PROVIDER" in
|
||||||
digitalocean)
|
hetzner)
|
||||||
guess="/dev/sda"
|
volDevPath="/dev/sdb"
|
||||||
;;
|
;;
|
||||||
*)
|
digitalocean)
|
||||||
return 1
|
volDevPath="/dev/sda"
|
||||||
;;
|
;;
|
||||||
esac
|
*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
rootFsDev="$(findmnt -no source -T /)"
|
rootFsDev="$(findmnt -no source -T /)"
|
||||||
[[ -b "$guess" && "$guess" != "$rootFsDev" ]] && echo "$guess"
|
[[ -b "$volDevPath" && "$volDevPath" != "$rootFsDev" ]] && echo "$volDevPath"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Merge original userdata.json with deployment specific fields and print result.
|
# Merge original userdata.json with deployment specific fields and print result.
|
||||||
|
|
Loading…
Reference in a new issue