updated scripts (added podman-update.sh)

This commit is contained in:
liph
2026-02-25 10:26:28 +01:00
parent 1baf5ecddf
commit 07d8051731
18 changed files with 703 additions and 22 deletions

View File

91
scripts/scripts/aria.sh Executable file
View File

@@ -0,0 +1,91 @@
#!/bin/bash
# Fast Aria2 Download Script
# Usage: ./aria2-download.sh <URL> [output-filename]
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if aria2c is installed
if ! command -v aria2c &> /dev/null; then
echo -e "${RED}aria2c is not installed!${NC}"
echo "Installing aria2..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt-get &> /dev/null; then
sudo apt-get update && sudo apt-get install -y aria2
elif command -v yum &> /dev/null; then
sudo yum install -y aria2
elif command -v pacman &> /dev/null; then
sudo pacman -S aria2
else
echo -e "${RED}Please install aria2 manually${NC}"
exit 1
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install aria2
else
echo -e "${RED}Please install Homebrew or aria2 manually${NC}"
exit 1
fi
else
echo -e "${RED}Unsupported OS. Please install aria2 manually${NC}"
exit 1
fi
fi
# Check if URL is provided
if [ -z "$1" ]; then
echo -e "${RED}Error: No URL provided${NC}"
echo "Usage: $0 <URL> [output-filename]"
exit 1
fi
URL="$1"
OUTPUT_FILE="$2"
# Build aria2c command with optimized settings
ARIA2_CMD="aria2c \
--max-connection-per-server=16 \
--split=16 \
--min-split-size=1M \
--max-concurrent-downloads=16 \
--continue=true \
--max-tries=5 \
--retry-wait=3 \
--timeout=60 \
--connect-timeout=30 \
--file-allocation=none \
--summary-interval=0 \
--console-log-level=notice"
# Add output filename if provided
if [ -n "$OUTPUT_FILE" ]; then
ARIA2_CMD="$ARIA2_CMD --out=\"$OUTPUT_FILE\""
fi
# Add URL
ARIA2_CMD="$ARIA2_CMD \"$URL\""
echo -e "${GREEN}Starting download...${NC}"
echo -e "${YELLOW}URL: $URL${NC}"
if [ -n "$OUTPUT_FILE" ]; then
echo -e "${YELLOW}Output: $OUTPUT_FILE${NC}"
fi
echo ""
# Execute download
eval $ARIA2_CMD
if [ $? -eq 0 ]; then
echo -e "\n${GREEN}✓ Download completed successfully!${NC}"
else
echo -e "\n${RED}✗ Download failed!${NC}"
exit 1
fi

107
scripts/scripts/extraudio.sh Executable file
View File

