This commit is contained in:
teldra 2022-02-07 15:07:41 +01:00
parent ed5bc28ec5
commit b2cc80a615
2 changed files with 18 additions and 23 deletions

41
main.sh
View File

@ -19,7 +19,7 @@ target_phy_disk() {
header "Choose target disk"
local DISKS_DETAILS
local output
DISKS_DETAILS=$(lsblk -l -o KNAME,TYPE,SIZE,MODEL,WWN|grep disk)
DISKS_DETAILS=$(lsblk -l -o KNAME,TYPE,SIZE,MODEL|grep disk)
echo "$DISKS_DETAILS"
multiplechoice $(echo "${DISKS_DETAILS}"|awk '{print $1}')
TARGET_PHY_DISK="/dev/${output}"
@ -27,15 +27,10 @@ target_phy_disk() {
target_phy_id() {
local i
local f1
local f2
for i in $(find /dev/disk/by-id|grep -v part); do
if realpath "$i" | grep -q -i "$TARGET_PHY_DISK"; then
if echo "$i" | grep -q "wwn"; then
TARGET_PHY_WWN="$i"
f1=1
fi
if echo "$i" | grep -q -v "wwn"; then
if echo "$i" | grep -q -v "wwn" | grep -q -v "eui"; then
TARGET_PHY_ID="$i"
f2=1
fi
@ -93,36 +88,36 @@ do_partition() {
header "do partition"
start=1
if [ "$EFI" == "1" ]; then
parted -a optimal $TARGET_PHY_WWN -s -- mklabel gpt
parted -a optimal $TARGET_PHY_ID -s -- mklabel gpt
size=500
parted -a optimal $TARGET_PHY_WWN unit mib -s -- mkpart EFI fat32 $start $(( start + size ))
parted -a optimal $TARGET_PHY_ID unit mib -s -- mkpart EFI fat32 $start $(( start + size ))
sleep 2
start=$(( start + size ))
parted -a optimal $TARGET_PHY_WWN unit mib -s -- mkpart root $start -1s
mkfs.vfat -F32 ${TARGET_PHY_WWN}-part1
parted -a optimal $TARGET_PHY_ID unit mib -s -- mkpart root $start -1s
mkfs.vfat -F32 ${TARGET_PHY_ID}-part1
TARGET_PART="2"
else
parted -a optimal $TARGET_PHY_WWN -s -- mklabel msdos
parted -a optimal $TARGET_PHY_ID -s -- mklabel msdos
TARGET_PART="1"
if [ "$ENCRYPTION_STYLE" == "b" ] || [ "$ENCRYPTION_STYLE" == "e" ]; then
size=2048
parted -a optimal $TARGET_PHY_WWN unit mib -s -- mkpart primary ext4 $start $(( start + size ))
parted -a optimal $TARGET_PHY_ID unit mib -s -- mkpart primary ext4 $start $(( start + size ))
sleep 2
start=$(( start + size ))
mkfs.btrfs -f "${TARGET_PHY_WWN}-part1"
mkfs.btrfs -f "${TARGET_PHY_ID}-part1"
TARGET_PART="2"
fi
parted -a optimal $TARGET_PHY_WWN unit mib -s -- mkpart primary ext4 $start -1s
parted -a optimal $TARGET_PHY_ID unit mib -s -- mkpart primary ext4 $start -1s
fi
sleep 2
TARGETNAME=$(basename ${TARGET_PHY_WWN}-part${TARGET_PART})
TARGETNAME=$(basename ${TARGET_PHY_ID}-part${TARGET_PART})
TARGETNAME_UNDERSCORE=${TARGETNAME//-/_}
T=/dev/disk/by-id/${TARGET_PHY_WWN}-part${TARGET_PART}
T=/dev/disk/by-id/${TARGET_PHY_ID}-part${TARGET_PART}
if [ "$ENCRYPTION_STYLE" == "a" ]; then
T=/dev/mapper/luks_${TARGETNAME_UNDERSCORE}
echo -n $pass | cryptsetup luksFormat ${TARGET_PHY_WWN}-part${TARGET_PART} -d -
echo -n $pass | cryptsetup luksFormat ${TARGET_PHY_ID}-part${TARGET_PART} -d -
#echo -n $pass | sudo cryptsetup luksOpen /dev/sdc1 sdc1 -d -
echo -n $pass | cryptsetup luksOpen ${TARGET_PHY_WWN}-part${TARGET_PART} "luks_${TARGETNAME_UNDERSCORE}" -d -
echo -n $pass | cryptsetup luksOpen ${TARGET_PHY_ID}-part${TARGET_PART} "luks_${TARGETNAME_UNDERSCORE}" -d -
fi
vgcreate vg_${TARGETNAME_UNDERSCORE} $T
lvcreate --name swap -L ${SWAPSIZE}G vg_${TARGETNAME_UNDERSCORE}
@ -136,11 +131,11 @@ do_partition() {
mount /dev/mapper/vg_${TARGETNAME_UNDERSCORE}-root $target -o subvol=root
if [ "$EFI" == "1" ]; then
mkdir -p ${target}/boot/efi
mount ${TARGET_PHY_WWN}-part1 ${target}/boot/efi
mount ${TARGET_PHY_ID}-part1 ${target}/boot/efi
else
if [ "$ENCRYPTION_STYLE" == "b" ] || [ "$ENCRYPTION_STYLE" == "e" ]; then
mkdir -p ${target}/boot
mount ${TARGET_PHY_WWN}-part1 ${target}/boot
mount ${TARGET_PHY_ID}-part1 ${target}/boot
fi
fi
@ -342,7 +337,7 @@ do_chroot() {
echo "HOSTNAME=$HOSTNAME" >> ${target}/tmp/vinstaller/vars
echo "EFI=$EFI" >> ${target}/tmp/vinstaller/vars
echo "LANGUAGE=$LANGUAGE" >> ${target}/tmp/vinstaller/vars
echo "TARGET_PHY_WWN=$TARGET_PHY_WWN" >> ${target}/tmp/vinstaller/vars
echo "TARGET_PHY_ID=$TARGET_PHY_ID" >> ${target}/tmp/vinstaller/vars
echo "TARGET_PART=$TARGET_PART" >> ${target}/tmp/vinstaller/vars
echo "TARGETNAME_UNDERSCORE=$TARGETNAME_UNDERSCORE" >> ${target}/tmp/vinstaller/vars
echo "ENCRYPTION_STYLE=$ENCRYPTION_STYLE" >> ${target}/tmp/vinstaller/vars
@ -375,4 +370,4 @@ profile
printing
do_partition
do_install
do_chroot
do_chroot