Move crypt question to main script

This commit is contained in:
maride 2018-03-04 14:00:22 +01:00
parent 408f2aa873
commit d872a99180
3 changed files with 12 additions and 7 deletions

7
run.py
View File

@ -42,6 +42,12 @@ def blockdevice(termsize, settings):
settings["blockdevice"] = _ask("Install where?", os.listdir("/sys/block/"), enforce=False)
def cryptroot(termsize, settings):
print("Do you want to encrypt your root partition?")
print("Please note that there is no way to recover your data if you forget your password.")
settings["cryptroot"] = _ask("Encrypt root?", [ "yes", "no" ])
def rundir(termsize, settings, directory, validation_suffix, subfile="", ask=False):
for filename in sorted(os.listdir(directory)):
if filename[-len(validation_suffix):] == validation_suffix:
@ -108,6 +114,7 @@ def main():
motd(termsize, settings)
efibios(termsize, settings)
blockdevice(termsize, settings)
cryptroot(termsize, settings)
rundir(termsize, settings, "checks", ".check")
rundir(termsize, settings, "steps", ".step")
rundir(termsize, settings, "flavours", ".flavour", "install.sh", ask=True)

View File

@ -6,11 +6,7 @@ mkfs.fat -F32 ${blockdevice}1
echo -n "~> Do you want to encrypt root? (Y/n) "
read answer
if [ "$answer" == "n" ] || [ "$answer" == "N" ]; then
echo "~> There are close to no reasons to not do this, but hey, you're an adult."
rootformat=${blockdevice}2
didCrypt=0
else
if [ "$cryptroot" == "yes" ]; then
echo "~> Formatting root (/) for crypto"
cryptsetup -v luksFormat ${blockdevice}2
echo "~> Here's the header crypto:"
@ -18,7 +14,9 @@ else
echo "~> Open the crypt container"
cryptsetup luksOpen ${blockdevice}2 cryptroot
rootformat=/dev/mapper/cryptroot
didCrypt=1
else
echo "~> There are close to no reasons to not do this, but hey, you're an adult."
rootformat=${blockdevice}2
fi
echo "~> Formatting $rootformat EXT4"

View File

@ -26,7 +26,7 @@ else
arch-chroot /mnt grub-install --target=i386-pc /dev/*da
fi
if [ "$didCrypt" -eq 1 ]; then
if [ "$cryptroot" -eq 1 ]; then
echo "GRUB_CMDLINE_LINUX='cryptdevice=UUID=`blkid -o value ${blockdevice}2 | head -n 1`:cryptroot'" > /mnt/etc/default/grub
fi