#!/bin/bash ######################## # What this script is: # # An automatic installer for Debian Stable with BTRFS, Snapshots, and Full-disk-encryption # # INSTRUCTIONS # # For new disk installs, initialize the disk to setup Encryption and partitions from the main menu. # # Before running the install, ensure that you have Internet access. # # Please be sure to change USER,USER_PASSWORD,DISK_PASSWORD, and ROOT_PASSWORD strings in this file # # To install a new OS to a disk, run debian.sh and choose option 1 from the main menu # ######################## #Configure this section ######################## PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin export DEBIAN_FRONTEND=noninteractive TARGET='/install' mkdir $TARGET ###################################### echo HARD_DISK=$2 ###################################### USER="user" USER_PASSWORD="123456" ROOT_PASSWORD="123456" WIRELESS_PASSWORD='123456' SSID='wifi' WIRELESS_INTERFACE='wlan0' DISK_PASSWORD='123456' COMPRESSION='compress=zlib:5' AUTO_DECRYPT='True' FLATPAKS+=(org.kde.kapman net.sourceforge.ExtremeTuxRacer com.github.bjaraujo.Bombermaaan org.supertuxproject.SuperTux net.supertuxkart.SuperTuxKart net.sourceforge.chromium-bsu io.jor.mightymike com.eduke32.EDuke32 com.zandronum.Zandronum net.openra.OpenRA) #Packages PACKAGES=" resolvconf wireguard wireguard-tools nmap libsecret-tools libglu1-mesa preload flatpak powertop acpi cockpit cockpit-podman packagekit cockpit-packagekit cockpit-storaged " BASE_PACKAGES=" inotify-tools debootstrap cups apt-transport-https samba samba-common nfs-common nfs-kernel-server linux-cpupower locales zram-tools acpid podman ghostscript cifs-utils ntp vim-airline rsync screen base udev git network-manager efibootmgr linux-headers-amd64 cryptsetup network-manager-openvpn ntp screen docbook-xsl alsa-utils sysstat fuse3 build-essential unzip bash-completion parted dosfstools wget curl " SHARED_DESKTOP_APPS=" nheko firefox-esr kwin-addons kde-standard konsole dolphin kde-spectacle print-manager digikam keepassxc telegram-desktop krita nextcloud-desktop handbrake calligra " #REMOVED=" cockpit-pcp " #TROUBLESOME_PACKAGES - packages here that may not be available for your Debian release TROUBLESOME_PACKAGES=" aardvark-dns shfmt podman-compose btop podman-toolbox yt-dlp power-profiles-daemon " VIRTUALIZATION=" virt-manager qemu-system libvirt-daemon-system ovmf cockpit-machines" PACKAGES=$BASE_PACKAGES$PACKAGES$SHARED_DESKTOP_APPS #PACKAGES=$BASE_PACKAGES TAR_EXCLUDES="--exclude=/.snapshots --exclude=/snapshots --exclude=/var/backups --exclude=/volumes/* --exclude=/mnt/* --exclude=/var/tmp/* --exclude=/tmp/* --exclude=/raid/* --exclude=/root/* --exclude=/var/cache/apt/archives/* --exclude=/proc/* --exclude=/.snapshots/* --exclude=/var/lib/libvirt/* --exclude=/dev/* --exclude=/sys/* --exclude=/home/* --exclude=/var/lib/flatpak --exclude=/var/lib/postgresql --exclude=/var/lib/containers" partitionDetection() { #This is used for the installer to do script-based actions EFI="/dev/$(lsblk | grep $HARD_DISK | head -2 | tail -1 | sed 's/├─//' | cut -d ' ' -f1)" BTRFS="/dev/$(lsblk | grep $HARD_DISK | head -4 | tail -1 | sed 's/└─//' | cut -d ' ' -f1)" BOOT="/dev/$(lsblk | grep $HARD_DISK | head -3 | tail -1 | sed 's/├─//' | cut -d ' ' -f1)" } partitionDetection auto_login() { mkdir -p $TARGET/etc/sddm.conf.d echo "[Autologin]" >$TARGET/etc/sddm.conf.d/autologin echo "User=$USER" >>$TARGET/etc/sddm.conf.d/autologin echo "Session=plasma.desktop" >>$TARGET/etc/sddm.conf.d/autologin echo "Relogin=false" >>$TARGET/etc/sddm.conf.d/autologin } create-os-snapshots() { echo mkdir $2 echo "[Creating new OS snapshot to $2/$3.tgz]" echo echo NEW_TAR_EXCLUDES="$TAR_EXCLUDES --exclude=$TARGET/*" echo time tar cpzf $2/$3.tgz $NEW_TAR_EXCLUDES / chown $USER:$USER $2/$3.tgz } homeBackup() { echo echo "[Copying USER data from /home to $TARGET/@home]" echo rsync -a --delete /home/ --exclude=.cache --exclude=.local/share/flatpak --exclude=.local/share/containers $TARGET/\@home/ } os-backup() { umount $TARGET printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} $ROOT_MAPPER_NAME if [[ -e "/dev/mapper/$ROOT_MAPPER_NAME" ]]; then echo echo "[Mounting.....]" echo mount /dev/mapper/$ROOT_MAPPER_NAME $TARGET if [[ -e "$TARGET/@$ROOT_NAME/usr/bin/bash" ]]; then if [ "$1" = "home" ]; then homeBackup fi create-os-snapshots "$1" "$2" "$3" else echo echo "Aborting Install, $TARGET/@$ROOT_MAPPER_NAME/usr/bin/bash not found!" echo echo exit 1 fi else echo echo "Aborting Install, /dev/mapper/$ROOT_MAPPER_NAME not found!" echo echo exit 1 fi ls $TARGET/ umount $TARGET cryptsetup close $ROOT_MAPPER_NAME } os-restore() { partitions rm -rf $TARGET/usr $TARGET/sbin $TARGET/lib32 $TARGET/libx32 $TARGET/lib $TARGET/vmlinuz* $TARGET/initrd* $TARGET/bin $TARGET/var $TARGET/root $TARGET/opt $TARGET/etc $TARGET/run clear echo "[Restoring OS tarfile from $4/$2.tgz]" echo tar xfp $4/$2.tgz -C $TARGET/ if [ "$3" = "home" ]; then echo "[Restoring /home]" echo rsync -a --delete /home/ $TARGET/home/ fi fstab cp -f debian.sh $TARGET/ systemMounts chmod +x $TARGET/debian.sh chroot $TARGET /debian.sh bootloader $1 $2 $5 chroot $TARGET /debian.sh btrfs-tweaks chroot $TARGET /debian.sh accounts chown -R $USER:$USER $TARGET/home/$USER auto_login rm -f $TARGET/debian.sh unmount } systemMounts() { mount -o rbind /dev $TARGET/dev mount -o rbind /dev/pts $TARGET/dev/pts mount -o rbind /proc $TARGET/proc mount -o rbind /sys $TARGET/sys mount -t efivarfs none $TARGET/sys/firmware/efi/efivars } decryptBoot() { KEYFILE='keyfile.key' echo echo "Setting LUKS to use Keyfile for password entry" echo echo echo "Clearing Old Keys" echo for i in 1 2 3 4 5 6; do printf "$DISK_PASSWORD" | cryptsetup luksKillSlot $1 $i done dd if=/dev/urandom of=/etc/$KEYFILE bs=1024 count=4 chown root:root /etc/$KEYFILE chmod 0400 /etc/$KEYFILE echo echo "Adding new key......" echo printf "$DISK_PASSWORD" | cryptsetup luksAddKey $1 /etc/$KEYFILE sed -i "s/none/\/etc\/$KEYFILE/" /etc/crypttab echo "KEYFILE_PATTERN=\"/etc/*.key\"" >/etc/cryptsetup-initramfs/conf-hook } configure-repository() { echo 'force-unsafe-io' >$TARGET/etc/dpkg/dpkg.cfg.d/docker-apt-speedup if [ "$DEBIAN_RELEASE" == "testing" ]; then echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE main contrib non-free non-free-firmware" >$TARGET/etc/apt/sources.list chroot $TARGET /usr/bin/apt update chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt install -y $PACKAGES" else echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE main contrib non-free non-free-firmware" >$TARGET/etc/apt/sources.list echo "deb https://deb.debian.org/debian-security $DEBIAN_RELEASE-security main" >>$TARGET/etc/apt/sources.list echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE-updates main " >>$TARGET/etc/apt/sources.list echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE-backports main" >>$TARGET/etc/apt/sources.list chroot $TARGET /usr/bin/apt update chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt install -y $PACKAGES" chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt dist-upgrade -y -t $DEBIAN_RELEASE-backports" chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt install -y -t $DEBIAN_RELEASE-backports $TROUBLESOME_PACKAGES" chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt auto-remove -y" fi echo 'DPkg::Post-Invoke {"/usr/bin/debian.sh snapshot";};' >$TARGET/etc/apt/apt.conf } make-image() { umount $TARGET mount -t tmpfs tmpfs -o size=11G,dev,exec $TARGET debootstrap --arch amd64 $DEBIAN_RELEASE $TARGET https://deb.debian.org/debian configure-repository locale custom_service_files cp -f debian.sh $TARGET/usr/bin/ cp -f debian.tar $TARGET/etc/default/ echo 'bash /usr/bin/debian.sh kernel-packages' >>$TARGET/setup.sh echo "bash /usr/bin/debian.sh bootloader $1 $ROOT_NAME $ROOT_MAPPER_NAME" >>$TARGET/setup.sh echo 'bash /usr/bin/debian.sh grub-snapshots' >>$TARGET/setup.sh echo 'bash /usr/bin/debian.sh desktop' >>$TARGET/setup.sh echo '/usr/bin/apt clean all' >>$TARGET/setup.sh chmod +x $TARGET/usr/bin/debian.sh chmod +x $TARGET/setup.sh chroot $TARGET /setup.sh rm -f $TARGET/setup.sh echo -e "ALGO=zstd\nPERCENT=60" | tee -a $TARGET/etc/default/zramswap cd $TARGET echo "[Creating new OS image to $1/$ROOT_NAME.tgz]" time tar cpzf $1/$ROOT_NAME.tgz $TAR_EXCLUDES . cd $1 umount $TARGET } install() { partitions sed -i '/^SigLevel/s/^\(.*\)$/#\1\n/' /etc/pacman.conf sed -i '/#SigLevel/a SigLevel = Never' /etc/pacman.conf pacman -Sy archlinux-keyring debootstrap --noconfirm apt update apt install debootstrap -y rm -rf /debootstrap debootstrap --arch amd64 $DEBIAN_RELEASE $TARGET https://deb.debian.org/debian systemMounts cp -f /etc/resolv.conf $TARGET/etc/ echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >$TARGET/setup.sh configure-repository cp -f debian.tar $TARGET/etc/default/ locale auto_login custom_service_files setup_script "$1" echo -e "ALGO=zstd\nPERCENT=60" | tee -a $TARGET/etc/default/zramswap unmount } desktop() { SERVICES+=(pmcd pmie pmlogger pmproxy exim4 cockpit.socket apparmor nfs-server smbd rpbind rpcbind.socket avahi-daemon bluetooth) for i in "${SERVICES[@]}"; do systemctl disable --now $i done apt -y purge apparmor apt remove unattended-upgrades chromium chromium-common chromium-sandbox epiphany-browser epiphany-browser-data -y apt autoremove -y } snapshots() { echo echo "Creating Snapshots....." echo DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S)) btrfs sub snapshot / /.snapshots/root-${DATE} #update-grub } remove-snapshots() { btrfs sub delete /.snapshots/* rm -f /boot/loader/entries/root-* } flatpaks() { flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo for i in "${FLATPAKS[@]}"; do echo $i flatpak install $i -y done } grub-snapshots() { cd /opt git clone https://github.com/Antynea/grub-btrfs.git cd /opt/grub-btrfs make make install systemctl enable --now grub-btrfsd.service } kernel-packages() { /usr/bin/apt install --reinstall -y linux-image-amd64 grub-efi efibootmgr plymouth plymouth-themes btrfs-progs cryptsetup-initramfs linux-image-amd64 linux-headers-amd64 firmware-iwlwifi firmware-linux firmware-linux-nonfree } secure-boot() { if [ -z "$1" ]; then clear echo echo "Error: No Disk specified!" echo else clear echo echo "Disabling Automatic Password Decryption for Hard Disk....." echo AUTO_DECRYPT='False' bootloader "$1" "$ROOT_NAME" "$ROOT_MAPPER_NAME" fi } bootloader() { if [ -z "$1" ]; then echo echo "Error: No Disk specified!" echo else ROOT_MAPPER_NAME="$3" ROOT_NAME="$2" rm -rf /boot/grub/themes mkdir -p /boot/grub/themes tar xf /etc/default/debian.tar -C /boot/grub/themes/ plymouth-set-default-theme -R spacefun echo "$ROOT_MAPPER_NAME UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2) none luks" >/etc/crypttab if [ "$AUTO_DECRYPT" == "True" ]; then decryptBoot "${BTRFS}" fi /sbin/update-initramfs -c -k all echo "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"" >/etc/default/grub echo "GRUB_CMDLINE_LINUX=cryptdevice=UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2):$ROOT_MAPPER_NAME root=UUID=$(/sbin/blkid | grep $ROOT_MAPPER_NAME | cut -d '"' -f4) rootflags=subvol@${ROOT_NAME} mitigations=-off" >>/etc/default/grub echo "GRUB_ENABLE_CRYPTODISK=n" >>/etc/default/grub echo "GRUB_DISABLE_OS_PROBER=true" >>/etc/default/grub echo "GRUB_THEME=/boot/grub/themes/theme.txt" >>/etc/default/grub /sbin/grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=debian /sbin/update-grub fi } function setup_script() { cp -f debian.sh $TARGET/usr/bin/ echo 'bash /usr/bin/debian.sh kernel-packages' >>$TARGET/setup.sh #sed -i 's/most/dep/i' $TARGET/etc/initramfs-tools/initramfs.conf echo "bash /usr/bin/debian.sh bootloader $1 $ROOT_NAME $ROOT_MAPPER_NAME" >>$TARGET/setup.sh echo 'bash /usr/bin/debian.sh grub-snapshots' >>$TARGET/setup.sh echo 'bash /usr/bin/debian.sh accounts' >>$TARGET/setup.sh echo 'bash /usr/bin/debian.sh desktop' >>$TARGET/setup.sh echo 'bash /usr/bin/debian.sh btrfs-tweaks' >>$TARGET/setup.sh chmod +x $TARGET/usr/bin/debian.sh chmod +x $TARGET/setup.sh chroot $TARGET /setup.sh rm -f $TARGET/setup.sh } btrfs_filesytem() { btrfs sub create $TARGET/@$ROOT_NAME btrfs sub create $TARGET/@.snapshots btrfs sub create $TARGET/@libvirt btrfs sub create $TARGET/@home btrfs sub create $TARGET/@root btrfs sub create $TARGET/@containers echo echo "Binding BTRFS Root" echo umount $TARGET mount -o $COMPRESSION,subvol=@$ROOT_NAME /dev/mapper/$ROOT_MAPPER_NAME $TARGET } mounts() { echo echo "Mounting......." mount /dev/mapper/$ROOT_MAPPER_NAME $TARGET btrfs_filesytem mkdir -p $TARGET/boot mount -t ext4 $BOOT $TARGET/boot mkdir -p $TARGET/boot/efi mount $EFI $TARGET/boot/efi #CONFIGURE DATA DIRS (HOME) mkdir $TARGET/home mount -o subvol=@home /dev/mapper/$ROOT_MAPPER_NAME $TARGET/home } unmount() { echo echo "Unmounting....." umount $TARGET/proc umount $TARGET/dev umount $TARGET/sys umount $TARGET/boot umount $TARGET/home umount -lR $TARGET/* umount -R $TARGET umount -R $TARGET cryptsetup close $ROOT_MAPPER_NAME } locale() { echo "ln -sf /usr/share/zoneinfo/US/Mountain /etc/localtime" >>$TARGET/setup.sh echo "hwclock --systohc" >>$TARGET/setup.sh echo "en_US.UTF-8 UTF-8" >$TARGET/etc/locale.gen echo "locale-gen" >>$TARGET/setup.sh } partitions() { echo echo "Setting Up Partitions....." printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} $ROOT_MAPPER_NAME if [[ -e "/dev/mapper/$ROOT_MAPPER_NAME" ]]; then echo echo "Formatting $EFI" echo echo y | mkfs.vfat $EFI echo "Formatting $BOOT" echo y | mkfs.ext4 $BOOT mounts fstab else echo echo "Aborting Install, /dev/mapper/$ROOT_MAPPER_NAME not found!" echo echo exit 1 fi } fstab() { mkdir $TARGET/etc echo "UUID=$(/sbin/blkid | grep ${BOOT} | cut -d '"' -f2) /boot ext4 defaults 0 1" >$TARGET/etc/fstab echo "UUID=$(/sbin/blkid | grep ${EFI} | cut -d '"' -f4) /boot/efi vfat umask=0077 0 1" >>$TARGET/etc/fstab echo "/dev/mapper/$ROOT_MAPPER_NAME / btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@$ROOT_NAME 0 1" >>$TARGET/etc/fstab echo "/dev/mapper/$ROOT_MAPPER_NAME /.snapshots btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@.snapshots 0 1" >>$TARGET/etc/fstab echo "/dev/mapper/$ROOT_MAPPER_NAME /var/lib/libvirt btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@libvirt 0 1" >>$TARGET/etc/fstab echo "tmpfs /var/log tmpfs defaults,dev,exec 0 0" >>$TARGET/etc/fstab echo "tmpfs /tmp tmpfs defaults 0 0" >>$TARGET/etc/fstab #echo "tmpfs /var/tmp tmpfs defaults 0 0" >>$TARGET/etc/fstab echo "tmpfs /home/${USER}/.cache tmpfs rw,user,exec 0 0" >>$TARGET/etc/fstab echo "tmpfs /home/${USER}/Downloads tmpfs rw,user,exec 0 0" >>$TARGET/etc/fstab echo "/dev/mapper/$ROOT_MAPPER_NAME /home btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@home 0 1" >>$TARGET/etc/fstab echo "/dev/mapper/$ROOT_MAPPER_NAME /root btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@root 0 1" >>$TARGET/etc/fstab echo "/dev/mapper/$ROOT_MAPPER_NAME /var/lib/containers btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@containers 0 1" >>$TARGET/etc/fstab } accounts() { echo echo "Set Password for $USER" useradd -m -s /bin/bash $USER echo "$USER:$USER_PASSWORD" | chpasswd gpasswd -a $USER wheel gpasswd -a $USER network gpasswd -a $USER video gpasswd -a $USER libvirt gpasswd -a $USER netdev gpasswd -a $USER adm echo "$USER ALL=(ALL) ALL" >/etc/sudoers echo "root ALL=(ALL) ALL" >>/etc/sudoers echo echo "Setting ROOT Password:" echo "root:$ROOT_PASSWORD" | chpasswd /usr/bin/hostnamectl set-hostname $ROOT_NAME } btrfs-tweaks() { DISABLE_COW=("/var/lib/docker" "/var/lib/containers" "/volumes" "/var/lib/mysql" "/var/lib/libvirt") for i in "${DISABLE_COW[@]}"; do chattr -R +C $i done } custom_service_files() { echo "systemctl set-default graphical.target" >>$TARGET/setup.sh echo "[Unit]" >$TARGET/etc/systemd/system/powertop.service echo "Description=Powertop tunings" >>$TARGET/etc/systemd/system/powertop.service echo "[Service]" >>$TARGET/etc/systemd/system/powertop.service echo "Type=oneshot" >>$TARGET/etc/systemd/system/powertop.service echo "ExecStart=/usr/sbin/powertop --auto-tune" >>$TARGET/etc/systemd/system/powertop.service echo "[Install]" >>$TARGET/etc/systemd/system/powertop.service echo "WantedBy=multi-user.target" >>$TARGET/etc/systemd/system/powertop.service } initialize-disk() { parted /dev/$HARD_DISK mklabel gpt parted /dev/$HARD_DISK mkpart primary fat32 1MiB 200MiB parted /dev/$HARD_DISK mkpart primary ext3 200MiB 700MiB parted /dev/$HARD_DISK set 1 esp on parted /dev/$HARD_DISK mkpart P2 ext3 700MiB 100% printf "$DISK_PASSWORD\n$DISK_PASSWORD" | cryptsetup luksFormat ${BTRFS} printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} $ROOT_MAPPER_NAME echo echo "Formatting....." echo y | mkfs.btrfs /dev/mapper/$ROOT_MAPPER_NAME --force echo;echo "Initialize Complete. Please reboot your machine to avoid any issues";echo } wifi() { iwctl --passphrase $WIRELESS_PASSWORD station $WIRELESS_INTERFACE connect $SSID } show-help() { clear echo echo "[debian.sh arguments]" echo echo "./debian.sh install" echo "./debian.sh backup" echo "./debian.sh restore" echo "./debian.sh make-image" echo "./debian.sh secure-boot" echo "./debian.sh wifi" echo "./debian.sh bootloader [disk] [ROOT_NAME] [ROOT_MAPPER_NAME]" echo "./debian.sh initialize" echo "./debian.sh tar [device name] [location]" echo "./debian.sh snapshot" echo "./debian.sh reomve-snapshot" echo "./debian.sh btrfs-tweaks" echo } menu() { clear echo echo "[Welcome to Verita84's Debian Installer System]" echo echo "[1] Install" echo "[2] Backup" echo "[3] Restore" echo "[4] Create a deployable System Image" echo "[5] Enable/Disable Disk Password at Boot" echo "[6] Initialize Disk" echo read -p 'Your Choice: ' choice if [[ $choice = 1 ]]; then clear echo "[Install] OS]" echo echo read -p 'Debian Version: ' -e -i "stable" DEBIAN_RELEASE set-devices install "$HARD_DISK" elif [[ $choice = 2 ]]; then clear echo "[Backup OS]" echo set-devices read -p 'Backup Home Directory? : ' -e -i 'y' home_backup read -p 'OS Backup Directory Location : ' -e -i "/install/\@$ROOT_NAME/var/backups" backup_directory if [[ $home_backup = *n* ]]; then os-backup "none" "$backup_directory" "$ROOT_NAME" else os-backup "home" "$backup_directory" "$ROOT_NAME" fi elif [[ $choice = 3 ]]; then clear echo "[Restore from Backup]" echo echo set-devices read -p 'Restore Directory Image Source: ' -e -i "/var/backups" restore_directory read -p 'Restore Home Directory? : ' -e -i 'n' home_restore read -p 'Backup file name to restore: ' -e -i 'debian' backup_name if [[ $home_restore = *n* ]]; then os-restore "$HARD_DISK" "$backup_name" "none" "$restore_directory" "$ROOT_MAPPER_NAME" else os-restore "$HARD_DISK" "$backup_name" "home" "$restore_directory" "$ROOT_MAPPER_NAME" fi elif [[ $choice = 4 ]]; then clear echo echo "[Create Debian Image]" echo read -p 'Location to Store Image: ' -e -i "/home/$USER" image_directory read -p 'Image File Name: ' -e -i "debian" ROOT_NAME read -p 'Debian Version: ' -e -i "stable" DEBIAN_RELEASE ROOT_MAPPER_NAME="/dev/foo" make-image "$image_directory" elif [[ $choice = 5 ]]; then clear echo "[Password Protection at Boot]" echo echo set-devices read -p 'Unlock Disk without password at boot time? ' -e -i "y" root_name if [[ $pass_change = *n* ]]; then bootloader "$HARD_DISK" "$ROOT_NAME" "$ROOT_MAPPER_NAME" else secure-boot "$HARD_DISK" fi elif [[ $choice = 6 ]]; then clear echo "[Initialize Disk]" echo echo set-devices initialize-disk else menu fi } set-devices() { i=0 while [ $i != "n" ]; do clear echo echo "Disks and Partitions:" echo cat /proc/partitions echo echo "Erase the line and press enter to skip to the next detected disk" echo i=$(expr $i + 1) read -p 'Disk Device to Use: ' -e -i $(lsblk | grep -i disk | grep -Evi 'swap' | cut -d ' ' -f1 | head -$i | tail -1) device if [[ ! -z $device ]]; then i="n" fi done read -p 'BTRFS Root Volume name: ' -e -i "debian" root_name read -p 'LUKS Device Mapper Name: ' -e -i "root" device_mapper_name HARD_DISK=$device partitionDetection ROOT_NAME=$root_name ROOT_MAPPER_NAME=$device_mapper_name } if [ "$1" = "desktop" ]; then desktop elif [ "$1" = "tar" ]; then create-os-snapshots "null" "$3" "$2" elif [ "$1" = "kernel-packages" ]; then kernel-packages elif [ "$1" = "upgrade-system" ]; then upgrade-system elif [ "$1" = "wifi" ]; then wifi elif [ "$1" = "accounts" ]; then accounts elif [ "$1" = "flatpaks" ]; then flatpaks elif [ "$1" = "bootloader" ]; then bootloader "$2" "$3" "$4" elif [ "$1" = "snapshot" ]; then snapshots elif [ "$1" = "grub-snapshots" ]; then grub-snapshots elif [ "$1" = "btrfs-tweaks" ]; then btrfs-tweaks elif [ "$1" = "remove-snapshot" ]; then remove-snapshots elif [ "$1" = "help" ]; then show-help else menu fi