36 Commits

Author SHA1 Message Date
b84d11cd18 handbrake_for_plex.sh
- move to trash after conversion (gio trash on linux)
- compteur de vidéos
2022-08-07 07:23:41 +02:00
240d5457ef mkbuild.sh
-shellcheck script
2022-08-05 10:40:29 +02:00
7a5cd20024 handbrake_for_plex.sh
-shellcheck script
2022-08-05 10:35:00 +02:00
bb2b797bac handbrake_for_plex.sh
-ajout d’une notification quand la conversion est finie
-ajout d’un fichier /tmp/HandBrake.log pour limiter le verbiage
2022-08-04 10:47:47 +02:00
37e61286c8 handbrake_for_plex.sh
Convertit les fichiers vidéos pour l’AppleTV avec handbrake
2022-08-03 15:37:43 +02:00
5d57207bb8 convert-videos-for-plex.sh
-affiche la version de handbrake
2022-08-03 15:36:20 +02:00
d5020f5e55 mkbuild
-test si le seveur est dispo
-affichage d’une notif
2022-08-03 15:35:19 +02:00
c1ae96f4d0 16-02-2022 (2) 2022-02-16 13:21:17 +01:00
217bfb2f52 16-02-2022 2022-02-16 13:20:38 +01:00
9bf07ab9c7 bugfix 2021-09-02 22:56:44 +02:00
b69f54cd4e mkbuild - venv
mkbuild:
-fix airbook hostname

venv:
-moved to kymsu
2021-08-31 09:31:39 +02:00
5dfc07918d mkbuild.sh
-support mkdocs in venv
2021-07-27 17:50:16 +02:00
f23fa229dc 09-03-2021 2021-03-09 06:38:04 +01:00
86cfb95f27 backup_mysql.sh
-change sound
2021-02-21 11:41:46 +01:00
f128ece768 backup-conf.sh
gpg crypte .password.txt et .my.cnf
2021-02-21 11:40:33 +01:00
4341a6a667 sonos.sh
Features:
+ALL status light
2020-12-27 16:56:50 +01:00
96877df4dc sonos.sh
Feature:
+switch status light
2020-12-26 10:51:54 +01:00
2219d769e6 sonos.sh
Features:
+entry ->All
+help
2020-12-26 10:20:15 +01:00
4dd8279d35 sonos.sh
Feature:
+remove a track from playlist
2020-12-24 07:10:16 +01:00
2b295b74e4 sonos.sh
Features:
+list playlists
+delete playlists
2020-12-20 13:57:21 +01:00
733e69d6dd sonos.sh
Feature:
+remove from queue
2020-12-20 12:49:47 +01:00
3e150d6235 sonos.sh
Feature:
+pause
2020-12-20 09:41:51 +01:00
96b1f9d772 sonos.sh
Features:
+playlist
+timer
2020-12-20 09:26:48 +01:00
84a4aef5f1 sonos.sh
rewrite from scratch
2020-12-18 17:46:41 +01:00
5bc89e08a4 sonos.sh
+ local or discover
2020-12-18 17:33:17 +01:00
1323857b0f sonos.sh
+soco_infos()
+soco_lists()
2020-12-16 07:39:36 +01:00
fb35ec9e8e sonos.sh
+ raccourcis-clavier dans les menus
2020-12-15 08:58:16 +01:00
2108a54086 sonos.sh
+ information sur le sonos
2020-12-14 18:09:10 +01:00
474e815118 sonos.sh
GUI pour soco-cli
1ere version
2020-12-14 14:06:02 +01:00
385d175e02 backup_mysql.sh
Remplacement de password.txt par .my.cnf
2020-12-14 14:04:42 +01:00
7f8ba8d3c6 MàJ du README 2020-11-28 10:43:27 +01:00
45718462ca Nouveau script
+backup_Joplin.sh
2020-11-28 10:29:45 +01:00
497cc8996a backup-joplin.sh
Backup des notes de Joplin. 1ere version.
2020-10-22 20:05:33 +02:00
da3e666d9f backup_mysql.sh
-nettoyage des serveurs
2020-10-22 20:04:19 +02:00
e4e1dc3dd0 apache_tools.sh
-remplacement de sphp par Brew PHP switcher
2020-09-03 07:18:52 +02:00
4446560915 mbv-gitea-upd.sh
-bugfix
2020-09-03 07:17:57 +02:00
14 changed files with 1261 additions and 83 deletions

17
README.md Normal file
View File

@@ -0,0 +1,17 @@
# README
- **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)
- **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.
- **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
- **zsh_tools.sh**: Edit/backup/restore .zshrc file

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash
[[ $@ =~ "--install" ]] && echo "Let's install...'"
#version=7.2
editeur=/usr/local/bin/bbedit
@@ -15,7 +17,7 @@ vhost=$(grep -e 'httpd-vhosts.conf' "$conf_apa" | awk '{print $2}')
ssl=$(grep -e 'httpd-ssl.conf' "$conf_apa" | awk '{print $2}')
# PHP
v_php=$(php --ini | grep -E 'usr.*ini')
v_php=$(php --ini | grep -E "$(brew --prefix).*ini")
php_ini=$(php --ini)
@@ -41,6 +43,7 @@ echo ""
# MySQL
v_mysql=$(mysql --help | grep -A1 'Default options')
v_php_apache=$(php --info | grep 'PHP Version' | sed -n '1p')
options=(
"Apache (r)estart"
@@ -53,12 +56,17 @@ options=(
"(O)pen PHP info page in browser"
"Apache/PHP/MySQL (V)ersion"
"Apache/PHP/MySQL (C)onfiguration files"
"S(w)itch to PHP version (sphp)"
"S(w)itch to PHP version"
"(U)pdate sphp"
"Edit additio(n)nals *.ini files"
"(Q)uit"
)
# --> sphp:<--
# mod-php: https://gist.github.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/
# php-fpm: https://gist.github.com/rozsival/10289d1e2006c68009ace0478306ecd2/
# Brew PHP switcher
# https://github.com/philcook/brew-php-switcher#readme
select option in "${options[@]}"; do
case "$REPLY" in
@@ -70,13 +78,13 @@ select option in "${options[@]}"; do
6|a|A) tail -f "$access_apa" ;;
7|p|P) "$editeur" "$conf_php" ;; # php.ini
8|o|O) echo '<?php echo phpinfo(); ?>' > $document_root/php-info.php && open 'http://localhost/php-info.php' ;;
9|v|V) apachectl -v && echo ' ' && php -v && echo ' ' && mysql --version ;;
10|c|C) echo -e "\033[4mApache:\033[0m " && echo $v_apa && echo ' ' && echo -e "\033[4mPHP:\033[0m " && echo $v_php && echo ' ' && echo -e "\033[4mMySQL:\033[0m " && echo $v_mysql ;;
11|w|W) read -e -n 3 -p "Which PHP version? (7.2/7.3/7.4): " choice
# if [ "$choice" == "7.2" ] || [ "$choice" == "7.3" ] || [ "$choice" == "7.4" ]; then sphp "$choice" ; fi ;;
# if [ "$choice" == "7.2" ] || [ "$choice" == "7.3" ] || [ "$choice" == "7.4" ]; then echo "$choice" | xargs -p -n 1 sphp ; fi ;;
if [[ "$choice" == "7.2" ]] || [[ "$choice" == "7.3" ]] || [[ "$choice" == "7.4" ]]; then echo "$choice" | xargs -p -n 1 sphp ; fi ;;
12|u|U) curl -L 'https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw' > /usr/local/bin/sphp && chmod +x /usr/local/bin/sphp ;;
9|v|V) apachectl -v && echo ' ' && php -v && echo ' ' && echo "$v_php_apache (Apache)" && echo ' ' && mysql --version ;;
10|c|C) echo -e "\033[4mApache:\033[0m " && echo $v_apa && echo ' ' && echo -e "\033[4mPHP:\033[0m " && echo "$v_php" && echo ' ' && echo -e "\033[4mMySQL:\033[0m " && echo $v_mysql ;;
11|w|W) read -e -n 3 -p "Which PHP version? (7.3/7.4/8.0/8.1): " choice
if [[ "$choice" == "7.3" ]] || [[ "$choice" == "7.4" ]] || [[ "$choice" == "8.0" ]] || [[ "$choice" == "8.1" ]]; then echo "$choice" | xargs -p -n 1 sphp ; fi ;;
#if [[ "$choice" == "7.3" ]] || [[ "$choice" == "7.4" ]] || [[ "$choice" == "8.0" ]]; then echo "$choice" | xargs -p -n 1 brew-php-switcher ; fi ;;
#12|u|U) curl -L 'https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw' > /usr/local/bin/sphp && chmod +x /usr/local/bin/sphp ;;
12|u|U) open 'https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw' ;;
13|n|N) add_ini
read -e -n 1 -p "Edit which file ?: " choice
#if [[ "$choice" == 1 ]] || [[ "$choice" == 4 ]]; then "$editeur" ${additionnal[$choice]}; fi ;;

