2022-12-07 14:24:20 -07:00
|
|
|
#!/bin/bash
|
|
|
|
########################
|
2022-12-08 08:26:11 -07:00
|
|
|
# INSTRUCTIONS
|
|
|
|
# For new disk installs, initialize the disk to setup Encryption and partitions:
|
2022-12-09 09:49:37 -07:00
|
|
|
# ./debian.sh initialize nvme0n1 (DO NOT SPECIFY /dev/ !)
|
2022-12-08 08:26:11 -07:00
|
|
|
#
|
2022-12-09 09:49:37 -07:00
|
|
|
# Before running the install, ensure that you have Internet access. If you modify the
|
|
|
|
# WIRELESS_PASSWORD and SSID in this file, you can connect to the Internet with:
|
|
|
|
# ./debian.sh wifi
|
|
|
|
#
|
|
|
|
# Plesae be sure to change USER,USER_PASSWORD,DISK_PASSWORD, and ROOT_PASSWORD strings in this file
|
2022-12-08 08:26:11 -07:00
|
|
|
#
|
|
|
|
# To install/reinstall the OS:
|
|
|
|
# ./debian.sh install nvme0n1
|
|
|
|
#
|
|
|
|
# reboot
|
|
|
|
########################
|
2022-12-07 14:24:20 -07:00
|
|
|
#Configure this section
|
|
|
|
########################
|
2022-12-07 20:05:53 -07:00
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
2022-12-07 22:12:26 -07:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2022-12-09 14:22:25 -07:00
|
|
|
TARGET='/mnt'
|
2022-12-07 16:15:01 -07:00
|
|
|
mkdir $TARGET
|
2022-12-07 14:24:20 -07:00
|
|
|
######################################
|
|
|
|
echo
|
2022-12-07 16:15:01 -07:00
|
|
|
HARD_DISK=$2
|
|
|
|
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)"
|
|
|
|
BOOT="/dev/$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
|
2022-12-08 06:47:22 -07:00
|
|
|
ROOT_NAME='debian'
|
2022-12-07 20:05:53 -07:00
|
|
|
USB_BACKUP='/dev/disk/by-uuid/1a143f83-d4fe-4894-8e67-2b6d3baacea6'
|
2022-12-07 14:24:20 -07:00
|
|
|
######################################
|
2022-12-09 14:05:22 -07:00
|
|
|
USER="verita84"
|
2022-12-07 14:24:20 -07:00
|
|
|
USER_PASSWORD="123456"
|
|
|
|
ROOT_PASSWORD="123456"
|
|
|
|
WIRELESS_PASSWORD='123456'
|
2022-12-07 16:15:01 -07:00
|
|
|
SSID='123456'
|
2022-12-07 14:24:20 -07:00
|
|
|
WIRELESS_INTERFACE='wlan0'
|
|
|
|
DISK_PASSWORD='123456'
|
2022-12-10 13:48:49 -07:00
|
|
|
COMPRESSION='compress=zlib:5'
|
2022-12-09 14:05:22 -07:00
|
|
|
DEBIAN_RELEASE='testing'
|
2022-12-07 20:05:53 -07:00
|
|
|
FLATPAKS+=( app/net.brinkervii.grapejuice app/org.gnome.Photos app/org.mozilla.firefox org.gnome.Evolution app/com.vscodium.codium app/org.libreoffice.LibreOffice org.gajim.Gajim org.gajim.Gajim.Plugin.omemo org.telegram.desktop app/im.riot.Riot app/io.mpv.Mpv app/org.gimp.GIMP fr.handbrake.ghb org.kde.kdenlive )
|
2022-12-07 14:24:20 -07:00
|
|
|
|
|
|
|
#Packages
|
2022-12-10 09:00:01 -07:00
|
|
|
SHARED_DESKTOP_APPS=" gnome-core "
|
|
|
|
PACKAGES=" zram-tools samba samba-common nfs-common nfs-kernel-server linux-cpupower locales syncthing redis cockpit cockpit-machines cockpit-podman flatpak powertop blueman cups acpi packagekit cockpit-packagekit cockpit-pcp cockpit-storaged acpid podman pulseaudio 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 postgresql redis neofetch fuse3 build-essential unzip bash-completion parted dosfstools wget curl "
|
|
|
|
#REMOVED=" yt-dlp aardvark-dns podman-compose systemd-zram-generator podman-toolbox "
|
2022-12-07 16:17:50 -07:00
|
|
|
VIRTUALIZATION=" virt-manager qemu-system libvirt-daemon-system ovmf "
|
2022-12-07 14:24:20 -07:00
|
|
|
PACKAGES=$PACKAGES$SHARED_DESKTOP_APPS$VIRTUALIZATION
|
2022-12-08 07:14:42 -07:00
|
|
|
SERVICES+=( powertop );
|
2022-12-07 14:24:20 -07:00
|
|
|
|
2022-12-10 09:00:01 -07:00
|
|
|
|
2022-12-07 14:24:20 -07:00
|
|
|
auto_login(){
|
|
|
|
sed -i "/#WaylandEnable=false/a AutomaticLoginEnable=True" $TARGET/etc/gdm3/daemon.conf
|
|
|
|
sed -i "/True/a AutomaticLogin=$USER" $TARGET/etc/gdm3/daemon.conf
|
|
|
|
}
|
|
|
|
|
|
|
|
clean-old-usb-snapshots(){
|
|
|
|
echo;echo "[Cleaning up old USB snapshots.....]";echo
|
|
|
|
btrfs sub delete $TARGET/$ROOT_NAME-$1
|
|
|
|
echo;echo "[Cleaning up old EFI data.....]";echo
|
|
|
|
rm -rf $TARGET/efi-$1
|
|
|
|
}
|
|
|
|
|
|
|
|
clean-old-snapshots() {
|
|
|
|
echo;echo "[Cleaning up old snapshots.....]";echo
|
|
|
|
btrfs sub delete /.snapshots/$ROOT_NAME-$1
|
|
|
|
}
|
|
|
|
|
|
|
|
create-usb-snapshots(){
|
2022-12-07 20:05:53 -07:00
|
|
|
echo;echo "[Creating new snapshots.....]";echo
|
2022-12-07 14:24:20 -07:00
|
|
|
btrfs sub snap -r / /.snapshots/$ROOT_NAME-$1
|
|
|
|
}
|
|
|
|
|
|
|
|
send-snapshots(){
|
|
|
|
echo;echo "[Sending snapshot to $USB_BACKUP]";echo
|
|
|
|
btrfs send /.snapshots/$ROOT_NAME-$1 | btrfs receive $TARGET
|
|
|
|
}
|
|
|
|
|
|
|
|
copy-efi-to-usb(){
|
|
|
|
echo;echo "[Copying EFI data....]";echo
|
|
|
|
mkdir $TARGET/efi-$1
|
|
|
|
mkdir $TARGET/$1
|
|
|
|
cp -rf /boot/* $TARGET/efi-$1/
|
|
|
|
}
|
|
|
|
|
|
|
|
homeBackup() {
|
|
|
|
echo;echo "[Copying USER data....]";echo
|
2022-12-07 16:15:01 -07:00
|
|
|
rsync -av --delete /home/ $TARGET/home/
|
2022-12-07 14:24:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
usb-backup() {
|
|
|
|
umount $TARGET
|
|
|
|
|
|
|
|
echo;echo "[Mounting $USB_BACKUP]";echo
|
|
|
|
mount $USB_BACKUP $TARGET
|
2022-12-09 14:05:22 -07:00
|
|
|
|
|
|
|
if [ "$2" = "home" ]; then
|
|
|
|
homeBackup
|
|
|
|
fi
|
|
|
|
|
2022-12-07 14:24:20 -07:00
|
|
|
clean-old-snapshots "$1"
|
|
|
|
clean-old-usb-snapshots "$1"
|
|
|
|
create-usb-snapshots "$1"
|
|
|
|
send-snapshots "$1"
|
|
|
|
clean-old-snapshots "$1"
|
|
|
|
copy-efi-to-usb "$1"
|
|
|
|
cp -f /usr/bin/debian.sh $TARGET/$1
|
|
|
|
ls $TARGET/
|
|
|
|
umount $TARGET
|
|
|
|
}
|
|
|
|
|
|
|
|
usb-restore() {
|
|
|
|
partitions
|
2022-12-07 20:05:53 -07:00
|
|
|
rsync -av ../$ROOT_NAME-$2/ $TARGET/ --exclude=/home --delete
|
2022-12-09 14:05:22 -07:00
|
|
|
|
|
|
|
if [ "$2" = "home" ]; then
|
|
|
|
rsync -av --delete ../home/ $TARGET/home/
|
|
|
|
fi
|
|
|
|
|
2022-12-07 20:05:53 -07:00
|
|
|
cp -rf ../efi-$2/* $TARGET/boot/
|
2022-12-07 14:24:20 -07:00
|
|
|
fstab
|
|
|
|
cp -f debian.sh $TARGET/
|
|
|
|
systemMounts
|
2022-12-07 20:05:53 -07:00
|
|
|
chroot $TARGET /debian.sh bootloader $1
|
2022-12-07 14:24:20 -07:00
|
|
|
chroot $TARGET /debian.sh btrfs-tweaks
|
|
|
|
rm -f $TARGET/debian.sh
|
|
|
|
unmount
|
|
|
|
}
|
|
|
|
|
|
|
|
systemMounts(){
|
|
|
|
mount -o bind /dev $TARGET/dev
|
|
|
|
mount -o bind /dev/pts $TARGET/dev/pts
|
|
|
|
mount -o bind /proc $TARGET/proc
|
|
|
|
mount -o bind /sys $TARGET/sys
|
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
|
|
|
partitions
|
2022-12-07 15:43:41 -07:00
|
|
|
sed -i '/^SigLevel/s/^\(.*\)$/#\1\n/' /etc/pacman.conf
|
|
|
|
sed -i '/#SigLevel/a SigLevel = Never' /etc/pacman.conf
|
|
|
|
pacman -Sy archlinux-keyring debootstrap --noconfirm
|
2022-12-07 14:24:20 -07:00
|
|
|
apt update;apt install debootstrap -y
|
|
|
|
rm -rf /debootstrap
|
2022-12-09 13:30:36 -07:00
|
|
|
debootstrap --arch amd64 $DEBIAN_RELEASE $TARGET https://deb.debian.org/debian
|
2022-12-07 14:24:20 -07:00
|
|
|
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
|
2022-12-09 13:30:36 -07:00
|
|
|
echo "deb https://deb.debian.org/debian $DEBIAN_RELEASE main contrib non-free" >>$TARGET/etc/apt/sources.list
|
2022-12-07 14:24:20 -07:00
|
|
|
chroot $TARGET /usr/bin/apt update
|
2022-12-07 22:12:26 -07:00
|
|
|
chroot $TARGET /usr/bin/bash -c "export DEBIAN_FRONTEND=noninteractive;/usr/bin/apt install -y $PACKAGES"
|
2022-12-07 14:24:20 -07:00
|
|
|
locale
|
|
|
|
accounts
|
|
|
|
auto_login
|
|
|
|
custom_service_files
|
|
|
|
services
|
|
|
|
btrfs-tweaks
|
2022-12-07 20:05:53 -07:00
|
|
|
setup_script "$1"
|
2022-12-07 14:24:20 -07:00
|
|
|
unmount
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
desktop(){
|
|
|
|
systemctl disable --now exim4
|
|
|
|
systemctl disable --now cockpit.socket
|
|
|
|
systemctl disable --now redis-server
|
|
|
|
systemctl disable --now postgresql
|
|
|
|
apt remove firefox-esr -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-*
|
|
|
|
}
|
|
|
|
|
|
|
|
enter_chroot() {
|
|
|
|
printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root
|
|
|
|
mounts
|
|
|
|
systemMounts
|
|
|
|
chroot $TARGET /bin/bash
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
kernel-packages(){
|
2022-12-07 20:05:53 -07:00
|
|
|
/usr/bin/apt install --reinstall -y linux-image-`ls /lib/modules/` grub-efi efibootmgr plymouth plymouth-themes btrfs-progs cryptsetup-initramfs linux-image-amd64 linux-headers-amd64 firmware-iwlwifi firmware-linux firmware-linux-nonfree
|
2022-12-07 14:24:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bootloader() {
|
|
|
|
echo "root UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2) none luks" > /etc/crypttab
|
|
|
|
/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 root=UUID=$(/sbin/blkid | grep root | cut -d '"' -f4) rootflags=subvol@${ROOT_NAME} mitigations=-off" >>/etc/default/grub
|
|
|
|
echo "GRUB_ENABLE_CRYPTODISK=y" >>/etc/default/grub
|
2022-12-10 13:42:48 -07:00
|
|
|
/sbin/grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=debian
|
2022-12-07 14:24:20 -07:00
|
|
|
/sbin/update-grub
|
|
|
|
}
|
|
|
|
|
|
|
|
function setup_script() {
|
|
|
|
cp -f debian.sh $TARGET/usr/bin/
|
|
|
|
echo 'bash /usr/bin/debian.sh kernel-packages' >>$TARGET/setup.sh
|
2022-12-07 20:05:53 -07:00
|
|
|
echo "bash /usr/bin/debian.sh bootloader $1" >>$TARGET/setup.sh
|
2022-12-07 20:14:55 -07:00
|
|
|
echo 'bash /usr/bin/debian.sh grub-snapshots' >>$TARGET/setup.sh
|
|
|
|
echo 'bash /usr/bin/debian.sh desktop' >>$TARGET/setup.sh
|
|
|
|
echo 'bash /usr/bin/debian.sh btrfs-tweaks' >>$TARGET/setup.sh
|
2022-12-07 14:24:20 -07:00
|
|
|
|
|
|
|
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/@postgres
|
|
|
|
btrfs sub create $TARGET/@containers
|
|
|
|
echo
|
|
|
|
echo "Binding BTRFS Root"
|
|
|
|
echo
|
|
|
|
umount $TARGET
|
2022-12-09 09:49:37 -07:00
|
|
|
mount -o $COMPRESSION,subvol=@$ROOT_NAME /dev/mapper/root $TARGET
|
2022-12-07 14:24:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mounts() {
|
|
|
|
echo
|
|
|
|
echo "Mounting......."
|
|
|
|
mount /dev/mapper/root $TARGET
|
|
|
|
btrfs_filesytem
|
|
|
|
mkdir -p $TARGET/boot
|
|
|
|
mount -t ext4 $BOOT $TARGET/boot
|
|
|
|
mkdir -p $TARGET/boot/efi
|
|
|
|
mount $EFI $TARGET/boot/efi
|
2022-12-08 08:11:29 -07:00
|
|
|
#CONFIGURE DATA DIRS (HOME)
|
2022-12-07 14:24:20 -07:00
|
|
|
mkdir $TARGET/home
|
|
|
|
mount -o subvol=@home /dev/mapper/root $TARGET/home
|
|
|
|
}
|
|
|
|
|
|
|
|
unmount() {
|
|
|
|
echo
|
|
|
|
echo "Unmounting....."
|
|
|
|
umount $TARGET/proc
|
|
|
|
umount $TARGET/dev
|
|
|
|
umount $TARGET/sys
|
|
|
|
umount $TARGET/boot
|
|
|
|
umount $TARGET/home
|
|
|
|
umount -R $TARGET/*
|
|
|
|
umount -R $TARGET
|
|
|
|
umount -R $TARGET
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
unmount
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Formatting $EFI"
|
|
|
|
echo
|
2022-12-07 16:15:01 -07:00
|
|
|
echo y | mkfs.vfat $EFI
|
2022-12-07 14:24:20 -07:00
|
|
|
echo "Formatting $BOOT"
|
2022-12-07 16:15:01 -07:00
|
|
|
echo y | mkfs.ext4 $BOOT
|
2022-12-07 14:24:20 -07:00
|
|
|
|
|
|
|
mounts
|
|
|
|
|
|
|
|
#Configure /etc/fstab
|
|
|
|
fstab
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2022-12-09 09:49:37 -07:00
|
|
|
echo "/dev/mapper/root / 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 /var/lib/libvirt btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@libvirt 0 1" >>$TARGET/etc/fstab
|
2022-12-07 14:24:20 -07:00
|
|
|
echo "tmpfs /var/log tmpfs defaults 0 0" >>$TARGET/etc/fstab
|
|
|
|
echo "tmpfs /var/cache/pacman/pkg tmpfs defaults 0 0" >>$TARGET/etc/fstab
|
2022-12-09 09:49:37 -07:00
|
|
|
echo "/dev/mapper/root /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 /var/lib/postgresql btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@postgres 0 1" >>$TARGET/etc/fstab
|
|
|
|
echo "/dev/mapper/root /var/lib/containers btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@containers 0 1" >>$TARGET/etc/fstab
|
2022-12-07 14:24:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
accounts() {
|
|
|
|
echo
|
|
|
|
echo "Set Password for $USER"
|
|
|
|
echo "useradd -m -s /bin/bash $USER" >>$TARGET/setup.sh
|
|
|
|
echo "echo \"$USER:$USER_PASSWORD\"| chpasswd " >>$TARGET/setup.sh
|
|
|
|
echo "gpasswd -a $USER wheel" >>$TARGET/setup.sh
|
|
|
|
echo "gpasswd -a $USER network" >>$TARGET/setup.sh
|
|
|
|
echo "gpasswd -a $USER video" >>$TARGET/setup.sh
|
|
|
|
echo "gpasswd -a $USER libvirt" >>$TARGET/setup.sh
|
2022-12-08 06:53:25 -07:00
|
|
|
echo "gpasswd -a $USER netdev" >>$TARGET/setup.sh
|
2022-12-07 14:24:20 -07:00
|
|
|
echo "$USER ALL=(ALL) ALL" >$TARGET/etc/sudoers
|
|
|
|
echo "root ALL=(ALL) ALL" >>$TARGET/etc/sudoers
|
|
|
|
echo
|
|
|
|
echo "Setting ROOT Password:"
|
|
|
|
echo "echo \"root:$ROOT_PASSWORD\"| chpasswd " >>$TARGET/setup.sh
|
2022-12-09 13:38:14 -07:00
|
|
|
echo "/usr/bin/hostnamectl set-hostname $ROOT_NAME" >>$TARGET/setup.sh
|
2022-12-07 14:24:20 -07:00
|
|
|
|
|
|
|
#Change Shell to ZSH
|
|
|
|
#echo "printf "$USER_PASSWORD" | chsh -s /bin/zsh $USER" >>$TARGET/setup.sh
|
|
|
|
#echo "printf "$ROOT_PASSWORD" | chsh -s /bin/zsh " >>$TARGET/setup.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
btrfs-tweaks() {
|
2022-12-09 09:49:37 -07:00
|
|
|
DISABLE_COW=("/var/lib/docker" "/var/lib/containers" "/var/lib/postgresql" "/var/lib/mysql" "/var/lib/libvirt");
|
2022-12-07 14:24:20 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
services() {
|
|
|
|
for i in "${SERVICES[@]}"
|
|
|
|
do
|
|
|
|
echo "systemctl enable $i" >>$TARGET/setup.sh
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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 500MiB
|
|
|
|
parted /dev/$HARD_DISK set 1 esp on
|
|
|
|
parted /dev/$HARD_DISK mkpart P2 ext3 500MiB 100%
|
|
|
|
printf "$DISK_PASSWORD\n$DISK_PASSWORD" | cryptsetup luksFormat ${BTRFS}
|
|
|
|
printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root
|
|
|
|
echo
|
|
|
|
echo "Formatting....."
|
|
|
|
echo y | mkfs.btrfs /dev/mapper/root --force
|
|
|
|
}
|
|
|
|
|
|
|
|
wifi() {
|
|
|
|
iwctl --passphrase $WIRELESS_PASSWORD station $WIRELESS_INTERFACE connect $SSID
|
|
|
|
}
|
|
|
|
|
|
|
|
show-help() {
|
|
|
|
echo
|
|
|
|
echo "debian.sh arguments:"
|
|
|
|
echo
|
2022-12-07 16:15:01 -07:00
|
|
|
echo "./debian.sh install [disk]"
|
2022-12-09 14:05:22 -07:00
|
|
|
echo "./debian.sh backup [device name] [home]"
|
2022-12-09 14:06:04 -07:00
|
|
|
echo "./debian.sh restore [disk] [backup name] [home]"
|
2022-12-07 20:05:53 -07:00
|
|
|
echo "./debian.sh chroot [disk]"
|
2022-12-07 14:24:20 -07:00
|
|
|
echo "./debian.sh wifi"
|
2022-12-07 20:14:55 -07:00
|
|
|
echo "./debian.sh bootloader [disk]"
|
2022-12-07 16:15:01 -07:00
|
|
|
echo "./debian.sh initialize [disk]"
|
2022-12-07 14:24:20 -07:00
|
|
|
echo "./debian.sh snapshot"
|
|
|
|
echo "./debian.sh reomve-snapshot"
|
|
|
|
echo "./debian.sh btrfs-tweaks"
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" = "install" ]; then
|
2022-12-07 20:05:53 -07:00
|
|
|
install "$2"
|
2022-12-07 14:24:20 -07:00
|
|
|
elif [ "$1" = "desktop" ]; then
|
|
|
|
desktop
|
|
|
|
elif [ "$1" = "kernel-packages" ]; then
|
|
|
|
kernel-packages
|
|
|
|
elif [ "$1" = "upgrade-system" ]; then
|
|
|
|
upgrade-system
|
|
|
|
elif [ "$1" = "chroot" ]; then
|
|
|
|
enter_chroot
|
|
|
|
elif [ "$1" = "initialize" ]; then
|
|
|
|
initialize-disk
|
|
|
|
elif [ "$1" = "wifi" ]; then
|
|
|
|
wifi
|
|
|
|
elif [ "$1" = "flatpaks" ]; then
|
|
|
|
flatpaks
|
|
|
|
elif [ "$1" = "bootloader" ]; then
|
|
|
|
bootloader
|
|
|
|
elif [ "$1" = "snapshot" ]; then
|
|
|
|
snapshots
|
|
|
|
elif [ "$1" = "backup" ]; then
|
2022-12-09 14:05:22 -07:00
|
|
|
usb-backup "$2" "$3"
|
2022-12-07 14:24:20 -07:00
|
|
|
elif [ "$1" = "grub-snapshots" ]; then
|
|
|
|
grub-snapshots
|
|
|
|
elif [ "$1" = "btrfs-tweaks" ]; then
|
|
|
|
btrfs-tweaks
|
|
|
|
elif [ "$1" = "restore" ]; then
|
2022-12-07 20:05:53 -07:00
|
|
|
usb-restore "$2" "$3"
|
2022-12-07 14:24:20 -07:00
|
|
|
elif [ "$1" = "remove-snapshot" ]; then
|
|
|
|
remove-snapshots
|
|
|
|
elif [ "$1" = "help" ]; then
|
|
|
|
show-help
|
|
|
|
else
|
|
|
|
show-help
|
|
|
|
fi
|