commit 5c89710983e104a0a0b0456c9193d83cae3767be Author: Lorenzo Tucci Date: Wed Aug 24 16:40:31 2022 +0200 initialize repo diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e320ff --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# scripts + +A collection of scripts that I wrote and use occasionally, or simply stuff that I want to save but isn't really finished or meant to be published alone. + diff --git a/borg.sh b/borg.sh new file mode 100755 index 0000000..996d887 --- /dev/null +++ b/borg.sh @@ -0,0 +1,55 @@ +export BORG_REPO='/storage/backup' +export BORG_PASSPHRASE='discount-wham-untruth-apostle-mastiff-expand-foster-zealous-tricky' +export CLOUDDEST='backup_1:/backup' +export BORG_CACHE_DIR='/storage/backup/user/appdata/borg/cache/' +export BORG_BASE_DIR='/storage/backup/user/appdata/borg/' + + +echo "$(date "+%m-%d-%Y %T") : Borg backup has started" 2>&1 | tee -a $LOGFILE +SECONDS=0 + + +borg create \ + --verbose \ + --info \ + --list \ + --stats \ + --show-rc \ + --compression lz4 \ + --exclude-caches \ + $BORG_REPO::"root-{now:%Y-%m-%d}" \ + /home \ + /etc \ + /usr/src/linux \ + +backup_exit=$? + + +borg prune \ + --list \ + --prefix "$(hostname)-" \ + --show-rc \ + --keep-daily 7 \ + --keep-weekly 4 \ + --keep-monthly 6 \ +prune_exit=$? + + +global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit )) + +if [ ${global_exit} -eq 0 ]; +then + borgstart=$SECONDS + echo "$(date "+%m-%d-%Y %T") : Borg backup completed in $(($borgstart/ 3600))h:$(($borgstart% 3600/60))m:$(($borgstart% 60))s" | tee -a >> $LOGFILE 2>&1 + +#Reset timer + SECONDS=0 + echo "$(date "+%m-%d-%Y %T") : Rclone Borg sync has started" >> $LOGFILE + rclone sync $BORG_REPO $CLOUDDEST -P --stats 1s -v 2>&1 | tee -a $LOGFILE + rclonestart=$SECONDS + echo "$(date "+%m-%d-%Y %T") : Rclone Borg sync completed in $(($rclonestart/ 3600))h:$(($rclonestart% 3600/60))m:$(($rclonestart% 60))s" 2>&1 | tee -a $LOGFILE +# All other errors +else + echo "$(date "+%m-%d-%Y %T") : Borg has errors code:" $global_exit 2>&1 | tee -a $LOGFILE +fi +exit ${global_exit} diff --git a/kernel_update.sh b/kernel_update.sh new file mode 100755 index 0000000..9a58584 --- /dev/null +++ b/kernel_update.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Note: this script is meant to run post emerge --depclean +eselect kernel set 1 + +cp /usr/src/linux-$(uname -r)/.config /usr/src/linux + + +genkernel --install --lvm --luks --no-mountboot --no-ramdisk-modules \ +--compress-initramfs-type=lz4 --initramfs-filename=initramfs.img initramfs + +if [ -d "/usr/src/initramfs" ]; then + lz4cat /boot/initramfs.img | cpio --directory=/usr/src/initramfs -imdv +else + echo "/usr/src/initramfs does not exist. exiting" + exit +fi + +cd /usr/src/linux + +make -j16 + +if [ $? -eq 0 ]; then + mount /dev/nvme0n1p1 /boot/efi + cp arch/x86/boot/bzImage /boot/efi/EFI/Gentoo/gentoox64.efi +else + echo "Kernel compilation failed. Exiting" + exit +fi + + +# Signing for SecureBoot, expected directory is /etc/efikeys/ + +cd /etc/efikeys/ + +sbsign --key db.key --cert db.crt --output /boot/efi/EFI/Gentoo/gentoox64.efi /boot/efi/EFI/Gentoo/gentoox64.efi + +umount /boot/efi