View File

@@ -9,7 +9,8 @@ if [ "$1" == "-h" ]; then
echo " - my.cnf"
echo " - .bash_profile, .bash_aliases"
echo " - .config (folder)"
echo " - .gitconfig"
echo " - .dircolors"
echo " - .gitconfig, .gitignore"
echo " - .gnupg (folder)"
echo " - /etc/hosts"
echo " - .wg++"
@@ -43,19 +44,20 @@ notification() {
fi
if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
# BUG: No image on BigSur
terminal-notifier -title "$1" -message "$message" -sound "$sound" -contentImage "$image"
fi
fi
}
copy() {
if [[ -d $1 ]]; then cp -R $1 $2; fi
if [[ -f $1 ]]; then cp $1 $2; fi
if [[ -d $1 ]]; then cp -R "$1" "$2"; fi
if [[ -f $1 ]]; then cp "$1" "$2"; fi
}
# Backup folder
# Backups folder
dest=$HOME/Documents/Configurations/SilverBook
dest2="$HOME/pCloud Drive/Linux/Silverbook"
# Web: PHP / Apache / MySQL
@@ -101,6 +103,8 @@ copy $HOME/.zsh_plugins.sh "$dest_shell"
copy $HOME/.zsh_plugins.txt "$dest_shell"
copy $HOME/.zshrc "$dest_shell"
copy "$dest_shell" "$dest2"
#
#echo '----------'
#while read
@@ -114,27 +118,34 @@ copy $HOME/.zshrc "$dest_shell"
copy $HOME/.backup_list.conf "$dest"
copy $HOME/.config "$dest" # folder (joplin, mpv, rclone, xnview)
copy $HOME/.dircolors "$dest"
copy $HOME/.exclude-rsync "$dest"
copy $HOME/.gitconfig "$dest"
copy $HOME/.gitignore "$dest"
# https://gpgtools.tenderapp.com/kb/gpg-keychain-faq/backup-or-transfer-your-keys
copy $HOME/.gnupg "$dest" #folder
copy $HOME/.gnupg_pre_2.1 "$dest" #folder
copy $HOME/.iterm2 "$dest" #folder
copy $HOME/.kymsu "$dest" #folder
gpg2 --output "$dest/.my.cnf.gpg" --recipient bruno.pesenti@orange.fr --encrypt $HOME/.my.cnf
#copy $HOME/.my.cnf.gpg "$dest"
copy $HOME/.nanorc "$dest"
copy $HOME/.nanorc "$dest2"
copy $HOME/.nanosyntax "$dest" #folder
copy $HOME/.password.txt "$dest"
copy $HOME/.nanosyntax "$dest2" #folder
gpg2 --output "$dest/.password.txt.gpg" --recipient bruno.pesenti@orange.fr --encrypt $HOME/.password.txt
#copy $HOME/.password.txt.gpg "$dest"
copy $HOME/.ssh "$dest" #folder
copy $HOME/.ssh/config "$dest2" #folder
copy $HOME/.vnc "$dest" #folder
copy /private/etc/hosts "$dest"
copy $HOME/Library/Application\ Support/Transmit "$dest" #folder
copy "$HOME/Library/Application\ Support/Transmit" "$dest" #folder
copy "$HOME/Library/Application\ Support/iTerm2" "$dest" #folder
copy $HOME/Library/LaunchAgents "$dest" #folder
copy $HOME/Documents/Scripts/kymsu2/plugins.d/Brewfile "$dest"
copy $HOME/Documents/Scripts/kymsu2/plugins.d/Installed_SilverBook*.md "$dest"
copy $HOME/Dropbox/Dash.dash "$dest"
copy $HOME/.wg++/WebGrab++.config.xml "$dest"
terminal-notifier -title 'Backup configurations' -message 'Sauvegarde terminée !' -sound 'Glass'

22
backup_Joplin.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Joplin.job
# Changement de version de node: supprimer/ remettre variable PATH
# nvm which current
# /Users/bruno/.nvm/versions/node/v14.15.0/bin/node
# which joplin
# /Users/bruno/.nvm/versions/node/v14.15.0/bin/joplin
#joplin_exe=$(which joplin)
profile=~/.config/joplin-desktop/
format=jex
bkp_date="$(date +"%d-%m-%Y")";
dexport=~/Documents/Joplin
fexport="$dexport/joplin_$bkp_date.jex"
bkp_length=7
# joplin -- profile "" export "" --format "" dans cet ordre
joplin --profile "$profile" export "$fexport" "Codes Projet" --format "$format"
find "$dexport" -mtime +"$bkp_length"d -name 'joplin*.jex' -delete
echo $?

View File

