From ae536c5ed6df6f225b123f2f503603fd6790ef30 Mon Sep 17 00:00:00 2001 From: teldra Date: Mon, 12 Sep 2022 11:36:19 +0200 Subject: [PATCH] test --- main.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/main.sh b/main.sh index e8aa827..ebf9aaa 100755 --- a/main.sh +++ b/main.sh @@ -47,10 +47,12 @@ target_phy_id() { if echo "${i}" | grep -v "wwn" | grep -q -v "eui"; then TARGET_PHY_ID="${i}" f2="1" + part="-part" fi fi done else + ln "/dev/${TARGET_PHY_DISK}" /dev/disk/by-id/vda TARGET_PHY_ID="/dev/${TARGET_PHY_DISK}" f2="1" fi @@ -122,19 +124,19 @@ do_partition() { TARGET_PART="2" start="$(( end ))" sleep 2 - mkfs.vfat -I -F32 "${TARGET_PHY_ID}-part1" + mkfs.vfat -I -F32 "${TARGET_PHY_ID}${part}1" if [ "${ENCRYPTION_STYLE}" == "e" ]; then size=2048 end=$(( start + size )) parted "${TARGET_PHY_ID}" unit mib -s -- mkpart boot ext4 "$start" "${end}" TARGET_PART="3" start="$(( end ))" - BOOTDEV="${TARGET_PHY_ID}-part2" + BOOTDEV="${TARGET_PHY_ID}${part}2" sleep 2 - mkfs.btrfs -q -f "${TARGET_PHY_ID}-part2" + mkfs.btrfs -q -f "${TARGET_PHY_ID}${part}2" fi parted "${TARGET_PHY_ID}" unit mib -s -- mkpart root ext4 "$start" 100% - dd if=/dev/random of="${TARGET_PHY_ID}-part${TARGET_PART}" bs=512 count=4 + dd if=/dev/random of="${TARGET_PHY_ID}${part}${TARGET_PART}" bs=512 count=4 else parted "${TARGET_PHY_ID}" -s -- mklabel msdos sleep 2 @@ -144,22 +146,22 @@ do_partition() { parted "${TARGET_PHY_ID}" unit mib -s -- mkpart primary ext4 "${start}" "${end}" start="$(( end ))" TARGET_PART="2" - BOOTDEV="${TARGET_PHY_ID}-part1" + BOOTDEV="${TARGET_PHY_ID}${part}1" sleep 2 - mkfs.btrfs -q -f "${TARGET_PHY_ID}-part1" + mkfs.btrfs -q -f "${TARGET_PHY_ID}${part}1" fi parted "${TARGET_PHY_ID}" unit mib -s -- mkpart primary ext4 "$start" -1s - dd if=/dev/random of="${TARGET_PHY_ID}-part${TARGET_PART}" bs=512 count=4 + dd if=/dev/random of="${TARGET_PHY_ID}${part}${TARGET_PART}" bs=512 count=4 fi sleep 2 - TARGETNAME="$(basename "${TARGET_PHY_ID}-part${TARGET_PART}")" + TARGETNAME="$(basename "${TARGET_PHY_ID}${part}${TARGET_PART}")" TARGETNAME_UNDERSCORE="${TARGETNAME//-/_}" - T="${TARGET_PHY_ID}-part${TARGET_PART}" + T="${TARGET_PHY_ID}${part}${TARGET_PART}" if [ "${ENCRYPTION_STYLE}" == "a" ] || [ "${ENCRYPTION_STYLE}" == "c" ] || [ "${ENCRYPTION_STYLE}" == "d" ] || [ "${ENCRYPTION_STYLE}" == "e" ]; then T="/dev/mapper/luks_${TARGETNAME_UNDERSCORE}" - echo -n "${PASS}" | cryptsetup luksFormat --type luks1 "${TARGET_PHY_ID}-part${TARGET_PART}" -d - + echo -n "${PASS}" | cryptsetup luksFormat --type luks1 "${TARGET_PHY_ID}${part}${TARGET_PART}" -d - #echo -n "${PASS}" | sudo cryptsetup luksOpen /dev/sdc1 sdc1 -d - - echo -n "${PASS}" | cryptsetup luksOpen "${TARGET_PHY_ID}-part${TARGET_PART}" "luks_${TARGETNAME_UNDERSCORE}" -d - + echo -n "${PASS}" | cryptsetup luksOpen "${TARGET_PHY_ID}${part}${TARGET_PART}" "luks_${TARGETNAME_UNDERSCORE}" -d - fi vgcreate -y --force "vg_${TARGETNAME_UNDERSCORE}" "${T}" lvcreate -y --name swap -L "${SWAPSIZE}G" "vg_${TARGETNAME_UNDERSCORE}"