TEST
This commit is contained in:
@@ -377,10 +377,11 @@ disk_config_generation() {
|
||||
num_parity=0
|
||||
num_content=0
|
||||
|
||||
if (( num_selected == 1 )); then
|
||||
if (( num_selected == 1 )); then # If only one data disk is selected, it is a content disk
|
||||
num_content=1
|
||||
num_parity=0
|
||||
elif (( num_selected > 1 )); then
|
||||
elif (( num_selected > 1 )); then # If more than one data disk is selected
|
||||
# 1 parity for up to 2 content disks.
|
||||
num_parity=$(( (num_selected + 2) / 3 ))
|
||||
num_content=$(( num_selected - num_parity ))
|
||||
fi
|
||||
@@ -484,7 +485,7 @@ EOF
|
||||
|
||||
# --> Generate automatic unlock configuration in ./nix-config/disks/snapraid.nix
|
||||
if [[ "$NUMBER_OF_CONTENT_DISKS" -gt 0 || "$NUMBER_OF_PARITY_DISKS" -gt 0 ]]; then
|
||||
echo -e "\n\n ✅ Adding automatic disk unlocking configuration to './nix-config/disks/snapraid.nix'..."
|
||||
echo -e "\n\n ✅ Generating automatic disk unlocking configuration..."
|
||||
sed -i '$ d' ./nix-config/disks/snapraid.nix
|
||||
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
@@ -492,25 +493,30 @@ EOF
|
||||
boot.initrd.luks.devices = {
|
||||
EOF
|
||||
|
||||
for i in $(seq 1 $NUMBER_OF_CONTENT_DISKS); do
|
||||
disk_var="CONTENT_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
if [[ "$NUMBER_OF_CONTENT_DISKS" -gt 0 ]]; then
|
||||
for i in $(seq 1 $NUMBER_OF_CONTENT_DISKS); do
|
||||
disk_var="CONTENT_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
"crypted-content-disk-${i}" = {
|
||||
device = "${!disk_var}";
|
||||
keyFile = "/etc/secrets/disks/content-disk-${i}";
|
||||
};
|
||||
EOF
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
for i in $(seq 1 $NUMBER_OF_PARITY_DISKS); do
|
||||
disk_var="PARITY_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
if [[ "$NUMBER_OF_PARITY_DISKS" -gt 0 ]]; then
|
||||
for i in $(seq 1 $NUMBER_OF_PARITY_DISKS); do
|
||||
disk_var="PARITY_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
"crypted-parity-disk-${i}" = {
|
||||
device = "${!disk_var}";
|
||||
keyFile = "/etc/secrets/disks/parity-disk-${i}";
|
||||
};
|
||||
EOF
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
cat <<'EOF' >> ./nix-config/disks/snapraid.nix
|
||||
# Automatic data disks unlock <--
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user