@@ -21,19 +21,35 @@
#####################################################################
#
#
BKP_USER="mysqlbackupuser" # Enter the username for backup
BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user
#CREATE USER 'mysqlbackupuser'@'localhost' IDENTIFIED BY '34diK=[6]Zui';
#GRANT SELECT ON * . * TO 'mysqlbackupuser'@'localhost';
pass=$(gpg --quiet --decrypt $HOME/.my.cnf.gpg)
x=$(echo $pass | awk '{print $2}')
BKP_USER=${x:5}
y=$(echo $pass | awk '{print $3}')
BKP_PASS=${y:9}
machine=$(hostname | awk -F"." '{print $1}')
BKP_BASE_DIR=$(dirname "$0")
# Read l/p from .my.cnf
#BKP_USER="mysqlbackupuser" # Enter the username for backup
#BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user
#BKP_PASS="${PASSWORD}" # direnv (.envrc)
#
BKP_DEST="$HOME/Documents/MySQL" # Enter the Backup directory,change this if you have someother location
BKP_DEST="$HOME/Documents/MySQL" # Enter the Backup directory,change this if you have someother location
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_WEEKS="22"
BKP_MONTHS="93"
BKP_DAYS=3 # Enter how many days backup you want,
BKP_WEEKS=21 # 3*7
BKP_MONTHS=93 # 3*31
#
########### Use This for only local server #############################
MYSQL_HOST="localhost"
@@ -46,9 +62,10 @@ MYSQL_HOST="localhost"
##################### Get Backup DATE ##################################
#
#BKP_DATE="$(date +"%A_%d-%m-%Y_%H-%M-%S")";
# Pour les date en français: LC_ALL="fr_FR.UTF-8" date +"%B_%Y"
#lundi=date +%u
if [ $(date +%d) = "01" ]; then # 1er du mois => octobre_2019
BKP_DATE="$(date +"%B_%Y")";
BKP_DATE="$(date +"%B_%Y" | sed 'y/áàâäçéèêëîïìôöóûùúüñÂÀÄÇÉÈÊËÎÏÔÖÙÜÑ/aaaaceeeeiiiooouuuunAAACEEEEIIOOUUN/')";
elif [ $(date +%u) -eq 1 ]; then # lundi => S44_2019
BKP_DATE="$(date +"S%V_%Y")";
else
@@ -58,7 +75,7 @@ fi
#
########## Ignore these default databases shen taking backup ############
#
IGNORE_DB="information_schema mysql performance_schema"
IGNORE_DB="information_schema mysql performance_schema sys"
#
########## Creating backup dir if not exist #############################
#
@@ -72,11 +89,11 @@ GZIP="$(which gzip)"
notification() {
if [ $3 -eq 0 ];
then
sound="Glass"
sound="Boop"
message="Envoi terminé sur $2 !"
image="$BKP_BASE_DIR/success.png"
else
sound="Basso"
sound="Galet"
message="Echec lors de l'envoi sur $2 : erreur $result"
image="$BKP_BASE_DIR/error.png"
fi
@@ -89,6 +106,8 @@ notification() {
###################### 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')"
#
for db in $DB_LIST
do
@@ -107,10 +126,16 @@ do
#
################ Using MYSQLDUMP for bakup and Gzip for compression ###################
#
# Dans les dossiers Backup: mkdir -p silverbook/Bases_MySQL
$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
server1="ftp.cluster011.ovh.net:www/backup/SilverBook/Bases_MySQL/"
server1="ftp.cluster011.ovh.net:backup/$machine/Bases_MySQL/"
scp "$BKP_GZ_FILENAME" funnymac@"$server1"
result=$?
@@ -118,44 +143,97 @@ do
sleep 1
server2="clicclac.synology.me:/volume1/Backup/SilverBook/Bases_MySQL/"
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=$?
notification "Backup MySQL: base $db" "$server2" $result
#echo "----"
fi
done
#########To delete all backup files older then BKP_DAYS #################
#
#find $BKP_DEST -type f -mtime +$BKP_DAYS -delete
# Nettoyage serveurs locaux:
# xxx.S44_2019.sql.gz
# find . -name "*.sql.gz" -mtime +$BKP_WEEKS | grep -E 'S\d{2}_\d{4}'
# xxx.octobre_2019.sql.gz
# find . -name "*.sql.gz" -mtime +$BKP_MONTHS | grep -E 'janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre'
# xxx.Mercredi_30-10-2019_11-33-17.sql.gz
if find --version >/dev/null 2>&1 ; then
echo Using GNU date
d_duration="$BKP_DAYS"
w_duration="$BKP_DAYS"
m_duration="$BKP_DAYS"
else
echo Using BSD date
d_duration="$BKP_DAYS"d
w_duration="$BKP_DAYS"d
m_duration="$BKP_DAYS"d
fi
#find $BKP_DEST -name "*.sql.gz" -mtime +$BKP_DAYS | grep -v -E '(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)|(S\d{2}_\d{4})' > day.txt
find -E $BKP_DEST -mtime +$BKP_DAYS -regex '.*(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)|(S\d{2}_\d{4})' > day.txt
echo $?
#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
##gfind /Users/bruno/Documents/MySQL -mtime +93 -iregex '.*\(January\|February\|March\|April\|May\|June\|July\|September\|October\|November\|December\).*'
#find $BKP_DEST -name "*.sql.gz" -mtime +$BKP_WEEKS | grep -E 'S\d{2}_\d{4}' > week.txt
find -E $BKP_DEST -mtime +$BKP_WEEKS -regex 'S\d{2}_\d{4}' > week.txt
echo $?
find $BKP_DEST -name "*.sql.gz" -mtime +"$w_duration" | grep -E 'S\d{2}_\d{4}' | xargs rm -f
##gfind /Users/bruno/Documents/MySQL -mtime +22 -regextype posix-extended -iregex '.*S[0-9]{2}_[0-9]{4}.*'
#find $BKP_DEST -name "*.sql.gz" -mtime +$BKP_MONTHS | grep -E '(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)' > month.txt
find -E $BKP_DEST -mtime +$BKP_MONTHS -regex '.*(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)' > month.txt
echo $?
#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
#
# find . -name "*.sql.gz" | grep -E 'Monday|Tuesday' | xargs rm
# Nettoyage serveurs distants:
#916_dest="/volume1/Backup/SilverBook/Bases_MySQL"
# ssh dsm916e "find /volume1/Backup/SilverBook/Bases_MySQL -type f -name '*.sql.gz' | grep -P '(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)' | xargs rm -f"
# cd /volume1/Backup/SilverBook/Bases_MySQL
# find . -type f -mtime +3 -name '*.sql.gz' -delete
ssh dsm916e "set -o pipefail; find /volume1/Backup/$machine/Bases_MySQL -type f -mtime +$BKP_DAYS -name '*.sql.gz' | grep -P '(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)' | xargs rm -f"
retCode[1]=$?
errMsg[1]="daily backup bases @ dsm916"
ssh dsm916e "set -o pipefail; find /volume1/Backup/$machine/Bases_MySQL -type f -mtime +$BKP_WEEKS -name '*.sql.gz' | grep -P 'S\d{2}_\d{4}' | xargs rm -f"
retCode[2]=$?
errMsg[2]="weekly backup bases @ dsm916"
ssh dsm916e "set -o pipefail; find /volume1/Backup/$machine/Bases_MySQL -type f -mtime +$BKP_MONTHS -name '*.sql.gz' | grep -P '(January|February|March|April|May|June|July|August|September|October|November|December)' | xargs rm -f"
retCode[3]=$?
errMsg[3]="monthly backup bases @ dsm916"
ovh_dest="/homez.528/funnymac/backup/$machine/Bases_MySQL"
# ssh ovh "find /homez.528/funnymac/backup/SilverBook/Bases_MySQL -type f -name '*.sql.gz' | grep -P '(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)' | xargs rm -f"
ssh ovh "set -o pipefail; find $ovh_dest -type f -mtime +1 -name '*.sql.gz' | grep -P '(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)' | xargs rm -f"
retCode[4]=$?
errMsg[4]="daily backup bases @ ovh"
ssh ovh "set -o pipefail; find $ovh_dest -type f -mtime +$BKP_WEEKS -name '*.sql.gz' | grep -P 'S\d{2}_\d{4}' | xargs rm -f"
retCode[5]=$?
errMsg[5]="weekly backup bases @ ovh"
ssh ovh "set -o pipefail; find $ovh_dest -type f -mtime +$BKP_MONTHS -name '*.sql.gz' | grep -P '(January|February|March|April|May|June|July|August|September|October|November|December)' | xargs rm -f"
retCode[6]=$?
errMsg[6]="monthly backup bases @ ovh"
# Codes retour:
# grep: 0 -> si lignes, 1 -> pas de lignes, 2 -> erreur
# find: 0 -> si ok, >0 -> si erreur
# xarg: 0 -> si ok, 123 à 127 si erreur, 1 -> autres erreurs
for (( c=1; c<=6; c++ ))
do
#if [ ${retCode[$c]} -eq 1 ]; then
#echo "erreur"
#notification "Error on deleting remote files ${errMsg[$c]}" $result
#notification "Error" ${retCode[$c]}
#fi
if [ ${retCode[$c]} -eq 0 ]; then
echo "Pas d'erreur"
#notification "Error on deleting remote files ${errMsg[$c]}" $result
notification "No Error" ${retCode[$c]}
fi
done
# find /volume1/Backup/SilverBook/Bases_MySQL -type f -mtime +1 -name '*.sql.gz'
# ssh dsm916e 'find /volume1/Backup/SilverBook/Bases_MySQL -type f -mtime +1 -name "*.sql.gz" -delete'
#
#### End of script ####

85
backup_vps.sh Normal file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
# backup files on mbv
if [ "$1" == "-h" ]; then
echo -e "\033[93mbackup-conf.sh\033[0m"
echo "Backup several files and folders:"
echo
#echo " - httpd.conf, httpd-vhosts.conf, httpd-ssl.conf"
#echo " - php.ini"
#echo " - my.cnf"
echo " - .bash_profile, .bash_aliases"
#echo " - .config (folder)"
#echo " - .gitconfig"
echo " - .gnupg (folder)"
#echo " - /etc/hosts"
# " - .nanorc, .nanosyntax"
echo " - .ssh (folder)"
#echo " - .vnc (folder)"
#echo " - .kymsu (folder)"
echo
echo "USAGE: backup-conf"
echo
echo " -h display this help"
echo
exit 0
fi
BKP_BASE_DIR=$(dirname "$0")
echo "$BKP_BASE_DIR"
# Functions
copy() {
if [[ -d $1 ]]; then cp -R $1 $2; fi
if [[ -f $1 ]]; then cp $1 $2; fi
}
# Backup folder
dest=$HOME/backup/vpsmbv
# Web: PHP / Apache / MySQL
cd "$dest"
if [ ! -d "mysql" ]; then mkdir "mysql"; fi
dest_my=$dest/mysql/
copy /etc/mysql/mariadb.conf.d/nextcloud.cnf "$dest_my"
# Shell: bash / zsh
cd "$dest"
if [ ! -d "shell" ]; then mkdir "shell"; fi
dest_shell=$dest/shell/
copy $HOME/.bash_profile "$dest_shell"
copy $HOME/.bash_aliases "$dest_shell"
copy $HOME/.ssh "$dest_shell"
# Nextcloud
cd "$dest"
if [ ! -d "nextcloud" ]; then mkdir "nextcloud"; fi
dest_nc=$dest/nextcloud/
# /var/www/vhosts/maboiteverte.fr/httpdocs/nextcloud/config
copy $HOME/httpdocs/nextcloud/config/config.php "$dest_nc"
# zenphoto
cd "$dest"
if [ ! -d "zenphoto" ]; then mkdir "zenphoto"; fi
dest_zp=$dest/zenphoto/
copy $HOME/httpdocs/zenphoto/zp-data "$dest_zp"
#
server1="clicclac.synology.me:/volume1/Backup/vpsmbv/"
rsync -e '/usr/bin/ssh -p 42666' --exclude-from="$HOME/.exclude-rsync.txt" --rsync-path=/bin/rsync -zarvh "$dest/" bruno@$server1
result=$?
echo "$result"
server2="ftp.cluster011.ovh.net:www/backup/vpsmbv/"
rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh "$dest/" funnymac@$server2
result=$?
echo "$result"

292
convert-videos-for-plex.sh Executable file
View File

@@ -0,0 +1,292 @@
#!/usr/bin/env bash
shopt -s globstar
# Initialise variables
function showHelp() {
echo "----------------"
echo "Convert videos for Plex Media Server"
echo "----------------"
echo "Converts all videos in nested folders to h264 and audio to aac using HandBrake with the Normal preset."
echo "This saves Plex from having to transcode files which is CPU intensive."
echo
echo "Prerequisites"
echo
echo "Requires HandBrackCLI and media-info."
echo " macOS:"
echo " $ brew install handbrake"
echo " $ brew install media-info"
echo " Arch Linux:"
echo " $ sudo pacman -S handbrake-cli mediainfo"
echo "(Package names may vary depending on your distribution)"
echo "This script uses glob patterns, which requires Bash 4+ and globstar enabled"
echo " $ bash --version"
echo " Mac https://gist.github.com/reggi/475793ea1846affbcfe8"
echo
echo "----------------"
echo
echo "Command line options:"
echo "-a Select an audio track to use."
echo "-b Select a subtitle track to burn in."
echo "-c Codec to modify. Default is MPEG-4"
echo "-d Delete original."
echo "-f Force overwriting of files if already exist in output destination."
echo "-o Output folder directory path."
echo " Default is the same directory as the input file."
echo "-p The directory path of the movies to be tidied."
echo " Default is '.', the location of this script."
echo "-q Quality of HandBrake encoding preset. Default is 'Fast 1080p30'."
echo " For a full list of presets in CMD line run:"
echo " HandBrakeCLI --preset-list"
echo " https://handbrake.fr/docs/en/latest/workflow/select-preset.html"
echo "-r Run transcoding. Exclude for dry run."
echo "-s Skip transcoding if there is already a matching file name in the output destination."
echo " Force takes precedence over skipping files and will overwrite them if both flags present."
echo "-w Workspace directory path for processing. Set a local directory for faster transcoding over network."
echo
echo "Examples:"
echo " Dry run all movies in the Movies directory"
echo " .convert-videos-for-plex.sh -p Movies"
echo
echo " Transcode all movies in the current directory force overwriting matching .mp4 files."
echo " .convert-videos-for-plex.sh -fr"
echo
echo " Transcode all network movies using Desktop as temp directory and delete original files."
echo " .convert-videos-for-plex.sh -rd -p /Volumes/Public/Movies -w ~/Desktop"
echo
}
codec="MPEG-4"
delete=false
path="./"
out="$HOME/Movies"
name=""
ext=".mp4"
force=false
skip=false
forceOverwrite=false
run=false
workspace=""
fileIn=""
fileOut=""
count=0
#qualityPreset="Fast 1080p30"
qualityPreset="Apple 720p30 Surround"
audio=""
subtitle=""
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
version=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null)
if [ "$version" != "" ]; then
handbrake="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI"
echo "Handbrake $version"
else {
cli=$(which HandBrakeCLI)
if [ "$cli" != "" ]; then
handbrake="$cli"
version=$("$handbrake" --version 2>/dev/null | sed -n '1p')
echo "$version"
else
echo "handbrake not installed!"
fi
}
fi
function removeLock {
if [[ -f "$1" ]]; then
rm "$1"
fi
}
while getopts "h?dfsrp:o:c:w:q:a:b:" opt; do
case "$opt" in
h|\?)
showHelp
exit 0
;;
d) del=true
;;
f) force=true
;;
s) skip=true
;;
r) run=true
;;
p) path="$OPTARG"
;;
o) out="$OPTARG"
;;
c) codec="$OPTARG"
;;
w) workspace="$OPTARG"
;;
q) qualityPreset="$OPTARG"
;;
a) audio="--audio $OPTARG"
;;
b) subtitle="--subtitle $OPTARG --subtitle-burned"
;;
esac
done
# Reset OPTIND
shift $((OPTIND-1))
echo
if [[ $run == true ]]; then
echo -e "${BLUE}TRANSCODING${NC}"
else
echo -e "${BLUE}DRY RUN${NC}"
fi
echo "----------------"
# Make sure all user inputted paths have trailing slashes
if [[ $path != */ ]]; then
path=$path"/"
fi
if [[ $out != "" && $out != */ ]]; then
out=$out"/"
fi
if [[ $workspace != "" && $workspace != */ ]]; then
workspace=$workspace"/"
fi
for i in "${path}"{,**/}*.*; do
forceOverwrite=false
# Prevent processing on non-files
if [[ $i != *\*.* ]]; then
# Loop over avi, mkv, iso, img, mp4 and m4v files only.
if [[ $i == *.avi || $i == *.mkv || $i == *.iso || $i == *.img || $i == *.mp4 || $i == *.m4v ]]; then
((count++))
lockPath="${i}.lock"
if [[ -f "${lockPath}" ]]; then
echo -e "${BLUE}Lockfile for $i exists. Skipping.${NC}"
continue
fi
if [[ $run == true ]]; then
touch "${lockPath}"
fi
echo
echo "${count}) Checking: "$i
if [[ ($audio != "" || $subtitle != "")
|| $(mediainfo --Inform="Video;%Format%" "$i") == *$codec*
|| $(mediainfo --Inform="Video;%Format%" "$i") == "HEVC"
|| $(mediainfo --Inform="Video;%Format%" "$i") == "xvid"
|| ($(mediainfo --Inform="Video;%Format%" "$i") == "AVC"
&& ($(mediainfo --Inform="Video;%Format_Profile%" "$i") == *"@L5"*))
]]; then
# Set audio options to defaults if required
if [[ $audio == "" ]]; then
audio="--audio-lang-list 'und' --all-audio"
fi
# Set subtitle options to defaults if required
if [[ $subtitle == "" ]]; then
subtitle="-s 'scan'"
fi
# Get file name minus extension
name=${i%.*}
# Set out directory if different from current
if [[ $out != "" ]]; then
name=${name##*/}
name=$out$name
fi
# Check for existing .mp4; ask for overwrite or set force overwrite.
if [[ -e $name$ext ]]; then
if [[ $force == false ]]; then
if [[ $skip == false ]]; then
read -p "'$name$ext' already exists. Do you wish to overwrite it?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
forceOverwrite=true
echo -e "${BLUE}Overwriting:${NC} "$name$ext
else
echo -e "${RED}Skipping (already exists):${NC} "$name$ext
removeLock "${lockPath}"
continue
fi
else
echo -e "${RED}Skipping (already exists):${NC} "$name$ext
removeLock "${lockPath}"
continue
fi
else
forceOverwrite=true
echo -e "${BLUE}Overwriting:${NC} "$name$ext
fi
fi
echo "Transcoding: "${i} to $name$ext
if [[ $run == true ]]; then
# Set file locations: in situ or separate workspace
if [[ $workspace == "" ]]; then
fileIn="${i}"
fileOut="${name}"
else
echo "Copying "$i" to "$workspace
cp "$i" "${workspace}"
fileIn=$workspace${i##*/}
fileOut=${fileIn%.*}
fi
# Modified from http://pastebin.com/9JnS23fK
#HandBrakeCLI -i "${fileIn}" -o "${fileOut}""_processing""${ext}" --preset="${qualityPreset}" -O ${subtitle} ${audio}
"$handbrake" -i "${fileIn}" -o "${fileOut}""_processing""${ext}" --preset="${qualityPreset}" -O ${subtitle} ${audio}
# if HandBrake did not exit gracefully, continue with next iteration
if [[ $? -ne 0 ]]; then
removeLock "${lockPath}"
continue
else
# Delete original files
if [[ $del == true ]]; then
rm -f "${i}"
elif [[ $forceOverwrite == true ]]; then
rm -f "${name}""${ext}"
fi
mv "${fileOut}""_processing""${ext}" "${fileOut}""${ext}"
chmod 666 "${fileOut}""${ext}"
# Move files from workspace back to original locations
if [[ $workspace != "" ]]; then
echo "Copying from workspace ""${fileOut}${ext}"" to ""$(dirname "${name}${ext}")"
cp "${fileOut}${ext}" "$(dirname "${name}${ext}")"
rm -f "${fileIn}"
rm -f "${fileOut}""${ext}"
fi
echo -e "${GREEN}Transcoded:${NC} "$name$ext
fi
else
echo -e "${GREEN}Transcoded (DRY RUN):${NC} "$name$ext
fi
else
currentFormat=$(mediainfo --Inform="Video;%Format%" "$i")
currentProfile=$(mediainfo --Inform="Video;%Format_Profile%" "$i")
echo -e "${RED}Skipping (video format ${currentFormat} ${currentProfile} will already play in Plex)${NC}"
fi
removeLock "${lockPath}"
fi
fi
done
exit 0

374
handbrake_for_plex.sh Executable file
View File

@@ -0,0 +1,374 @@
#!/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
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; }
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
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
}
notification() {
#path_img=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ "$3" -eq 0 ];
then
sound="Glass"
#image="$path_img/success.png"
#image="$path_img/HandBrake.icns"
else
sound="Basso"
#image="$path_img/error.png"
fi
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
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
fi
}
while getopts "h?i:o:p:" opt; do
case "$opt" in
h|\?)
showHelp
exit 0
;;
i) input_path="$OPTARG"
;;
o) output_path="$OPTARG"
;;
p) profile="$OPTARG"
;;
esac
done
# Reset OPTIND
shift $((OPTIND-1))
# https://stackoverflow.com/questions/59895/how-can-i-get-the-directory-where-a-bash-script-is-located-from-within-the-scrip
#DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
#SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
#DIR_SCRIPT=$(dirname -- "$( readlink -f -- "$0"; )")
####
# Configuration
# Source video folder
[[ "$input_path" == "" ]] && SRC="$HOME/Downloads" || SRC="$input_path"
# Destination video folder
[[ "$output_path" == "" ]] && DEST="$HOME/Movies" || DEST="$output_path"
# Extension video file
DEST_EXT=mp4
# Handbrake preset
[[ "$profile" == "" ]] && PRESET="Apple 720p30 Surround" || PRESET="$profile"
# Only files larger than $MAXSIZE will be processed
MAXSIZE=30000000
#MAXSIZE=300
# Open converted video file in an application
APP="Subler"
# log
# this reduce handbrake verbosity
logfile=/tmp/HandBrake.log
#Move to trash after conversion
trash=true
###
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"
else
echo -e "${red}HandBrake not installed!${reset}\n"
exit 1
fi
}
fi
echo -e "Source folder: ${italic}$SRC${reset}"
echo -e "Destination folder: ${italic}$DEST${reset}"
echo -e "HandBrake Profile: ${italic}$PRESET${reset}"
# nok en bash, ok en zsh
#ls -1 **/*.(mkv|mp4)
#ls **/*.(mkv|avi|mp4|m4v)
#ls "$HOME/Downloads"/**/*.(mkv|avi|mp4|m4v)
#ls "$SRC"/**/*.{mkv,avi,mp4,m4v}
count=0
# Series: SxxEyy
REGEX="([sS]([0-9]{2,}|[X]{2,})[eE]([0-9]{2,}|[Y]{2,}))"
# Films: 2
REGEX2="[0-9]{4}"
movies=()
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}
do
# Get file size
FILESIZE=$(stat -c%s "$FILE")
if (( FILESIZE > MAXSIZE )); then
movies+=("${FILE}")
fi
done
nb_movies=${#movies[@]}
for FILE in "${movies[@]}"
do
filename=$(basename "$FILE")
#extension=${filename##*.}
filename=${filename%.*}
: <<'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')
info=$(sed "1s/.*/\\${bold}$l\\${reset}/" <<< "$media")
echo -e "$info\n"
END_COMMENT
if [[ $filename =~ $REGEX ]]; then
MATCH="${BASH_REMATCH[1]}"
e=$(echo "${filename%$MATCH*}" | sed 's/\./\ /g' | xargs)
new_name="$e - $MATCH.$DEST_EXT"
elif [[ $filename =~ $REGEX2 ]]; then
MATCH2="${BASH_REMATCH[0]}"
e=$(echo "${filename%$MATCH2*}" | sed 's/\./\ /g' | xargs)
new_name="$e ($MATCH2).$DEST_EXT"
else
echo "Could not find SXXEYY pattern"
new_name="$filename"
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})')
# General
#nb_video=$(echo "$infos" | jq -j '.[] | .VideoCount')
nb_audio=$(echo "$infos" | jq -j '.[] | .AudioCount')
if [[ "$nb_audio" == "null" ]]; then nb_audio=0; fi
nb_text=$(echo "$infos" | jq -j '.[] | .TextCount')
if [[ "$nb_text" == "null" ]]; then nb_text=0; fi
nb_menu=$(echo "$infos" | jq -j '.[] | .MenuCount')
if [[ "$nb_menu" == "null" ]]; then nb_menu=0; fi
format_fichier=$(echo "$infos" | jq -j '.[] | .FormatFichier')
filesize=$(echo "$infos" | jq -j '.[] | .FileSize' | numfmt --to=si --format "%8.2f" | xargs)
#fsize=$(numfmt --to iec --format "%8.2f" "$filesize")
duree=$(echo "$infos" | jq -j '.[] | .Duration' | awk -F "." '{print $1}' | awk '{printf "%d:%02d:%02d", $1/3600, ($1/60)%60, $1%60}' | xargs)
# Video
format_video=$(echo "$infos" | jq -j '.[] | .FormatVideo')
format_profile=$(echo "$infos" | jq -j '.[] | .Format_Profile')
format_level=$(echo "$infos" | jq -j '.[] | .Format_Level')
codec_video=$(echo "$infos" | jq -j '.[] | .CodecVideo')
width=$(echo "$infos" | jq -j '.[] | .Width')
height=$(echo "$infos" | jq -j '.[] | .Height')
# Audio
format_audio=$(echo "$infos" | jq -j '.[] | .FormatAudio')
format_addition=$(echo "$infos" | jq -j '.[] | .FormatAdditionalFeatures')
if [[ "$format_addition" == "null" ]]; then format_addition=""; fi
codec_audio=$(echo "$infos" | jq -j '.[] | .CodecAudio')
title_audio=$(echo "$infos" | jq -j '.[] | .TitleAudio')
language_audio=$(echo "$infos" | jq -j '.[] | .LanguageAudio')
if [[ "$language_audio" == "null" ]]; then language_audio=""; fi
default_audio=$(echo "$infos" | jq -j '.[] | .DefaultAudio')
if [[ "$default_audio" == "null" ]]; then default_audio=""; fi
# Text
format_text=$(echo "$infos" | jq -j '.[] | .FormatText')
codec_text=$(echo "$infos" | jq -j '.[] | .CodecText')
language_text=$(echo "$infos" | jq -j '.[] | .LanguageText')
default_text=$(echo "$infos" | jq -j '.[] | .DefaultText')
# Menu
menu=$(echo "$infos" | jq -j '.[] | .Menu' | sed '1d;$d')
m=""
while IFS= read -r line
do
t=$(echo "$line" | awk -F": " '{print $1}')
c=$(echo "$line" | awk -F": " '{print $2}')
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.*//')
cc=$(echo "$c" | tr -d '"' | xargs | awk -F ":" '{print $2}' | sed 's/,$//' | sed 's/^/ /')
m+="$cc : $tt\n"
done <<< "$menu"
echo -e "\n\n${bold}(${red}$(( count + 1 ))${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}"
printf " %-21s %-35s \n" "Duree:" "${duree}"
echo -e "\n${bold}Video:${reset}"
printf " %-21s %-35s \n" "Format video:" "${format_video}"
printf " %-20s %-35s \n" "Profile:" "${format_profile}"
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}"
printf " %-20s %-35s \n" "Codec:" "${codec_audio}"
printf " %-20s %-35s \n" "Titre:" "${title_audio}"
printf " %-20s %-35s \n" "Language:" "${language_audio}"
printf " %-20s %-35s \n" "Defaut:" "${default_audio}"
if [[ "$nb_text" != 0 ]]; then
echo -e "\n${bold}Text:${reset}"
printf " %-20s %-35s \n" "Format text:" "${format_text}"
printf " %-20s %-35s \n" "Codec:" "${codec_text}"
printf " %-20s %-35s \n" "Language:" "${language_text}"
printf " %-20s %-35s \n" "Defaut:" "${default_text}"
fi
if [[ "$nb_menu" != 0 ]]; then
echo -e "\n${bold}Menu:${reset}"
echo -e "$m"
fi
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}\n"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2> $logfile
result=$?
if [ "$result" = 0 ]; then
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)
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
# if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
# gvfs-trash filepath - gio trash some_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
else
echo -e "\n${italic}Move ${filename} to trash...${reset}"
fi
echo ""
((count++))
else
echo -e "\n${green}$file_export already transcoded !${reset}\n"
fi
FILESIZE=
done
if [ "$count" -eq 0 ]; then
echo -e "\n${red}No file to transcode !${reset}"
else
echo -e "\n${green}${count} files successfully transcoded !${reset}"
fi

