This commit is contained in:
Your Name 2023-02-10 14:54:48 -07:00
parent 3fe2d2657e
commit 010a9dec5e

View File

@ -32,7 +32,10 @@ HARD_DISK=$2
EFI="/dev/$(lsblk | grep $HARD_DISK | head -2 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)" EFI="/dev/$(lsblk | grep $HARD_DISK | head -2 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
BTRFS="/dev/$(lsblk | grep $HARD_DISK | head -4 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)" BTRFS="/dev/$(lsblk | grep $HARD_DISK | head -4 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
BOOT="/dev/$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)" BOOT="/dev/$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
ROOT_NAME='debian' ROOT_NAME='deb-root'
ROOT_MAPPER_NAME='root'
#NET_BACKUP='-t cifs -o username=guest,password=123456 //192.168.0.153/backup'
#HOME_BACKUP="root@server2:/raid/backup/home/"
NET_BACKUP='/dev/disk/by-uuid/1a143f83-d4fe-4894-8e67-2b6d3baacea6' NET_BACKUP='/dev/disk/by-uuid/1a143f83-d4fe-4894-8e67-2b6d3baacea6'
HOME_BACKUP="$TARGET/home" HOME_BACKUP="$TARGET/home"
@ -40,12 +43,13 @@ HOME_BACKUP="$TARGET/home"
USER="verita84" USER="verita84"
USER_PASSWORD="123456" USER_PASSWORD="123456"
ROOT_PASSWORD="123456" ROOT_PASSWORD="123456"
WIRELESS_PASSWORD='815721984' WIRELESS_PASSWORD='123456'
SSID='123456' SSID='123456'
WIRELESS_INTERFACE='wlan0' WIRELESS_INTERFACE='wlan0'
DISK_PASSWORD='123456' DISK_PASSWORD='123456'
COMPRESSION='compress=zlib:5' COMPRESSION='compress=zlib:5'
DEBIAN_RELEASE='stable' DEBIAN_RELEASE='stable'
CURRENT_STABLE_NAME='bullseye'
AUTO_DECRYPT='True' AUTO_DECRYPT='True'
FLATPAKS+=( app/net.brinkervii.grapejuice org.kde.kdenlive ) FLATPAKS+=( app/net.brinkervii.grapejuice org.kde.kdenlive )
@ -163,6 +167,26 @@ additional-software(){
#install-vivaldi #install-vivaldi
} }
configure-repository(){
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
else
echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE main contrib non-free" >$TARGET/etc/apt/sources.list
fi
chroot $TARGET /usr/bin/apt update
chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt install -y $PACKAGES"
if [ "$DEBIAN_RELEASE" == "stable" ];then
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 dist-upgrade -y -t $CURRENT_STABLE_NAME-backports"
chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt auto-remove -y"
fi
}
install() { install() {
partitions partitions
sed -i '/^SigLevel/s/^\(.*\)$/#\1\n/' /etc/pacman.conf sed -i '/^SigLevel/s/^\(.*\)$/#\1\n/' /etc/pacman.conf
@ -175,12 +199,7 @@ install() {
systemMounts systemMounts
cp -f /etc/resolv.conf $TARGET/etc/ cp -f /etc/resolv.conf $TARGET/etc/
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > $TARGET/setup.sh echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > $TARGET/setup.sh
echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE main contrib non-free" >>$TARGET/etc/apt/sources.list configure-repository
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"
cp -f debian.tar $TARGET/etc/default/ cp -f debian.tar $TARGET/etc/default/
locale locale
accounts accounts
@ -224,7 +243,7 @@ remove-snapshots() {
} }
enter_chroot() { enter_chroot() {
printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} $ROOT_MAPPER_NAME
mounts mounts
systemMounts systemMounts
chroot $TARGET /bin/bash chroot $TARGET /bin/bash
@ -254,13 +273,13 @@ bootloader() {
mkdir /boot/grub/themes mkdir /boot/grub/themes
tar xf /etc/default/debian.tar -C /boot/grub/themes/ tar xf /etc/default/debian.tar -C /boot/grub/themes/
plymouth-set-default-theme -R spacefun plymouth-set-default-theme -R spacefun
echo "root UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2) none luks" > /etc/crypttab echo "$ROOT_MAPPER_NAME UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2) none luks" > /etc/crypttab
if [ "$AUTO_DECRYPT" == "True" ];then if [ "$AUTO_DECRYPT" == "True" ];then
decryptBoot decryptBoot
fi fi
/sbin/update-initramfs -c -k all /sbin/update-initramfs -c -k all
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"" >/etc/default/grub echo "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"" >/etc/default/grub
echo "GRUB_CMDLINE_LINUX=cryptdevice=UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2):root root=UUID=$(/sbin/blkid | grep root | cut -d '"' -f4) rootflags=subvol@${ROOT_NAME} mitigations=-off" >>/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=y" >>/etc/default/grub echo "GRUB_ENABLE_CRYPTODISK=y" >>/etc/default/grub
echo "GRUB_THEME=/boot/grub/themes/theme.txt" >>/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/grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=debian
@ -295,13 +314,13 @@ btrfs_filesytem() {
echo "Binding BTRFS Root" echo "Binding BTRFS Root"
echo echo
umount $TARGET umount $TARGET
mount -o $COMPRESSION,subvol=@$ROOT_NAME /dev/mapper/root $TARGET mount -o $COMPRESSION,subvol=@$ROOT_NAME /dev/mapper/$ROOT_MAPPER_NAME $TARGET
} }
mounts() { mounts() {
echo echo
echo "Mounting......." echo "Mounting......."
mount /dev/mapper/root $TARGET mount /dev/mapper/$ROOT_MAPPER_NAME $TARGET
btrfs_filesytem btrfs_filesytem
mkdir -p $TARGET/boot mkdir -p $TARGET/boot
mount -t ext4 $BOOT $TARGET/boot mount -t ext4 $BOOT $TARGET/boot
@ -309,7 +328,7 @@ mounts() {
mount $EFI $TARGET/boot/efi mount $EFI $TARGET/boot/efi
#CONFIGURE DATA DIRS (HOME) #CONFIGURE DATA DIRS (HOME)
mkdir $TARGET/home mkdir $TARGET/home
mount -o subvol=@home /dev/mapper/root $TARGET/home mount -o subvol=@home /dev/mapper/$ROOT_MAPPER_NAME $TARGET/home
} }
unmount() { unmount() {
@ -356,16 +375,16 @@ fstab() {
mkdir $TARGET/etc 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 ${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 "UUID=$(/sbin/blkid | grep ${EFI} | cut -d '"' -f4) /boot/efi vfat umask=0077 0 1" >>$TARGET/etc/fstab
echo "/dev/mapper/root / btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@$ROOT_NAME 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 /.snapshots btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@.snapshots 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 /var/lib/libvirt btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@libvirt 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 0 0" >>$TARGET/etc/fstab echo "tmpfs /var/log tmpfs defaults 0 0" >>$TARGET/etc/fstab
echo "tmpfs /var/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}/.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 "tmpfs /home/${USER}/Downloads tmpfs rw,user,exec 0 0" >>$TARGET/etc/fstab
echo "/dev/mapper/root /home btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@home 0 1" >>$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 /root btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@root 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 /var/lib/containers btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@containers 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() { accounts() {
@ -383,7 +402,7 @@ accounts() {
echo echo
echo "Setting ROOT Password:" echo "Setting ROOT Password:"
echo "echo \"root:$ROOT_PASSWORD\"| chpasswd " >>$TARGET/setup.sh echo "echo \"root:$ROOT_PASSWORD\"| chpasswd " >>$TARGET/setup.sh
echo "/usr/bin/hostnamectl hostname $ROOT_NAME" >>$TARGET/setup.sh echo "/usr/bin/hostnamectl set-hostname $ROOT_NAME" >>$TARGET/setup.sh
} }
btrfs-tweaks() { btrfs-tweaks() {
@ -452,7 +471,7 @@ initialize-disk() {
printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root
echo echo
echo "Formatting....." echo "Formatting....."
echo y | mkfs.btrfs /dev/mapper/root --force echo y | mkfs.btrfs /dev/mapper/$ROOT_MAPPER_NAME--force
} }
wifi() { wifi() {