This commit is contained in:
Your Name 2024-07-29 22:12:20 -06:00
parent bb70f48f36
commit 4f0f5fa5ce

134
debian.sh
View File

@ -82,7 +82,7 @@ auto_login() {
fi
}
hibernate-setup() {
hibernation() {
echo "[Sleep]" >/etc/systemd/sleep.conf
echo "AllowSuspend=yes" >>/etc/systemd/sleep.conf
echo "AllowHibernation=yes" >>/etc/systemd/sleep.conf
@ -97,7 +97,7 @@ hibernate-setup() {
ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /usr/lib/systemd/system/systemd-suspend.service
}
create-os-snapshots() {
osSnapshots() {
echo
mkdir $2
echo "[Creating new OS snapshot to $2/$3.tgz]"
@ -117,7 +117,7 @@ homeBackup() {
rsync -a --delete /home/ --exclude=.cache --exclude=.local/share/flatpak --exclude=.local/share/containers $TARGET/\@home/
}
os-backup() {
osBackup() {
umount $TARGET
printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} $ROOT_MAPPER_NAME
@ -132,7 +132,7 @@ os-backup() {
homeBackup
fi
create-os-snapshots "$1" "$2" "$3"
osSnapshots "$1" "$2" "$3"
else
echo
echo "Aborting Install, $TARGET/@$ROOT_MAPPER_NAME/usr/bin/bash not found!"
@ -154,7 +154,7 @@ os-backup() {
cryptsetup close $ROOT_MAPPER_NAME
}
live-os-restore() {
liveOSrestore() {
clear
mkdir /tmp/live
LIVE_OS_DM="/dev/mapper/$(mount | grep -i ' / ' | cut -d '/' -f4 | cut -d ' ' -f1)"
@ -178,7 +178,7 @@ live-os-restore() {
rsync -av --delete /boot/ $TARGET/boot/
chmod +x $TARGET/usr/bin/debian.sh
chroot $TARGET /usr/bin/debian.sh bootloader $1 $5 $2
chroot $TARGET /usr/bin/debian.sh btrfs-tweaks
chroot $TARGET /usr/bin/debian.sh btrfsTweaks
chroot $TARGET /usr/bin/debian.sh accounts
read -p 'Would you like to run your UserTweaks? :' -e -i 'y' user_tweaks
@ -197,10 +197,29 @@ live-os-restore() {
}
userTweaks() {
echo "Nothing here yet!"
mkdir $TARGET/home/$USER/.librewolf
mkdir -p $TARGET/home/$USER/.config/autostart
mkdir -p $TARGET/home/$USER/Documents/keys/keepass
mkdir -p $TARGET/home/$USER/dotfiles
mkdir -p $TARGET/home/$USER/server
mkdir -p $TARGET/home/$USER/.config/Exodus
mkdir -p $TARGET/home/$USER/.config/evolution
mkdir -p $TARGET/home/$USER/.config/goa-1.0
rsync -av --delete /home/$USER/server/ $TARGET/home/$USER/server/
rsync -av --delete /home/$USER/.config/Exodus/ $TARGET/home/$USER/.config/Exodus/
rsync -av --delete /home/$USER/.config/evolution/ $TARGET/home/$USER/.config/evolution/
rsync -av --delete /home/$USER/.config/goa-1.0/ $TARGET/home/$USER/.config/goa-1.0/
rsync -av --delete /home/$USER/.librewolf/ $TARGET/home/$USER/.librewolf/
rsync -av --delete /home/$USER/.config/autostart/ $TARGET/home/$USER/.config/autostart/
rsync -av --delete /home/$USER/Documents/keys/keepass/ $TARGET/home/$USER/Documents/keys/keepass/
rsync -av --delete /home/$USER/dotfiles/ $TARGET/home/$USER/dotfiles/
rsync -av --delete /home/$USER/.config/keepassxc/ $TARGET/home/$USER/.config/keepassxc/
chmod +x $TARGET/home/$USER/dotfiles/scripts/keepass.sh
chroot $TARGET /usr/bin/systemctl disable libvirtd libvirtd.socket firewall.service
}
os-restore() {
osRestore() {
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
@ -219,7 +238,7 @@ os-restore() {
systemMounts
chmod +x $TARGET/debian.sh
chroot $TARGET /debian.sh bootloader $1 $2 $5
chroot $TARGET /debian.sh btrfs-tweaks
chroot $TARGET /debian.sh btrfsTweaks
chroot $TARGET /debian.sh accounts
chown -R $USER:$USER $TARGET/home/$USER
auto_login
@ -274,14 +293,14 @@ make-image() {
umount $TARGET
mount -t tmpfs tmpfs -o size=15G,dev,exec $TARGET
debootstrap --arch amd64 $DEBIAN_RELEASE $TARGET https://deb.debian.org/debian
configure-repository
configureRepository
locale
custom_service_files
rm -rf $TARGET/var/lib/flatpak
cp -f debian.sh $TARGET/usr/bin/
echo 'bash /usr/bin/debian.sh hibernate' >>$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 grubSnapshotss' >>$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
@ -309,11 +328,11 @@ install() {
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
configureRepository
locale
auto_login
custom_service_files
setup_script "$1"
setupScript "$1"
echo -e "ALGO=zstd\nPERCENT=60" | tee -a $TARGET/etc/default/zramswap
echo 'DPkg::Post-Invoke {"/usr/bin/debian.sh snapshot";};' >$TARGET/etc/apt/apt.conf
#unmount
@ -347,8 +366,9 @@ stableDiffusion() {
}
desktop() {
SERVICES+=(pmcd pmie pmlogger pmproxy exim4 cockpit.socket apparmor nfs-server smbd rpbind rpcbind.socket avahi-daemon bluetooth)
for i in "${SERVICES[@]}"; do
OS_SERVICES=("pmcd" "pmie" "pmlogger" "pmproxy" "exim4" "cockpit.socket" "apparmor" "nfs-server" "smbd" "rpbind" "rpcbind.socket" "avahi-daemon" "bluetooth")
for i in "${OS_SERVICES[@]}"; do
systemctl disable --now $i
done
@ -356,7 +376,7 @@ desktop() {
echo
echo "Performing KDE Bloat Removal"
echo
BLOAT_APPS+=(dragonplayer akregator kate konqueror kdeconnect)
BLOAT_APPS=(dragonplayer akregator kate konqueror kdeconnect)
for i in "${BLOAT_APPS[@]}"; do
echo "Removing: $i"
apt remove --purge -y $i
@ -374,7 +394,7 @@ desktop() {
chmod -x /usr/libexec/evolution-data-server/evolution-alarm-notify
mv /usr/lib/evolution-data-server /usr/lib/evolution-data-server-disabled
mv /usr/lib/evolution /usr/lib/evolution-disabled
BLOAT_APPS+=(evolution four-in-a-row iagno aisleriot gnome-mahjongg gnome-software lightsoff zutty gnome-taquin gnome-tetravex simple-scan gnome-text-editor gnome-chess gnome-contacts gnome-clocks unattended-upgrades apparmor gnome-sound-recorder hitori shotwell quadrapassel quadrapassel gnome-sudoku swell-foop gnome-maps transmission-gtk cheese libgnome-games-support-common chromium chromium-common chromium-sandbox epiphany-browser epiphany-browser-data)
BLOAT_APPS=(evolution four-in-a-row iagno aisleriot gnome-mahjongg gnome-software lightsoff zutty gnome-taquin gnome-tetravex simple-scan gnome-text-editor gnome-chess gnome-contacts gnome-clocks unattended-upgrades apparmor gnome-sound-recorder hitori shotwell quadrapassel quadrapassel gnome-sudoku swell-foop gnome-maps transmission-gtk cheese libgnome-games-support-common chromium chromium-common chromium-sandbox epiphany-browser epiphany-browser-data)
for i in "${BLOAT_APPS[@]}"; do
echo "Removing: $i"
apt remove --purge -y $i
@ -386,7 +406,7 @@ desktop() {
installCodium
installSteam
if [[ $SWAP_CHOICE = *y* ]]; then
hibernate-setup
hibernation
fi
apt autoremove -y
}
@ -400,7 +420,7 @@ snapshots() {
#update-grub
}
remove-snapshots() {
removeSnapshots() {
btrfs sub delete /.snapshots/*
rm -f /boot/loader/entries/root-*
}
@ -416,7 +436,7 @@ flatpaks() {
done
}
grub-snapshots() {
grubSnapshotss() {
cd /opt
git clone https://github.com/Antynea/grub-btrfs.git
cd /opt/grub-btrfs
@ -455,15 +475,15 @@ bootloader() {
}
function setup_script() {
setupScript() {
cp -f debian.sh $TARGET/usr/bin/
#sed -i 's/most/dep/i' $TARGET/etc/initramfs-tools/initramfs.conf
echo 'bash /usr/bin/debian.sh hibernate' >>$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 grubSnapshotss' >>$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
echo 'bash /usr/bin/debian.sh btrfsTweaks' >>$TARGET/setup.sh
chmod +x $TARGET/usr/bin/debian.sh
chmod +x $TARGET/setup.sh
@ -612,7 +632,7 @@ accounts() {
/usr/bin/hostnamectl set-hostname $ROOT_NAME
}
btrfs-tweaks() {
btrfsTweaks() {
DISABLE_COW=("/var/lib/docker" "/var/lib/containers" "/volumes" "/var/lib/mysql" "/var/lib/libvirt")
for i in "${DISABLE_COW[@]}"; do
@ -633,12 +653,12 @@ custom_service_files() {
}
gnome-unmounter() {
gnomeUnmounter() {
umount /media/*/* -R
/sbin/cryptsetup close /dev/mapper/luks-*
}
legacy-efi-resize() {
legacyEFIresize() {
clear
echo
echo "[Debian Installer - Resize EFI]"
@ -670,7 +690,7 @@ legacy-efi-resize() {
echo
}
initialize-disk() {
initializeDisk() {
clear
echo
echo "[Debian Installer - Initialize Device]"
@ -710,7 +730,7 @@ wifi() {
iwctl --passphrase $WIRELESS_PASSWORD station $WIRELESS_INTERFACE connect $SSID
}
show-help() {
showHelp() {
clear
echo
echo "[debian.sh arguments]"
@ -721,7 +741,7 @@ show-help() {
echo "./debian.sh tar [device name] [location]"
echo "./debian.sh snapshot"
echo "./debian.sh reomve-snapshot"
echo "./debian.sh btrfs-tweaks"
echo "./debian.sh btrfsTweaks"
echo
}
@ -743,7 +763,7 @@ tweaks() {
echo "[Password Protection at Boot]"
echo
echo
set-devices
setDevices
read -p 'Unlock Disk without password at boot time? ' -e -i "y" pass_change
if [[ $pass_change = *n* ]]; then
AUTO_DECRYPT="False"
@ -767,12 +787,12 @@ tweaks() {
PACKAGES=$BASE_PACKAGES$SHARED_DESKTOP_APPS$GNOME_DESKTOP_ENV$VIRTUALIZATION
fi
ROOT_MAPPER_NAME="/dev/foo"
make-image "$image_directory"
makeImage "$image_directory"
elif [[ $choice = 3 ]]; then
set-devices
setDevices
bootloader $HARD_DISK $ROOT_NAME $ROOT_MAPPER_NAME
elif [[ $choice = 4 ]]; then
set-devices
setDevices
partitions
systemMounts
if [[ -e "$TARGET/usr/bin/bash" ]]; then
@ -785,11 +805,11 @@ tweaks() {
#unmount
elif [[ $choice = 5 ]]; then
rm -f /tmp/disk
set-devices
legacy-efi-resize
setDevices
legacyEFIresize
elif [[ $choice = 6 ]]; then
set-devices
live-os-restore "$HARD_DISK" $ROOT_MAPPER_NAME "none" "none" "$ROOT_NAME"
setDevices
liveOSrestore "$HARD_DISK" $ROOT_MAPPER_NAME "none" "none" "$ROOT_NAME"
fi
}
@ -817,34 +837,34 @@ menu() {
else
PACKAGES=$BASE_PACKAGES$SHARED_DESKTOP_APPS$GNOME_DESKTOP_ENV
fi
set-devices
setDevices
install "$HARD_DISK"
elif [[ $choice = 2 ]]; then
clear
echo "[Backup OS]"
echo
set-devices
setDevices
read -p 'Backup Home Directory? : ' -e -i 'n' home_backup
read -p 'OS Backup Directory Location : ' -e -i "/install/@$ROOT_NAME" backup_directory
if [[ $home_backup = *n* ]]; then
os-backup "none" "$backup_directory" "$ROOT_NAME"
osBackup "none" "$backup_directory" "$ROOT_NAME"
else
os-backup "home" "$backup_directory" "$ROOT_NAME"
osBackup "home" "$backup_directory" "$ROOT_NAME"
fi
elif [[ $choice = 3 ]]; then
clear
echo "[Restore from Backup]"
echo
echo
set-devices
setDevices
read -p 'Restore Directory Image Source: ' -e -i "/mnt" 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"
osRestore "$HARD_DISK" "$backup_name" "none" "$restore_directory" "$ROOT_MAPPER_NAME"
else
os-restore "$HARD_DISK" "$backup_name" "home" "$restore_directory" "$ROOT_MAPPER_NAME"
osRestore "$HARD_DISK" "$backup_name" "home" "$restore_directory" "$ROOT_MAPPER_NAME"
fi
elif [[ $choice = 4 ]]; then
tweaks
@ -854,15 +874,15 @@ menu() {
echo
echo
rm -f /tmp/disk
set-devices
initialize-disk
setDevices
initializeDisk
else
menu
fi
}
set-devices() {
setDevices() {
if [ -f "/tmp/disk" ]; then
HARD_DISK=$(cat /tmp/disk | head -1)
ROOT_NAME=$(cat /tmp/disk | tail -3 | head -1)
@ -894,17 +914,17 @@ set-devices() {
echo $root_name >>/tmp/disk
echo $device_mapper_name >>/tmp/disk
echo $SWAP_CHOICE >>/tmp/disk
set-devices
etDevices
fi
partitionDetection
}
gnome-unmounter
gnomeUnmounter
if [ "$1" = "desktop" ]; then
desktop
elif [ "$1" = "tar" ]; then
create-os-snapshots "null" "$3" "$2"
osSnapshots "null" "$3" "$2"
elif [ "$1" = "upgrade-system" ]; then
upgrade-system
elif [ "$1" = "wifi" ]; then
@ -914,21 +934,21 @@ elif [ "$1" = "stable-diffusion" ]; then
elif [ "$1" = "accounts" ]; then
accounts
elif [ "$1" = "hibernate" ]; then
hibernate-setup
hibernation
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" = "grubSnapshotss" ]; then
grubSnapshotss
elif [ "$1" = "btrfsTweaks" ]; then
btrfsTweaks
elif [ "$1" = "remove-snapshot" ]; then
remove-snapshots
removeSnapshots
elif [ "$1" = "help" ]; then
show-help
showHelp
else
menu
fi