24
install_adobe_apps.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
venv_path=$HOME/Documents/venv/
folder=adobeCC
# Virtual environnment
cd $venv_path
python3 -m venv $folder
$folder/bin/pip3 install -U pip setuptools
$folder/bin/pip3 install -U requests tqdm
cd $venv_path$folder
# dl gist
wget https://gist.github.com/ayyybe/a5f01c6f40020f9a7bc4939beeb2df1d/raw/6e82a23d381059a345cdf77fc29595ef11985d31/ccdl.py
# Launch script
echo "#!/usr/bin/env bash" > $folder.command
echo "$venv_path$folder/bin/python3 $venv_path$folder/ccdl.py" > $folder.command
chmod +x $folder.command
# Link in /Applications
ln -s "$venv_path$folder/$folder.command" "/Applications/Adobe CC_Offline_Package_Generator_2"

View File

@@ -4,7 +4,7 @@ echo "* Update gitea *"
echo "****************"
GITEA_BIN=`which gitea`
if [ "$GITEA_BIN" == "*gitea*" ]; then
if [ "$GITEA_BIN" == "*gitea*" ]; then
echo "Gitea is not installed..."
exit 0
fi

View File

@@ -1,5 +1,14 @@
#!/usr/local/bin/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"
if [ "$1" == "-h" ]; then
echo -e "\\033[93mmkbuild.sh\\033[0m"
echo "Build MkDocs project and send him on servers"
@@ -11,7 +20,23 @@ if [ "$1" == "-h" ]; then
exit 0
fi
project_dir=/Users/bruno/project
if ! command -v mkdocs &> /dev/null
then
echo -e "${bold}Mkdocs${reset} could not be found !\n"
echo -e "You should install ${bold}Mkdocs${reset}:\n"
echo -e " - pip install mkdocs"
echo -e " - pipx install mkdocs"
echo -e " - pipx inject mkdocs mkdocs-material mkdocs-material-extensions mkdocs-minify-plugin mkdocs-git-revision-date-localized-plugin mkdocs-pdf-export-plugin fontawesome_markdown"
exit
fi
device=$(hostname)
if [[ "$device" == "airbook.local" ]]; then
project_dir=$HOME/Documents/docs
else
project_dir=$HOME/project
fi
#exe=/usr/local/bin/
folder="central_docs"
@@ -20,73 +45,111 @@ 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
notification() {
path_img=`dirname "$0"`
#path_img=`dirname "$0"`
path_img=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ $3 -eq 0 ];
if [ "$3" -eq 0 ];
then
sound="Glass"
message="Envoi terminé sur $2 !"
image="$path_img/success.png"
else
sound="Basso"
message="Echec lors de l'envoi sur $2 : erreur $result"
message="Echec lors de l'envoi sur $2"
image="$path_img/error.png"
fi
#echo "$image"
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
zenity --title="$1" --notification --text="$message"
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$1" -message "$message" -sound "$sound" -contentImage "$image"
#terminal-notifier -title "$1" -message "$message" -sound "$sound" -appIcon "$image"
fi
}
cd $project_dir || exit
cd "$project_dir" || exit
mkdocs build --clean
echo ""
echo "*********************************************"
echo "* sending Docs to ${server1[server]}... *"
echo "*********************************************"
echo ""
: <<'END_COMMENT'
if [[ "$device" == "airbook" ]]; then
$HOME/Documents/venv/mkdocs/bin/mkdocs build --clean
else
mkdocs build --clean
fi
END_COMMENT
rsync -e '/usr/bin/ssh -p 42666' --exclude-from="$HOME/.exclude-rsync.txt" --rsync-path=/bin/rsync -zarvh --stats --progress "$folder/" ${server1[user]}@${server1[server]}:${server1[dest]}
result=$?
if nmap "${server1[server]}" -PN -p ${server1[port]} | grep open &>/dev/null; then
notification "MkDocs: sending Docs to ${server1[server]}..." "${server1[server]}" $result
echo ""
echo -e "${bold}*********************************************"
echo -e "* Sending Docs to ${server1[server]}... *"
echo -e "*********************************************${reset}"
echo ""
echo ""
echo "***********************************************"
echo "* sending Docs to ${server2[server]}... *"
echo "***********************************************"
echo ""
rsync -e '/usr/bin/ssh -p 42666' --exclude-from="$HOME/.exclude-rsync.txt" --rsync-path=/bin/rsync -zarvh --stats --progress "$folder/" ${server1[user]}@${server1[server]}:${server1[dest]}
result=$?
rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh --stats --progress "$folder/" ${server2[user]}@${server2[server]}:${server2[dest]}
result=$?
notification "MkDocs: sending Docs to ${server1[server]}..." "${server1[server]}" $result
else
notification "Server ${server1[server]} down !" "${server1[server]}" 1
echo -e "\n${bold}${red}Server ${server1[server]} down !${reset}\n"
fi
if nmap "${server2[server]}" -PN -p ${server2[port]} | grep open &>/dev/null; then
echo ""
echo -e "${bold}***********************************************"
echo -e "* Sending Docs to ${server2[server]}... *"
echo -e "***********************************************${reset}"
echo ""
rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh --stats --progress "$folder/" ${server2[user]}@${server2[server]}:${server2[dest]}
result=$?
notification "MkDocs: sending Docs to ${server2[server]}..." "${server2[server]}" $result
else
notification "Server ${server2[server]} down !" "${server2[server]}" 1
echo -e "\n${bold}${red}Server ${server2[server]} down !${reset}\n"
fi
if nmap "${server3[server]}" -PN -p ${server3[port]} | grep open &>/dev/null; then
echo ""
echo -e "${bold}********************************************"
echo -e "* Sending Docs to ${server3[server]}... *"
echo -e "********************************************${reset}"
echo ""
rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh --stats --progress "$folder/" ${server3[user]}@${server3[server]}:${server3[dest]}
result=$?
notification "MkDocs: sending Docs to ${server2[server]}..." "${server2[server]}" $result
notification "MkDocs: sending Docs to ${server3[server]}..." "${server3[server]}" $result
echo ""
echo "********************************************"
echo "* sending Docs to ${server3[server]}... *"
echo "********************************************"
echo ""
else
notification "Server ${server3[server]} down !" "${server3[server]}" 1
echo -e "\n${bold}${red}Server ${server3[server]} down !${reset}\n"
fi
rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh --stats --progress "$folder/" ${server3[user]}@${server3[server]}:${server3[dest]}
result=$?
notification "MkDocs: sending Docs to ${server3[server]}..." "${server3[server]}" $result

