this is my life now. infinite frustration cast upon me by an evil curse
This commit is contained in:
+28
-16
@@ -6,7 +6,7 @@
|
|||||||
## x ERR/TERMINATE traps
|
## x ERR/TERMINATE traps
|
||||||
### x NO cleanup trap on EXIT
|
### x NO cleanup trap on EXIT
|
||||||
## x finish the pi query
|
## x finish the pi query
|
||||||
## add filename query
|
## x add filename query
|
||||||
|
|
||||||
set -euo pipefail # fail on fuckups to iterate fasterrr :pope: strict fuk u mode :3
|
set -euo pipefail # fail on fuckups to iterate fasterrr :pope: strict fuk u mode :3
|
||||||
|
|
||||||
@@ -16,21 +16,24 @@ timestamp="$(date +%Y-%m-%d-%H%M-%Z)"
|
|||||||
# img_name="${timestamp}_Kali-Pi5-1TB-Working.img"
|
# img_name="${timestamp}_Kali-Pi5-1TB-Working.img"
|
||||||
|
|
||||||
check_command() {
|
check_command() {
|
||||||
command -v "$1" >/dev/null 2>&1 || {
|
if ! command -v "$1" >/dev/null 2>&1; then
|
||||||
# outputz it as errror
|
# output as error to stderr, and append to log only if defined
|
||||||
echo >&2 "Required command '$1' not found. Install it and retry." | tee -a "$log"
|
echo "Required command '$1' not found. Install it and retry." >&2
|
||||||
|
if [ -n "${log:-}" ]; then
|
||||||
|
echo "Required command '$1' not found. Install it and retry." >>"$log"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# check da needed cmds~
|
# check da needed cmds~
|
||||||
for cmd in webhook xz pishrink sha256 sudo lsblk dd; do
|
for cmd in webhook xz pishrink sha256sum sudo lsblk dd; do
|
||||||
check_command "$cmd"
|
check_command "$cmd"
|
||||||
done
|
done
|
||||||
|
|
||||||
# trap function cleanup
|
# trap function cleanup
|
||||||
cleanup () {
|
cleanup () {
|
||||||
webhook "$0 errored! Cleaning up! seconds: $SECONDS line: $LINENO command: $BASHCOMMAND" true
|
webhook "$0 errored! Cleaning up! seconds: $SECONDS line: $LINENO command: $BASH_COMMAND" true
|
||||||
# supress errors if they not there
|
# supress errors if they not there
|
||||||
# to save me from testing each one or writing a fun :poe:
|
# to save me from testing each one or writing a fun :poe:
|
||||||
for file in "$img_name" "$img_name.sha256" "$img_name.xz" "$img_name.xz.sha256" "$log"; do
|
for file in "$img_name" "$img_name.sha256" "$img_name.xz" "$img_name.xz.sha256" "$log"; do
|
||||||
@@ -52,32 +55,38 @@ echo -e "\n\n\nSTARTING DUMP OPS\n\n\n"
|
|||||||
# get disk
|
# get disk
|
||||||
lsblk
|
lsblk
|
||||||
read -p "Enter Disk Name (ex. sda, sdb no /dev or anything else) " disk_choice
|
read -p "Enter Disk Name (ex. sda, sdb no /dev or anything else) " disk_choice
|
||||||
|
if [ -z "${disk_choice:-}" ]; then
|
||||||
|
echo "ERROR: No disk entered." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
disk="/dev/$disk_choice"
|
disk="/dev/$disk_choice"
|
||||||
if [ ! -e "$disk" ]; then
|
if [ ! -e "$disk" ]; then
|
||||||
echo "ERROR! /dev/$disk is not a device device!"
|
echo "ERROR: $disk is not a device." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "For Raspberry Pi? y\n default y" picheck
|
read -p "For Raspberry Pi? y\n default y" picheck
|
||||||
|
# set default to 'y' when empty
|
||||||
|
picheck=${picheck:-y}
|
||||||
|
|
||||||
# for when ask for tag
|
# for when ask for tag
|
||||||
read -p "Input File Tag" filetag
|
read -p "Input File Tag" filetag
|
||||||
# sanity check it
|
# sanity check it
|
||||||
if [ -z "$filetag" ];
|
if [ -z "$filetag" ]; then
|
||||||
echo "ERROR! File Tag is Emprty!"
|
echo "ERROR! File Tag is Empty!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log="${timestamp}_${filetag}.log"
|
log="${timestamp}_${filetag}.log"
|
||||||
echo > "$log" # initialize to empty
|
echo > "$log" # initialize to empty
|
||||||
img_name="${timestamp_${filetag}.img"
|
img_name="${timestamp}_${filetag}.img"
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# logging optinos to log file
|
# logging optinos to log file
|
||||||
echo "Selections! filetag: $filetag disk: $disk picheck: $picheck log: $log img_name: $img_name (Script Has Run $SECONDS Seconds Date $(date))" | tee -a "$log"
|
webhook "Selections! filetag: $filetag disk: $disk picheck: $picheck log: $log img_name: $img_name (Script Has Run $SECONDS Seconds Date $(date))" | tee -a "$log"
|
||||||
|
|
||||||
webhook "runnan raw dd img on $disk at to $img_name using 4M bs size (Script Has Run $SECONDS Seconds Date $(date))"
|
webhook "runnan raw dd img on $disk at to $img_name using 4M bs size (Script Has Run $SECONDS Seconds Date $(date))"
|
||||||
sudo dd if="$disk" of="$img_name" status=progress bs=4M | tee -a "$log"
|
sudo dd if="$disk" of="$img_name" status=progress bs=4M 2>&1 | tee -a "$log"
|
||||||
|
|
||||||
webhook "Changing perms abd ownership on $img_name (Script has run $SECONDS seconds date $(date))"
|
webhook "Changing perms abd ownership on $img_name (Script has run $SECONDS seconds date $(date))"
|
||||||
sudo chown princesspi:princesspi "$img_name"
|
sudo chown princesspi:princesspi "$img_name"
|
||||||
@@ -99,7 +108,7 @@ else
|
|||||||
## -n disable update check
|
## -n disable update check
|
||||||
## disavble upgrade check
|
## disavble upgrade check
|
||||||
webhook "Doing pi compress using pishrink from $img_name ($disk) to $img_name.xz (Script Has Run $SECONDS Seconds Date $(date))"
|
webhook "Doing pi compress using pishrink from $img_name ($disk) to $img_name.xz (Script Has Run $SECONDS Seconds Date $(date))"
|
||||||
pishrink -v -r -Z -a -n "$img_name" | tee -a "$log"
|
sudo pishrink -v -r -Z -a -n "$img_name" | tee -a "$log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# fuck yourself
|
# fuck yourself
|
||||||
@@ -107,8 +116,11 @@ fi
|
|||||||
# xz -t -v "$img_name.xz" | tee -a "$log"
|
# xz -t -v "$img_name.xz" | tee -a "$log"
|
||||||
# webhook "xz integrity response code: $?"
|
# webhook "xz integrity response code: $?"
|
||||||
|
|
||||||
webhook "Generating sha256 checksums of $img_name.xz to $img_name.xz.sha256 # webhook "testing xz integrity: $img_name.xz (Script Has Run $SECONDS Seconds Date $(date))"
|
msg="Generating sha256 checksums of $img_name.xz to $img_name.xz.sha256"
|
||||||
sha256sum "$img_name.xz" | tee -a "$img_name.xz.sha256"
|
webhook "$msg"
|
||||||
|
echo "$msg" >>"$log"
|
||||||
|
webhook "testing xz integrity: $img_name.xz (Script Has Run $SECONDS Seconds Date $(date))"
|
||||||
|
sha256sum "$img_name.xz" > "$img_name.xz.sha256"
|
||||||
|
|
||||||
# do not fuckin deletee this shit till it works right
|
# do not fuckin deletee this shit till it works right
|
||||||
# if [ -f "$img_name" ]; then
|
# if [ -f "$img_name" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user