feat: el segundo disco no puede tener particiones

closes #6
This commit is contained in:
2026-05-21 10:55:24 -03:00
parent c58ffb9e4d
commit adb768fc30
+18 -4
View File
@@ -22,6 +22,20 @@ if test `cat $authorized_keys | wc -l` -eq 0; then
exit 1
fi
if test -z "$1"; then
not_ok "El primer parámetro tiene que ser un disco completo sin particiones"
exit 1
fi
disk=$1
for part in ${disk}?; do
if test -b "$part"; then
not_ok "El disco ${disk} contiene particiones, la instalación destruirá datos"
exit 1
fi
done
apt update
apt install -y dropbear-initramfs busybox-initramfs smartmontools git rsync make tinc dialog locales bash-completion gnutls-bin nano
@@ -61,12 +75,12 @@ NETWORK=comun ./rap install $HOSTNAME
if ! test -b /dev/mapper/dm_crypt-1 ; then
ok "Cifrando el disco, usa la misma contraseña de cifrado que usaste durante la instalación"
cryptsetup luksFormat /dev/sdb
cryptsetup luksFormat $disk
fi
if ! test -b /dev/mapper/dm_crypt-1 ; then
ok "Abriendo el disco cifrado"
cryptsetup open /dev/sdb dm_crypt-1
cryptsetup open $disk dm_crypt-1
fi
key_file=/etc/dm_crypt-1.key
@@ -76,11 +90,11 @@ if ! test -f "$key_file" ; then
dd bs=512 count=4 if=/dev/random iflag=fullblock | install -m 0600 /dev/stdin "$key_file"
ok "Asignando archivo de contraseña"
cryptsetup luksAddKey /dev/sdb /etc/dm_crypt-1.key
cryptsetup luksAddKey $disk /etc/dm_crypt-1.key
fi
if ! grep -q dm_crypt-1 /etc/crypttab ; then
uuid="`blkid /dev/sdb -o value -p | head -n2 | tail -n 1`"
uuid="`blkid $disk -o value -p | head -n2 | tail -n 1`"
ok "Agregando $uuid a /etc/crypttab"
echo "dm_crypt-1 UUID=$uuid /etc/dm_crypt-1.key luks" >> /etc/crypttab