37
thumbsup-npm.sh Normal file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
bold="\033[1m"
italic="\033[3m"
reset="\033[0m"
command -v thumbsup >/dev/null 2>&1 || { echo -e "This script require ${bold}thumbsup${reset} but it's not installed.\nRun ${italic}npm install -g thumbsup${reset}\nAborting..." >&2; exit 1; }
thumbsup_folder="/var/www/vhosts/sur-le-sentier.fr/thumbsup"
config_file="config-npm.json"
echo -e "\n|--------------------------------------------|"
echo -e "| |"
echo -e "| ${bold}Thumbsup${reset} |"
echo -e "| - https://thumbsup.github.io/ |"
echo -e "| - https://github.com/thumbsup/thumbsup |"
echo -e "| |"
echo -e "|--------------------------------------------|\n"
echo -e "\n${bold}Thumbsup config and theme folder:${reset} $thumbsup_folder\n"
cd $thumbsup_folder
echo -e "\n${bold}Configuration file:${reset} $thumbsup_folder/$config_file\n"
cat "$config_file"
echo -e "\n${bold}Theme options file:${reset}\n"
cat "theme_options.json"
echo -e "\n\n${bold}Generating gallery...${reset}\n"
thumbsup --config="$config_file"
echo -e "\n${bold}Gallery files:${reset} /var/www/vhosts/sur-le-sentier.fr/httpdocs/gallery"
echo -e "\n${bold}Visit Gallery:${reset} https://sur-le-sentier.fr/gallery"
echo ""