@@ -0,0 +1,107 @@
#!/bin/bash
# Ask where to place the MP3 files
read -p "Place MP3s in same folder as MP4s? (y/n) [y]: " same_folder
same_folder=${same_folder:-y}
if [[ "$same_folder" =~ ^[Nn]$ ]]; then
read -p "Enter output folder path: " output_folder
mkdir -p "$output_folder"
else
output_folder=""
fi
# Get default values from folder structure
# Current directory is "The Energies of Love"
default_album=$(basename "$PWD")
# Parent directory is "Donna Eden & David Feinstein"
default_album_artist=$(basename "$(dirname "$PWD")")
# Prompt for metadata with defaults
read -p "Enter Album Artist [$default_album_artist]: " album_artist
album_artist=${album_artist:-$default_album_artist}
read -p "Enter Release Date (YYYY): " release_date
echo ""
echo "Processing MP4 files..."
echo "Album Artist: $album_artist"
echo ""
counter=0
# Process all mp4 files in subdirectories
for file in */*.mp4 *.mp4; do
# Skip if file doesn't exist
[ -e "$file" ] || continue
dir=$(dirname "$file")
filename=$(basename "$file" .mp4)
# Determine album based on folder structure
if [ "$dir" != "." ]; then
# File is in subfolder (Intro, week1, week2, etc.)
album=$(basename "$dir")
else
# File is in current directory
album="$default_album"
fi
# Set output location
if [ -n "$output_folder" ]; then
# Create matching folder structure in output folder
if [ "$dir" != "." ]; then
mkdir -p "$output_folder/$dir"
output="$output_folder/$dir/${filename}.mp3"
else
output="$output_folder/${filename}.mp3"
fi
else
output="$dir/${filename}.mp3"
fi
# Skip if already exists
if [ -f "$output" ]; then
echo "Skip: $filename (exists)"
continue
fi
# Get track number
track_num=$(echo "$filename" | grep -oP '^\d+')
echo "Converting: $filename"
echo " Album: $album"
# Convert using temp file
temp_file="/tmp/convert_$$.mp3"
if [ -n "$track_num" ]; then
ffmpeg -i "$file" -vn -acodec libmp3lame -q:a 0 \
-metadata title="$filename" \
-metadata track="$track_num" \
-metadata album_artist="$album_artist" \
-metadata artist="$album_artist" \
-metadata album="$album" \
-metadata date="$release_date" \
"$temp_file" -y >/dev/null 2>&1
else
ffmpeg -i "$file" -vn -acodec libmp3lame -q:a 0 \
-metadata title="$filename" \
-metadata album_artist="$album_artist" \
-metadata artist="$album_artist" \
-metadata album="$album" \
-metadata date="$release_date" \
"$temp_file" -y >/dev/null 2>&1
fi
if [ -f "$temp_file" ]; then
mv "$temp_file" "$output"
echo " ✓ Done"
((counter++))
else
echo " ✗ Failed"
fi
done
echo ""
echo "Converted $counter files"

17
scripts/scripts/m3u8.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Ask for the final filename first
echo "=== Video Downloader (yt-dlp + aria2c) ==="
read -p "Enter the final filename (without extension): " filename
# Then ask for the m3u8 URL
read -p "Enter the m3u8 URL: " url
# Download using yt-dlp with aria2c
echo "Starting download..."
yt-dlp --external-downloader aria2c \
--external-downloader-args "aria2c:-x 16 -s 16" \
-o "${filename}.%(ext)s" \
"$url"
echo "Download complete: ${filename}.mp4"

22
scripts/scripts/move-trash_1.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Read the message file path from aerc
while read -r filepath; do
# Get the base mail directory
maildir="$HOME/.local/share/mail"
# Extract the filename
filename=$(basename "$filepath")
# Create Trash/cur if it doesn't exist
mkdir -p "$maildir/Trash/cur"
# Move the file to Trash
if [[ -f "$filepath" ]]; then
mv "$filepath" "$maildir/Trash/cur/$filename"
echo "Moved to Trash: $filename" >&2
fi
done
# Re-index with notmuch
notmuch new >/dev/null 2>&1

37
scripts/scripts/nonum.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
echo "Removing numbers from filenames and titles (keeping track numbers)..."
echo ""
for file in *.mp3; do
filename="${file%.*}"
# Extract track number before removing it from filename
track_num=$(echo "$filename" | grep -oP '^\d+')
# Remove leading numbers and dot/space from filename
new_filename=$(echo "$filename" | sed 's/^[0-9]\+[. ]\+//')
new_file="${new_filename}.mp3"
if [ "$file" != "$new_file" ]; then
echo "Processing: $file"
echo " New filename: $new_file"
echo " New title: $new_filename"
echo " Track number: $track_num (kept)"
# Retag with new title (without number) but keep track number
ffmpeg -i "$file" -c copy \
-metadata title="$new_filename" \
-metadata track="$track_num" \
"${new_filename}_temp.mp3" 2>/dev/null
# Remove original and rename temp file
rm "$file"
mv "${new_filename}_temp.mp3" "$new_file"
echo " ✓ Done"
echo ""
fi
done
echo "Complete! All files processed."

47
scripts/scripts/nothumb.sh Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
echo "Removing thumbnails and associated CDs from MP3 files..."
echo ""
counter=0
# Process all mp3 files
for file in *.mp3 */*.mp3 */*/*.mp3; do
# Skip if file doesn't exist
[ -e "$file" ] || continue
filename=$(basename "$file")
echo "Processing: $file"
# Create temp file
temp_file="/tmp/strip_${counter}_$$.mp3"
# Remove all images/artwork and strip video streams
ffmpeg -i "$file" \
-map 0:a \
-c copy \
-map_metadata 0 \
-id3v2_version 3 \
-vn \
"$temp_file" -y >/dev/null 2>&1
if [ -f "$temp_file" ] && [ -s "$temp_file" ]; then
# Remove disc number metadata using eyeD3 if available
if command -v eyeD3 &> /dev/null; then
eyeD3 --remove-images \
--disc-num "" \
"$temp_file" >/dev/null 2>&1
fi
mv "$temp_file" "$file"
echo " ✓ Done"
((counter++))
else
echo " ✗ Failed"
[ -f "$temp_file" ] && rm "$temp_file"
fi
done
echo ""
echo "Processed $counter files"

View File

@@ -0,0 +1,62 @@
#!/bin/bash
# 1. Configuration: List the folder names you wish to EXCLUDE from updates.
# Separate names with a space. Example: EXCLUDED_FOLDERS=("ai-stack" "testing")
EXCLUDED_FOLDERS=("ai","dns-adguard","dns-pihole","immich")
# 2. Set the base directory to the current location where the script is run.
# This assumes you place the script inside your /podman folder.
BASE_DIR="."
echo "========================================"
echo "Starting Podman Update Script"
echo "Current Directory: $(pwd)"
echo "Excluded Folders: ${EXCLUDED_FOLDERS[*]}"
echo "========================================"
# 3. Loop through all directories in the base directory
for dir in "$BASE_DIR"/*/; do
# Extract just the folder name (e.g., /podman/essential/ -> "essential")
folder_name=$(basename "$dir")
# Check if this folder is in the exclusion list
# [[ " ${array[@]} " =~ " ${value} " ]] is a bash pattern matching trick
if [[ " ${EXCLUDED_FOLDERS[@]} " =~ " ${folder_name} " ]]; then
echo "[SKIPPING] Excluded folder found: $folder_name"
continue
fi
# Check if docker-compose.yml exists in this folder
if [ -f "$dir/docker-compose.yml" ]; then
echo ""
echo "[PROCESSING] Updating stack in: $folder_name"
# Change directory to the folder containing the compose file
cd "$dir" || {
echo "Error: Could not enter $dir"
continue
}
# Pull the latest images
echo " -> Pulling latest images..."
podman-compose pull
# Force recreate and restart containers
# -d: Detached mode (run in background)
# --force-recreate: Stops and recreates containers even if config hasn't changed
echo " -> Force restarting services..."
podman-compose up -d --force-recreate
# Return to the original base directory
cd "$BASE_DIR" || exit
echo "[FINISHED] $folder_name updated."
else
# Optional: Silence this if you have many non-compose folders
echo "[IGNORE] No docker-compose.yml found in $folder_name"
fi
done
echo "========================================"
echo "All tasks completed."
echo "========================================"

