Compare commits

...

11 Commits

Author SHA1 Message Date
839d05bfbb 27-08-2025 2025-08-27 09:14:20 +02:00
947698f00b handbrake_for_plex.sh
shellcheck.sh
2025-03-06 14:24:48 +01:00
0e6f7c5196 handbrake_for_plex.sh
-si une nouvelle version de handbrakeCLI est disponible, on affiche les nouveautés
2025-02-28 20:49:45 +01:00
b264b99cf0 handbrake_for_plex.sh
-mise-à-jour de handbrakeCli depuis Github
2025-02-28 10:50:34 +01:00
32c1293017 v1.5
Ajout:
-aide
-tri les dossiers mensuels dans des dossiers annuels
2025-02-08 20:10:59 +01:00
b7f9d9aac7 API ovh 2025-02-08 07:24:01 +01:00
fef1ced910 sort_export_folder.sh
tri les photos d’un dossier et les déplace dans des dossiers mensuels
2025-02-08 07:22:10 +01:00
b31f31c17f stacks.sh
Backup des docker-compose.yml et des .env sur le NAS
2024-12-29 19:58:24 +01:00
df32b22fd3 Gotify
fonction send_gotify_notification()
2024-08-25 18:50:36 +02:00
1245ea5a5c Pushover
# ./pushover.sh  -t "Pushover via Bash" -m "Pushover message sent with bash from $(hostname -f)" -p1  -s siren -u http://www.google.com -n "Google"
2024-08-25 18:49:58 +02:00
e14588d06e 25-08-2024 2024-08-25 18:47:43 +02:00
13 changed files with 1095 additions and 491 deletions

View File

@@ -1,17 +1,75 @@
# README
# Scripts bash
Collection of various bash scripts.
## Getting Started
- **apache_tools.sh**: Edit Apache/PHP/MySQL configurations files, restart Apache, view Log files, switch PHP version
- **backup-conf.sh**: Backup several files and folders and send them on 2 servers (rsync)
- **api_deepl.sh**: Translate text to another language using DeepL API (function translate). Require a $DEEPL_KEY.
- **api-ovh.sh**:
- **backup-conf.sh**: Backup several files and folders and send them on 2 servers (rsync). (uses GPG2 to encrypt certain files)
- **backup_conf.sh**: Copy several .conf files on Mac to destination folder
- **backup_Joplin.sh**: Backup all Joplin notes
- **backup_mysql.sh**: Sauvegarde toutes les bases MySQL et les envoie sur 2 serveurs (rsync).
- **bash_tools.sh**: Edit/backup/restore .bash_profile file
- **install_adobe_apps.sh**: installe les apps Adobe (Lightroom, Photoshop) depuis les srveurs Adobe.
- ! **backup_mysql.sh**: Sauvegarde toutes les bases MySQL et les envoie sur 2 serveurs (rsync). (use gpg to decrypt MySQL conf file)
- ! **backup_vps.sh**: Backup files/folders on VPS server and send them to NAS and OVH with rsync.
- **bash_tools.sh**: Edit/backup/restore .bash_profile file.
- **convert-videos-for-plex.sh**: Obsolete. Replaced by **handbrake_for_plex.sh**
- **crypt.sh**: encrypt/decrypt password with openssl. .env file usage.
- curl.sh:
- **curl2.sh**: upload content folder to OVH using curl.(!! PASSWD)
- **exiftool.sh**: display or remove EXIF from picture. (Error !!!)
- **git_reachable.sh**: test if a repo git is reachable.
- **git-sparse.sh**: function git-scp (Error !!!)
- **handbrake_for_plex.sh**:
- **iconv.sh**: converts keywords from utf-8 to ASCII
- **install_adobe_apps.sh**: installe les apps Adobe (Lightroom, Photoshop) depuis les serveurs Adobe.
- **latest_release_on_github.sh**: retrieve the latest release from a GitHub repo with the API.
- **mbv-gitea-upd.sh**: met à jour Gitea sur maboiteverte.fr
- **mkbuild.sh**: Build MkDocs project and send him on 2 servers (rsync)
- **syno-cron-gitea-update.sh**: met à jour Gitea sur le NAS Syno
- **ovh_api.sh:** OVH API usage (functions: add_cname, remove_cname, refresh, export_zone)(require OVH_CONSUMER_KEY, OVH_APP_KEY, OVH_APP_SECRET)
- ! **photo_du_mois.sh**:
- **purge_server.sh**: libère de la place sur le VPS 1and1
- **reachable.sh**: vérifie si les serveurs sont joignables avec ping, nc & nmap
- **remote_scripts.sh**: exécute des scripts via ssh sur maboiteverte.fr
- **rename_series.sh**: renomme les séries. Utilisé dans **handbrake_for_plex.sh**.
- **rsync-retry.sh**: runs rsync, retrying on errors up to a maximum number of tries.
- **run.sh**: menu pour lancer updates.sh, mkdocs serve, mkbuid.sh, photo_du_mois.sh
- **server.sh**: liste des serveurs/users/dest/port
- **sphp.sh**: change PHP version
- **sphp_php-fpm.sh**: change PHP -FPM version
- ssl-cert-info.sh:
- **syno-cron-gitea-update.sh**: met à jour Gitea (binaire) sur le NAS Syno.
- **thumbsup-npm.sh**: exécute `thumbsup --config="$config_file"` pour créer une galerie Thumbsup.
- **update_container.sh**: recherche les M-à-J de containers Docker.
- **upgrade_nextcloud.sh**: met à jour Nextcloud sur le NAS ou VPS.
- **urls_check.sh**: check if url is up or down (code 200|301|302\|303)
- **venv_solus.sh**: update apps in Python virtuals environments
- **zsh_tools.sh**: Edit/backup/restore .zshrc file
### Prerequisites
Requirements for the scripts: Bash
## Authors
- **Billie Thompson** - *Provided README Template* -
[PurpleBooth](https://github.com/PurpleBooth)
## License
This project is licensed under the [CC0 1.0 Universal](LICENSE.md)
Creative Commons License - see the [LICENSE.md](LICENSE.md) file for
details
-

17
api-ovh.sh Normal file
View File

@@ -0,0 +1,17 @@
OVH_HTTP_METHOD="POST"
OVH_HTTP_QUERY="$OVH_API_URL/$OVH_API_END_POINT_DOMAIN_ZONE_DNS/domain.com/$OVH_API_END_POINT_DOMAIN_ZONE_DNS_RECORD"
OVH_FIELD_TYPE="TXT"
OVH_SUB_DOMAIN=""
OVH_TARGET="\"google-site-verification=O_Kd7lqvCvpBz7fzEeUKGVKBmsAsfJgaJuh3PZRnrsk\""
OVH_HTTP_BODY="{\"fieldType\":\"$OVH_FIELD_TYPE\",\"subDomain\":\"$OVH_SUB_DOMAIN\",\"target\":\"$OVH_TARGET\"}"
curl -X $OVH_HTTP_METHOD \
$OVH_HTTP_QUERY \
-H "Content-Type: application/json" \
-H "X-Ovh-Application: $OVH_API_APPLICATION_KEY" \
-H "X-Ovh-Timestamp: $OVH_TIME" \
-H "X-Ovh-Signature: $OVH_SIG" \
-H "X-Ovh-Consumer: $OVH_API_CONSUMER_KEY" \
--data "$OVH_HTTP_BODY"

View File

@@ -22,10 +22,33 @@
#
#
# 04-09-2024 : backup, sending remote, notification OK
# 04-09-2024 : TO DO : test deleting local files after $BKP_DAYS
red="\033[1;31m"
greenbold="\033[1;32m"
green="\033[0;32m"
yellow="\033[0;33m"
yellowbold="\033[1;33m"
bold="\033[1m"
#bold_under="\033[1;4m"
underline="\033[4m"
reset="\033[0m"
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo .env file found ! Could'nt get update from Github.'.${reset}"
set +a
}
dotenv
#CREATE USER 'mysqlbackupuser'@'localhost' IDENTIFIED BY '34diK=[6]Zui';
#GRANT SELECT ON * . * TO 'mysqlbackupuser'@'localhost';
pass=$(gpg --quiet --decrypt $HOME/.my.cnf.gpg)
pass=$(gpg --quiet --decrypt $HOME/.my.cnf.gpg)
x=$(echo $pass | awk '{print $2}')
BKP_USER=${x:5}
@@ -47,7 +70,7 @@ if [ ! -d $BKP_DEST ]; then mkdir $BKP_DEST; fi
## Note: Scripts will delete all backup which are older then BKP_DAYS##
#
# D:3 W:22 M:93
BKP_DAYS=3 # Enter how many days backup you want,
BKP_DAYS=1 # 3 Enter how many days backup you want,
BKP_WEEKS=21 # 3*7
BKP_MONTHS=93 # 3*31
#
@@ -82,31 +105,39 @@ IGNORE_DB="information_schema mysql performance_schema sys"
[ ! -d $BKP_DEST ] && mkdir -p $BKP_DEST || :
#
################# Autodetect the linux bin path #########################
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
#
notification() {
if [ $3 -eq 0 ];
then
sound="Boop"
message="Envoi terminé sur $2 !"
image="$BKP_BASE_DIR/success.png"
else
sound="Galet"
message="Echec lors de l'envoi sur $2 : erreur $result"
image="$BKP_BASE_DIR/error.png"
fi
if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$1" -message "$message" -sound "$sound" -contentImage "$image"
fi
curl -Is https://www.apple.com | head -1 | grep 200 1>/dev/null
if [[ $? -eq 1 ]]; then
echo -e "\n${red}No Internet connection !${reset}"
echo -e "No pushover notification !"
#exit 1
fi
send_pushover_notification() {
echo -e "Sending Pushover notification ..."
curl -s -F "token=$AIRBOOK_APP" \
-F "user=$USER_KEY" \
-F "title=$1" \
-F priority=2 \
-F html=1 \
-F retry=300 \
-F expire=86400 \
-F "message=$2" https://api.pushover.net/1/messages.json
[ $? -eq 0 ] && echo -e "${greenbold}\Pushover notification sent successfully !${reset}" || echo -e "${redbold}error sending Pushover notification !${reset}"
}
###################### Get database list ################################
#
DB_LIST="$($MYSQL -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -Bse 'SHOW DATABASES')"
#DB_LIST="$($MYSQL -h $MYSQL_HOST -Bse 'SHOW DATABASES')"
: <<'END_COMMENT'
END_COMMENT
#
for db in $DB_LIST
@@ -129,32 +160,39 @@ do
# Dans les dossiers Backup: mkdir -p silverbook/Bases_MySQL
echo -e "Backup $db database..."
$MYSQLDUMP -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -r$BKP_FILENAME $db
#$MYSQLDUMP -h $MYSQL_HOST -r$BKP_FILENAME $db
#echo $db
#cat $BKP_FILENAME
$GZIP -9 $BKP_FILENAME
f=$(basename "$BKP_GZ_FILENAME")
server1="ftp.cluster011.ovh.net:backup/$machine/Bases_MySQL/"
echo -e "Transfer $f to $server1"
scp "$BKP_GZ_FILENAME" funnymac@"$server1"
result=$?
result1=$?
notification "Backup MySQL: base $db" "$server1" $result
[ $? -ne 0 ] && send_pushover_notification "Backup MySQL Db" "Error when transfering $f on $s1 "
sleep 1
server2="clicclac.synology.me:/volume1/Backup/$machine/Bases_MySQL/"
#scp -P42666 -p "$BKP_GZ_FILENAME" bruno@"$server2"
scp -P42666 -p "$BKP_GZ_FILENAME" bruno@"$server2"
#scp -P42666 -p "$BKP_GZ_FILENAME" bruno@clicclac.synology.me:/volume1/Backup/$machine/Bases_MySQL/
result=$?
# NAS Synology: scp -O
server2="photos-nas.ovh:/volume1/Backup/$machine/Bases_MySQL/"
s2=$(echo $server2 | awk -F":" '{print $1}')
echo -e "Transfer $f to $server2"
scp -O -P42667 -p "$BKP_GZ_FILENAME" bruno@"$server2"
result2=$?
notification "Backup MySQL: base $db" "$server2" $result
[ $? -ne 0 ] && send_pushover_notification "Backup MySQL Db" "Error when transfering $f on $s2 "
#echo "----"
echo
fi
done
#########To delete all backup files older then BKP_DAYS #################
#
# Nettoyage serveurs locaux:
@@ -162,26 +200,35 @@ done
if find --version >/dev/null 2>&1 ; then
echo Using GNU date
d_duration="$BKP_DAYS"
w_duration="$BKP_DAYS"
m_duration="$BKP_DAYS"
w_duration="$BKP_WEEKS"
m_duration="$BKP_MONTHS"
else
echo Using BSD date
d_duration="$BKP_DAYS"d
w_duration="$BKP_DAYS"d
m_duration="$BKP_DAYS"d
w_duration="$BKP_WEEKS"d
m_duration="$BKP_MONTHS"d
echo "$d_duration"
echo "$w_duration"
echo "$m_duration"
fi
echo -e "Find daily backups..."
#find $BKP_DEST -name "*.sql.gz" -mtime +$BKP_DAYS | grep -v -E '(January|February|March|April|May|June|July|August|September|October|November|December)|(S\d{2}_\d{4})' | xargs rm -f
find $BKP_DEST -name "*.sql.gz" -mtime +"$d_duration" | grep -v -E '(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)|(S\d{2}_\d{4})' | xargs rm -f
find $BKP_DEST -name "*.sql.gz" -mtime +"$d_duration" | grep -v -E '(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)|(Sd{2}_d{4})' | xargs rm -f
##gfind /Users/bruno/Documents/MySQL -mtime +93 -iregex '.*\(January\|February\|March\|April\|May\|June\|July\|September\|October\|November\|December\).*'
echo "----"
find $BKP_DEST -name "*.sql.gz" -mtime +"$w_duration" | grep -E 'S\d{2}_\d{4}' | xargs rm -f
echo -e "Find weekly backups..."
find $BKP_DEST -name "*.sql.gz" -mtime +"$w_duration" | grep -E 'Sd{2}_d{4}' | xargs rm -f
##gfind /Users/bruno/Documents/MySQL -mtime +22 -regextype posix-extended -iregex '.*S[0-9]{2}_[0-9]{4}.*'
echo "----"
echo -e "Find monthly backups..."
#find $BKP_DEST -name "*.sql.gz" -mtime +$BKP_MONTHS | grep -E '(January|February|March|April|May|June|July|August|September|October|November|December)' | xargs rm -f
find $BKP_DEST -name "*.sql.gz" -mtime +"$m_duration" | grep -E '(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|decembre)' | xargs rm -f
#
: <<'END_COMMENT2'
# Nettoyage serveurs distants:
#916_dest="/volume1/Backup/SilverBook/Bases_MySQL"
@@ -238,5 +285,6 @@ done
#### End of script ####
END_COMMENT2

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
# https://itnext.io/upgrading-bash-on-macos-7138bd1066ba
echo $BASH_VERSION

29
gotify.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
token_gotify=
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! No token for gotify.${reset}"
set +a
}
send_gotify_notification() {
now=$(date +"%d-%m-%Y %T")
gotify_server="https://gotify.maboiteverte.fr"
TITLE="IP has changed on $host"
MESSAGE="**L'IP externe a changé:**\n\n - ancienne IP: $old_ip_externe\n - **nouvelle IP: $ip_externe**\n\n [^]: $now\n"
PRIORITY=8
URL="$gotify_server/message?token=$token_gotify&?format=markdown"
echo -e "Sending notification to $gotify_server ..."
curl -L -S -s --data '{"message": "'"${MESSAGE}"'", "title": "'"${TITLE}"'", "priority":'"${PRIORITY}"', "extras": {"client::display": {"contentType": "text/markdown"}}}' -H 'Content-Type: application/json' "$URL" > /dev/null
[ $? -eq 0 ] && echo -e "${greenbold}Gotify notification sent successfully !${reset}" || echo -e "${redbold}error sending Gotify notification !${reset}"
}
dotenv
send_gotify_notification

