From 13a7e95a52425803ba2be74cfe601e2bac960748 Mon Sep 17 00:00:00 2001 From: Matan Horovitz Date: Sat, 18 Dec 2021 16:15:54 +0200 Subject: [PATCH] Removing old scripts, renaming and cleaning up --- Bit-Frigger-Tarballer | 30 ------------------------------ GitDaemon | 11 ----------- GitUpstreamer | 22 ---------------------- Okiru | 5 ++--- Resticer.sh => Resticer | 3 +-- Vol-Sync | 18 ------------------ WindowsBoot | 11 +++++++++-- 7 files changed, 12 insertions(+), 88 deletions(-) delete mode 100755 Bit-Frigger-Tarballer delete mode 100755 GitDaemon delete mode 100755 GitUpstreamer rename Resticer.sh => Resticer (94%) delete mode 100755 Vol-Sync diff --git a/Bit-Frigger-Tarballer b/Bit-Frigger-Tarballer deleted file mode 100755 index d6e067c..0000000 --- a/Bit-Frigger-Tarballer +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# Script to export the Bit Frigger's rootfs to a zstd tarball periodically -FINAL_DIR="/Red-Vol/Backups/Bit-Frigger/Tarball" -#Check for root permissions -if [[ $(whoami) != "root" ]]; then - echo "Please run this script as root or with sudo." - exit -fi -#Create directory if it does not exist -if [[ ! -d $FINAL_DIR ]]; then - echo "Destination directory $FINAL_DIR does not exist. Creating..." - mkdir $FINAL_DIR - echo "Changing ownership to shmick." - chown -r shmick:shmick $FINAL_DIR -else - echo "Destination directory exists." -fi -#Sync everything to it -echo "Gathering files for the tarball" -rsync -aHAXSv --progress --exclude=/dev --exclude=/Red-Vol --exclude=/proc --exclude=/rksmb --exclude=/sys --exclude="/.snapshots" --exclude="/run" --exclude="/tmp" "/" "$FINAL_DIR" -#And tar it with ZSTD -echo "Compressing tarball" -cd $FINAL_DIR -echo "Working in directory $(pwd)" -if [[ -f "$FINAL_DIR/Bit-Frigger.tar" ]]; then - tar rvf Bit-Frigger.tar $(pwd) && echo "Running xz..." && xz -vv -z --threads=0 -9 Bit-Frigger.tar --memlimit=$(free -h | grep -v Swap | grep -v total | awk '{print $NF}') - -else - tar cvf Bit-Frigger.tar $(pwd) && echo "Running xz..." && xz -vv -z --threads=0 -9 Bit-Frigger.tar --memlimit=$(free -h | grep -v Swap | grep -v total | awk '{print $NF}') -fi diff --git a/GitDaemon b/GitDaemon deleted file mode 100755 index a2e5fbf..0000000 --- a/GitDaemon +++ /dev/null @@ -1,11 +0,0 @@ -#small script to be appended to bash.profile; calls the GitUpstreamer script to auto-commit changes -function cd { -# Actually change the directory with all args passed to the function -if builtin cd "$@"; then - # If the dir exists, run the git script on git directories - if [[ -d ".git" ]] ; then - echo "[git]: Note $(pwd) is under Git revision control." - . "$SCRIPTS/GitUpstreamer" - fi -fi - } diff --git a/GitUpstreamer b/GitUpstreamer deleted file mode 100755 index 57d105b..0000000 --- a/GitUpstreamer +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -#Scripts to detect and push changes if exist; Runs in Git direcories, called by GitDaemon script. -source ~/.zshrc > /dev/null 2>&1 -#This system is opt in; only kick in if there's a .autocommit file. -if [[ -f .autocommit ]]; then - if [[ -z $(git status | grep "nothing") ]]; then - #If working state is not clean - assume dirty directory - echo "[git]: Directory $(pwd) has changes uncommited to git." - echo "Auto-Commit detected changes?" - read COMMIT - if [[ $COMMIT == "Y" ]] || [[ $COMMIT == "y" ]]; then - git add . -A #Adds only essentials via reverse gitignore - echo "[git]: Committing changes..." - git commit -m "Scripted commit - $(date)" - git push >/dev/null 2>&1 - elif [[ $COMMIT == "N" ]] || [[ $COMMIT == "n" ]]; then - echo "[git]: Ignoring changes per user request." - fi - elif [[ -n $(git status | grep "nothing") ]]; then - echo "[git]: Directory has no uncommited changes." - fi -fi diff --git a/Okiru b/Okiru index a4b9a54..a33d902 100755 --- a/Okiru +++ b/Okiru @@ -50,12 +50,11 @@ logging () { export REPORT="/home/shmick/Scripts/Logs/$1/$1" export PREFIX=$1 fi - ls $LOG if [[ -f "$LOG" ]]; then OLD_LOG_DATE=$(stat $LOG | grep Modify | awk '{print $2}' | sed -e 's/-//g') OLD_LOG_TIME=$(stat $LOG | grep Modify | awk '{print $3}' | sed -e 's/://g' | awk -F. '{print $1}') - mv "$LOG" "$(dirname $LOG)/$(basename $LOG)_"$OLD_LOG_DATE"_"$OLD_LOG_TIME"" 2> /dev/null - zstd -11 --rm -f "$(dirname $LOG)/$(basename $LOG)_"$OLD_LOG_DATE"_"$OLD_LOG_TIME"" > /dev/null + mv "$LOG" "$(dirname $LOG)/$(basename $LOG)_"$OLD_LOG_DATE"_"$OLD_LOG_TIME"" 2> /dev/null 2>&1 + zstd -11 --rm -f "$(dirname $LOG)/$(basename $LOG)_"$OLD_LOG_DATE"_"$OLD_LOG_TIME"" > /dev/null 2>&1 # ^ Append timestamp (YYYYMMDD_HHMMSS - ex 20210301_093543) to log if it exists fi touch $LOG diff --git a/Resticer.sh b/Resticer similarity index 94% rename from Resticer.sh rename to Resticer index 1fac805..4681285 100755 --- a/Resticer.sh +++ b/Resticer @@ -1,7 +1,6 @@ #!/bin/bash ##Simple script to run Restic backups -source /etc/zsh/zprofile > /dev/null 2>&1 -source /home/shmick/Scripts/Okiru +source $SCRIPTS/Okiru logging Restic #Safety function; accepts repository to check diff --git a/Vol-Sync b/Vol-Sync deleted file mode 100755 index 950d10f..0000000 --- a/Vol-Sync +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -#Script to sync the Red-Vol when it comes up with the Tui64 share. -INIT_DIR='/Red-Vol' -FINAL_DIR='/rksmb/*' -HOST_IP='192.168.1.66' - -#Ping check -ping -c 4 $HOST_IP > /dev/null -#If there is ping, sync the Media and Backups subvolumes. -if [[ $(echo $?) == 0 ]]; then - sshpass -f /shmick/.ssh/sshpasskey rsync -aHAXv --progress --exclude="Torrents" shmick@$HOST_IP:$FINAL_DIR $INIT_DIR -#No DNS resolution -elif [[ $(echo $?) == 2 ]]; then - echo "Could not resolve host." -#No ping -elif [[ $(echo $?) == 1 ]]; then - echo "No communications with host." -fi diff --git a/WindowsBoot b/WindowsBoot index 83642bf..8dc4a45 100755 --- a/WindowsBoot +++ b/WindowsBoot @@ -1,4 +1,11 @@ #!/bin/bash +source $GIT_SCRIPTS/Okiru WindowsEntry=$(efibootmgr | grep "Windows Boot Manager" | awk '{print $1}' | sed -e 's/Boot//g') -efibootmgr -n $WindowsEntry -reboot +if [[ -n $WindowsEntry ]]; then + debug "Found Windows entry: $WindowsEntry" + ok "Found Windows! Rebooting" + efibootmgr -n $WindowsEntry + reboot +else + error "Found no Windows entry. SAD!" +fi