From 23987b208758db934a12e732c7e27d4a73572769 Mon Sep 17 00:00:00 2001 From: Steve Dogiakos Date: Sun, 28 Dec 2025 20:18:55 -0700 Subject: [PATCH] debian scripts from 7040 --- debian/ip_address_fix.sh | 33 ++++++++++++++++++++++++++++ debian/move_recent.sh | 35 ++++++++++++++++++++++++++++++ debian/paperless_tmp_clean.sh | 2 ++ debian/update_yacreader_library.sh | 22 +++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100755 debian/ip_address_fix.sh create mode 100644 debian/move_recent.sh create mode 100644 debian/paperless_tmp_clean.sh create mode 100755 debian/update_yacreader_library.sh diff --git a/debian/ip_address_fix.sh b/debian/ip_address_fix.sh new file mode 100755 index 0000000..30ace15 --- /dev/null +++ b/debian/ip_address_fix.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Ensure the script is run as root +if [ "$EUID" -ne 0 ]; then + echo "Please run as root or use sudo" + exit 1 +fi + +# Install resolvconf +apt update && apt install -y resolvconf + +# Enable and start resolvconf service +systemctl enable resolvconf +systemctl start resolvconf + +# Check service status +systemctl status resolvconf --no-pager + +# Update resolv.conf head file +cat < /etc/resolvconf/resolv.conf.d/head +nameserver 8.8.8.8 +nameserver 8.8.4.4 +EOF + +# Apply changes +resolvconf --enable-updates +resolvconf -u + +# Confirm changes +echo "Updated resolv.conf file:" +cat /etc/resolv.conf + +echo "resolvconf setup completed successfully." diff --git a/debian/move_recent.sh b/debian/move_recent.sh new file mode 100644 index 0000000..d21d18c --- /dev/null +++ b/debian/move_recent.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Configuration +SOURCE_DIR="/mnt/storage/Downloads" +DEST_DIR="/home/steve/new_books" +TIMESTAMP_FILE="/home/steve/.last_book_upload_time" + +# Resolve full path of this script so we can exclude it +SCRIPT_PATH="$(readlink -f "$0")" + +# Ensure destination exists +mkdir -p "$DEST_DIR" + +# If no timestamp file exists, create one with a default time +if [ ! -f "$TIMESTAMP_FILE" ]; then + echo "First run. Creating timestamp file." + date -d "1 day ago" +"%Y-%m-%d %H:%M:%S" > "$TIMESTAMP_FILE" +fi + +# Read the last run time +LAST_RUN=$(cat "$TIMESTAMP_FILE") + +echo "Syncing items modified since: $LAST_RUN" + +# Find modified items (top-level only), excluding this script +find "$SOURCE_DIR" -mindepth 1 -maxdepth 1 -newermt "$LAST_RUN" -print0 | +while IFS= read -r -d '' ITEM; do + ITEM_PATH="$(readlink -f "$ITEM")" + if [ "$ITEM_PATH" != "$SCRIPT_PATH" ]; then + rsync -rP "$ITEM" "$DEST_DIR/" + fi +done + +# Update timestamp after sync +date +"%Y-%m-%d %H:%M:%S" > "$TIMESTAMP_FILE" diff --git a/debian/paperless_tmp_clean.sh b/debian/paperless_tmp_clean.sh new file mode 100644 index 0000000..96cf8dc --- /dev/null +++ b/debian/paperless_tmp_clean.sh @@ -0,0 +1,2 @@ +#!/bin/bash +find /var/lib/docker/overlay2/${TMP}/diff/tmp -type f -atime +1 -exec rm -f {} \; diff --git a/debian/update_yacreader_library.sh b/debian/update_yacreader_library.sh new file mode 100755 index 0000000..875647a --- /dev/null +++ b/debian/update_yacreader_library.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Variables +CONTAINER_NAME="yacreader" +LIBRARY_PATH="/comics" +COMMAND="YACReaderLibraryServer update-library" + +# Check if the container is running +if docker ps --format "{{.Names}}" | grep -q "^$CONTAINER_NAME$"; then + echo "Container '$CONTAINER_NAME' is running. Executing the update command..." + docker exec "$CONTAINER_NAME" $COMMAND "$LIBRARY_PATH" + if [ $? -eq 0 ]; then + echo "Library update completed successfully." + else + echo "An error occurred while updating the library." + exit 1 + fi +else + echo "Error: Container '$CONTAINER_NAME' is not running." + exit 1 +fi +