15
scripts/scripts/pve_chmod.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
sudo chown -R 101000:100033 /mnt/{hdd1,hdd2,hdd3,hdd4,hdd5,ssd1,ssd2}
sudo chmod -R 775 /mnt/{hdd1,hdd2,hdd3,hdd4,hdd5,ssd1,ssd2}
sudo chown -R 101000:101000 /mnt/tank/audio
sudo chmod -R 777 /mnt/tank/audio
sudo chown -R 101000:101000 /mnt/flash1/downloads/music
sudo chmod -R 755 /mnt/flash1/downloads/music
sudo chown -R 101000:100033 /mnt/ssd2/cloud_phil /mnt/flash1/podman/browser/data/.consume
sudo chmod -R 775 /mnt/ssd2/cloud_phil /mnt/flash1/podman/browser/data/.consume

76
scripts/scripts/retag.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
# Get metadata from first mp3 file if it exists
first_file=$(ls *.mp3 2>/dev/null | head -n 1)
if [ -n "$first_file" ]; then
default_artist=$(ffprobe -v quiet -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$first_file")
default_album=$(ffprobe -v quiet -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 "$first_file")
default_date=$(ffprobe -v quiet -show_entries format_tags=date -of default=noprint_wrappers=1:nokey=1 "$first_file")
default_composer=$(ffprobe -v quiet -show_entries format_tags=composer -of default=noprint_wrappers=1:nokey=1 "$first_file")
fi
# Prompt with defaults
read -p "Enter Album Artist [$default_artist]: " album_artist
album_artist=${album_artist:-$default_artist}
read -p "Enter Album [$default_album]: " album
album=${album:-$default_album}
read -p "Enter Release Date (YYYY or YYYY-MM-DD) [$default_date]: " release_date
release_date=${release_date:-$default_date}
read -p "Enter Composer [$default_composer]: " composer
composer=${composer:-$default_composer}
echo ""
echo "Retagging files..."
echo "Album Artist: $album_artist"
echo "Album: $album"
echo "Release Date: $release_date"
echo "Composer: $composer"
echo ""
for file in *.mp3; do
filename="${file%.*}"
track_num=$(echo "$filename" | grep -oP '^\d+')
echo "Retagging: $file (Track $track_num)"
if [ -n "$composer" ]; then
ffmpeg -i "$file" -c copy \
-metadata title="$filename" \
-metadata track="$track_num" \
-metadata album_artist="$album_artist" \
-metadata artist="$album_artist" \
-metadata album="$album" \
-metadata date="$release_date" \
-metadata composer="$composer" \
-metadata disc="" \
-metadata discnumber="" \
-metadata totaldiscs="" \
-metadata disk="" \
-metadata disknumber="" \
"${filename}_temp.mp3" 2>/dev/null
else
ffmpeg -i "$file" -c copy \
-metadata title="$filename" \
-metadata track="$track_num" \
-metadata album_artist="$album_artist" \
-metadata artist="$album_artist" \
-metadata album="$album" \
-metadata date="$release_date" \
-metadata composer="" \
-metadata disc="" \
-metadata discnumber="" \
-metadata totaldiscs="" \
-metadata disk="" \
-metadata disknumber="" \
"${filename}_temp.mp3" 2>/dev/null
fi
mv "${filename}_temp.mp3" "$file"
done
echo ""
echo "Done! All files retagged."

105
scripts/scripts/split.sh Executable file
View File

@@ -0,0 +1,105 @@
#!/bin/bash
# Handle Ctrl+C gracefully
trap ctrl_c INT
function ctrl_c() {
echo ""
echo "Cancelled by user."
exit 0
}
# Function to read input with tab completion for paths
read_path() {
local prompt="$1"
local input
# Use read with -e flag for readline editing (enables tab completion)
read -e -p "$prompt" input
echo "$input"
}
# Get source folder
SOURCE=$(read_path "Enter source folder path: ")
# Validate source exists
if [ ! -d "$SOURCE" ]; then
echo "Error: Source folder '$SOURCE' does not exist!"
exit 1
fi
# Get destination folders
echo "Enter destination folders (one per line, empty line to finish):"
echo "(Tip: Use TAB for folder completion, Ctrl+C to cancel)"
DESTINATIONS=()
while true; do
dest=$(read_path "Destination $((${#DESTINATIONS[@]} + 1)): ")
if [ -z "$dest" ]; then
break
fi
# Create destination if it doesn't exist
if [ ! -d "$dest" ]; then
read -p "Destination '$dest' doesn't exist. Create it? (y/n): " create
if [ "$create" = "y" ]; then
mkdir -p "$dest"
else
continue
fi
fi
DESTINATIONS+=("$dest")
done
# Validate we have destinations
if [ ${#DESTINATIONS[@]} -eq 0 ]; then
echo "Error: No destination folders provided!"
exit 1
fi
# Display summary
echo ""
echo "=== Summary ==="
echo "Source: $SOURCE"
echo "Destinations:"
for i in "${!DESTINATIONS[@]}"; do
echo " $((i + 1)). ${DESTINATIONS[$i]}"
done
# Get list of items in source
items=("$SOURCE"/*)
total=${#items[@]}
items_per_dest=$((total / ${#DESTINATIONS[@]}))
echo ""
echo "Total items to split: $total"
echo "Items per destination: ~$items_per_dest"
echo ""
read -p "Proceed with copy? (y/n): " confirm
if [ "$confirm" != "y" ]; then
echo "Cancelled."
exit 0
fi
# Distribute items
echo ""
echo "Starting distribution..."
for i in "${!DESTINATIONS[@]}"; do
start=$((i * items_per_dest))
if [ $i -eq $((${#DESTINATIONS[@]} - 1)) ]; then
# Last destination gets remainder
end=$total
else
end=$(((i + 1) * items_per_dest))
fi
echo ""
echo "Copying to ${DESTINATIONS[$i]} (items $((start + 1)) to $end)..."
for ((j=start; j<end; j++)); do
item_name=$(basename "${items[$j]}")
echo " -> $item_name"
rsync -a "${items[$j]}" "${DESTINATIONS[$i]}/"
done
done
echo ""
echo "Distribution complete!"

13
scripts/scripts/sync-mail_1.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
# Sync with server (this pushes local changes including deletions)
mbsync -a
# Re-index
notmuch new
# Auto-tag folders
notmuch tag +sent -- folder:Sent and not tag:sent
notmuch tag +draft -- folder:Drafts and not tag:draft
notmuch tag +trash -- folder:Trash and not tag:trash
notmuch tag +spam -- folder:Spam and not tag:spam

76
scripts/scripts/thumb.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
# Ask for the thumbnail filename
echo "=== Album Art Embedder (Recursive) ==="
echo "Current directory: $(pwd)"
read -p "Enter thumbnail filename in this directory (e.g., cover.jpg): " thumbnail
# Full path to thumbnail
thumbnail_path="$(pwd)/$thumbnail"
# Check if thumbnail exists
if [ ! -f "$thumbnail_path" ]; then
echo "Error: Thumbnail not found at $thumbnail_path"
exit 1
fi
# Ask for album artist
read -p "Enter album artist name: " album_artist
# Get album name from current directory
album_name="$(basename "$(pwd)")"
echo ""
echo "Found thumbnail: $thumbnail_path"
echo "Album: $album_name"
echo "Album Artist: $album_artist"
echo "Processing all mp3/mp4 files in subdirectories..."
echo ""
# Counter for processed files
count=0
# Find all mp3 and mp4 files in subdirectories (not current dir)
find . -mindepth 2 -type f \( -name "*.mp3" -o -name "*.mp4" \) | while read -r file; do
echo "Processing: $file"
# Get file extension
ext="${file##*.}"
# Create temporary filename
temp_file="${file}.tmp.${ext}"
# Add thumbnail and metadata using ffmpeg
if [ "$ext" = "mp3" ]; then
ffmpeg -i "$file" -i "$thumbnail_path" \
-map 0 -map 1 \
-c copy \
-metadata album_artist="$album_artist" \
-metadata album="$album_name" \
-disposition:v:0 attached_pic \
"$temp_file" 2>/dev/null
else
# For mp4 files
ffmpeg -i "$file" -i "$thumbnail_path" \
-map 0 -map 1 \
-c copy \
-metadata artist="$album_artist" \
-metadata album="$album_name" \
-disposition:v:0 attached_pic \
"$temp_file" 2>/dev/null
fi
if [ $? -eq 0 ]; then
mv "$temp_file" "$file"
((count++))
echo "✓ Done"
else
echo "✗ Failed"
[ -f "$temp_file" ] && rm "$temp_file"
fi
echo ""
done
echo "Finished! Processed $count files."
echo "Album Artist set to: $album_artist"
echo "Album set to: $album_name"

11
scripts/scripts/yazi-picker.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# ~/scripts/yazi-picker.sh
# Launch Yazi and capture the selected file
selected_file=$(yazi --chooser-file)
# If a file was selected, print it (or pass it to another application)
if [ -n "$selected_file" ]; then
echo "$selected_file" | xclip -selection clipboard # Copy to clipboard (optional)
echo "Selected file: $selected_file"
fi