50
upgrade_nextcloud.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
host=$(hostname)
if [ "$host" = "DS916" ]; then
php_version=74
php_bin=/usr/local/bin/php$php_version
nc_dir=/volume1/web/nextcloud
cd $nc_dir || exit
sudo -u http $php_bin -d memory_limit=1024M occ maintenance:mode --on
sudo -u http $php_bin -d memory_limit=1024M occ maintenance:repair
#echo ""
#echo -e "\033[4mWhen the message 'Should the \"occ upgrade\" command be executed? [Y/n]' is displayed, you must choice 'n' (no)\033[0m"
#echo ""
sudo -u http $php_bin -d memory_limit=1024M updater/updater.phar
# Should the "occ upgrade" command be executed? [Y/n] n
# non
#echo ""
#echo -e "\033[4mLa version par défaut de PHP est la 5.6.11, ce qui est insuffisant (7.2 requis). On relance la suite avec la bonne version de php\033[0m"
#echo ""
#sudo -u http $php_bin -d memory_limit=1024M occ maintenance:mode --on
sudo -u http $php_bin -d memory_limit=1024M occ upgrade
sudo -u http $php_bin -d memory_limit=1024M occ maintenance:mode --off
elif [ "$host" == "localhost" ]; then
ip=$(hostname -I | awk '{print $1}')
if [ "$ip" = "212.227.191.167" ]; then
php_version=7.4
php_bin=/opt/plesk/php/$php_version/bin/php
nc_dir=/var/www/vhosts/maboiteverte.fr/httpdocs/nextcloud
cd $nc_dir || exit
sudo -u bruno $php_bin occ maintenance:mode --on
sudo -u bruno $php_bin occ maintenance:repair
sudo -u bruno $php_bin updater/updater.phar
sudo -u bruno $php_bin occ upgrade
sudo -u bruno $php_bin occ maintenance:mode --off
fi
fi