View File

@@ -31,6 +31,7 @@ shopt -s globstar
DEST_EXT=mp4
# Handbrake preset
# handbrakeCli --preset-list (or -z) to get all availables profiles
[[ "$profile" == "" ]] && PRESET="Apple 720p30 Surround" || PRESET="$profile"
# Only files larger than $MAXSIZE will be processed (> 30Mo)
@@ -58,106 +59,177 @@ fi
logsize=$(wc -c <"$logfile")
if [ $logsize -ge 1000 ]; then
if [ "$logsize" -ge 1000 ]; then
cp "$logfile" "$logfile.old"
truncate -s 0 "$logfile"
fi
#Move to trash after conversion
trash=true
internet=0
command -v jq >/dev/null 2>&1 || { echo -e "${bold}93mhandbrake_for_plex${reset} require ${bold}jq${reset} but it's not installed.\nRun ${italic}(brew install jq)${reset}\nAborting..." >&2; exit 1; }
command -v jq >/dev/null 2>&1 || {
echo -e "${bold}93mhandbrake_for_plex${reset} require ${bold}jq${reset} but it's not installed.\nRun ${italic}(brew install jq)${reset}\nAborting..." >&2
exit 1
}
fzf_bin=0
if (! type fzf > /dev/null 2>&1); then
if (! type fzf >/dev/null 2>&1); then
echo -e "Install ${bold}fzf${reset} for a better experience !"
echo -e "${italic}brew install fzf${reset}"
fzf_bin=0
else {
fzf_bin=1
fzf_args=(
--height=8
--with-nth=2..
--layout=reverse
--info=hidden
--border
)
else
{
fzf_bin=1
fzf_args=(
--height=8
--with-nth=2..
--layout=reverse
--info=hidden
--border
)
}
fi
showHelp() {
clear
echo -e "\033[93mhandbrake_for_plex.sh\033[0m"
echo "Convert and rename video files for Plex:"
echo
echo
echo "USAGE: handbrake_for_plex.sh"
echo
echo "Configure:"
echo " -\$SRC : source folder (recursive)"
echo " -\$DEST : destination folder"
echo " -\$DEST_EXT : destination extension"
echo " -\$PRESET : preset HandBrake"
echo " and run script..."
echo
echo "OPTION:"
echo " -h display this help"
echo " -i source folder (recursive)"
echo " -o destination folder"
echo " -p preset HandBrake"
echo " -z install handbrake_for_plex.sh"
echo
echo -e "Example: ${italic}./handbrake_for_plex.sh -i $HOME/Downloads -o $HOME/Images -p 'Apple 720p30 Surround'${reset}"
echo
echo -e "To known Preset, run ${italic}HandBrakeCLI --preset-list${reset}"
echo
exit 0
clear
echo -e "\033[93mhandbrake_for_plex.sh\033[0m"
echo "Convert and rename video files for Plex:"
echo
echo
echo "USAGE: handbrake_for_plex.sh"
echo
echo "Configure:"
echo " -\$SRC : source folder (recursive)"
echo " -\$DEST : destination folder"
echo " -\$DEST_EXT : destination extension"
echo " -\$PRESET : preset HandBrake"
echo " and run script..."
echo
echo "OPTION:"
echo " -h display this help"
echo " -i source folder (recursive)"
echo " -o destination folder"
echo " -p preset HandBrake"
echo " -z install handbrake_for_plex.sh"
echo
echo -e "Example: ${italic}./handbrake_for_plex.sh -i $HOME/Downloads -o $HOME/Images -p 'Apple 720p30 Surround'${reset}"
echo
echo -e "To known Preset, run ${italic}HandBrakeCLI --preset-list${reset}"
echo
exit 0
}
update_handbrake() {
# https://www.thegeekdiary.com/how-to-install-dmg-file-on-mac-from-command-line/
if [ "$(printf '%s\n' "$HB_VERSION" "$last_hbc_release" | sort -V | head -n1)" = "$HB_VERSION" ]; then
if [ "$HB_VERSION" != "$last_hbc_release" ]; then
# release=$(gh release list -L 1 --repo HandBrake/HandBrake | cut -f1 | xargs -I{} gh release view {} --repo HandBrake/HandBrake)
# news=$(echo "$release" | awk '/Upgrade Notice/,0')
# news=$(gh release list -L 1 --repo HandBrake/HandBrake | cut -f1 | xargs -I{} gh release view {} --repo HandBrake/HandBrake | awk '/Upgrade Notice/,0')
# asset=$(echo "$release" | awk '/Upgrade Notice/{exit} 1' | grep '^asset:' | grep -v '.sig' | grep 'HandBrakeCLI' | cut -f 2)
# url = https://github.com/HandBrake/HandBrake/releases/download/1.9.2/HandBrakeCLI-1.9.2.dmg
latest=$(curl --silent "https://api.github.com/repos/${gh_hbc_repo}/releases/latest")
last_hbc_dl_url=$(echo "$latest" | grep 'HandBrakeCLI' | grep -v '.sig' | grep 'browser_download_url' | awk -F": " '{print $2}' | sed 's/"//g')
last_hbc_news=$(echo "$latest" | jq '.body')
echo -e "${green}Current version: $HB_VERSION - Version $last_hbc_release available !${reset}"
echo -e "$last_hbc_news"
a=$(echo -e "${bold}Do you want to install HandBrakeCLI v$last_hbc_release (y/n)${reset}")
read -p "$a" hbc
if [[ "$hbc" == "y" || "$hbc" == "Y" ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
url=$(echo "$last_hbc_dl_url" | grep '.dmg')
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
url=$(echo "$last_hbc_dl_url" | grep '.flatpak')
fi
echo "Downloading $url"
dest=$HOME/Downloads
filename=$(basename "$url")
curl -L -O --output-dir "$dest" "$url"
if [[ $? -eq 0 ]]; then
vol=$(hdiutil mount "$dest"/"$filename" | tail -1 | awk '{print $3}')
app=$vol/HandBrakeCLI
install_folder=$HOME/.local/bin/
if [ -f "$app" ]; then
echo "Copying $filename to $install_folder"
cp "$app" "$install_folder"
fi
x="$install_folder""HandBrakeCLI"
if [ -f "$x" ]; then
v=$("$x" --version 2>/dev/null | awk '{print $2}')
if [ "$v" == "$last_hbc_release" ]; then
echo -e "${green}HandBrakeCLI v$v successfully installed !${reset}"
else
echo -e "${red}HandBrakeCLI v$v installed !${reset}"
fi
fi
cd "$HOME" || exit
hdiutil unmount "$vol"
fi
fi
fi
fi
}
installation() {
#long_path=`pwd`"/"`basename "$0"`
long_path=$(realpath "$0")
echo -e "${bold}Installing "`basename "$0"`"${reset}"
echo
echo -e "${bold}Installing $(basename "$0")${reset}"
echo
fzf_install_paths=("/usr/local/bin" "$HOME/.local/bin" "$HOME")
if [ $fzf_bin -eq 1 ]; then
prompt="Choose the install's path: "
choice=$(printf "Play %s\n" "${fzf_install_paths[@]}" | sort | fzf "${fzf_args[@]}" --prompt "$prompt")
prompt="Choose the install's path: "
choice=$(printf "Play %s\n" "${fzf_install_paths[@]}" | sort | fzf "${fzf_args[@]}" --prompt "$prompt")
install_path=${choice:5}
else
read -e -p "Choose the install's path: " install_path
fi
fi
[[ ! $PATH =~ $install_path ]] && echo "$install_path in not in \$PATH !!"
if [ -d "$install_path" ]; then
if [ -w "$install_path" ]; then
cp "$long_path" "$install_path"
else
echo -e "${red}$install_path is not writeable !${reset}"
echo -e "${red}${bold}Using sudo ! Enter your password:${reset}"
sudo cp "$long_path" "$install_path"
fi
result=$?
[ "$result" = 0 ] && echo -e "$long_path ${italic}is now installed in${reset} $install_path"
else
echo -e "${red}$install_path is not writeable !${reset}"
echo -e "${red}${bold}Using sudo ! Enter your password:${reset}"
sudo cp "$long_path" "$install_path"
fi
result=$?
[ "$result" = 0 ] && echo -e "$long_path ${italic}is now installed in${reset} $install_path"
else
echo -e "${red}This folder does not exist !${reset}"
fi
}
notification() {
#path_img=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ "$3" -eq 0 ];
then
if [ "$3" -eq 0 ]; then
sound="Glass"
#image="$path_img/success.png"
#image="$path_img/HandBrake.icns"
@@ -167,67 +239,125 @@ notification() {
fi
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
zenity --title="$1" --notification --text="$2"
zenity --title="$1" --notification --text="$2"
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
### -appIcon ne marche avec BigSur
# terminal-notifier -title "$1" -message "$2" -sound "$sound" -contentImage "$image" -activate "com.colliderli.iina"
terminal-notifier -title "$1" -message "$2" -sound "$sound" -appIcon "https://sur-le-sentier.fr/HandBrake.png" -activate "com.colliderli.iina"
# org.galad.Subler.plist com.colliderli.iina.plist -appIcon http://vjeantet.fr/images/logo.png
# terminal-notifier -title "$1" -message "$2" -sound "$sound" -contentImage "$image" -activate "com.colliderli.iina"
terminal-notifier -title "$1" -message "$2" -sound "$sound" -appIcon "https://sur-le-sentier.fr/HandBrake.png" -activate "com.colliderli.iina"
# org.galad.Subler.plist com.colliderli.iina.plist -appIcon http://vjeantet.fr/images/logo.png
fi
}
while getopts "h?i:o:p:z" opt; do
case "$opt" in
h|\?)
showHelp
exit 0
;;
i) input_path="$OPTARG"
;;
o) output_path="$OPTARG"
;;
p) profile="$OPTARG"
;;
z) installation
exit 0
;;
esac
case "$opt" in
h | \?)
showHelp
;;
i)
input_path="$OPTARG"
;;
o)
output_path="$OPTARG"
;;
p)
profile="$OPTARG"
;;
z)
installation
exit 0
;;
esac
done
# Reset OPTIND
shift $((OPTIND-1))
shift $((OPTIND - 1))
# Update handbrake_for_plex.sh from GitHub
#Github="https://github.com/HandBrake/HandBrake"
# Public Repo:
#RawUrl="https://raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
# Private Repo:
#RawUrl="https://x-access-token:$GITHUB_TOKEN@raw.githubusercontent.com/HandBrake/HandBrake/main/bashbirds.sh"
### Check if there's a new release of the script:
#LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
#LatestChanges="$(curl -s -r 0-2000 $RawUrl | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
#LatestChanges="$(curl -s -r 0-2000 $RawUrl | grep "^### ChangeNotes:" | sed 's/### ChangeNotes://g')"
###
echo "_ _ ____ _ _ ___ ___ ____ ____ _ _ ____ ____ ____ ____ ___ _ ____ _ _ ";
echo "|__| |__| |\ | | \ |__] |__/ |__| |_/ |___ |___ | | |__/ |__] | |___ \/ ";
echo "| | | | | \| |__/ |__] | \ | | | \_ |___ | |__| | \ | |___ |___ _/\_ ";
echo " ";
echo " ";
echo " ";
echo "_ _ ____ _ _ ___ ___ ____ ____ _ _ ____ ____ ____ ____ ___ _ ____ _ _ "
echo "|__| |__| |\ | | \ |__] |__/ |__| |_/ |___ |___ | | |__/ |__] | |___ \/ "
echo "| | | | | \| |__/ |__] | \ | | | \_ |___ | |__| | \ | |___ |___ _/\_ "
echo " "
echo " "
echo " "
version=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null)
if [ "$version" != "" ]; then
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
echo -e "${bold}HandBrake $version${reset}"
echo -e "$HANDBRAKE_CLI\n"
else {
cli=$(which HandBrakeCLI)
if [ "$cli" != "" ]; then
HANDBRAKE_CLI="$cli"
version=$("$HANDBRAKE_CLI" --version 2>/dev/null | sed -n '1p')
echo -e "${bold}HandBrake $version${reset}"
echo -e "$HANDBRAKE_CLI\n"
gh_hbc_repo="HandBrake/HandBrake"
curl -sS -I github.com >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
last_hbc_release=$(curl --silent "https://api.github.com/repos/${gh_hbc_repo}/releases/latest" | grep -Po "(?<=\"tag_name\": \").*(?=\")") # 1.10.0
internet=1
fi
# installation brew
version_brew=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null) # 1.10.0_1
# installation manuelle
cli=$(which HandBrakeCLI) # /Users/bruno/.local/bin/HandBrakeCLI
version_cli=$("$cli" --version 2>/dev/null | awk '{print $2}') # HandBrake 1.9.2
echo "last_hbc_release: $last_hbc_release"
echo "version_brew: $version_brew"
echo "cli: $cli"
echo "version_cli: $version_cli"
# bo handbrake
# /opt/homebrew/Cellar/handbrake/1.10.1 (9 files, 19.3MB)
# installation brew
if [ "$version_brew" != "" ]; then
if [ "$version_cli" != "" ]; then
if [ "$(printf '%s\n' "$version_cli" "$version_brew" | sort -V | head -n1)" = "$version_cli" ]; then
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version_brew/bin/HandBrakeCLI"
HB_VERSION="$version_brew"
else
HANDBRAKE_CLI="$cli"
HB_VERSION="$version_cli"
if [ "$internet" = 1 ]; then
update_handbrake
else
echo "No internet connection !"
fi
fi
else
echo -e "${red}HandBrake not installed!${reset}\n"
HANDBRAKE_CLI="/opt/homebrew/Cellar/handbrake/$version_brew/bin/HandBrakeCLI"
HB_VERSION="$version_brew"
fi
# installation manuelle
else
if [ "$version_cli" != "" ]; then
HANDBRAKE_CLI="$cli"
HB_VERSION="$version_cli"
update_handbrake
else
echo -e "\n${red}HandBrake not installed!${reset}\n"
echo -e "\n${red}You should run ${italic}brew install handbrake${reset}\n"
exit 1
fi
}
fi
echo "HANDBRAKE_CLI: $HANDBRAKE_CLI"
echo "HB_VERSION: $HB_VERSION"
#exit
echo -e "\n${bold}HandBrake $HB_VERSION${reset}"
echo -e "$HANDBRAKE_CLI\n"
echo -e "Source folder: ${italic}$SRC${reset}"
echo -e "Destination folder: ${italic}$DEST${reset}"
echo -e "HandBrake Profile: ${italic}$PRESET${reset}"
@@ -243,34 +373,32 @@ count=0
# Series: SxxEyy
REGEX="([sS]([0-9]{2,}|[X]{2,})[eE]([0-9]{2,}|[Y]{2,}))"
# Films:
# Films:
REGEX2=".[0-9]{4}" # année 2019 mais avec un caractère avant (chaine ne commence pas par 2019)
movies=()
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}
do
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}; do
# Get file size
FILESIZE=$(stat -c%s "$FILE")
if (( FILESIZE > MAXSIZE )); then
FILESIZE=$(stat -c%s "$FILE" 2> /dev/null)
if ((FILESIZE > MAXSIZE)); then
movies+=("${FILE}")
fi
done
nb_movies=${#movies[@]}
for FILE in "${movies[@]}"
do
filename=$(basename "$FILE")
#extension=${filename##*.}
filename=${filename%.*}
declare -a ft=()
for FILE in "${movies[@]}"; do
filename=$(basename "$FILE")
#extension=${filename##*.}
filename=${filename%.*}
declare -a ft=()
declare -a ct=()
declare -a tt=()
declare -a lt=()
declare -a dt=()
: <<'END_COMMENT'
: <<'END_COMMENT'
https://stackoverflow.com/questions/41231998/mediainfo-cli-command-line-interface-syntax-teaching-me-once-for-all
media=$(mediainfo --Output=file:///$SCRIPT_DIR/template.txt "$FILE")
l=$(echo "$media" | sed -n '1p')
@@ -278,86 +406,84 @@ do
echo -e "$info\n"
END_COMMENT
# Suprrime [ Torrent911.io ]
a="[${filename#*[}"
a="${a%]*}] "
filename=${filename#"$a"}
# Suprrime [ Torrent911.io ]
a="[${filename#*[}"
a="${a%]*}] "
filename=${filename#"$a"}
# Séries
if [[ $filename =~ $REGEX ]]; then
MATCH="${BASH_REMATCH[1]}"
# Remplace les . par des espaces
e=$(echo "${filename%$MATCH*}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
# Capitalise chaque mot
f=( $e )
g=${f[@]^}
# Met en majuscule SxxExx
new_name="$g - ${MATCH^^}.$DEST_EXT"
# Séries
if [[ $filename =~ $REGEX ]]; then
MATCH="${BASH_REMATCH[1]}"
# Remplace les . par des espaces
e=$(echo "${filename%$MATCH*}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
# Capitalise chaque mot
f=($e)
g=${f[@]^}
# Met en majuscule SxxExx
new_name="$g - ${MATCH^^}.$DEST_EXT"
# Films
elif [[ $filename =~ $REGEX2 ]]; then
MATCH2="${BASH_REMATCH[0]}"
MATCH2=${MATCH2:1}
e=$(echo "${filename%$MATCH2*}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
new_name="$e ($MATCH2).$DEST_EXT"
else
echo -e "${red}\nCould not find SXXEYY or YYYY pattern${reset}"
e=$(echo "${filename}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
read -e -p "Title: " -i "$e" e
new_name="$e.$DEST_EXT"
#echo "new_name: $new_name"
#continue
fi
if ! command -v mediainfo &> /dev/null; then
echo -e "${bold}mediainfo${reset} could not be found !\n"
echo -e "You should install ${bold}mediainfo${reset}:\n"
echo -e " - brew install mediainfo"
echo -e ""
else
elif [[ $filename =~ $REGEX2 ]]; then
MATCH2="${BASH_REMATCH[0]}"
MATCH2=${MATCH2:1}
e=$(echo "${filename%$MATCH2*}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
new_name="$e ($MATCH2).$DEST_EXT"
else
echo -e "${red}\nCould not find SXXEYY or YYYY pattern${reset}"
e=$(echo "${filename}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
read -e -p "Title: " -i "$e" e
new_name="$e.$DEST_EXT"
#echo "new_name: $new_name"
#continue
fi
if ! command -v mediainfo &>/dev/null; then
echo -e "${bold}mediainfo${reset} could not be found !\n"
echo -e "You should install ${bold}mediainfo${reset}:\n"
echo -e " - brew install mediainfo"
echo -e ""
else
#infos=$(mediainfo "$FILE" --output=JSON | jq -s 'map({ VideoCount: .media.track[0].VideoCount, AudioCount: .media.track[0].AudioCount, TextCount: .media.track[0].TextCount, MenuCount: .media.track[0].MenuCount, FormatFichier: .media.track[0].Format, FileSize: .media.track[0].FileSize, Duration: .media.track[0].Duration, FormatVideo: .media.track[1].Format, Format_Profile: .media.track[1].Format_Profile, Format_Level: .media.track[1].Format_Level, "CodecVideo": .media.track[1].CodecID, Width: .media.track[1].Width, Height: .media.track[1].Height, FormatAudio: .media.track[2].Format, FormatAdditionalFeatures: .media.track[2].Format_AdditionalFeatures, CodecAudio: .media.track[2].CodecID, TitleAudio: .media.track[2].Title, LanguageAudio: .media.track[2].Language, DefaultAudio: .media.track[2].Default, FormatText: .media.track[3].Format, CodecText: .media.track[3].CodecID, LanguageText: .media.track[3].Language, DefaultText: .media.track[3].Default, Menu: .media.track[4].extra})')
infos=$(mediainfo "$FILE" --output=JSON | jq '.media.track')
while read row
do
type=$(echo "$row" | jq -r '.["@type"]')
if [[ "$type" == "General" ]]; then
general="$row"
#echo "$general" | jq
nb_audio=$(echo "$general" | jq -j '.AudioCount')
if [[ "$nb_audio" == "null" ]]; then nb_audio=0; fi
infos=$(mediainfo "$FILE" --output=JSON | jq '.media.track')
while read row; do
type=$(echo "$row" | jq -r '.["@type"]')
if [[ "$type" == "General" ]]; then
general="$row"
#echo "$general" | jq
nb_audio=$(echo "$general" | jq -j '.AudioCount')
if [[ "$nb_audio" == "null" ]]; then nb_audio=0; fi
nb_text=$(echo "$general" | jq -j '.TextCount')
if [[ "$nb_text" == "null" ]]; then nb_text=0; fi
if [[ "$nb_text" == "null" ]]; then nb_text=0; fi
nb_menu=$(echo "$general" | jq -j '.MenuCount')
if [[ "$nb_menu" == "null" ]]; then nb_menu=0; fi
format_fichier=$(echo "$general" | jq -j '.Format')
filesize=$(echo "$general" | jq -j '.FileSize' | numfmt --to=si --format "%8.2f" | xargs)
duree=$(echo "$general" | jq -j '.Duration' | awk -F "." '{print $1}' | awk '{printf "%d:%02d:%02d", $1/3600, ($1/60)%60, $1%60}' | xargs)
elif [[ "$type" == "Video" ]]; then
video="$row"
#echo "$video" | jq
elif [[ "$type" == "Video" ]]; then
video="$row"
#echo "$video" | jq
fmt=$(echo "$video" | jq -j '.Format | select( . != null )')
if [ $fmt != "JPEG" ]; then
format_video=$(echo "$video" | jq -j '.Format | select( . != null )')
format_profile=$(echo "$video" | jq -j '.Format_Profile | select( . != null )')
format_level=$(echo "$video" | jq -j '.Format_Level | select( . != null )')
codec_video=$(echo "$video" | jq -j '.CodecID | select( . != null )')
width=$(echo "$video" | jq -j '.Width | select( . != null )')
height=$(echo "$video" | jq -j '.Height | select( . != null )')
if [ "$fmt" != "JPEG" ]; then
format_video=$(echo "$video" | jq -j '.Format | select( . != null )')
format_profile=$(echo "$video" | jq -j '.Format_Profile | select( . != null )')
format_level=$(echo "$video" | jq -j '.Format_Level | select( . != null )')
codec_video=$(echo "$video" | jq -j '.CodecID | select( . != null )')
width=$(echo "$video" | jq -j '.Width | select( . != null )')
height=$(echo "$video" | jq -j '.Height | select( . != null )')
fi
elif [[ "$type" == "Audio" ]]; then
audio="$row"
#echo "$audio" | jq
elif [[ "$type" == "Audio" ]]; then
audio="$row"
#echo "$audio" | jq
format_audio=$(echo "$audio" | jq -j '.Format | select( . != null )')
format_addition=$(echo "$audio" | jq -j '.Format_AdditionalFeatures | select( . != null )')
@@ -367,10 +493,10 @@ END_COMMENT
language_audio=$(echo "$audio" | jq -j '.Language | select( . != null )')
default_audio=$(echo "$audio" | jq -j '.Default | select( . != null )')
elif [[ "$type" == "Text" ]]; then
text="$row"
#echo "$text" | jq
elif [[ "$type" == "Text" ]]; then
text="$row"
#echo "$text" | jq
format_text=$(echo "$text" | jq -j '.Format | select( . != null )')
codec_text=$(echo "$text" | jq -j '.CodecID | select( . != null )')
title_text=$(echo "$text" | jq -j '.Title | select( . != null )')
@@ -382,38 +508,31 @@ END_COMMENT
tt+=("$title_text")
lt+=("$language_text")
dt+=("$default_text")
elif [[ "$type" == "Menu" ]]; then
menu="$row"
#echo "$menu" | jq
fi
elif [[ "$type" == "Menu" ]]; then
menu="$row"
#echo "$menu" | jq
fi
done < <(echo "$infos" | jq -c '.[]')
echo -e "${red}nb_audio: $nb_audio${reset}"
echo -e "${red}nb_text: $nb_text${reset}"
echo -e "${red}nb_menu: $nb_menu${reset}"
# Menu
#menu=$(echo "$infos" | jq -j '.[] | .Menu' | sed '1d;$d')
menus=$(echo "$menu" | jq -j '.extra' | sed '1d;$d')
#echo "menus: $menus"
m=()
n=1
while IFS= read -r line
do
# L'apparition
# "_00_07_57_920": "en:00:07:57.920",
# Kandahar
# "_00_00_00_000": "1. Studio Logo",
while IFS= read -r line; do
# L'apparition
# "_00_07_57_920": "en:00:07:57.920",
# Kandahar
# "_00_00_00_000": "1. Studio Logo",
REGEX1="^_(0[0-9]|1[0-9]|2[0-3])_([0-5][0-9])_([0-5][0-9])_([0-9][0-9][0-9])$"
if [[ ${line:3:13} =~ $REGEX1 ]]; then
if [[ ${line:3:13} =~ $REGEX1 ]]; then
t=$(echo "$line" | awk -F": " '{print $1}')
c=$(echo "$line" | awk -F": " '{print $2}')
@@ -423,8 +542,7 @@ END_COMMENT
# t: "_00_07_57_920"
# c: "en:00:07:57.920",
tt=$(echo "$t" | sed -n '1 s/"//gp' | xargs | sed 's/^_//' | sed 's/_/h/1' | sed 's/_/mm/1' | sed 's/_/s/1' | sed 's/s.*//')
ti=$(echo "$t" | sed -n '1 s/"//gp' | xargs | sed 's/^_//' | sed 's/_/h/1' | sed 's/_/mm/1' | sed 's/_/s/1' | sed 's/s.*//')
#cc=$(echo "$c" | tr -d '"' | xargs | awk -F ":" '{print $2}' | sed 's/,$//' | sed 's/^/ /')
cc=$(echo "$c" | tr -d '"' | xargs | sed 's/,$//' | sed 's/^/ /' | xargs)
#echo "tt: $tt"
@@ -432,16 +550,16 @@ END_COMMENT
# L'apparition
# tt: 00h07mm57
# cc: en:00:07:57.920
#m+=("$n:$tt")
m+=("$n:$cc ($tt)")
((n=n+1))
fi
done <<< "$menus"
m+=("$n:$cc ($ti)")
((n = n + 1))
fi
done <<<"$menus"
((count++))
echo -e "\n\n${bold}(${red}$count${reset}${bold} / $nb_movies) $filename${reset}"
echo -e "\n${bold}General:${reset}"
printf " %-20s %-35s \n" "Format de fichier:" "${format_fichier}"
printf " %-20s %-35s \n" "Taille de fichier:" "${filesize}"
@@ -453,7 +571,7 @@ END_COMMENT
printf " %-20s %-35s \n" "Level:" "${format_level}"
printf " %-20s %-35s \n" "Codec:" "${codec_video}"
printf " %-20s %-35s \n" "Dimensions:" "${width} x ${height}"
echo -e "\n${bold}Audio:${reset}"
printf " %-20s %-35s \n" "Format audio:" "${format_audio}"
printf " %-20s %-35s \n" "Format additionnel:" "${format_addition}"
@@ -462,7 +580,7 @@ END_COMMENT
printf " %-20s %-35s \n" "Titre:" "${title_audio}"
printf " %-20s %-35s \n" "Language:" "${language_audio}"
printf " %-20s %-35s \n" "Defaut:" "${default_audio}"
#if [ "$nb_text" -ge 1 ]; then
# echo -e "\n${bold}Text:${reset}"
# printf " %-20s %-35s \n" "Titre:" "${title_text}"
@@ -473,12 +591,11 @@ END_COMMENT
#fi
if [ "$nb_text" -ge 1 ]; then
for val in ${!ft[@]}
do
for val in "${!ft[@]}"; do
index=${val}
((index++))
echo -e "\n${bold}Text $index:${reset}"
printf " %-20s %-35s \n" "Titre:" "${tt[$val]}"
printf " %-20s %-35s \n" "Format:" "${ft[$val]}"
@@ -488,100 +605,94 @@ END_COMMENT
done
fi
if [ "$nb_menu" -ge 1 ]; then
echo -e "\n${bold}Menu:${reset}"
for elem in "${m[@]}";
do
echo -e "\n${bold}Menu:${reset}"
for elem in "${m[@]}"; do
#echo "${elem}"
# en:00:07:57.920 : 00h07mm57
c=$(echo "${elem}" | awk -F":" '{print $1}')
t=$(echo "${elem}" | awk -F":" '{print $2}')
printf " %-20s %-35s \n" "$c:" "${t}"
done
fi
fi # if mediainfo installed
fi # if mediainfo installed
file_export="$DEST"/"$new_name"
if [ ! -f "$file_export" ]; then
#echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}"
z="\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}"
#echo -e "${red}language_text: ${language_text}${reset}" # fr-FR (killers of...) fr-FR (yannick)
#echo -e "${red}lt: ${lt[@]}${reset}" # fr fr-FR (killers of...) fr-FR (yannick)
#echo -e "${red}SUBTITLE_LIST: $SUBTITLE_LIST${reset}" # eng,fre
if [ "$nb_text" -ge 1 ]; then
echo -e "$z (with ${bold}${language_text}${reset} subtitle track)" # with fr-FR
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" --subtitle-lang-list "$SUBTITLE_LIST" --all-subtitles 2>>$logfile
else
echo -e "$z"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2>>$logfile
fi
result=$?
echo
file_export="$DEST"/"$new_name"
if [ ! -f "$file_export" ]; then
#echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}"
z="\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}"
#echo -e "${red}language_text: ${language_text}${reset}" # fr-FR (killers of...) fr-FR (yannick)
#echo -e "${red}lt: ${lt[@]}${reset}" # fr fr-FR (killers of...) fr-FR (yannick)
#echo -e "${red}SUBTITLE_LIST: $SUBTITLE_LIST${reset}" # eng,fre
if [ "$nb_text" -ge 1 ]; then
echo -e "$z (with ${bold}${language_text}${reset} subtitle track)" # with fr-FR
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" --subtitle-lang-list "$SUBTITLE_LIST" --all-subtitles 2>> $logfile
if [ "$result" = 0 ]; then
echo -e "${green}$new_name available in $DEST${reset}"
notification "HandBrake for Plex" "$new_name available in $DEST" $result
fi
# Open DEST file in an app
if [ "$APP" != "" ]; then
if [[ $(command -v mdfind) == "" ]]; then
echo -e "\n${red}mdfind not find ! mdfind is a part macOS.${reset}"
else
echo -e "$z"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2>> $logfile
fi
echo
result=$?
if [ "$result" = 0 ]; then
echo -e "${green}$new_name available in $DEST${reset}"
notification "HandBrake for Plex" "$new_name available in $DEST" $result
fi
# Open DEST file in an app
if [ "$APP" != "" ]; then
if [[ $(command -v mdfind) == "" ]]; then
echo -e "\n${red}mdfind not find ! mdfind is a part macOS.${reset}"
else
#x=$(mdfind -name "$APP" kind:application)
# /usr/bin/mdfind $@ 2> >(grep --invert-match ' \[UserQueryParser\] ' >&2)
x=$(mdfind -name "$APP" kind:application 2> /dev/null)
if [ "$x" != "" ]; then
if [ -f "$file_export" ]; then
echo -e "\n${bold}Opening $file_export in $APP...${reset}"
open -a "$APP" "$file_export"
fi
else
echo -e "\n${red}$APP was not found...${reset}"
#x=$(mdfind -name "$APP" kind:application)
# /usr/bin/mdfind $@ 2> >(grep --invert-match ' \[UserQueryParser\] ' >&2)
x=$(mdfind -name "$APP" kind:application 2>/dev/null)
if [ "$x" != "" ]; then
if [ -f "$file_export" ]; then
echo -e "\n${bold}Opening $file_export in $APP...${reset}"
open -a "$APP" "$file_export"
fi
else
echo -e "\n${red}$APP was not found...${reset}"
fi
fi
fi
# Move SRC file to trash
parent_folder=${FILE%/*}
if [ "$trash" = true ] && [[ "$OSTYPE" == "darwin"* ]]; then
echo -e "\n${italic}Move ${filename} to trash...${reset}"
osascript -e "tell application \"Finder\" to delete POSIX file \"${FILE}\"" >/dev/null
fi
if [ "$trash" = true ] && [[ "$OSTYPE" == "linux-gnu"* ]] && [[ $(command -v gio) != "" ]]; then
echo -e "\n${italic}Move ${filename} to trash...${reset}"
gio trash "$FILE" >/dev/null
fi
[ "$(echo "${parent_folder}/"*)" = "${parent_folder}/*" ] && rm -rf "${parent_folder}";
echo ""
# Move SRC file to trash
parent_folder=${FILE%/*}
if [ "$trash" = true ] && [[ "$OSTYPE" == "darwin"* ]]; then
echo -e "\n${italic}Move ${filename} to trash...${reset}"
osascript -e "tell application \"Finder\" to delete POSIX file \"${FILE}\"" >/dev/null
fi
if [ "$trash" = true ] && [[ "$OSTYPE" == "linux-gnu"* ]] && [[ $(command -v gio) != "" ]]; then
echo -e "\n${italic}Move ${filename} to trash...${reset}"
gio trash "$FILE" >/dev/null
fi
else
echo -e "\n${green}$file_export already transcoded !${reset}\n"
((already_transcoded+=1))
fi
FILESIZE=
[ "$(echo "${parent_folder}/"*)" = "${parent_folder}/*" ] && rm -rf "${parent_folder}"
echo ""
else
echo -e "\n${green}$file_export already transcoded !${reset}\n"
((already_transcoded += 1))
fi
FILESIZE=
done
transcoded=$((count-already_transcoded))
transcoded=$((count - already_transcoded))
if [ "$transcoded" -eq 0 ]; then
echo -e "\n${red}No file to transcode !${reset}"
else
echo -e "\n${green}${transcoded} files successfully transcoded !${reset}"
echo -e "\n${green}${transcoded} files successfully transcoded !${reset}"
fi

View File

@@ -123,16 +123,3 @@ remove_cname() {
#remove_cname "kuma"
#curl -X POST "https://eu.api.ovh.com/v1/domain/zone/photos-nas.ovh/record" \
# -H "accept: application/json"\
# -H "authorization: Bearer eyJhbGciOiJFZERTQSIsImtpZCI6IkVGNThFMkUxMTFBODNCREFEMDE4OUUzMzZERTk3MDhFNjRDMDA4MDEiLCJraW5kIjoib2F1dGgyIiwidHlwIjoiSldUIn0.eyJBY2Nlc3NUb2tlbiI6ImY4MGU5NmQwZmFiZmM3ZWY0MmMzZjZjNjcxNjZiOWUzNWQwMDc3NTJiOTFhNGQ0NDQyNmY3NTM1MzhiM2M5N2EiLCJpYXQiOjE3MjIyNTk0NzF9.C4MFvrgfF53n87q3h1xny7NBYAOozwzA5t8ty9TqNprMTfWz0Fx5JwvFaCVi8jzDvjzwIYd4MLNm-WqTfLfsAw"\
# -H "content-type: application/json" \
# -d '{"fieldType":"CNAME","subDomain":"api-test","target":"photos-nas.ovh.","ttl":0}' \
# {"fieldType": "CNAME","subDomain": "api-test","target": "photos-nas.ovh.","ttl": 0}
# refresh
# curl -X POST "https://eu.api.ovh.com/v1/domain/zone/photos-nas.ovh/refresh" \
# -H "authorization: Bearer eyJhbGciOiJFZERTQSIsImtpZCI6IkVGNThFMkUxMTFBODNCREFEMDE4OUUzMzZERTk3MDhFNjRDMDA4MDEiLCJraW5kIjoib2F1dGgyIiwidHlwIjoiSldUIn0.eyJBY2Nlc3NUb2tlbiI6ImY4MGU5NmQwZmFiZmM3ZWY0MmMzZjZjNjcxNjZiOWUzNWQwMDc3NTJiOTFhNGQ0NDQyNmY3NTM1MzhiM2M5N2EiLCJpYXQiOjE3MjIyNTk0NzF9.C4MFvrgfF53n87q3h1xny7NBYAOozwzA5t8ty9TqNprMTfWz0Fx5JwvFaCVi8jzDvjzwIYd4MLNm-WqTfLfsAw"

View File

@@ -16,7 +16,7 @@ shopt -s globstar
# Source image folder
#ln -s ~/Sites/sls/photos/img ~/Pictures/Export/photos-du-mois
[[ "$input_path" == "" ]] && SRC="$HOME/Sites/sls/photos/img" || SRC="$input_path"
[[ "$input_path" == "" ]] && SRC="$HOME/Sites/_sls/photos/img" || SRC="$input_path"
# Server
@@ -61,6 +61,7 @@ last_remote_files() {
lrf=$(rsync -zarvh -e "ssh -p ${port[$i]}" "${user[$i]}"@"${server[$i]}":"${dest[$i]}*" | grep -E "$last_year.jpg|$current_year.jpg")
fi
echo "$lrf"
# rsync -zarvh -e "ssh -p 22" "sentier@sur-le-sentier.fr:httpdocs/photos/img/*"
l=$(echo "$lrf" | awk '{print $NF}' | awk -F"." '{print $1}') # 1_2022
@@ -196,8 +197,8 @@ do
#elif [ "$i" -eq 1 ]; then
else
echo -e "\n${bold}5. Open ${italic}https://${server[$i]}/insert_bdd.php${reset}${bold}...${reset}\n"
open https://"${server[$i]}"/insert_bdd.php
echo -e "\n${bold}5. Open ${italic}https://${server[$i]}/admin/insert_bdd.php${reset}${bold}...${reset}\n"
open https://"${server[$i]}"/admin/insert_bdd.php
fi
else

241
pushover.sh Executable file
View File

@@ -0,0 +1,241 @@
#!/usr/bin/env bash
# ./pushover.sh -t "Pushover via Bash" -m "Pushover message sent with bash from $(hostname -f)" -p1 -s siren -u http://www.google.com -n "Google"
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo $HOME/.env file found ! Could'nt get update from Github.'.${reset}"
set +a
}
dotenv
USER_TOKEN=$USER_KEY
# YOUR APPS TOKENS / UPPERCASE NAME WITH _TOKEN (usage: "-a monitor" uses MONITOR_TOKEN)
BASH_TOKEN=$BASH_APP
SYNO_TOKEN=$SYNO_APP
APP_LIST="bash, syno" # FOR USAGE
APP_ID="bash" # Default app
# v1.8
# 24-08-2024 :
# 14-03-2018 : - Request send only necessary fields.
# - Added message pipe.
# - Added monospace option.
# - Default monitor name
# 12-03-2018 : Added image attachment.
# 30-01-2016 : Added -getopts- arguments to set retry/expire.
# 23-04-2015 : HTML markup language option.
VERSION=1.8
TITLE="<empty>"
URL="<empty>"
URL_TITLE="untitled"
PRIORITY=0
RETRY=60
EXPIRE=86400
SOUND="pushover"
HTML=0
MONOSPACE=0
DEVICE="all"
IMAGE=
DEBUG=0
usage()
{
cat << EOF
usage: $0 options
Push notifications to your Android, iOS, or desktop devices
OPTIONS:
-a Application name : "$APP_LIST" (required)
-m Message (required) If the -f (html) flag = 1, message must be surrounded by a single quote
Example: -m \"'This is a <b>HTML</b> test'\"
-t Title of your notification
-d Send to a specific device name Comma seperated list of devices to receive message
-p Priority of your message : -2 (Silent), -1 (Quiet), 0 (Normal), 1 (High), 2 (Emergency)
-s Sound (https://pushover.net/api#sounds):
pushover - Pushover (default)
bike - Bike
bugle - Bugle
cashregister - Cash Register
classical - Classical
cosmic - Cosmic
falling - Falling
gamelan - Gamelan
incoming - Incoming
intermission - Intermission
magic - Magic
mechanical - Mechanical
pianobar - Piano Bar
siren - Siren
spacealarm - Space Alarm
tugboat - Tug Boat
alien - Alien Alarm (long)
climb - Climb (long)
persistent - Persistent (long)
echo - Pushover Echo (long)
updown - Up Down (long)
none - None (silent)
-i Attach an image (up to 2.5mb)
-u URL Link
-n URL Title
-r Retry (seconds) Set retry period for notifications with priority 2 (default ${RETRY})"
-e Expire (seconds) Set expiration time for notifications with priority 2 (default ${EXPIRE})"
-f HTML Format Enable HTML formatting, cannot be used with the -k (monospace) flag
-k Monospace Format Enable monospace messages, cannot be used with the -f (html) flag
-x Debug Must be the first argument !!
-z Show some examples
-h Show this message
EOF
}
examples()
{
local script=`basename "$0"`
echo "EXAMPLES:"
echo
echo " ${script} -a \"bash\" -m \"This is a test\""
echo " Sends a simple \"This is a test\" message to all devices."
echo
echo " ${script} -a \"bash\" -m \"This is a test\" -t \"Test Title\""
echo " Sends a simple \"This is a test\" message with the title \"Test Title\" to all devices."
echo
echo " ${script} -a \"bash\" -m \"This is a test\" -d \"pixel8,Safari_airbook\""
echo " Sends a simple \"This is a test\" message to the devices named \"pixel8\" and \"Safari_airbook\"."
echo
echo " ${script} -a \"bash\" -m \"This is a test\" -u \"http://www.google.com\" -n Google"
echo " Sends a simple \"This is a test\" message to all devices that contains a link to www.google.com titled \"Google\"."
echo
echo " ${script} -a \"bash\" -m \"This is a test\" -p 1"
echo " Sends a simple \"This is a test\" high priority message to all devices."
echo
echo " ${script} -a \"bash\" -m \"This is a test\" -s bike"
echo " Sends a simple \"This is a test\" message to all devices that uses the sound of a bike bell as the notification sound."
echo
echo " ${script} -a \"bash\" -m \"This is a test Pic\" -i /path/to/pic.jpg "
echo " Sends a simple \"This is a test Pic\" message to all devices and send the Picture with the message."
echo
echo " ${script} -a \"bash\" -m \"'This is a <b>HTML</b> test'\" -f 1 "
echo " Sends a simple \"This is a HTML test\" message with html tag"
echo
}
ARGS=( -F "user=$USER_TOKEN" )
# MESSAGE PIPE
if [ -p /dev/stdin ]
then
MESSAGE=$(</dev/stdin)
ARGS+=( -F "message=$MESSAGE" )
else
MESSAGE=
fi
while getopts “hfkvt:r:e:u:n:p:s:m:a:d:i:xz” OPTION
do
case $OPTION in
t) TITLE=$OPTARG
ARGS+=( -F "title=$TITLE" ) ;;
u) URL=$OPTARG
ARGS+=( -F "url=$URL" ) ;;
n) URL_TITLE=$OPTARG
ARGS+=( -F "url_title=$URL_TITLE" ) ;;
p) PRIORITY=$OPTARG
ARGS+=( -F "priority=$PRIORITY" ) ;;
s) SOUND=$OPTARG
ARGS+=( -F "sound=$SOUND" ) ;;
f) HTML=1
ARGS+=( -F "html=$HTML" ) ;;
k) MONOSPACE=1
ARGS+=( -F "monospace=$MONOSPACE" ) ;;
r) [ ! -z $OPTARG ] && RETRY=$OPTARG ;;
e) [ ! -z $OPTARG ] && EXPIRE=$OPTARG ;;
d) DEVICE=$OPTARG
ARGS+=( -F "device=$DEVICE" ) ;;
i) IMAGE="$OPTARG"
ARGS+=( -F "attachment=@${IMAGE}" ) ;;
a)
APP_ID="$OPTARG"
;;
m)
if [[ -z $MESSAGE ]]
then
MESSAGE=$OPTARG
ARGS+=( -F "message=$MESSAGE" )
#ARGS+=( -F "message='$MESSAGE'" )
fi
;;
v) echo "Pushover shell script version ${VERSION}" && exit 1 ;;
x) DEBUG=1 ;;
:) echo "Option -$OPTARG requires an argument." >&2; exit 1 ;;
h) usage; exit 1 ;;
z) examples; exit 1 ;;
?) usage; exit ;;
esac
done
# APP TOKEN
if [[ ! -z $APP_ID ]]
then
APP_ID=`echo $APP_ID | tr '[:lower:]' '[:upper:]'`
APP_NAME="${APP_ID}_TOKEN"
APP_TOKEN="${!APP_NAME}"
ARGS+=( -F "token=$APP_TOKEN" )
fi
# EMERGENCY PRIORITY
if [[ $PRIORITY == 2 ]]
then
ARGS+=( -F "retry=$RETRY" )
ARGS+=( -F "expire=$EXPIRE" )
fi
# REQUIRED FIELDS
if [[ -z $MESSAGE ]] || [[ -z $APP_TOKEN ]]
then
echo -e "\n\\033[31mMessage and Application token are required.\\033[0m"
usage
exit 1
fi
if [[ $HTML == 1 ]]
then
MESSAGE="'$MESSAGE'"
fi
# DEBUG PRINT
if [[ $DEBUG == 1 ]]
then
echo "TITLE ...... $TITLE"
echo "DEVICE ..... $DEVICE"
echo "URL ........ ${URL} (${URL_TITLE})"
echo "FORMAT ..... HTML ${HTML} MONOSPACE ${MONOSPACE}"
echo "APP ........ ID:${APP_ID} TOKEN:${APP_TOKEN}"
echo "PRIORITY ... $PRIORITY"
if [[ $PRIORITY == 2 ]]
then
echo "RETRY ...... $RETRY"
echo "EXPIRE ..... $EXPIRE"
fi
echo "SOUND ...... $SOUND"
echo "IMAGE ..... $IMAGE"
echo "MESSAGE -----------------------------------------"
echo "${MESSAGE}"
echo "-------------------------------------------------"
exit 0
fi
# SEND NOTIFICATION
curl -s "${ARGS[@]}" https://api.pushover.net/1/messages.json
#echo "${ARGS[@]}"

186
sort_export_folder.sh Executable file
View File

@@ -0,0 +1,186 @@
#!/bin/bash
VERSION=1.5
#NO_COLOR=1
# Check if NO_COLOR is set to disable colorization
if [ -z "$NO_COLOR" ]; then
: "${COLOR_GREEN:=$'\e[32m'}"
: "${COLOR_GREEN_BOLD:=$'\e[1;32m'}"
: "${COLOR_RED:=$'\e[31m'}"
: "${COLOR_RED_BOLD:=$'\e[1;31m'}"
: "${COLOR_YELLOW=$'\e[33m'}"
: "${COLOR_YELLOW_BOLD:=$'\e[1;33m'}"
: "${COLOR_SILVER=$'\e[37m'}"
: "${COLOR_LIGHT_GREY=$'\e[249m'}"
: "${COLOR_BRIGHT_PURPLE=$'\e[35;1m'}"
: "${COLOR_PURPLE=$'\e[35m'}"
: "${BOLD:=$'\e[1m'}"
: "${ITALIC:=$'\e[3m'}"
: "${COLOR_RESET:=$'\e[00m'}"
else
: "${BOLD:=$'\e[1m'}"
: "${COLOR_RESET:=$'\e[00m'}"
: "${ITALIC:=$'\e[3m'}"
fi
fr_months=("Janvier" "Février" "Mars" "Avril" "Mai" "Juin" "Juillet" "Août" "Septembre" "Octobre" "Novembre" "Décembre")
# Vérifiez si exiftool est installé
if ! command -v exiftool &> /dev/null; then
echo "exiftool n'est pas installé. Veuillez l'installer d'abord."
exit 1
fi
# Help
Help() {
clear
echo -e "\n${COLOR_GREEN_BOLD}Sort Export Folder $VERSION${COLOR_RESET}\n"
echo "Syntaxe: sort_export_folder.sh [<folder>]"
echo
echo "Tri les photos contenues dans un dossier, et selon le mois de prise de vue, les copies dans des dossiers AN/Mois AN"
echo "Requiert le tag -CreateDate avec exiftool"
echo
echo "Options:"
echo " -h Affiche l'aide"
echo " -d Dossier à trier"
echo
echo "Exemples: sort_export_folder.sh -d /Volumes/Sophie/Export"
echo " sort_export_folder.sh"
echo
echo "Requiert l'installation de exiftool"
echo " -https://exiftool.org"
echo " -brew install exiftool"
}
### Parse options
optspec="fh"
while getopts "$optspec" opt
do
case ${opt} in
d) PHOTO_DIR="${!OPTIND}"; OPTIND=$(( OPTIND + 1 )) ;;
h) Help
Help
exit 2
;;
*) exit 1 ;;
esac
done
shift $((OPTIND -1))
if [[ -z "$PHOTO_DIR" ]]; then
# Répertoire contenant les photos
while :
do
read -e -p "Répertoire contenant les photos: " PHOTO_DIR
[ "$PHOTO_DIR" == "q" ] && exit 1
if [ "$PHOTO_DIR" != "q" ] && [ -d "$PHOTO_DIR" ]; then
break 2
fi
done
fi
nb_jpg_before=$(ls -Uba1 "$PHOTO_DIR" | grep -E -c '.jpg|.jpeg|.cr3|.tif|.dng|.webp|.avif'$)
echo "$nb_jpg_before images trouvées dans $PHOTO_DIR"
[ $nb_jpg_before -eq 0 ] && exit 3
echo
i=0
# Parcourir chaque fichier dans le répertoire
for PHOTO in "$PHOTO_DIR"/*; do
# Vérifiez si le fichier est une image
if [[ -f "$PHOTO" ]] && [[ $(file --mime-type -b "$PHOTO") == image/* ]]; then
# Extraire la date de création EXIF
DATE=$(exiftool -d "%Y-%m" -CreateDate -s -s -s "$PHOTO" 2>/dev/null)
if [[ -n "$DATE" ]]; then
y=$(echo "$DATE" | awk -F"-" '{print $1}')
m=$(echo "$DATE" | awk -F"-" '{print $2}')
else
# image extraite d'une vidéo -> pas de -CreateDate
# 2015-09-11_Daguet_0090.jpg
x=$(basename "$PHOTO" | awk -F"_" '{print $1}')
y=$(echo "$x" | awk -F"-" '{print $1}')
m=$(echo "$x" | awk -F"-" '{print $2}')
fi
# Si le mois commence par 0, on supprime le 0
[ ${m:0:1} == "0" ] && m=${m:1}
# L'index du tableau commence par 0, donc on retranche 1
d=${fr_months["$((m - 1))"]}
month=$(echo "$d $y" | sed 'y/àáâäãåèéêëìíîïòóôöõùúûüÿćčçčďđłńňřśšťžż/aaaaaaeeeeiiiiooooouuuuyccccddlnnrsstzz/')
# Si la date est extraite avec succès
if [[ -n "$month" ]]; then
# Créer le répertoire pour le mois correspondant
MONTH_DIR="$PHOTO_DIR/$month"
mkdir -p "$MONTH_DIR"
# Déplacer la photo dans le répertoire du mois
mv "$PHOTO" "$MONTH_DIR/" &
#echo "Déplacé : $PHOTO -> $MONTH_DIR/"
else
echo "Aucune date EXIF trouvée pour : $PHOTO"
fi
((++i))
fi
done
wait
echo "Triage de $i photos terminé."
nb_jpg_after=$(ls -Uba1 "$PHOTO_DIR" | grep -E -c '.jpg|.jpeg|.cr3|.tif|.dng|.webp|.avif'$)
echo "$nb_jpg_after images trouvées dans $PHOTO_DIR"
#subfolders=$(ls -A "$PHOTO_DIR" | tr '\n' ', ' | sed 's/.$//')
subfolders=$(ls -A "$PHOTO_DIR" | tr '\n' ' ' | sed 's/.$//')
#####
echo
nb_subfolders=$(ls -l "$PHOTO_DIR" | grep -c ^d)
echo "Il y a $nb_subfolders sous-dossiers dans $PHOTO_DIR. Rangeons-les par année !"
for DIR in "$PHOTO_DIR"/*; do
if [[ -d "$DIR" ]]; then
year=$(basename "$DIR" | awk -F" " '{print $2}')
new_year+=(${year})
if [[ -n "$year" ]]; then
# Créer le répertoire pour l'année correspondante
YEAR_DIR="$PHOTO_DIR/$year"
mkdir -p "$YEAR_DIR"
mv "$DIR" "$YEAR_DIR/" &
#echo "Déplacé : $DIR -> $YEAR_DIR/"
fi
fi
done
nb_year_folders=$(ls -l "$PHOTO_DIR" | grep -c ^d)
#year_folders=$(ls -d *)
year_folders=$(cd "$PHOTO_DIR"; ls -d * | tr '\n' ' ')
echo "$nb_year_folders sous-répertoires $year_folders crées."
###
nb_jpg_id_dest=$(find "$PHOTO_DIR" -mindepth 2 -type f -exec bash -c 'echo ${0%${0#$1}}' {} "$PHOTO_DIR" \; | uniq -c | awk '{print $1}')
echo "$nb_jpg_id_dest images trouvées dans les sous-répertoires $subfolders"
[ $nb_jpg_after -ne 0 ] && echo "Erreur !! Il reste des photos dans le dossier d'origine."
[ $nb_jpg_before -ne $nb_jpg_id_dest ] && echo "Erreur !! Toutes les photos n'ont pas été déplacées."
echo
tr=$(tree -d "$PHOTO_DIR" | head -n -1)
echo -e "${COLOR_PURPLE}$tr${COLOR_RESET}"
tree -a "$PHOTO_DIR" | tail -n 1

67
stacks.sh Normal file
View File

@@ -0,0 +1,67 @@
#!/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"
italic="\033[3m"
underline="\033[4m"
reset="\033[0m"
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo .env file found ! Archive won't be encrypted !${reset}"
set +a
}
dotenv
dir_docker="/volume1/docker"
dir_stacks="/volume1/docker/dockge/stacks"
dir_backup="/volume1/docker/_backup"
[ ! -d "$dir_backup" ] && mkdir "$dir_backup"
stacks=$(cd "$dir_stacks" && fd -g docker-compose.yml)
nb=0
while IFS= read -r line; do
app=$(echo "${line}" | awk -F"/" '{print $1}')
folder="$dir_backup/$app"
[ ! -d "$folder" ] && mkdir "$folder"
cp "$line" "$folder"
((nb++))
done <<< "$stacks"
echo -e "$nb 'docker-compose.yml' files founds in DockGe !"
env=$(cd "$dir_stacks" && fd -H -g .env)
nb=0
while IFS= read -r line; do
app=$(echo "${line}" | awk -F"/" '{print $1}')
folder="$dir_backup/$app"
[ -d "$folder" ] && cp "$line" "$folder"
((nb++))
done <<< "$env"
echo -e "$nb '.env' files founds in DockGe !"
echo -e "Archivage du dossier _backup..."
if ! command -v gpg &> /dev/null; then
echo -e "${bold}gpg${reset} could not be found !\n"
echo -e "Archive won't be encrypted !\n"
echo -e ""
tar -zcvf "$dir_docker/backup_Docker.tar.gz" "$dir_backup" >/dev/null 2>&1
else
rm "$dir_docker/backup_Docker.tar".gpg && tar -cvzf - "$dir_backup" | gpg --encrypt --recipient $recipient -o "$dir_docker/backup_Docker.tar".gpg
fi

View File

@@ -1,76 +0,0 @@
#!/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"
greenbold="\033[1;32m"
reset="\033[0m"
: << 'COMMENTS'
echo "toto"
COMMENTS
cat < /dev/null > /dev/tcp/1.1.1.1/53
if [[ $? -ne 0 ]]; then
echo -e "\n${red}No Internet connection !${reset}"
echo -e "Exit !"
exit 1
fi
#urls=("https://clicclac.info" "https://clicclac.info/wordpress" "https://sur-le-sentier.fr" "https://maboiteverte.fr"
# "https://ds923.photos-nas.ovh" "https://portainer.photos-nas.ovh/" "https://dockge.photos-nas.ovh/" "https://kuma.photos-nas.ovh/")
urls=()
while read -r line
do
urls+=("$line")
done < urls_list.txt
check() {
website=$(echo "$1" | awk -F "\/\/" '{print $2}')
# https://developer.mozilla.org/fr/docs/Web/HTTP/Status
if wget --no-verbose --tries=1 --spider "$1" 2>&1 | grep -w "200\|301" ; then
#echo -e "${greenbold}$1 is up${reset}\n"
echo -e "${greenbold}$website is up${reset}\n"
else
echo -e "${redbold}$1 is down${reset}\n"
fi
}
check2() {
website=$(echo "$1" | awk -F "\/\/" '{print $2}')
response=$(curl --write-out '%{http_code}' --silent --output /dev/null "$1")
if [ $(grep -w "200\|301\|302\|303" <<< "$response") ];then
echo -e "${greenbold}$website is up${reset} ($response)\n"
else
echo -e "${redbold}$1 is down${reset} ($response)\n"
fi
}
info_cn() {
cn=$(echo | openssl s_client -connect $1 2>/dev/null | openssl x509 -noout -subject -dates -issuer)
}
: << 'COMMENTS2'
COMMENTS2
for url in "${!urls[@]}"
do
#check "${urls[$url]}"
check2 "${urls[$url]}"
done
# curl --write-out "%{json}" https://nextcloud.photos-nas.ovh | jq

View File

@@ -1,60 +0,0 @@
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