From aaf3776e62a7bbc1291c5ce292ea654ba6b872ca Mon Sep 17 00:00:00 2001 From: Bruno21 Date: Thu, 22 Aug 2024 08:44:15 +0200 Subject: [PATCH] 22-08-2024 --- api_deepl.sh | 17 +++++++ backup_conf.sh | 22 +++++++++ backups_conf.sh | 28 +++++++++++ crypt.sh | 76 ++++++++++++++++++++++++++++++ curl2.sh | 28 +++++++++++ exiftool.sh | 68 ++++++++++++++++++++++++++ git-sparse.sh | 10 ++++ git_reachable.sh | 16 +++++++ iconv.sh | 46 ++++++++++++++++++ latest_release_on_github.sh | 18 +++++++ ovh_api.sh | 8 ++-- purge_server.sh | 53 +++++++++++++++++++++ reachable.sh | 59 +++++++++++++++++++++++ remote_scripts.sh | 48 +++++++++++++++++++ rename_series.sh | 67 ++++++++++++++++++++++++++ rsync-retry.sh | 74 +++++++++++++++++++++++++++++ run.sh | 41 ++++++++++++++++ server.sh | 47 ++++++++++++++++++ wget-url-check.sh => urls_check.sh | 0 urls_list.txt | 60 +++++++++++++++++++++++ 20 files changed, 782 insertions(+), 4 deletions(-) create mode 100755 api_deepl.sh create mode 100755 backup_conf.sh create mode 100755 backups_conf.sh create mode 100755 crypt.sh create mode 100755 curl2.sh create mode 100755 exiftool.sh create mode 100755 git-sparse.sh create mode 100755 git_reachable.sh create mode 100755 iconv.sh create mode 100755 latest_release_on_github.sh create mode 100755 purge_server.sh create mode 100755 reachable.sh create mode 100755 remote_scripts.sh create mode 100755 rename_series.sh create mode 100755 rsync-retry.sh create mode 100755 run.sh create mode 100755 server.sh rename wget-url-check.sh => urls_check.sh (100%) create mode 100644 urls_list.txt diff --git a/api_deepl.sh b/api_deepl.sh new file mode 100755 index 0000000..c2dbb16 --- /dev/null +++ b/api_deepl.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +[ ! -f "$HOME/.env" ] || export $(grep -v '^#' "$HOME/.env" | xargs) + +# DE/FR/ES/EN-GB/EN-US + +translate() { + + deepl=$(curl -s -X POST 'https://api-free.deepl.com/v2/translate' \ + --header "Authorization: DeepL-Auth-Key $DEEPL_KEY" \ + --data-urlencode "text=$2" \ + --data-urlencode "target_lang=$1" + ) + echo "$deepl" | jq -r .'translations[].text' +} + +translate "DE" "il fait beau !" diff --git a/backup_conf.sh b/backup_conf.sh new file mode 100755 index 0000000..d404d17 --- /dev/null +++ b/backup_conf.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +dest=$HOME/Documents/conf + +cp /opt/homebrew/etc/httpd/other/boiteverte.conf "$dest" +cp /opt/homebrew/etc/httpd/other/clicclac.conf "$dest" +cp /opt/homebrew/etc/httpd/other/sentier.conf "$dest" +cp /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf "$dest" +cp /opt/homebrew/etc/httpd/extra/httpd-ssl.conf "$dest" +cp /opt/homebrew/etc/httpd/httpd.conf "$dest" +cp -r /opt/homebrew/etc/httpd/certs "$dest" + +#cp /opt/homebrew/etc/php/8.1/conf.d/imagick.ini "$dest" +#cp /opt/homebrew/etc/php/8.1/php-fpm.conf "$dest" +#cp /opt/homebrew/etc/php/8.1/php.ini "$dest" +#cp /opt/homebrew/etc/php/8.1/php-fpm.d/www.conf "$dest" +#cp /opt/homebrew/etc/php/8.2/php.ini "$dest" +#cp -r /opt/homebrew/etc/php/8.1/conf.d "$dest" +#cp /opt/homebrew/etc/php/8.1/pear.conf "$dest" + +cp /opt/homebrew/etc/redis-sentinel.conf "$dest" +cp /opt/homebrew/etc/redis.conf "$dest" \ No newline at end of file diff --git a/backups_conf.sh b/backups_conf.sh new file mode 100755 index 0000000..714ef40 --- /dev/null +++ b/backups_conf.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + + +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bgd="\033[1;4;31m" +red="\033[1;31m" +bold="\033[1m" +bold_ita="\033[1;3m" +box="\033[1;41m" +redbold="\033[1;31m" +redbox="\033[1;41m" +green="\033[0;32m" +reset="\033[0m" + + +cp -r /opt/homebrew/etc/httpd /Users/bruno/Documents/webserver + +cp -r /opt/homebrew/etc/php /Users/bruno/Documents/webserver + +cp /opt/homebrew/etc/my.cnf /Users/bruno/Documents/webserver +cp -r /opt/homebrew/etc/my.cnf.d/ /Users/bruno/Documents/webserver + +cp /opt/homebrew/etc/phpmyadmin.config.inc.php /Users/bruno/Documents/webserver + +cp /opt/homebrew/etc/redis.conf /Users/bruno/Documents/webserver +cp /opt/homebrew/etc/redis-sentinel.conf /Users/bruno/Documents/webserver \ No newline at end of file diff --git a/crypt.sh b/crypt.sh new file mode 100755 index 0000000..682dd20 --- /dev/null +++ b/crypt.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# using aesutil +#SALT=$(mkrand 15) # mkrand generates a 15-character random passwd +#MYENCPASS="i/b9pkcpQAPy7BzH2JlqHVoJc2mNTBM=" # echo "passwd" | aes -e -b -B -p $SALT +#MYPASS=$(echo "$MYENCPASS" | aes -d -b -p $SALT) + +# and usage +#serverControl.sh -u admin -p $MYPASS -c shutdown + + + + +echo 'rusty!herring.pitshaft' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.' +# U2FsdGVkX199dZHjA0wtjtt0OapR8EOpVwZ5mPqN3JJd40yhCS3fYYxEflQTXTwr + +echo "U2FsdGVkX199dZHjA0wtjtt0OapR8EOpVwZ5mPqN3JJd40yhCS3fYYxEflQTXTwr" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.' + + + + +echo 'rusty!herring.pitshaft' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.' > .secret_vault.txt + +# chmod 600 .secret_vault.txt +cat .secret_vault.txt | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.' +#rusty!herring.pitshaft + + + + + +# Load environment variables from .env file +[ ! -f .env ] || export $(grep -v '^#' .env | xargs) # export $(grep -v '^#' .env | xargs -0) +# while read line; do export $line; done < .env + +Example of .env file: + +# Database settings +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=mydatabase +DB_USER=myuser +DB_PASSWORD=mypassword + +# API keys +API_KEY=abc123 +SECRET_KEY=def456 + + + + + +DB_NAME=mydb +DB_PASSWORD=abcd1234 + +source my_custom.env + + + + + + +set -o allexport +source conf-file +set +o allexport + +set -a +. ./env.txt +set +a + +# .env loading in the shell +dotenv () { + set -a + [ -f .env ] && . .env + set +a +} \ No newline at end of file diff --git a/curl2.sh b/curl2.sh new file mode 100755 index 0000000..5a4b108 --- /dev/null +++ b/curl2.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +folder=Janvier + +for file in /Users/bruno/Pictures/_Canon/Export/2023/Janvier/* +do + #curl -u username:password -T ${file} http://www.example.com/folder/${file} + + # crée l'arborescence + #/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo --ftp-create-dirs -T ${file} sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/${file} + + /opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -T ${file} sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/${folder}/${file}/ + +done + + +#ok +#find /Users/bruno/Pictures/_Canon/Export/2023/Janvier/ -type f | xargs -L 1 bash -c '/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -T $1 sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/${1##*/}' \; + +# ok +# /opt/homebrew/opt/curl/bin/curl -i -v --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -O sftp://ftp.cluster011.ovh.net:22/home/funnymac/8_2022.jpg + +# OK +# /opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -T '{2023-01-31_RuBlanc_0627,2023-01-31_RuBlanc_0623}.jpg' sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/ \; + +# ok +# find /Users/bruno/Desktop/Juin -type f | xargs -L 1 bash -c '/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo --ftp-create-dirs --output-dir 'juin' -T $1 sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/juin/${1##*/}' \; + diff --git a/exiftool.sh b/exiftool.sh new file mode 100755 index 0000000..68c0535 --- /dev/null +++ b/exiftool.sh @@ -0,0 +1,68 @@ +#! /bin/bash +function usage { + echo "usage: $0 -ms path_of_file" + echo " -m to remove useless exif entries" + echo " -s to show current exif entries" + exit -1 +} +if [ $# != 2 ]; then + usage +fi +OP=$1 +SRC=$2 +if [ ! -f $SRC ]; then + echo "error: file not found" + exit -2 +fi +if [ $OP = "-m" ]; then + cp "$SRC" "$SRC"."_tmp" + exiftool -all= "$SRC" + exiftool -overwrite_original + -TagsFromFile "$SRC"."_tmp" + -ExposureTime + -FNumber + -ExposureProgram + -ISO + -DateTimeOriginal + -CreateDate + -ExposureCompensation + -MaxApertureValue + -MeteringMode + -LightSource + -Flash + -FocalLength + -SubSecTime + -SubSecTimeOriginal + -SubSecTimeDigitized + -ColorSpace + -ExifImageWidth + -ExifImageHeight + -SensingMethod + -CustomRendered + -ExposureMode + -WhiteBalance + -DigitalZoomRatio + -FocalLengthIn35mmFormat + -SceneCaptureType + -GainControl + -Contrast + -Saturation + -Sharpness + -SubjectDistanceRange + -GPSVersionID + -GPSLatitudeRef + -GPSLatitude + -GPSLongitudeRef + -GPSLongitude + -Make + -Model + "$SRC" + exiftool -delete_original! "$SRC" + rm -f "$SRC"."_tmp" +else + if [ $OP = "-s" ]; then + exiftool "$SRC" + else + usage + fi +fi \ No newline at end of file diff --git a/git-sparse.sh b/git-sparse.sh new file mode 100755 index 0000000..cbbe82d --- /dev/null +++ b/git-sparse.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +function git-scp() ( + URL="$1" && shift 1 + svn export ${URL/blob\/master/trunk} +) + +# svn export --force https://github.com/jaysalvat/vegas/trunk/dist + +git-scp https://github.com/jaysalvat/vegas/trunk/dist \ No newline at end of file diff --git a/git_reachable.sh b/git_reachable.sh new file mode 100755 index 0000000..deb6c59 --- /dev/null +++ b/git_reachable.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +#url="git@gitea.maboiteverte.fr:shell/bash_mbv.git" +url="https://clicclac.synology.me:3000/shell/bash.git" +url="bruno@dsm916e:/volume1/Repositories/bash.git" +url="https://Bruno21@github.com/Bruno21/kymsu.git" + +## Returns errlvl 0 if $1 is a reachable git remote url +git-remote-url-reachable() { + git ls-remote "$1" CHECK_GIT_REMOTE_URL_REACHABILITY >/dev/null 2>&1 + } + +if git-remote-url-reachable "$url"; then + ## code + echo "reachable !" +fi \ No newline at end of file diff --git a/iconv.sh b/iconv.sh new file mode 100755 index 0000000..ed8b800 --- /dev/null +++ b/iconv.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +red="\033[1;31m" +greenbold="\033[1;32m" +green="\033[0;32m" +yellow="\033[0;33m" +bold="\033[1m" +#bold_under="\033[1;4m" +underline="\033[4m" +reset="\033[0m" + + +insta=false # #Becasseauvariable #LeTeich #Bird +flickr=true # "Bécasseau variable" "Le Teich" Bird +ccpx=true # Bécasseau variable, Le Teich, Bird + +# Tags automatically added +# You can add tags to this 4 arrays + +wild=("wildlife" "wildlifephoto" "wildlifephotographer") +nat=("naturelovers" "natureshot" "naturephotography") +reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or") +#cinqcent=("Bécasseau variable" "Le Teich" "Bird") + + + +for i in "${reg[@]}" +do + if [[ "$i" = *" "* ]]; then + region_flickr+="\"${i}\" " + #region_ccpx+="${i}," + else + region_flickr+="${i} " + #region_ccpx+="${i}," + fi + + ### + region_ccpx+="${i}," + + #region_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " + region_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ASCII//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " +done + +echo "$region_flickr" +echo "$region_insta" +echo "$region_ccpx" \ No newline at end of file diff --git a/latest_release_on_github.sh b/latest_release_on_github.sh new file mode 100755 index 0000000..6fbbd7a --- /dev/null +++ b/latest_release_on_github.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Usage: ./latest_release_on_github.sh trunk-rs/trunk + +a=$(curl --silent "https://api.github.com/repos/$1/releases/latest") + +body=$(echo "$a" | grep '"body":' | sed -E 's/.*"([^"]+)".*/\1/') +echo -e "$body" +tag=$(echo "$a" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +echo -e "$tag" + +get_latest_release() { + curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api + #grep '"tag_name":' | # Get tag line + grep '"body":' #| + #sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value +} + diff --git a/ovh_api.sh b/ovh_api.sh index 39fa7ad..942a6fd 100755 --- a/ovh_api.sh +++ b/ovh_api.sh @@ -28,7 +28,7 @@ export_zone() { fi } -export_zone +#export_zone cat $ZONE_FILE refresh() { @@ -81,7 +81,7 @@ add_cname() { fi } -#add_cname "example_cname" +add_cname "ntfy" remove_cname() { @@ -120,7 +120,7 @@ remove_cname() { } -remove_cname "kuma" +#remove_cname "kuma" #curl -X POST "https://eu.api.ovh.com/v1/domain/zone/photos-nas.ovh/record" \ @@ -135,4 +135,4 @@ remove_cname "kuma" # refresh # curl -X POST "https://eu.api.ovh.com/v1/domain/zone/photos-nas.ovh/refresh" \ -# -H "authorization: Bearer eyJhbGciOiJFZERTQSIsImtpZCI6IkVGNThFMkUxMTFBODNCREFEMDE4OUUzMzZERTk3MDhFNjRDMDA4MDEiLCJraW5kIjoib2F1dGgyIiwidHlwIjoiSldUIn0.eyJBY2Nlc3NUb2tlbiI6ImY4MGU5NmQwZmFiZmM3ZWY0MmMzZjZjNjcxNjZiOWUzNWQwMDc3NTJiOTFhNGQ0NDQyNmY3NTM1MzhiM2M5N2EiLCJpYXQiOjE3MjIyNTk0NzF9.C4MFvrgfF53n87q3h1xny7NBYAOozwzA5t8ty9TqNprMTfWz0Fx5JwvFaCVi8jzDvjzwIYd4MLNm-WqTfLfsAw" \ No newline at end of file +# -H "authorization: Bearer eyJhbGciOiJFZERTQSIsImtpZCI6IkVGNThFMkUxMTFBODNCREFEMDE4OUUzMzZERTk3MDhFNjRDMDA4MDEiLCJraW5kIjoib2F1dGgyIiwidHlwIjoiSldUIn0.eyJBY2Nlc3NUb2tlbiI6ImY4MGU5NmQwZmFiZmM3ZWY0MmMzZjZjNjcxNjZiOWUzNWQwMDc3NTJiOTFhNGQ0NDQyNmY3NTM1MzhiM2M5N2EiLCJpYXQiOjE3MjIyNTk0NzF9.C4MFvrgfF53n87q3h1xny7NBYAOozwzA5t8ty9TqNprMTfWz0Fx5JwvFaCVi8jzDvjzwIYd4MLNm-WqTfLfsAw" diff --git a/purge_server.sh b/purge_server.sh new file mode 100755 index 0000000..bb9e3bb --- /dev/null +++ b/purge_server.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +italic="\033[3m" +#underline="\033[4m" +#ita_under="\033[3;4m" +#bgd="\033[1;4;31m" +red="\033[1;31m" +green="\033[1;32m" +yellow="\033[1;33m" +bold="\033[1m" +#box="\033[1;41m" +reset="\033[0m" + +host=$(hostname) +# status change XX*24 hours ago. +ago=30 # 30 jours + +if [ "$host" == "localhost" ]; then + ip=$(hostname -I | awk '{print $1}') + + if [ "$ip" = "212.227.191.167" ]; then + + echo -e "\n${red}Running df -h /...${reset}" + + df -h / + + echo -e "\n${green}Remove backup logfiles ...${reset}" + + sudo find /var/log/plesk/PMM/ -name 'backup*' -type d -ctime +$ago -exec rm -rf {} +; + #find /var/log/plesk/PMM/ -name 'backup*' -type d -ctime +$ago -exec rm -rf {} +; + + echo -e "\n${green}Remove backup files ...${reset}" + + sudo find /var/lib/psa/dumps -name 'backup*' -type f -ctime +$ago -exec rm -rf {} +; + #find /var/lib/psa/dumps -name 'backup*' -type f -ctime +$ago -exec rm -rf {} +; + + echo -e "\n${green}Find files bigger than 200Mo ...${reset}" + + sudo find / -type f -size +200M -exec du -h {} + 2>/dev/null | sort -r -h + + echo -e "\n${green}Voir la place occupée par les logs ...${reset}" + + journalctl --disk-usage -q + + echo -e "\n${green}Décommenter la ligne SystemMaxUse dans /etc/systemd/journald.conf${reset}" + + echo -e "\n${green}Running df -h /...${reset}" + + df -h / + + echo + fi +fi \ No newline at end of file diff --git a/reachable.sh b/reachable.sh new file mode 100755 index 0000000..c545ff5 --- /dev/null +++ b/reachable.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +host1=maboiteverte.fr +port1=22 + +host2=clicclac.synology.me +port2=42666 + +echo -e "\nnc\n" + +if nc -z -G 2 $host1 $port1 &>/dev/null; then + echo $? + echo "server $host1 up" +else + echo $? + echo "server $host1 down" +fi + +if nc -z -G 2 $host2 $port2 &>/dev/null; then + echo $? + echo "server $host2 up" +else + echo $? + echo "server $host2 down" +fi + + + +echo -e "\nnmap\n" + +if nmap maboiteverte.fr -PN -p 22 | grep open &>/dev/null; then + echo $? + echo "server $host1 up" +else + echo $? + echo "server $host1 down" +fi + +if nmap clicclac.synology.me -PN -p 42666 | grep open &>/dev/null; then + echo $? + echo "server $host2 up" +else + echo $? + echo "server $host2 down" +fi + + + +echo -e "\nping\n" + +ping -c1 -W1 -q maboiteverte.fr 2>/dev/null; +echo $? + +ping -c1 -W1 -q clicclac.synology.me 2>/dev/null; +echo $? + + + + diff --git a/remote_scripts.sh b/remote_scripts.sh new file mode 100755 index 0000000..09b01f4 --- /dev/null +++ b/remote_scripts.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + + +# remote scripts + +ssh -t bruno@maboiteverte.fr ./purge_server.sh + +ssh -t bruno@maboiteverte.fr ./upgrade_joplin.sh + +ssh -t bruno@maboiteverte.fr ./mbv-gitea-upd.sh + +# sudo: /opt/plesk/php/7.2/bin/php: command not found +#ssh -t bruno@maboiteverte.fr ./upgrade_nextcloud.sh + +printf './upgrade_nextcloud.sh' | ssh -t bruno@maboiteverte.fr 'bash -l' + +# pb with ssh keys +ssh -t bruno@maboiteverte.fr ./backup_vps.sh + + + +# ssh bruno@maboiteverte.fr 'source ~/.bash_profile && php -v' +#PHP 7.2.24 + +# echo "php -v" | mbv +# PHP 8.2.6 + +# php -v | ssh 'bruno@maboiteverte.fr' +#-bash: line 1: syntax error near unexpected token `(' +#-bash: line 1: `PHP 8.2.10 (cli) (built: Sep 1 2023 00:17:29) (NTS)' + +# php -v | ssh bruno@maboiteverte.fr 'bash -l' +# bash: line 1: syntax error near unexpected token `(' +# bash: line 1: `PHP 8.2.10 (cli) (built: Sep 1 2023 00:17:29) (NTS)' + +# printf 'php -v' | ssh bruno@maboiteverte.fr 'bash -l' +# PHP 8.2.6 (cli) (built: May 15 2023 06:37:47) (NTS) +# Copyright (c) The PHP Group +# Zend Engine v4.2.6, Copyright (c) Zend Technologies +# with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies + +# printf 'php -v' | ssh bruno@maboiteverte.fr +# Pseudo-terminal will not be allocated because stdin is not a terminal. + +# PHP 8.2.6 (cli) (built: May 15 2023 06:37:47) (NTS) +# Copyright (c) The PHP Group +# Zend Engine v4.2.6, Copyright (c) Zend Technologies +# with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies \ No newline at end of file diff --git a/rename_series.sh b/rename_series.sh new file mode 100755 index 0000000..7ca6ddf --- /dev/null +++ b/rename_series.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bgd="\033[1;4;31m" +red="\033[1;31m" +green="\033[1;32m" +yellow="\033[1;33m" +bold="\033[1m" +box="\033[1;41m" +reset="\033[0m" + +shopt -s globstar + +SRC="$HOME/Downloads" +DEST="$HOME/Movies" +DEST_EXT=mp4 +#HANDBRAKE_CLI=HandBrakeCLI +PRESET="Apple 720p30 Surround" +MAXSIZE=30000000 + +REGEX="([sS]([0-9]{2,}|[X]{2,})[eE]([0-9]{2,}|[Y]{2,}))" +#REGEX2="[0-9]{4}" +REGEX2="2[0-9]{3}" + +for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v} +do + echo "$FILE" + filename=$(basename "$FILE") + #echo "$filename" # Arctic.Circle.S01E02.iNTERNAL.MULTi.720p.WEB.H264-CiELOS.mkv + + extension=${filename##*.} + #echo "$extension" # mkv + + filename=${filename%.*} # sans extension + #echo "$filename" # Arctic.Circle.S01E02.iNTERNAL.MULTi.720p.WEB.H264-CiELOS + + # Get file size + FILESIZE=$(stat -c%s "$FILE") + + if (( FILESIZE > MAXSIZE )); then + + if [[ $filename =~ $REGEX ]]; then + MATCH="${BASH_REMATCH[1]}" + e=$(echo ${filename%$MATCH*} | sed 's/\./\ /g' | xargs) + new_name="$e - $MATCH.$DEST_EXT" + echo "$new_name" + elif [[ $filename =~ $REGEX2 ]]; then + MATCH2="${BASH_REMATCH[0]}" + e=$(echo ${filename%$MATCH2*} | sed 's/\./\ /g' | xargs) + new_name="$e ($MATCH2).$DEST_EXT" + echo "$new_name" + else + echo "Could not find SXXEYY pattern in new format" + echo " " + continue + fi + + echo "--------------" + + fi + +done + + + diff --git a/rsync-retry.sh b/rsync-retry.sh new file mode 100755 index 0000000..17cec6d --- /dev/null +++ b/rsync-retry.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +### ABOUT: See: http://gist.github.com/366269 +### Runs rsync, retrying on errors up to a maximum number of tries. +### On failure script waits for internect connection to come back up by pinging google.com before continuing. +### +### Usage: $ ./rsync-retry.sh source destination +### Example: $ ./rsync-retry.sh user@server.example.com:~/* ~/destination/path/ +### +### INPORTANT: +### To avoid repeated password requests use public key authentication instead of passwords +### "ssh-keygen" (with no password), then "ssh-copy-id user@server.example.com" + +# ----------------------------- rSync Options ------------------------------------------------ + +OPT="--inplace -vzP" + +# -------------------- Shouldn't need to change anything bellow ------------------------------- +echo -n "Enter No. of retries to attempt... " +read MAX_RETRIES + +echo -n "Recursive flag ON? (y/n) " +read YN +if [[ $YN == "y" || $YN == "Y" ]]; then + RFLAG=r +fi + +COM="rsync $OPT$RFLAG -e 'ssh -o \"ServerAliveInterval 10\"' $1 $2" + +echo +echo "Using command: $COM" + +# Trap interrupts and exit instead of continuing the loop +trap "echo Ctl+C Detected... Exiting!; exit;" SIGINT SIGTERM + +COUNT=0 +START=$SECONDS + +# Set the initial exit value to failure +false +while [ $? -ne 0 -a $COUNT -lt $MAX_RETRIES ]; do + COUNT=$(($COUNT+1)) + if [ $COUNT -ne 1 ]; then + echo + echo "Waiting for Internet connection..." + false + until [ $? -eq 0 ]; do + wget -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null + done + fi + echo + echo "Attempt No. $COUNT / $MAX_RETRIES" + echo + ## Havn't got the quoting quite right above to just have $COM here. + #$COM + rsync -vzP$RFLAG --inplace -e 'ssh -o "ServerAliveInterval 10"' $1 $2 +done + +FINISH=$SECONDS +if [[ $(($FINISH - $START)) -gt 3600 ]]; then + ELAPSED="$((($FINISH - $START)/3600))hrs, $(((($FINISH - $START)/60)%60))min, $((($FINISH - $START)%60))sec" +elif [[ $(($FINISH - $START)) -gt 60 ]]; then + ELAPSED="$(((($FINISH - $START)/60)%60))min, $((($FINISH - $START)%60))sec" +else + ELAPSED="$(($FINISH - $START))sec" +fi + +if [ $COUNT -eq $MAX_RETRIES -a $? -ne 0 ]; then + echo "Hit maximum number of retries($MAX_RETRIES), giving up. Elapsed time: $ELAPSED" +fi + +if [ $? -eq 0 ]; then + echo "Finished after $COUNT retries!! Elapsed time: $ELAPSED" +fi \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..06cf071 --- /dev/null +++ b/run.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bgd="\033[1;4;31m" +red="\033[1;31m" +bold="\033[1m" +box="\033[1;41m" +reset="\033[0m" + +# Main menu +menu(){ + +options=( + "(u)pdates.sh (Update websites)" + "mk(s)erve (Serve MkDocs)" + "mk(b)uild.sh (Transfer MkDocs to servers)" + "photo_du_mois.sh (Transfer photo_du_mois.jpg to servers)" + "(Q)uit" +) + + +echo -e "\n\033[1mScripts menu: \033[0m\n" + +select option in "${options[@]}"; do + case "$REPLY" in + 1|u|U) ./updates.sh ;; + 2|s|S) cd $HOME/Documents/docs ; mkdocs serve ;; + 3|b|B) ./mkbuild.sh ;; + 4|m|M) ./photo_du_mois.sh ;; + 4|q|Q) exit 0 ;; + esac +done + +} + +menu + + + diff --git a/server.sh b/server.sh new file mode 100755 index 0000000..28933be --- /dev/null +++ b/server.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + + +: <<'END_COMMENT' + +# server1: clicclac.synology.me +declare -A server1 +server1[user]="bruno" +server1[server]="clicclac.synology.me" +server1[dest]="/volume1/web/$folder/" +server1[port]=42666 + +# server2: ovh.net +declare -A server2 +server2[user]="funnymac" +server2[server]="ftp.cluster011.ovh.net" +server2[dest]="www/$folder/" +server2[port]=22 + +# server3: maboiteverte.fr +declare -A server3 +server3[user]="bruno" +server3[server]="ftp.maboiteverte.fr" +server3[dest]="httpdocs/$folder/" +server3[port]=22 + +END_COMMENT + + +server=( "ftp.cluster011.ovh.net" "sur-le-sentier.fr" "ftp.maboiteverte.fr" "clicclac.synology.me" ) +user=( "funnymac" "sentier" "bruno" "bruno" ) +dest=( "www/zenphoto/albums/photos-du-mois/" "httpdocs/photos/img/" "httpdocs/" "/volume1/web/" ) +port=( "22" "22" "22" "42666" ) + +for new in "${server[@]}" +do + echo "${new}" +done + + +echo "" + +for ((i=0 ; i<"${#server[@]}" ; i++)) +do + echo ${server[$i]} - ${user[$i]} - ${dest[$i]} - ${port[$i]} + +done \ No newline at end of file diff --git a/wget-url-check.sh b/urls_check.sh similarity index 100% rename from wget-url-check.sh rename to urls_check.sh diff --git a/urls_list.txt b/urls_list.txt new file mode 100644 index 0000000..5c520b2 --- /dev/null +++ b/urls_list.txt @@ -0,0 +1,60 @@ +https://clicclac.info +https://clicclac.info/wordpress +https://sur-le-sentier.fr +https://maboiteverte.fr +https://photos-nas.ovh +https://airdrop.photos-nas.ovh +https://asus.photos-nas.ovh +https://books.photos-nas.ovh +https://change.photos-nas.ovh +https://chibisafe.photos-nas.ovh +https://dcommander.photos-nas.ovh +https://dockge.photos-nas.ovh +https://docspell.photos-nas.ovh +https://dozzle.photos-nas.ovh +https://drive.photos-nas.ovh +https://ds916.photos-nas.ovh +https://ds923.photos-nas.ovh +https://files.photos-nas.ovh +https://git.photos-nas.ovh +https://gitea.photos-nas.ovh +https://glances.photos-nas.ovh +https://gokapi.photos-nas.ovh +https://gotify.photos-nas.ovh +https://home-assistant.photos-nas.ovh +https://homebridge.photos-nas.ovh +https://igotify.photos-nas.ovh +https://immich.photos-nas.ovh/photos +https://invidious.photos-nas.ovh +https://it-tools.photos-nas.ovh +https://kuma.photos-nas.ovh +https://maloja.photos-nas.ovh +https://maps-server.photos-nas.ovh +https://maps.photos-nas.ovh +https://menu.photos-nas.ovh +https://musiiic.photos-nas.ovh +https://navidrome.photos-nas.ovh +https://nextcloud.photos-nas.ovh +https://notif.photos-nas.ovh +https://paperlessngx.photos-nas.ovh +https://pastebin.photos-nas.ovh +https://photos.photos-nas.ovh +https://pihole1.photos-nas.ovh/admin/login.php +https://pihole2.photos-nas.ovh/admin/login.php +https://pingvin.photos-nas.ovh +https://portainer.photos-nas.ovh +https://psitransfer.photos-nas.ovh +https://seafile.photos-nas.ovh +https://search.photos-nas.ovh +https://send.photos-nas.ovh +https://snippet.photos-nas.ovh +https://syno-dashboard.photos-nas.ovh +https://tautulli.photos-nas.ovh +https://test.photos-nas.ovh +https://tube.photos-nas.ovh +https://tunes.photos-nas.ovh +https://uptime.photos-nas.ovh +https://vault.photos-nas.ovh +https://wg.photos-nas.ovh +https://yacy.photos-nas.ovh +https://yatch.photos-nas.ovh