117
venv_solus.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/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"
echo -e "${bold}🐍 Update apps in Python virtuals environments ${reset}\n"
###########################################################
#
# Configuration
#
###########################################################
mkdocs_ext=("mkdocs-material" "mkdocs-material-extensions" "mkdocs-git-revision-date-localized-plugin" "mkdocs-minify-plugin" "fontawesome_markdown" "mkdocs-pdf-export-plugin")
sound="Glass"
image="$BKP_BASE_DIR/success.png"
# macos: silverbook
if [[ "$OSTYPE" == "darwin"* ]]; then
v=$HOME/Documents/venv
# Listes des apps:
declare -a apps=("soco-cli" "mkdocs")
# solus: linux-gnu
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
v=$HOME/Applications
# Listes des apps:
declare -a apps=("soco-cli" "mkdocs")
# rpi4: linux_gnueabihf
# rpi3:
elif [[ "$OSTYPE" == "linux_gnueabihf" ]]; then
v=$HOME/venv
# Listes des apps:
declare -a apps=("soco-cli" "mkdocs")
fi
###########################################################
#
# Script
#
###########################################################
for app in ${apps[*]}
do
echo -e "${bold}Update $app${reset}";
cd "$v/$app"
source bin/activate
python3 -V
pip3 install -U pip setuptools
echo ""
info=$(pip3 show "$app")
l1=$(echo "$info" | sed -n '1p')
l1="\\\033[4m$l1\\\033[0m"
info=$(echo "$info" | sed "1s/.*/$l1/")
echo -e "$info"
upd=$(pip3 install -U "$app")
a=$(grep "Successfully installed" <<< "$upd")
if [ -n "$a" ]; then
if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "Update $app package" -message "" -sound "$sound" -contentImage "$image"
elif [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v notify-send)" ]; then
notify-send -i "/usr/share/icons/Adwaita/48x48/legacy/face-laugh.png" "Update $app package" ""
fi
fi
<<COMMENT
echo ""
avail=$(pip3 list --outdated --format columns | sed '1,2d')
if [ -n "$avail" ]; then
while read i
do
pkg=$(echo "$i" | awk '{print $1}')
b=$(echo "$i" | awk 'NF{NF-=1};1')
#echo "pip3 install -U $pkg"
pip3 install -U "$pkg"
c+="$b\n"
d+="$pkg, "
done <<< "$avail"
title="Update outdated packages in $app venv"
if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$title" -message "$d" -sound "$sound" -contentImage "$image"
elif [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v notify-send)" ]; then
notify-send -i "/usr/share/icons/Adwaita/48x48/legacy/face-laugh.png" "$title" "$c"
fi
fi
COMMENT
# Update mkdocs plugins & themes:
if [ $app == "mkdocs" ]; then
for i in ${mkdocs_ext[*]}
do
echo -e "\n${bold}Update $i:${reset}" && pip3 install -U $i
done
fi
deactivate
echo ""
done