test
This commit is contained in:
parent
3461a54bc3
commit
ae536c5ed6
24
main.sh
24
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}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user