commit 304cbcc554aac1e0491afc3f1cfb6349410179e6 Author: rozbrian Date: Sat Jan 10 20:46:22 2026 +0900 update diff --git a/1024fj b/1024fj new file mode 100755 index 0000000..7e50fda --- /dev/null +++ b/1024fj @@ -0,0 +1 @@ +for a in 1024fj.com_*.mp4; do echo "======== $a ========"; mv "$a" "$(echo $a | gawk -F'1024fj.com_' '{print $2}')"; done diff --git a/2aac b/2aac new file mode 100755 index 0000000..0513003 --- /dev/null +++ b/2aac @@ -0,0 +1,13 @@ +#!/bin/bash +TMPFILE=$(mktemp) +LOGFILE="/tmp/2aac.log" + +if [ "$(is_cuda)" == "ok!" ]; then + echo "======== CUDA ========" + time ffmpeg -y -hwaccel cuda -i "$1" -f mp4 -vcodec copy -acodec aac -ar 44100 -ab 128k -ac 2 $TMPFILE +else + echo "======== VAPPI ========" + time ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i "$1" -f mp4 -vcodec copy -acodec aac -ar 44100 -ab 128k -ac 2 $TMPFILE +fi + +backup_and_replace "$1" "$TMPFILE" "$LOGFILE" diff --git a/2avc1 b/2avc1 new file mode 100755 index 0000000..1662d6d --- /dev/null +++ b/2avc1 @@ -0,0 +1,15 @@ +#!/bin/bash +TMPFILE=$(mktemp) +LOGFILE="/tmp/2avc1.log" + +BITRATE=$(ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of csv=p=0 "$1") + +if [ "$(is_cuda)" == "ok!" ]; then + echo "======== CUDA ========" + time ffmpeg -y -hwaccel cuda -i "$1" -f mp4 -vcodec h264_nvenc -acodec copy -b:v "$BITRATE" $TMPFILE +else + echo "======== VAPPI ========" + time ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i "$1" -f mp4 -vcodec h264 -acodec copy -b:v "$BITRATE" $TMPFILE +fi + +backup_and_replace "$1" "$TMPFILE" "$LOGFILE" diff --git a/2hevc b/2hevc new file mode 100755 index 0000000..4e3ffe9 --- /dev/null +++ b/2hevc @@ -0,0 +1,15 @@ +#!/bin/bash +TMPFILE=$(mktemp) +LOGFILE="/tmp/2hevc.log" + +BITRATE=$(ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of csv=p=0 "$1") + +if [ "$(is_cuda)" == "ok!" ]; then + echo "======== CUDA ========" + time ffmpeg -y -hwaccel cuda -i "$1" -f mp4 -vcodec hevc_nvenc -acodec copy -b:v "$BITRATE" $TMPFILE +else + echo "======== VAPPI ========" + time ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i "$1" -f mp4 -vcodec hevc -acodec copy -b:v "$BITRATE" $TMPFILE +fi + +backup_and_replace "$1" "$TMPFILE" "$LOGFILE" diff --git a/2mp3 b/2mp3 new file mode 100755 index 0000000..ed3d0a6 --- /dev/null +++ b/2mp3 @@ -0,0 +1,13 @@ +#!/bin/bash +TMPFILE=$(mktemp) +LOGFILE="/tmp/2mp3.log" + +if [ "$(is_cuda)" == "ok!" ]; then + echo "======== CUDA ========" + time ffmpeg -y -hwaccel cuda -i "$1" -f mp4 -vcodec copy -acodec mp3 -ar 44100 -ab 128k -ac 2 $TMPFILE +else + echo "======== VAPPI ========" + time ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i "$1" -f mp4 -vcodec copy -acodec mp3 -ar 44100 -ab 128k -ac 2 $TMPFILE +fi + +backup_and_replace "$1" "$TMPFILE" "$LOGFILE" diff --git a/2mp4 b/2mp4 new file mode 100755 index 0000000..230f961 --- /dev/null +++ b/2mp4 @@ -0,0 +1,13 @@ +#!/bin/bash +TMPFILE=$(mktemp) +LOGFILE="/tmp/2mp4.log" + +if [ "$(is_cuda)" == "ok!" ]; then + echo "======== CUDA ========" + time ffmpeg -y -hwaccel cuda -i "$1" -f mp4 -vcodec copy -acodec copy $TMPFILE +else + echo "======== VAPPI ========" + time ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i "$1" -f mp4 -vcodec copy -acodec copy $TMPFILE +fi + +backup_and_replace "$1" "$TMPFILE" "$LOGFILE" diff --git a/acodec b/acodec new file mode 100755 index 0000000..eec9696 --- /dev/null +++ b/acodec @@ -0,0 +1 @@ +ffp "$1" | grep -B 3 "codec_type\": \"audio" | grep codec_name | gawk -F'\"' '{print $4}' diff --git a/all2avc1 b/all2avc1 new file mode 100755 index 0000000..a0d657b --- /dev/null +++ b/all2avc1 @@ -0,0 +1,50 @@ +#!/bin/bash +EXITFILE="/tmp/all2avc1.stop" +if [[ $1 == stop ]] +then + touch $EXITFILE + exit 0 +fi + +if [[ $1 == resume ]] +then + rm $EXITFILE + exit 0 +fi + +if [[ -f $EXITFILE ]] +then + echo "FORCED STOP by $EXITFILE" + exit 0 +fi + +TMPFILE0=$(mktemp) +ls -l | grep "^d" | gawk -F":" '{print $2}' | cut -c 4- > $TMPFILE0 +TMPFILE=$(mktemp) +cat $TMPFILE0 | grep -v "\@eaDir" > $TMPFILE +rm $TMPFILE0 +IFS=$'\n' +DIRS=($(cat "$TMPFILE")) +NUMDIR=$(wc "$TMPFILE" | gawk -F' ' '{print $1}') +rm $TMPFILE +BASE_PATH=$(pwd) + +CNTDIR=1 +for a in "${DIRS[@]}" +do + pwd + echo "[$CNTDIR/$NUMDIR] $a ====" + CNTDIR="$(echo "$CNTDIR+1" | bc)" + cd "$a" + all2hevc + cd "$BASE_PATH" +done; + +TMPFILE1=$(mktemp) +ls -l | grep -v "^d" | gawk -F":" '{print $2}' | cut -c 4- > $TMPFILE1 +TMPFILE2=$(mktemp) +#echo "11111" +#cat $TMPFILE2 +#echo "22222" +for a in avi m4v mkv mp4 ts mov; do cat $TMPFILE1 | grep "."$a"$" > $TMPFILE2; all2avc1_ $TMPFILE2; done +rm $TMPFILE1 $TMPFILE2 diff --git a/all2avc1_ b/all2avc1_ new file mode 100755 index 0000000..a5f2523 --- /dev/null +++ b/all2avc1_ @@ -0,0 +1,34 @@ +#!/bin/bash +IFS=$'\n' +VIDEOS=($(cat $1)) +EXITFILE="/tmp/all2avc1.stop" +LOGFILE="/tmp/all2avc1.log" +NUMFILE=$(wc $1 | gawk -F' ' '{print $1}') +CNTFILE=1 +EXECFILE="2avc1" +#cat $1 +for a in ${VIDEOS[@]} +do + pwd + echo "[$CNTFILE/$NUMFILE] $a ====" + CNTFILE="$(echo "$CNTFILE+1" | bc)" + if [[ -f $EXITFILE ]] + then + exit 0 + fi + + if [[ $(ffp_vcodec "$a") != "hevc" ]] + then + res=$(ffp_resolution "$a") + val=$(($res - 1000)) + if [[ $val > 0 ]] + then + echo $(date) "\""$(pwd)"/"$a"\"" $(ffp_resolution "$a") >> $LOGFILE + $EXECFILE "$a" + else + echo $(date) "\"$(pwd)/$a\" $(ffp_resolution "$a") skipped!" >> $LOGFILE + fi + else + echo $(date) "\"$(pwd)/$a\"" $(ffp_vcodec "$a") "skipped!" >> $LOGFILE + fi +done diff --git a/all2hevc b/all2hevc new file mode 100755 index 0000000..aaf9dd4 --- /dev/null +++ b/all2hevc @@ -0,0 +1,50 @@ +#!/bin/bash +EXITFILE="/tmp/all2hevc.stop" +if [[ $1 == stop ]] +then + touch $EXITFILE + exit 0 +fi + +if [[ $1 == resume ]] +then + rm $EXITFILE + exit 0 +fi + +if [[ -f $EXITFILE ]] +then + echo "FORCED STOP by $EXITFILE" + exit 0 +fi + +TMPFILE0=$(mktemp) +ls -l | grep "^d" | gawk -F":" '{print $2}' | cut -c 4- > $TMPFILE0 +TMPFILE=$(mktemp) +cat $TMPFILE0 | grep -v "\@eaDir" > $TMPFILE +rm $TMPFILE0 +IFS=$'\n' +DIRS=($(cat "$TMPFILE")) +NUMDIR=$(wc "$TMPFILE" | gawk -F' ' '{print $1}') +rm $TMPFILE +BASE_PATH=$(pwd) + +CNTDIR=1 +for a in "${DIRS[@]}" +do + pwd + echo "[$CNTDIR/$NUMDIR] $a ====" + CNTDIR="$(echo "$CNTDIR+1" | bc)" + cd "$a" + all2hevc + cd "$BASE_PATH" +done; + +TMPFILE1=$(mktemp) +ls -l | grep -v "^d" | gawk -F":" '{print $2}' | cut -c 4- > $TMPFILE1 +TMPFILE2=$(mktemp) +#echo "11111" +#cat $TMPFILE2 +#echo "22222" +for a in avi m4v mkv mp4 ts; do cat $TMPFILE1 | grep "."$a"$" > $TMPFILE2; all2hevc_ $TMPFILE2; done +rm $TMPFILE1 $TMPFILE2 diff --git a/all2hevc_ b/all2hevc_ new file mode 100755 index 0000000..fe73273 --- /dev/null +++ b/all2hevc_ @@ -0,0 +1,32 @@ +#!/bin/bash +IFS=$'\n' +VIDEOS=($(cat $1)) +EXITFILE="/tmp/all2hevc.stop" +NUMFILE=$(wc $1 | gawk -F' ' '{print $1}') +CNTFILE=1 +#cat $1 +for a in ${VIDEOS[@]} +do + pwd + echo "[$CNTFILE/$NUMFILE] $a ====" + CNTFILE="$(echo "$CNTFILE+1" | bc)" + if [[ -f $EXITFILE ]] + then + exit 0 + fi + + if [[ $(ffp_vcodec "$a") != "hevc" ]] + then + res=$(ffp_resolution "$a") + val=$(($res - 1000)) + if [[ $val > 0 ]] + then + echo $(date) "\""$(pwd)"/"$a"\"" $(ffp_resolution "$a") >> /tmp/all2hevc.log + 2hevc "$a" + else + echo $(date) "\"$(pwd)/$a\" $(ffp_resolution "$a") skipped!" >> /tmp/all2hevc.log + fi + else + echo $(date) "\"$(pwd)/$a\"" $(ffp_vcodec "$a") "skipped!" >> /tmp/all2hevc.log + fi +done diff --git a/all2mp4 b/all2mp4 new file mode 100755 index 0000000..8011303 --- /dev/null +++ b/all2mp4 @@ -0,0 +1,38 @@ +#!/bin/bash +EXITFILE="/tmp/all2mp4.stop" +if [[ $1 == stop ]] +then + touch $EXITFILE + exit 0 +fi + +if [[ $1 == resume ]] +then + rm $EXITFILE + exit 0 +fi + +if [[ -f $EXITFILE ]] +then + echo "FORCED STOP by $EXITFILE" + exit 0 +fi + +TMPFILE0=$(mktemp) +ls -l | grep "^d" | gawk -F":" '{print $2}' | cut -c 4- > $TMPFILE0 +TMPFILE=$(mktemp) +cat $TMPFILE0 | grep -v "\@eaDir" > $TMPFILE +rm $TMPFILE0 +IFS=$'\n' +DIRS=($(cat "$TMPFILE")) +rm $TMPFILE +BASE_PATH=$(pwd) +for a in "${DIRS[@]}"; do echo "====" $a "===="; cd "$a"; pwd; all2mp4; cd "$BASE_PATH"; pwd; done; +TMPFILE1=$(mktemp) +ls -l | grep -v "^d" | gawk -F":" '{print $2}' | cut -c 4- > $TMPFILE1 +TMPFILE2=$(mktemp) +#echo "11111" +#cat $TMPFILE2 +#echo "22222" +for a in avi m4v mkv wmv ts; do cat $TMPFILE1 | grep "."$a"$" > $TMPFILE2; all2mp4_ $TMPFILE2; done +rm $TMPFILE1 $TMPFILE2 diff --git a/all2mp4_ b/all2mp4_ new file mode 100755 index 0000000..e3c8ca5 --- /dev/null +++ b/all2mp4_ @@ -0,0 +1,14 @@ +#!/bin/bash +IFS=$'\n' +VIDEOS=($(cat $1)) +EXITFILE="/tmp/all2mp4.stop" +#cat $1 +for a in ${VIDEOS[@]}; do echo "== $a ==" + if [[ -f $EXITFILE ]] + then + exit 0 + fi + + echo $(date) "\""$(pwd)"/"$a"\"" >> /tmp/all2mp4.log + 2mp4 "$a" +done diff --git a/any2hevc b/any2hevc new file mode 100755 index 0000000..15c681e --- /dev/null +++ b/any2hevc @@ -0,0 +1,2 @@ +#!/bin/bash +for a in wmv mkv mp4; do for b in *.$a; do if [[ -e "$b" ]]; then if [[ $(vcodec "$b") != "hevc" ]]; then echo "======== $b ========"; 2hevc "$b"; fi; fi; done; done diff --git a/apt_upgrade.sh b/apt_upgrade.sh new file mode 100755 index 0000000..860d351 --- /dev/null +++ b/apt_upgrade.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# This script will update and upgrade all packages automatically. +# Run as root or with sudo. + +set -e + +echo "=== Starting full system upgrade ===" + +# Update the package lists +apt update -y + +# Upgrade all packages without interaction +DEBIAN_FRONTEND=noninteractive apt -y upgrade + +# Upgrade including kernel and dependencies +DEBIAN_FRONTEND=noninteractive apt -y dist-upgrade + +# Remove unused packages +apt -y autoremove +apt -y autoclean + +echo "=== Upgrade completed successfully ===" diff --git a/backup_and_replace b/backup_and_replace new file mode 100755 index 0000000..1c5ab53 --- /dev/null +++ b/backup_and_replace @@ -0,0 +1,62 @@ +#!/bin/bash +SRCFILE="$1" +TMPFILE="$2" +LOGFILE="$3" +echo $(date) $TMPFILE "created for \"$SRCFILE\"" >> $LOGFILE +if [[ $(ffp_duration $TMPFILE) == $(ffp_duration "$SRCFILE") ]] +then + NEWFILE="$(cut_ext "$SRCFILE").mp4" + mv "$SRCFILE" "$SRCFILE.bak" + mv "$TMPFILE" "$NEWFILE" + echo $(date) "$(pwd)/$\" done!" >> $LOGFILE +else + keep_temp "$SRCFILE" $TMPFILE + echo "SOMETHING WRONG!!" + echo $(date) "\"$(pwd)/$SRCFILE\" NOT FINISHED!" >> $LOGFILE +fi +#!/bin/bash + +SRCFILE="$1" +TMPFILE="$2" +LOGFILE="$3" + +# Log the creation of the temporary file +echo "$(date) $TMPFILE created for \"$SRCFILE\"" >> "$LOGFILE" + +# Function to check duration +ffp_duration() { + ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1" +} + +# Function to remove the file extension +cut_ext() { + echo "${1%.*}" +} + +# Check if the durations of the source and temporary files match +if [[ $(ffp_duration "$TMPFILE") == $(ffp_duration "$SRCFILE") ]]; then + NEWFILE="$(cut_ext "$SRCFILE").mp4" + + # Backup the original file + mv "$SRCFILE" "$SRCFILE.bak" + + # Replace the original file with the new file + mv "$TMPFILE" "$NEWFILE" + + # Log the successful operation + echo "$(date) $(pwd)/$SRCFILE done!" >> "$LOGFILE" +else + # Function to keep the temporary file + keep_temp() { + local src="$1" + local tmp="$2" + mv "$tmp" "${src}_tmp" + } + + keep_temp "$SRCFILE" "$TMPFILE" + + # Log the failure + echo "SOMETHING WRONG!!" + echo "$(date) $(pwd)/$SRCFILE NOT FINISHED!" >> "$LOGFILE" +fi + diff --git a/backup_immich_ b/backup_immich_ new file mode 100755 index 0000000..d6d369c --- /dev/null +++ b/backup_immich_ @@ -0,0 +1 @@ +sudo rsync -rv --delete --exclude=*.xmp /mnt/hdd/immich/library/library/admin rsync://rozbrian@192.168.1.18/NetBackup/truenas/immich_photo diff --git a/backup_wiki b/backup_wiki new file mode 100755 index 0000000..4d7236c --- /dev/null +++ b/backup_wiki @@ -0,0 +1,9 @@ +#!/usr/bin/expect +set timeout -1 +spawn /home/rozbrian/bin/backup_wiki_ +match_max 100 +expect -exact "\[sudo\] password for rozbrian: " +send -- "$env(PASSWORD)\r" +expect -exact "Password: " +send -- "$env(PASSWORD4DS918)\r" +expect eof diff --git a/backup_wiki_ b/backup_wiki_ new file mode 100755 index 0000000..460fc1c --- /dev/null +++ b/backup_wiki_ @@ -0,0 +1 @@ +sudo rsync -avzP --delete /var/www/html/wiki rsync://rozbrian@192.168.1.18/NetBackup/truenas diff --git a/categorize b/categorize new file mode 100755 index 0000000..b021369 --- /dev/null +++ b/categorize @@ -0,0 +1,28 @@ +#!/bin/bash + +# Find directories in the current directory and process each one +find . -maxdepth 1 -type d -print0 | while IFS= read -r -d '' dir; do + if [[ "$dir" != "." ]]; then + # Extract the old directory name, stripping leading './' + OLDNAME="${dir:2}" + echo "==== $OLDNAME ====" + + # Generate the new directory name + NEWNAME=$(echo "$OLDNAME" | awk -F'시즌[0-9]' '{ print $1 }') + + if [[ "$OLDNAME" == "$NEWNAME" ]]; then + echo "\"$OLDNAME\" ok!" + else + echo "\"$OLDNAME\" -> \"$NEWNAME\"" + + # Ensure the new directory does not already exist to avoid overwriting + if [[ ! -d "$NEWNAME" ]]; then + sudo mkdir "$NEWNAME" + sudo mv "$dir" "$NEWNAME" + else + echo "\"$NEWNAME\" already exists, skipping move $OLDNAME" + fi + fi + fi +done + diff --git a/cert_install b/cert_install new file mode 100755 index 0000000..16a95ff --- /dev/null +++ b/cert_install @@ -0,0 +1,28 @@ +#!/usr/bin/bash +#tar xvf cert_key.tar +sudo ls > /dev/null +export DIR_SSL="/etc/ssl/private" +sudo cp cert.pem $DIR_SSL/cert.pem +sudo cp privkey.pem $DIR_SSL/key.pem; +#sudo cp $1 $DIR_SSL/cert.pem +#sudo cp $2 $DIR_SSL/key.pem; +#sudo cd $DIR_SSL; sudo chown root:root cert.pem key.pem + +for a in /etc/docker/homeassistant/ssl /etc/docker/jellyfin/config/ssl +do + cd $a; + echo "====" $(pwd) "====" + sudo rm cert.pem key.pem + sudo cp $DIR_SSL/cert.pem . + sudo cp $DIR_SSL/key.pem . +# sudo ln -s $DIR_SSL/cert.pem cert.pem +# sudo ln -s $DIR_SSL/key.pem key.pem +done + +cd /etc/cockpit/ws-certs.d +echo "====" $(pwd) "====" +sudo rm pem.cert pem.key +sudo cp $DIR_SSL/cert.pem pem.cert +sudo cp $DIR_SSL/key.pem pem.key +#sudo ln -s $DIR_SSL/cert.pem pem.cert +#sudo ln -s $DIR_SSL/key.pem pem.key diff --git a/cert_remove b/cert_remove new file mode 100755 index 0000000..5015deb --- /dev/null +++ b/cert_remove @@ -0,0 +1,17 @@ +#!/usr/bin/bash +#tar xvf cert_key.tar +sudo ls > /dev/null +export DIR_SSL="/etc/ssl/private" +sudo rm $DIR_SSL/cert.pem +sudo rm $DIR_SSL/key.pem + +for a in /etc/docker/homeassistant/ssl /etc/docker/jellyfin/config/ssl +do + cd $a; + echo "====" $(pwd) "====" + sudo rm cert.pem key.pem +done + +cd /etc/cockpit/ws-certs.d +echo "====" $(pwd) "====" +sudo rm pem.cert pem.key diff --git a/chmod_dri b/chmod_dri new file mode 100755 index 0000000..e78bef2 --- /dev/null +++ b/chmod_dri @@ -0,0 +1,2 @@ +#!/bin/bash +cd /dev/dri; sudo chmod 777 * diff --git a/cut_ext b/cut_ext new file mode 100755 index 0000000..52f91b0 --- /dev/null +++ b/cut_ext @@ -0,0 +1,4 @@ +#!/bin/bash +OLDFILE="$1" +NEWFILE=${OLDFILE::-4} +echo "$NEWFILE" diff --git a/deny b/deny new file mode 100755 index 0000000..96191f1 --- /dev/null +++ b/deny @@ -0,0 +1 @@ +sudo ufw deny from $1 to any diff --git a/dockerpid b/dockerpid new file mode 100755 index 0000000..12c23a9 --- /dev/null +++ b/dockerpid @@ -0,0 +1 @@ +sudo docker ps -q | xargs sudo docker inspect --format '{{.State.Pid}}: {{.Name}}' diff --git a/duckdns b/duckdns new file mode 100755 index 0000000..8f0ab99 --- /dev/null +++ b/duckdns @@ -0,0 +1,11 @@ +docker run -d \ + --name=duckdns \ + -e PUID=0 \ + -e PGID=0 \ + -e TZ=Asia/Seoul \ + -e SUBDOMAINS=rozbrian \ + -e TOKEN=bdb0d679-6419-4743-9e3c-085e7ecbf1b0 \ + -e LOG_FILE=false \ + -v /etc/docker/duckdns/config:/config \ + --restart unless-stopped \ + lscr.io/linuxserver/duckdns:latest diff --git a/ffmpeg_concat b/ffmpeg_concat new file mode 100755 index 0000000..27c99d4 --- /dev/null +++ b/ffmpeg_concat @@ -0,0 +1,41 @@ +#!/bin/bash + +# Check if all required arguments are provided +if [ $# -lt 2 ]; then + echo "Usage: $0 " + echo "" + echo "Arguments:" + echo " Text file containing a list of files to concatenate." + echo " Path to the output video file." + echo "" + echo "Example:" + echo " $0 file_list.txt output.mp4" + echo "" + echo "Notes:" + echo " - The must contain file paths in the following format:" + echo " file 'video1.mp4'" + echo " file 'video2.mp4'" + echo " - All files in the list must have the same codec, resolution, and frame rate." + exit 1 +fi + +# Assign input arguments to variables +file_list=$1 +output_file=$2 + +# Check if the file list exists +if [ ! -f "$file_list" ]; then + echo "Error: The file list '$file_list' does not exist." + exit 1 +fi + +# Run the ffmpeg command +ffmpeg -f concat -safe 0 -i "$file_list" -c copy "$output_file" + +# Check if the ffmpeg command succeeded +if [ $? -eq 0 ]; then + echo "Concatenation completed successfully. Output saved to '$output_file'." +else + echo "Error: ffmpeg failed to concatenate the files." + exit 1 +fi diff --git a/ffmpeg_cut b/ffmpeg_cut new file mode 100755 index 0000000..50b1c7f --- /dev/null +++ b/ffmpeg_cut @@ -0,0 +1,26 @@ +#!/bin/bash + +# Check if all required arguments are provided +if [ $# -lt 4 ]; then + echo "Usage: $0 " + echo "" + echo "Arguments:" + echo " Path to the input video file." + echo " Path to the output video file." + echo " Start time in format HH:MM:SS or seconds." + echo " Duration of the segment in format HH:MM:SS or seconds." + echo "" + echo "Example:" + echo " $0 input.mp4 output.mp4 00:01:00 30" + echo "" + exit 1 +fi + +# Assign input arguments to variables +input_file=$1 +output_file=$2 +start_time=$3 +duration=$4 + +# Run ffmpeg command +ffmpeg -i "$input_file" -ss "$start_time" -t "$duration" -vcodec copy -acodec copy "$output_file" diff --git a/ffmpeg_cut_head b/ffmpeg_cut_head new file mode 100755 index 0000000..f4a3997 --- /dev/null +++ b/ffmpeg_cut_head @@ -0,0 +1,41 @@ +#!/bin/bash + +# Check if all required arguments are provided +if [ $# -lt 3 ]; then + echo "Usage: $0 " + echo "" + echo "Arguments:" + echo " Path to the input video file." + echo " Path to the output video file." + echo " Duration of the extracted segment in format HH:MM:SS or seconds." + echo "" + echo "Example:" + echo " $0 input.mp4 output.mp4 30" + echo " $0 input.mp4 output.mp4 00:00:30" + echo "" + echo "Note: The output file will contain the first seconds of the input file." + exit 1 +fi + +# Assign input arguments to variables +input_file=$1 +output_file=$2 +duration=$3 + +# Check if the input file exists +if [ ! -f "$input_file" ]; then + echo "Error: The input file '$input_file' does not exist." + exit 1 +fi + +# Run the ffmpeg command +ffmpeg -i "$input_file" -t "$duration" -vcodec copy -acodec copy "$output_file" + +# Check if the ffmpeg command succeeded +if [ $? -eq 0 ]; then + echo "Video extraction completed successfully. Output saved to '$output_file'." +else + echo "Error: ffmpeg failed to extract the video." + exit 1 +fi + diff --git a/ffmpeg_cut_tail b/ffmpeg_cut_tail new file mode 100755 index 0000000..db88ae3 --- /dev/null +++ b/ffmpeg_cut_tail @@ -0,0 +1,39 @@ +#!/bin/bash + +# Check if all required arguments are provided +if [ $# -lt 3 ]; then + echo "Usage: $0 " + echo "" + echo "Arguments:" + echo " Path to the input video file." + echo " Path to the output video file." + echo " Start time in format HH:MM:SS or seconds." + echo "" + echo "Example:" + echo " $0 input.mp4 output.mp4 00:01:00" + echo "" + echo "Note: The output file will start from and will include all remaining content of the input file." + exit 1 +fi + +# Assign input arguments to variables +input_file=$1 +output_file=$2 +start_time=$3 + +# Check if the input file exists +if [ ! -f "$input_file" ]; then + echo "Error: The input file '$input_file' does not exist." + exit 1 +fi + +# Run the ffmpeg command +ffmpeg -i "$input_file" -ss "$start_time" -vcodec copy -acodec copy "$output_file" + +# Check if the ffmpeg command succeeded +if [ $? -eq 0 ]; then + echo "Video extraction completed successfully. Output saved to '$output_file'." +else + echo "Error: ffmpeg failed to extract the video." + exit 1 +fi diff --git a/ffp b/ffp new file mode 100755 index 0000000..2c118b7 --- /dev/null +++ b/ffp @@ -0,0 +1 @@ +ffprobe -show_format -show_streams -loglevel quiet -print_format json "$1" diff --git a/ffp_duration b/ffp_duration new file mode 100755 index 0000000..c011894 --- /dev/null +++ b/ffp_duration @@ -0,0 +1 @@ +printf "%.0f" $(ffp "$1" | grep -m 1 "\"duration\": " | gawk -F'\"' '{print $4}') diff --git a/ffp_forder b/ffp_forder new file mode 100755 index 0000000..aebc396 --- /dev/null +++ b/ffp_forder @@ -0,0 +1 @@ +ffp "$1" | grep "field_order\": \"tb" | gawk -F'\"' '{ print $4 }' diff --git a/ffp_resolution b/ffp_resolution new file mode 100755 index 0000000..90cd4df --- /dev/null +++ b/ffp_resolution @@ -0,0 +1 @@ +ffp "$1" | grep "coded_height\": " | gawk -F': ' '{print $2}' | gawk -F',' '{ print $1 }' diff --git a/ffp_vcodec b/ffp_vcodec new file mode 100755 index 0000000..c25bd23 --- /dev/null +++ b/ffp_vcodec @@ -0,0 +1 @@ +ffp "$1" | grep -B 3 "codec_type\": \"video" | grep codec_name | gawk -F'\"' '{print $4}' diff --git a/git_repo.sh b/git_repo.sh new file mode 100755 index 0000000..dcf8405 --- /dev/null +++ b/git_repo.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# This script creates a bare Git repository under /home/git/ +# Usage: ./create-git-repo.sh + +set -e + +if [ -z "$1" ]; then + echo "Error: Project name is required." + echo "Usage: $0 " + exit 1 +fi + +PROJECT_NAME=$1 +REPO_PATH="/home/git/${PROJECT_NAME}.git" + +# Create the directory +mkdir -p "$REPO_PATH" + +# Initialize as bare repository +git init --bare "$REPO_PATH" + +# Set ownership to user 'git' +chown -R git:git "$REPO_PATH" + +echo "=== Repository created successfully ===" +echo "Path: $REPO_PATH" +echo "To clone: git clone git@your-server:${PROJECT_NAME}.git" diff --git a/homeassistant b/homeassistant new file mode 100755 index 0000000..cdccab3 --- /dev/null +++ b/homeassistant @@ -0,0 +1,10 @@ +sudo docker run \ +--network=host \ +--detach \ +--name=homeassistant \ +-e PUDI0 -e PGID=0 \ +-e TZ=Asia/Seoul \ +-v /etc/docker/homeassistant:/config \ +--privileged \ +--restart unless-stopped \ +docker.io/homeassistant/home-assistant:latest diff --git a/is_cuda b/is_cuda new file mode 100755 index 0000000..da20c77 --- /dev/null +++ b/is_cuda @@ -0,0 +1 @@ +if [ "$( nvcc --version | grep "Cuda" | gawk -F" " '{ print $1 }' )" != "" ]; then echo "ok!"; else echo "NO"; fi diff --git a/jellyfin b/jellyfin new file mode 100755 index 0000000..34cbca1 --- /dev/null +++ b/jellyfin @@ -0,0 +1,17 @@ +sudo chmod 666 /dev/dri/renderD128 +sudo docker run \ + --network host \ + --detach \ + --label "io.containers.autoupdate=registry" \ + --name jellyfin \ + --publish 8096:8096 \ + --user 0:0 \ + --userns keep-id \ + --group-add="109" \ + --volume /etc/docker/jellyfin/cache:/cache \ + --volume /etc/docker/jellyfin/config:/config \ + --mount type=bind,source=/etc/docker/jellyfin/media,destination=/media,rw=true,relabel=private \ + --device /dev/dri/renderD128:/dev/dri/renderD128 \ + --tmpfs /sys \ + --no-healthcheck \ + docker.io/nyanmisaka/jellyfin:latest diff --git a/just-tit b/just-tit new file mode 100755 index 0000000..42774a3 --- /dev/null +++ b/just-tit @@ -0,0 +1,6 @@ +sudo docker run \ +--network=host \ +--detach \ +--name=just-tit \ +--publish 8080:8080 \ +docker.io/dsmatilla/just-tit:latest diff --git a/keep_temp b/keep_temp new file mode 100755 index 0000000..7a3e6d6 --- /dev/null +++ b/keep_temp @@ -0,0 +1,3 @@ +#!/bin/bash +NEWFILE="$(cut_ext "$1").$2.mp4" +mv "$2" "$NEWFILE" diff --git a/metatube b/metatube new file mode 100755 index 0000000..0b877b2 --- /dev/null +++ b/metatube @@ -0,0 +1,8 @@ +sudo docker run \ + --restart=always \ + --network=host \ + -d \ + -p 8080:8080 \ + -v /etc/docker/metatube/config:/config \ + --name metatube metatube/metatube-server:latest \ + -dsn /config/metatube.db diff --git a/mon b/mon new file mode 100755 index 0000000..0f39739 --- /dev/null +++ b/mon @@ -0,0 +1 @@ +while true; do sleep 1; head -v -n 8 /proc/meminfo; head -v -n 2 /proc/stat /proc/version /proc/uptime /proc/loadavg /proc/sys/fs/file-nr /proc/sys/kernel/hostname; tail -v -n 16 /proc/net/dev; echo '==> /proc/df <=='; df -l; echo '==> /proc/netstat <=='; netstat -tpan | grep -Ev '[a-fA-F:]*[0-9.+:[0-9]+ +[a-fA-F:]*[0-9.]:[0-9]+ | TIME_WAIT| CLOSING| CLOSE_WAIT'; echo '==> /proc/who <==';who;echo '==> /proc/end <=='; echo '##Moba##'; done diff --git a/mp3tag b/mp3tag new file mode 100755 index 0000000..b80c01c --- /dev/null +++ b/mp3tag @@ -0,0 +1,114 @@ +#!/usr/bin/python3 +import music_tag +import os +import sys +import subprocess + +def show_help(): + print("Usage: " + sys.argv[0] + " {value}") + print(" commands:") + print(" album albumartist") + print(" comment compilation composer") + print(" discnumber") + print(" genre") + print(" rename") + print(" totaldiscs totaltracks tracknumber tracktitle") + print(" year") + +if len(sys.argv) < 2: + show_help() + sys.exit() + +filename = sys.argv[1] +mp3 = music_tag.load_file(filename) + +if len(sys.argv) < 3: + show_tags(mp3) + sys.exit() + +command = sys.argv[2] + +# Dictionary to map commands to functions or subprocess commands +command_actions = { + 'rename': lambda: rename_mp3(mp3, filename), + 'folder': lambda: move_to_album_folder(mp3, filename), + '_folder': lambda: move_to_parent_album_folder(mp3, filename), + '~comment': lambda: remove_tag(mp3, 'comment'), + '~albumartist': lambda: remove_tag(mp3, 'albumartist'), + 'album': lambda value: set_tag(mp3, 'album', value), + 'albumartist': lambda value: set_tag(mp3, 'albumartist', value), + 'artist': lambda value: set_tag(mp3, 'artist', value), + 'comment': lambda value: set_tag(mp3, 'comment', value), + 'composer': lambda value: set_tag(mp3, 'composer', value), + 'discnumber': lambda value: set_tag(mp3, 'discnumber', value), + 'totaldiscs': lambda value: set_tag(mp3, 'totaldiscs', value), + 'genre': lambda value: set_tag(mp3, 'genre', value), + 'totaltracks': lambda value: set_tag(mp3, 'totaltracks', value), + 'tracktitle': lambda value: set_tag(mp3, 'tracktitle', value), + 'tracknumber': lambda value: set_tag(mp3, 'tracknumber', value), + 'year': lambda value: set_tag(mp3, 'year', value), +} + +if command in command_actions: + if len(sys.argv) < 4: + print("Value is missing!") + sys.exit() + + value = sys.argv[3] + command_actions[command](value) +else: + print("Unknown command:", command) + sys.exit() + +def rename_mp3(mp3, filename): + newfilename = f"{mp3['tracknumber'].value.zfill(3)}.{mp3['tracktitle']}.{bitrate_kbps(mp3)}.mp3" + subprocess.run(['mv', filename, newfilename]) + +def move_to_album_folder(mp3, filename): + folder = mp3['album'] + subprocess.run(['mkdir', folder]) + subprocess.run(['mv', filename, folder]) + +def move_to_parent_album_folder(mp3, filename): + folder = mp3['album'] + subprocess.run(['mkdir', f'../{folder}']) + subprocess.run(['mv', filename, f'../{folder}']) + +def remove_tag(mp3, tag): + mp3.remove_tag(tag) + mp3.save() + print(f"{tag} removed!") + +def set_tag(mp3, tag, value): + old_value = str(mp3[tag].value) + mp3[tag] = value + new_value = str(mp3[tag].value) + mp3.save() + print(f"{tag}: {old_value} -> {new_value}") + +def bitrate_kbps(mp3): + bitrate = int(int(mp3['#bitrate']) / 1000) + return f"{bitrate}kbps" + +def show_tags(mp3): + print(f"{mp3['artist']} / {mp3['album']} / {mp3['tracknumber'].value.zfill(3)}.{mp3['tracktitle']}") + print("========") + print(f"album : {mp3['album']}") + print(f"albumartist : {mp3['albumartist']}") + print(f"artist : {mp3['artist']}") + print(f"artwork : {mp3['artwork']}") + print(f"comment : {mp3['comment']}") + print(f"compilation : {mp3['compilation']}") + print(f"composer : {mp3['composer']}") + print(f"discnumber / totaldiscs : {mp3['discnumber'].value} / {mp3['totaldiscs'].value}") + print(f"genre : {mp3['genre']}") + print(f"tracknumber / totaltracks : {mp3['tracknumber'].value} / {mp3['totaltracks'].value}") + print(f"tracktitle : {mp3['tracktitle']}") + print(f"year : {mp3['year']}") + print(f"isrc : {mp3['isrc']}") + length = mp3['#length'].value + min = int(length / 60) + sec = int(length - min * 60 + .5) + print("---") + print(f"{bitrate_kbps(mp3)} / {mp3['#codec']} / {min}m{sec}s / {mp3['#channels']} channels / {mp3['#samplerate'] / 1000}kHz") + diff --git a/naver_campaign.py b/naver_campaign.py new file mode 100755 index 0000000..8ad647c --- /dev/null +++ b/naver_campaign.py @@ -0,0 +1,127 @@ +#!/usr/bin/python3 + +import os +import re # 정규 표현식 모듈 +import uuid # 고유 식별자 생성 모듈 +import requests # HTTP 요청을 처리하는 모듈 +import rsa # RSA 암호화 알고리즘 모듈 +import lzstring # LZ-String 압축 알고리즘 모듈 +from urllib3.util.retry import Retry # HTTP 요청 재시도를 위한 모듈 +from requests.adapters import HTTPAdapter # HTTP 어댑터 +import time # 시간 처리 모듈 +from bs4 import BeautifulSoup # HTML/XML 파서 +from urllib.parse import urljoin # URL 조합 함수 + +# 주어진 키와 사용자 정보를 이용하여 암호화하는 함수 +def encrypt(key_str, uid, upw): + # 문자열을 조합하는 함수 + def naver_style_join(l): + return ''.join([chr(len(s)) + s for s in l]) + + # 암호화 키 분리 및 정수 변환 + sessionkey, keyname, e_str, n_str = key_str.split(',') + e, n = int(e_str, 16), int(n_str, 16) + + # 메시지 조합 및 인코딩 + message = naver_style_join([sessionkey, uid, upw]).encode() + + # 공개키 생성 및 메시지 암호화 + pubkey = rsa.PublicKey(e, n) + encrypted = rsa.encrypt(message, pubkey) + + return keyname, encrypted.hex() + +# 사용자 계정을 암호화하는 함수 +def encrypt_account(uid, upw): + key_str = requests.get('https://nid.naver.com/login/ext/keys.nhn').content.decode("utf-8") + return encrypt(key_str, uid, upw) + +# 네이버 세션 생성 함수 +def naver_session(nid, npw): + encnm, encpw = encrypt_account(nid, npw) + + # HTTP 세션 설정 + s = requests.Session() + retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]) + s.mount('https://', HTTPAdapter(max_retries=retries)) + request_headers = {'User-agent': 'Mozilla/5.0'} + + # 인증 데이터 생성 및 압축 + bvsd_uuid = uuid.uuid4() + encData = '{"a":"%s-4","b":"1.3.4","d":[{"i":"id","b":{"a":["0,%s"]},"d":"%s","e":false,"f":false},{"i":"%s","e":true,"f":false}],"h":"1f","i":{"a":"Mozilla/5.0"}}' % (bvsd_uuid, nid, nid, npw) + bvsd = '{"uuid":"%s","encData":"%s"}' % (bvsd_uuid, lzstring.LZString.compressToEncodedURIComponent(encData)) + + # 로그인 요청 및 최종 URL 접속 + resp = s.post('https://nid.naver.com/nidlogin.login', data={'svctype': '0', 'enctp': '1', 'encnm': encnm, 'enc_url': 'http0X0.0000000000001P-10220.0000000.000000www.naver.com', 'url': 'www.naver.com', 'smart_level': '1', 'encpw': encpw, 'bvsd': bvsd}, headers=request_headers) + finalize_url = re.search(r'location\.replace\("([^"]+)"\)', resp.content.decode("utf-8")).group(1) + s.get(finalize_url) + + return s + +# 네이버 캠페인 링크를 찾는 함수 +def find_naver_campaign_links(base_url, visited_urls_file='/tmp/visited_urls.txt'): + # 방문한 URL 파일에서 읽기 + try: + with open(visited_urls_file, 'r') as file: + visited_urls = set(file.read().splitlines()) + except FileNotFoundError: + visited_urls = set() + + # 기본 URL에 대한 요청 + response = requests.get(base_url) + soup = BeautifulSoup(response.text, 'html.parser') + + # 'list_subject' 클래스를 가진 span 요소 찾기 및 'a' 태그 추출 + list_subject_links = soup.find_all('span', class_='list_subject') + naver_links = [] + for span in list_subject_links: + a_tag = span.find('a', href=True) + if a_tag and '네이버' in a_tag.text: + #print(a_tag['href']) + naver_links.append(a_tag['href']) + + # 캠페인 링크를 저장할 리스트 초기화 + campaign_links = [] + + # 각 네이버 링크 확인 + for link in naver_links: + full_link = urljoin(base_url, link) + if full_link in visited_urls: + print(link + " already visited!") + continue # 이미 방문한 링크는 건너뛰기 + + res = requests.get(full_link) + inner_soup = BeautifulSoup(res.text, 'html.parser') + + # 캠페인 URL로 시작하는 링크 찾기 + for a_tag in inner_soup.find_all('a', href=True): + if a_tag['href'].startswith("https://campaign2-api.naver.com"): + campaign_links.append(a_tag['href']) + + # 방문한 링크 추가 + visited_urls.add(full_link) + + # 방문한 URL 파일에 저장 + with open(visited_urls_file, 'w') as file: + for url in visited_urls: + file.write(url + '\n') + + return campaign_links + +# 시작할 기본 URL +base_url = "https://www.clien.net/service/board/jirum" + +# 메인 실행 부분 +if __name__ == "__main__": + s = naver_session(os.getenv('NAVER_ID'), os.getenv('NAVER_PWD')) + campaign_links = find_naver_campaign_links(base_url) + if(campaign_links == []): + print("All links visited.") + else: + for link in campaign_links: + print(link + "to be visited") + response = s.get(link) + #print(response.text) # 디버깅용 + response.raise_for_status() + time.sleep(5) + print(link + " done!") diff --git a/nfs b/nfs new file mode 100755 index 0000000..c483070 --- /dev/null +++ b/nfs @@ -0,0 +1,19 @@ +#!/usr/bin/bash +for a in homes music NetBackup photo tmp usbshare1 video video2 video3 video4; do sudo umount /mnt/diskstation/$a; sudo mkdir /mnt/diskstation/$a; done; +#for a in homes music NetBackup photo tmp usbshare2 video video2; do sudo umount /mnt/diskstation/$a; sudo mkdir /mnt/diskstation/$a; done; +nfs_ $DS918_IP volume1/homes $DS918_DIR/homes +nfs_ $DS918_IP volume1/music $DS918_DIR/music +nfs_ $DS918_IP volume3/NetBackup $DS918_DIR/NetBackup +nfs_ $DS918_IP volume1/photo $DS918_DIR/photo +nfs_ $DS918_IP volume5/tmp $DS918_DIR/tmp +nfs_ $DS918_IP volumeUSB1/usbshare $DS918_DIR/usbshare1 +#nfs_ $DS918_IP volumeUSB2/usbshare $DS918_DIR/usbshare2 +nfs_ $DS918_IP volume3/video $DS918_DIR/video +nfs_ $DS918_IP volume2/video2 $DS918_DIR/video2 +#nfs_ $DS918_IP volume3/video3 $DS918_DIR/video3 +nfs_ $DS918_IP volume4/video4 $DS918_DIR/video4 +nfs_ 192.168.1.28 mnt/hdd $DS918_DIR/hdd +nfs_ 192.168.1.28 mnt/hdd1 $DS918_DIR/hdd1 +nfs_ 192.168.1.28 mnt/hdd2 $DS918_DIR/hdd2 +nfs_ 192.168.1.28 mnt/hdd3 $DS918_DIR/hdd3 +#nfs_ 192.168.1.28 mnt/hdd4 $DS918_DIR/hdd4 diff --git a/nfs_ b/nfs_ new file mode 100755 index 0000000..c54724c --- /dev/null +++ b/nfs_ @@ -0,0 +1,10 @@ +#!/bin/bash +echo "==== $1:/$2 -> $3 ====" +if [ -d "$3" ]; then + echo "Directory found: $3" +else + echo "Directory NOT found. Creating: $3" + sudo mkdir -p "$3" + echo "done.." +fi +sudo mount -t nfs $(echo $1):/$2 $3 diff --git a/openmediavault b/openmediavault new file mode 100755 index 0000000..9a8056c --- /dev/null +++ b/openmediavault @@ -0,0 +1,9 @@ +sudo docker run -d \ + --name openmediavault \ + --privileged \ + -v /etc/docker/openmediavault/config:/etc/openmediavault \ + -v /etc/docker/openmediavault/data:/srv \ + -p 10080:80 \ + -p 10443:443 \ + --restart unless-stopped \ + openmediavault diff --git a/openvpn-client b/openvpn-client new file mode 100755 index 0000000..98380a3 --- /dev/null +++ b/openvpn-client @@ -0,0 +1,7 @@ +sudo docker run \ +--detach \ +--name=openvpn-client \ +--cap-add=NET_ADMIN \ +--device=/dev/net/tun \ +--volume /etc/docker/openvpn-client:/config \ +ghcr.io/wfg/openvpn-client diff --git a/openwrt b/openwrt new file mode 100755 index 0000000..b49a4c7 --- /dev/null +++ b/openwrt @@ -0,0 +1,4 @@ +sudo docker run --name openwrt -d --privileged \ + --network wan_network --network-alias=wan \ + --network lan_network --network-alias=lan \ + openwrt/rootfs diff --git a/plex b/plex new file mode 100755 index 0000000..ca9abe3 --- /dev/null +++ b/plex @@ -0,0 +1,17 @@ +sudo docker run \ +--network=host \ +--detach \ +--name=plex \ +-p 32400:32400 \ +-p 32400:32400/udp \ +-e VERSIONlatest \ +-e PUID=0 \ +-e PGID=0 \ +-e TZ=Asia/Seoul \ +-v /etc/docker/plex/config:/config \ +-v /etc/docker/plex/transcode:/transcode \ +-v /etc/docker/plex/media:/media \ +--device=/dev/dri:/dev/dri \ +--privileged \ +--restart unless-stopped \ +docker.io/linuxserver/plex:latest diff --git a/smb_ds918+ b/smb_ds918+ new file mode 100755 index 0000000..7afc026 --- /dev/null +++ b/smb_ds918+ @@ -0,0 +1,25 @@ +#!/usr/bin/expect +set timeout -1 +spawn smb_ds918+_ +match_max 100 +expect -exact "\[sudo\] password for rozbrian: " +send -- "$env(PASSWORD)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect -exact "Password for rozbrian@" +send -- "$env(PASSWORD4DS918)\r" +expect eof diff --git a/smb_ds918+_ b/smb_ds918+_ new file mode 100755 index 0000000..50c531e --- /dev/null +++ b/smb_ds918+_ @@ -0,0 +1,2 @@ +#sudo mkdir /mnt/diskstation +for a in homes music NetBackup photo usbshare2 video video1 video2 video3; do sudo umount /mnt/diskstation/$a; sudo mkdir /mnt/diskstation/$a; sudo mount -t cifs -o username=rozbrian //192.168.2.2/$a /mnt/diskstation/$a; done diff --git a/transmission b/transmission new file mode 100755 index 0000000..19f077b --- /dev/null +++ b/transmission @@ -0,0 +1,18 @@ +sudo docker run -d \ + --network=host \ + --detach \ + --name=transmission \ + -e PUID=1000 \ + -e PGID=1000 \ + -e TZ=Asia/Seoul \ + -e USER=rozbrian \ + -e PASS=m@libu0551 \ + -e HOST_WHITELIST= `#optional` \ + -p 9091:9091 \ + -p 51413:51413 \ + -p 51413:51413/udp \ + -v /etc/docker/transmission/config:/config \ + -v /etc/docker/transmission/downloads:/downloads \ + -v /etc/docker/transmission/watch:/watch \ + --restart unless-stopped \ + docker.io/linuxserver/transmission:latest diff --git a/tvshow_categorize b/tvshow_categorize new file mode 100755 index 0000000..6313037 --- /dev/null +++ b/tvshow_categorize @@ -0,0 +1,15 @@ +#!/bin/bash + +# Change to the target directory +TARGET_DIR="$DS918_DIR/video/#tvshow" +if cd "$TARGET_DIR"; then + echo "==== $(pwd) ====" +else + echo "Failed to change directory to $TARGET_DIR" + exit 1 +fi + +# Run the categorization scripts +tvshow_categorize_folders +tvshow_categorize_files +tvshow_categorize_etc diff --git a/tvshow_categorize_etc b/tvshow_categorize_etc new file mode 100755 index 0000000..4522ad0 --- /dev/null +++ b/tvshow_categorize_etc @@ -0,0 +1,52 @@ +#!/usr/bin/bash + +# source the other script +source tvshow_categorize_merge + +process_merge "1박2일시즌4" "1박2일/S04" +process_merge "MAKE미남(맥미남)" "MAKE(미남)" +process_merge "PD가사라졌다" "PD가사라졌다!" +process_merge "Singles" "솔로지옥/S3" +process_merge "가보자GO2" "가보자GO/S2" +process_merge "가보자GO시즌2" "가보자GO/S2" +process_merge "고딩엄빠5" "고딩엄빠/S5" +process_merge "고민순삭-있었는데요없었습니다" "고민순삭있었는데요없었습니다" +process_merge "과몰입인생사2" "과몰입인생사/S2" +process_merge "구해줘홈즈" "구해줘!홈즈" +process_merge "김창옥쇼2" "김창옥쇼/S2" +process_merge "꽃길만걸어요시즌2" "꽃길만걸어요/S2" +process_merge "나는SOLO그후,사랑은계속된다(나솔사계)" "나는SOLO그후사랑은계속된다" +process_merge "나는SOLO나는솔로" "나는SOLO" +process_merge "나만믿고따라와도시어부5" "나만믿고따라와도시어부/S5" +process_merge "놀라운토요일도레미마켓" "놀라운토요일" +process_merge "니돈내산독박투어3" "니돈내산독박투어/S3" +process_merge "대학체전소년선수촌" "대학체전-소년선수촌" +process_merge "더시즌즈-지코의아티스트" "더시즌즈/S5" +process_merge "더와일드(THEWILD)" "더와일드" +process_merge "돈쭐맛짱뜨러왔습니다2" "돈쭐,맛짱뜨러왔습니다2" +process_merge "돌싱글즈5" "돌싱글즈/S5" +process_merge "동상이몽2-너는내운명" "동상이몽2너는내운명" +process_merge "뭉쳐야찬다3" "뭉쳐야찬다/S3" +process_merge "박원숙의같이삽시다시즌3" "박원숙의같이삽시다/S3" +process_merge "빌드업-보컬보이그룹서바이벌" "빌드업보컬보이그룹서바이벌" +process_merge "살림하는남자들시즌2" "살림하는남자들/S2" +process_merge "서진이네2" "서진이네/S2" +process_merge "솔로지옥S3.Single'sInferno3" "솔로지옥/S3" +process_merge "쇼음악중심" "쇼!음악중심" +process_merge "쇼챔피언" "쇼!챔피언" +process_merge "심야괴담회4" "심야괴담회/S4" +process_merge "심야괴담회시즌4" "심야괴담회/S4" +process_merge "어서와~한국은처음이지" "어서와한국은처음이지/S2" +process_merge "어서와한국은처음이지시즌2" "어서와한국은처음이지/S2" +process_merge "연애의참견시즌3" "연애의참견/S3" +process_merge "오은영리포트-결혼지옥" "오은영리포트결혼지옥" +process_merge "요즘남자라이프-신랑수업" "요즘남자라이프신랑수업" +process_merge "용감한형사들3" "용감한형사들/S3" +process_merge "이혼숙려캠프-새로고침" "이혼숙려캠프새로고침" +process_merge "제철요리해주는옆집누나시즌3" "제철요리해주는옆집누나/S3" +process_merge "지구마불_세계여행2" "지구마불세계여행/S2" +process_merge "지구마불세계여행2" "지구마불세계여행/S2" +process_merge "지구마불세계여행시즌2" "지구마불세계여행/S2" +process_merge "태군노래자랑2" "태군노래자랑/S2" +process_merge "태군노래자랑PART2" "태군노래자랑/S2" +process_merge "태군노래자랑시즌2" "태군노래자랑/S2" diff --git a/tvshow_categorize_files b/tvshow_categorize_files new file mode 100755 index 0000000..fc5d6d3 --- /dev/null +++ b/tvshow_categorize_files @@ -0,0 +1,32 @@ +#!/bin/bash +# +# to categorize named files +# + +# Check if tvshow_categorize_name is available +if ! command -v tvshow_categorize_name &> /dev/null; then + echo "tvshow_categorize_name command not found" + exit 1 +fi + +# Find and process files +find . -maxdepth 1 -type f -print0 | while IFS= read -r -d '' file; do + # Get the name from tvshow_categorize_name + NAME="$(tvshow_categorize_name "$file")" + + # Check if the name was successfully retrieved + if [[ -z "$NAME" ]]; then + echo "Failed to categorize $file" + continue + fi + + echo "$file -> $NAME" + + # Create the directory if it doesn't exist + if [[ ! -d "$NAME" ]]; then + sudo mkdir -p "$NAME" + fi + + # Move the file to the categorized directory + sudo mv "$file" "$NAME" +done diff --git a/tvshow_categorize_folders b/tvshow_categorize_folders new file mode 100755 index 0000000..a9b4bf0 --- /dev/null +++ b/tvshow_categorize_folders @@ -0,0 +1,40 @@ +#!/bin/bash +# +# to categorize named folders +# + +# Check if tvshow_categorize_name is available +if ! command -v tvshow_categorize_name &> /dev/null; then + echo "tvshow_categorize_name command not found" + exit 1 +fi + +# Find and process directories +find . -maxdepth 1 -type d -name "[^.]*.*E[0-9][0-9]*" -print0 | while IFS= read -r -d '' dir; do + # Get the name from tvshow_categorize_name + NAME="$(tvshow_categorize_name "$dir")" + + # Check if the name was successfully retrieved + if [[ -z "$NAME" ]]; then + echo "Failed to categorize $dir" + continue + fi + + echo "$dir -> $NAME" + + # Create the destination directory if it doesn't exist + if [[ ! -d "$NAME" ]]; then + sudo mkdir -p "$NAME" + fi + + # Move the video files to the categorized directory + sudo mv "$dir/"*.mp4 "$NAME" 2>/dev/null + sudo mv "$dir/"*.mkv "$NAME" 2>/dev/null + + # Check if the move was successful before removing the directory + if [[ $? -eq 0 ]]; then + sudo rm -rf "$dir" + else + echo "Failed to move files from $dir to $NAME" + fi +done diff --git a/tvshow_categorize_merge b/tvshow_categorize_merge new file mode 100755 index 0000000..bad80af --- /dev/null +++ b/tvshow_categorize_merge @@ -0,0 +1,13 @@ +#!/usr/bin/bash +process_merge() { + local src="$1" + local dst="$2" + if [ -d "$src" ]; then + echo "======== $src -> $dst ========" +# echo $(pwd) +# mkdir -p "$dst" +# ls "$src/"* + mv "$src/"* "$dst" + rm -rf "$src" + fi +} diff --git a/tvshow_categorize_name b/tvshow_categorize_name new file mode 100755 index 0000000..8a03cec --- /dev/null +++ b/tvshow_categorize_name @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "$1" | sed -e 's/시즌/.S/g' -e 's/ //g' -e 's|^\./||' | awk -F'.' '{ print $1 }' diff --git a/tvshow_prune b/tvshow_prune new file mode 100755 index 0000000..7d61dd3 --- /dev/null +++ b/tvshow_prune @@ -0,0 +1,30 @@ +#!/bin/bash + +# Function to process files +process_files() { + local pattern="$1" + shift + local replacements=("$@") + + for file in *"$pattern"*; do + echo "==== $file ====" + for replacement in "${replacements[@]}"; do + local new_name="${file/$pattern/$replacement}" + if [ -e "$new_name" ]; then + echo "$new_name to be removed!" + rm "$new_name" + else + echo "$new_name NOT found" + fi + done + done +} + +# Process 720p files +process_files "720p-NEXT" "720p.H264-F1RST" "720p-NICE" "720p.WANNA" + +# Process 1080p files with 1080p.H264-F1RST +process_files "1080p.H264-F1RST" "1080p-NICE" "1080p.WANNA" "720p-NEXT" + +# Process 1080p files with 1080p-NEXT +process_files "1080p-NEXT" "720p-NEXT" "1080p.H264-F1RST" "1080p-NICE" "1080p.WANNA" diff --git a/tvshow_prune_all b/tvshow_prune_all new file mode 100755 index 0000000..7611e94 --- /dev/null +++ b/tvshow_prune_all @@ -0,0 +1,26 @@ +#!/bin/bash + +# Set up environment variables +TVSHOW_PATH="$DS918_DIR/video/#tvshow" +TVSHOW_DIRS=$(mktemp /tmp/tvshow_dir.XXXXXX) +TVSHOW_PRUNE=$(mktemp /tmp/tvshow_prune.XXXXXX) + +echo "TVSHOW_DIRS=$TVSHOW_DIRS" +echo "TVSHOW_PRUNE=$TVSHOW_PRUNE" + +# Change to the TV show directory +cd "$TVSHOW_PATH" || { echo "Failed to change directory to $TVSHOW_PATH"; exit 1; } +pwd + +# Find directories and save to TVSHOW_DIRS +find . -maxdepth 2 -type d > "$TVSHOW_DIRS" + +# Generate commands for pruning TV shows +awk -v PATH="$TVSHOW_PATH" -F"./" '{print "cd \""PATH"\"; pwd; export NEW_NAME=\""$2"\"; cd \"$NEW_NAME\"; pwd; tvshow_prune;"}' "$TVSHOW_DIRS" > "$TVSHOW_PRUNE" + +# Make the generated script executable and run it +chmod +x "$TVSHOW_PRUNE" +"$TVSHOW_PRUNE" + +# Clean up temporary files +#rm "$TVSHOW_DIRS" "$TVSHOW_PRUNE" diff --git a/tvshow_remove_empty b/tvshow_remove_empty new file mode 100755 index 0000000..67b5497 --- /dev/null +++ b/tvshow_remove_empty @@ -0,0 +1,12 @@ +#!/bin/bash +# +# Find and remove empty directories +# + +# Find and process empty directories +TARGET_DIR="$DS918_DIR/video/#tvshow" +cd "$TARGET_DIR" +find . -maxdepth 1 -type d -empty -print0 | while IFS= read -r -d '' dir; do + echo "$dir to be removed" + rm -r "$dir" || echo "Failed to remove $dir" +done diff --git a/vaultwarden b/vaultwarden new file mode 100755 index 0000000..9954065 --- /dev/null +++ b/vaultwarden @@ -0,0 +1,7 @@ +sudo docker run \ +--network=host \ +--detach \ +--name=vaultwarden \ +-p 8080:8080 \ +-v /etc/docker/vaultwarden/data:/data \ +docker.io/vaultwarden/server:latest diff --git a/vim4git.sh b/vim4git.sh new file mode 100755 index 0000000..7555c0d --- /dev/null +++ b/vim4git.sh @@ -0,0 +1 @@ +git config core.editor "vim"