Compare commits
47 Commits
Brew_PHP_s
...
aaf3776e62
| Author | SHA1 | Date | |
|---|---|---|---|
| aaf3776e62 | |||
| 4675acdd0d | |||
| e85e16190f | |||
| 1415706fec | |||
| 7ab0771eb9 | |||
| f37dbcf4d0 | |||
| d6439437e1 | |||
| 17a975effa | |||
| ef91f1a68e | |||
| c2ece3fefc | |||
| d8aa2777be | |||
| ade806d162 | |||
| 76bc76a872 | |||
| b84d11cd18 | |||
| 240d5457ef | |||
| 7a5cd20024 | |||
| bb2b797bac | |||
| 37e61286c8 | |||
| 5d57207bb8 | |||
| d5020f5e55 | |||
| c1ae96f4d0 | |||
| 217bfb2f52 | |||
| 9bf07ab9c7 | |||
| b69f54cd4e | |||
| 5dfc07918d | |||
|
f23fa229dc
|
|||
|
86cfb95f27
|
|||
|
f128ece768
|
|||
|
4341a6a667
|
|||
|
96877df4dc
|
|||
|
2219d769e6
|
|||
|
4dd8279d35
|
|||
|
2b295b74e4
|
|||
|
733e69d6dd
|
|||
|
3e150d6235
|
|||
|
96b1f9d772
|
|||
|
84a4aef5f1
|
|||
|
5bc89e08a4
|
|||
|
1323857b0f
|
|||
|
fb35ec9e8e
|
|||
|
2108a54086
|
|||
|
474e815118
|
|||
|
385d175e02
|
|||
|
7f8ba8d3c6
|
|||
|
45718462ca
|
|||
|
497cc8996a
|
|||
|
da3e666d9f
|
17
README.md
Normal file
17
README.md
Normal 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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -54,15 +56,16 @@ 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 (Brew PHP switcher)"
|
||||
#"(U)pdate sphp"
|
||||
"S(w)itch to PHP version"
|
||||
"(U)pdate sphp"
|
||||
"Edit additio(n)nals *.ini files"
|
||||
"(Q)uit"
|
||||
)
|
||||
|
||||
# sphp:
|
||||
# https://gist.github.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/
|
||||
# remplacé par Brew PHP switcher
|
||||
# --> 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
|
||||
@@ -76,12 +79,12 @@ select option in "${options[@]}"; do
|
||||
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 ' ' && 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.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 brew-php-switcher ; fi ;;
|
||||
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 ;;
|
||||
|
||||
215
apache_tools_v2.sh
Executable file
215
apache_tools_v2.sh
Executable file
@@ -0,0 +1,215 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
underline="\033[4m"
|
||||
red="\033[1;31m"
|
||||
green="\033[1;32m"
|
||||
yellow="\033[1;33m"
|
||||
bold="\033[1m"
|
||||
reset="\033[0m"
|
||||
|
||||
homebrew_path=$(brew --prefix)
|
||||
editeur=/usr/local/bin/bbedit
|
||||
|
||||
# apache
|
||||
v_apache=$(apachectl -v | sed -n '1p' | awk -F":" '{print $2}' | xargs)
|
||||
conf_apache=$(httpd -V | grep 'SERVER_CONFIG_FILE' | awk -F "\"" '{print $2}')
|
||||
document_root=$(grep -e '^DocumentRoot' "$conf_apache" | awk '{print $2}' | sed 's/\"//g')
|
||||
log_apa=$(grep -e '^ErrorLog' "$conf_apache" | awk -F "\"" '{print $2}')
|
||||
access_apa=$(grep -e 'CustomLog' "$conf_apache" | grep -v "#" | awk -F "\"" '{print $2}')
|
||||
vhost=$(grep -e 'httpd-vhosts.conf' "$conf_apache" | awk '{print $2}')
|
||||
ssl=$(grep -e 'httpd-ssl.conf' "$conf_apache" | awk '{print $2}')
|
||||
config_apache=()
|
||||
config_apache+=("$conf_apache")
|
||||
config_apache+=("$vhost")
|
||||
config_apache+=("$ssl")
|
||||
|
||||
|
||||
# PHP
|
||||
declare -a additionnal=()
|
||||
|
||||
add_ini() {
|
||||
|
||||
# Current php version (from httpd.conf)
|
||||
ip=$(grep -E SetHandler $conf_apache | grep -v \# | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}:[0-9]{4}")
|
||||
x=${ip: -2}
|
||||
current_simple_php_version="${x:0:1}.${x:1}"
|
||||
current_php_version="php@${x:0:1}.${x:1}"
|
||||
v_php=$($homebrew_path/opt/$current_php_version/bin/php -v)
|
||||
|
||||
php_ini="$homebrew_path/etc/php/$current_simple_php_version/php.ini"
|
||||
|
||||
conf_php=()
|
||||
conf_php+=("$php_ini")
|
||||
conf_php+=("$homebrew_path/etc/php/$current_simple_php_version/php-fpm.d/www.conf")
|
||||
|
||||
addconf_php=$(find "$homebrew_path/etc/php/$current_simple_php_version/conf.d" -name "*.ini" | sort -n)
|
||||
|
||||
z=0
|
||||
additionnal=()
|
||||
for i in $addconf_php
|
||||
do
|
||||
additionnal+=("$addconf_dir$i")
|
||||
done
|
||||
|
||||
conf_php+=(${additionnal[@]})
|
||||
}
|
||||
|
||||
|
||||
# MySQL
|
||||
my=$(mysql --help | grep -A1 'Default options' | grep '.my.cnf')
|
||||
conf_mysql=($my)
|
||||
v_mysql=$(mysql -V | awk -F"," '{print $1}' | xargs)
|
||||
|
||||
|
||||
# Functions
|
||||
error_log(){
|
||||
tail -f "$log_apa" &
|
||||
tailpid=$!
|
||||
sleep 0.25
|
||||
read -p "< Press Enter to quit tail ! >"
|
||||
|
||||
kill $tailpid
|
||||
}
|
||||
|
||||
acces_log(){
|
||||
tail -f "$access_apa" &
|
||||
tailpid=$!
|
||||
sleep 0.25
|
||||
read -p "< Press Enter to quit tail ! >"
|
||||
|
||||
kill $tailpid
|
||||
}
|
||||
|
||||
entete(){
|
||||
v_php_short=$(echo "$v_php" | sed -n '1p' )
|
||||
printf "Apache: %s\n" "$v_apache"
|
||||
printf "PHP: %s\n" "$v_php_short"
|
||||
printf "MySQL: %s\n" "$v_mysql"
|
||||
echo ""
|
||||
}
|
||||
|
||||
versions(){
|
||||
echo -e "\n${underline}Apache/PHP/MySQL Version:${reset}\n"
|
||||
|
||||
apachectl -v
|
||||
echo ""
|
||||
$homebrew_path/opt/$current_php_version/bin/php -v
|
||||
echo ""
|
||||
mysql --version
|
||||
echo ""
|
||||
read -p "< Press Enter>"
|
||||
}
|
||||
|
||||
conf_files(){
|
||||
echo -e "\n${underline}Apache/PHP/MySQL Configuration files:${reset}\n"
|
||||
|
||||
echo -e "\033[4mApache:\033[0m " #&& echo $conf_apache
|
||||
for line in "${config_apache[@]}"
|
||||
do
|
||||
echo -e " ● $line"
|
||||
done
|
||||
|
||||
|
||||
echo
|
||||
echo -e "\033[4mPHP:\033[0m " # && echo "$conf_php"
|
||||
for line in "${conf_php[@]}"
|
||||
do
|
||||
echo -e " ● $line"
|
||||
done
|
||||
|
||||
echo
|
||||
echo -e "\033[4mMySQL:\033[0m "
|
||||
for line in "${conf_mysql[@]}"
|
||||
do
|
||||
echo -e " ● $line"
|
||||
done
|
||||
|
||||
echo
|
||||
read -p "< Press Enter>"
|
||||
}
|
||||
|
||||
submenu(){
|
||||
options2=("${additionnal[@]}" "(M)enu")
|
||||
echo "Edit which file ?: "
|
||||
select opt in "${options2[@]}"; do
|
||||
[[ $opt == "(M)enu" ]] || [[ $REPLY == "m" ]] || [[ $REPLY == "M" ]] && menu;
|
||||
[[ -z $opt ]] && echo "Wrong choice !"
|
||||
[[ -n $opt ]] && "$editeur" "$opt";
|
||||
done
|
||||
}
|
||||
|
||||
switch_php(){
|
||||
php_installed_array=()
|
||||
|
||||
for i in $(ls $homebrew_path/etc/php/); do
|
||||
[[ -d "$homebrew_path/etc/php/$i" ]] && php_installed_array+=("$i");
|
||||
done
|
||||
php_installed_array+=("(M)enu" "Help")
|
||||
|
||||
echo -e "\nCurrent PHP: $current_simple_php_version"
|
||||
echo "Switch to PHP: "
|
||||
select version in "${php_installed_array[@]}"; do
|
||||
[[ $version == "(M)enu" ]] || [[ $REPLY == "m" ]] || [[ $REPLY == "M" ]] && menu;
|
||||
[[ $version == "Help" ]] && echo "Only currently PHP installed are displayed. To switch to another PHP version, install it before (brew install php@8.3) !";
|
||||
[[ -z $version ]] && [ "$version" != "Help" ] && echo "Wrong choice !"
|
||||
[[ -n $version ]] && [ "$version" != "Help" ] && echo "$version" | xargs -p -n 1 sphp && menu;
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Main menu
|
||||
menu(){
|
||||
|
||||
add_ini
|
||||
|
||||
options=(
|
||||
"Apache (r)estart"
|
||||
"(E)dit httpd.conf"
|
||||
"Edit httpd-v(h)osts.conf"
|
||||
"Edit httpd-(s)sl.conf"
|
||||
"error_(l)og Apache"
|
||||
"(a)ccess_log Apache"
|
||||
"Edit (P)HP.ini"
|
||||
"Edit additio(n)nals *.ini files"
|
||||
"Open PHP (i)nfo page in browser"
|
||||
"S(w)itch to PHP version"
|
||||
"Apache/PHP/MySQL (V)ersion"
|
||||
"Apache/PHP/MySQL (C)onfiguration 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
|
||||
|
||||
|
||||
echo -e "\n\033[1mApache Tools: \033[0m\n"
|
||||
entete
|
||||
|
||||
select option in "${options[@]}"; do
|
||||
case "$REPLY" in
|
||||
1|r|R) sudo apachectl -k restart ; menu ;;
|
||||
2|e|E) "$editeur" "$conf_apache" ;; # httpd.conf
|
||||
3|h|H) "$editeur" "$vhost" ; menu ;; # httpd-vhost.conf
|
||||
4|s|S) "$editeur" "$ssl" ; menu ;; # httpd-ssl.conf
|
||||
5|l|L) command -v ttab >/dev/null 2>&1 && ttab tail -f "$log_apa" || error_log ; menu ;;
|
||||
6|a|A) command -v ttab >/dev/null 2>&1 && ttab tail -f "$access_apa" || acces_log ; menu ;;
|
||||
7|p|P) "$editeur" "$php_ini" ; menu ;; # php.ini
|
||||
8|n|N) submenu ;;
|
||||
9|i|I) echo '<?php echo phpinfo(); ?>' > $document_root/php-info.php && open 'http://localhost/php-info.php' ;;
|
||||
10|w|W) switch_php; menu ;;
|
||||
#read -e -n 3 -p "Which PHP version? (7.4/8.0/8.1/8.2/8.3): " choice
|
||||
#if [[ "$choice" == "7.4" ]] || [[ "$choice" == "8.0" ]] || [[ "$choice" == "8.1" ]] || [[ "$choice" == "8.2" ]] || [[ "$choice" == "8.3" ]]; then echo "$choice" | xargs -p -n 1 sphp ; fi ; menu ;;
|
||||
11|v|V) versions ; menu ;;
|
||||
12|c|C) conf_files ; menu ;;
|
||||
13|q|Q) exit 0 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
menu
|
||||
|
||||
17
api_deepl.sh
Executable file
17
api_deepl.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
[ ! -f "$HOME/.env" ] || export $(grep -v '^#' "$HOME/.env" | xargs)
|
||||
|
||||
# DE/FR/ES/EN-GB/EN-US
|
||||
|
||||
translate() {
|
||||
|
||||
deepl=$(curl -s -X POST 'https://api-free.deepl.com/v2/translate' \
|
||||
--header "Authorization: DeepL-Auth-Key $DEEPL_KEY" \
|
||||
--data-urlencode "text=$2" \
|
||||
--data-urlencode "target_lang=$1"
|
||||
)
|
||||
echo "$deepl" | jq -r .'translations[].text'
|
||||
}
|
||||
|
||||
translate "DE" "il fait beau !"
|
||||
@@ -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
22
backup_Joplin.sh
Executable 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 $?
|
||||
22
backup_conf.sh
Executable file
22
backup_conf.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
dest=$HOME/Documents/conf
|
||||
|
||||
cp /opt/homebrew/etc/httpd/other/boiteverte.conf "$dest"
|
||||
cp /opt/homebrew/etc/httpd/other/clicclac.conf "$dest"
|
||||
cp /opt/homebrew/etc/httpd/other/sentier.conf "$dest"
|
||||
cp /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf "$dest"
|
||||
cp /opt/homebrew/etc/httpd/extra/httpd-ssl.conf "$dest"
|
||||
cp /opt/homebrew/etc/httpd/httpd.conf "$dest"
|
||||
cp -r /opt/homebrew/etc/httpd/certs "$dest"
|
||||
|
||||
#cp /opt/homebrew/etc/php/8.1/conf.d/imagick.ini "$dest"
|
||||
#cp /opt/homebrew/etc/php/8.1/php-fpm.conf "$dest"
|
||||
#cp /opt/homebrew/etc/php/8.1/php.ini "$dest"
|
||||
#cp /opt/homebrew/etc/php/8.1/php-fpm.d/www.conf "$dest"
|
||||
#cp /opt/homebrew/etc/php/8.2/php.ini "$dest"
|
||||
#cp -r /opt/homebrew/etc/php/8.1/conf.d "$dest"
|
||||
#cp /opt/homebrew/etc/php/8.1/pear.conf "$dest"
|
||||
|
||||
cp /opt/homebrew/etc/redis-sentinel.conf "$dest"
|
||||
cp /opt/homebrew/etc/redis.conf "$dest"
|
||||
142
backup_mysql.sh
142
backup_mysql.sh
@@ -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
85
backup_vps.sh
Normal 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"
|
||||
|
||||
28
backups_conf.sh
Executable file
28
backups_conf.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
bold="\033[1m"
|
||||
bold_ita="\033[1;3m"
|
||||
box="\033[1;41m"
|
||||
redbold="\033[1;31m"
|
||||
redbox="\033[1;41m"
|
||||
green="\033[0;32m"
|
||||
reset="\033[0m"
|
||||
|
||||
|
||||
cp -r /opt/homebrew/etc/httpd /Users/bruno/Documents/webserver
|
||||
|
||||
cp -r /opt/homebrew/etc/php /Users/bruno/Documents/webserver
|
||||
|
||||
cp /opt/homebrew/etc/my.cnf /Users/bruno/Documents/webserver
|
||||
cp -r /opt/homebrew/etc/my.cnf.d/ /Users/bruno/Documents/webserver
|
||||
|
||||
cp /opt/homebrew/etc/phpmyadmin.config.inc.php /Users/bruno/Documents/webserver
|
||||
|
||||
cp /opt/homebrew/etc/redis.conf /Users/bruno/Documents/webserver
|
||||
cp /opt/homebrew/etc/redis-sentinel.conf /Users/bruno/Documents/webserver
|
||||
5
bash_version.sh
Executable file
5
bash_version.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# https://itnext.io/upgrading-bash-on-macos-7138bd1066ba
|
||||
|
||||
echo $BASH_VERSION
|
||||
292
convert-videos-for-plex.sh
Executable file
292
convert-videos-for-plex.sh
Executable 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
|
||||
76
crypt.sh
Executable file
76
crypt.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# using aesutil
|
||||
#SALT=$(mkrand 15) # mkrand generates a 15-character random passwd
|
||||
#MYENCPASS="i/b9pkcpQAPy7BzH2JlqHVoJc2mNTBM=" # echo "passwd" | aes -e -b -B -p $SALT
|
||||
#MYPASS=$(echo "$MYENCPASS" | aes -d -b -p $SALT)
|
||||
|
||||
# and usage
|
||||
#serverControl.sh -u admin -p $MYPASS -c shutdown
|
||||
|
||||
|
||||
|
||||
|
||||
echo 'rusty!herring.pitshaft' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.'
|
||||
# U2FsdGVkX199dZHjA0wtjtt0OapR8EOpVwZ5mPqN3JJd40yhCS3fYYxEflQTXTwr
|
||||
|
||||
echo "U2FsdGVkX199dZHjA0wtjtt0OapR8EOpVwZ5mPqN3JJd40yhCS3fYYxEflQTXTwr" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.'
|
||||
|
||||
|
||||
|
||||
|
||||
echo 'rusty!herring.pitshaft' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.' > .secret_vault.txt
|
||||
|
||||
# chmod 600 .secret_vault.txt
|
||||
cat .secret_vault.txt | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:'sjkXF*4kX.@9mh-ut8y.'
|
||||
#rusty!herring.pitshaft
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Load environment variables from .env file
|
||||
[ ! -f .env ] || export $(grep -v '^#' .env | xargs) # export $(grep -v '^#' .env | xargs -0)
|
||||
# while read line; do export $line; done < .env
|
||||
|
||||
Example of .env file:
|
||||
|
||||
# Database settings
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_NAME=mydatabase
|
||||
DB_USER=myuser
|
||||
DB_PASSWORD=mypassword
|
||||
|
||||
# API keys
|
||||
API_KEY=abc123
|
||||
SECRET_KEY=def456
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DB_NAME=mydb
|
||||
DB_PASSWORD=abcd1234
|
||||
|
||||
source my_custom.env
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set -o allexport
|
||||
source conf-file
|
||||
set +o allexport
|
||||
|
||||
set -a
|
||||
. ./env.txt
|
||||
set +a
|
||||
|
||||
# .env loading in the shell
|
||||
dotenv () {
|
||||
set -a
|
||||
[ -f .env ] && . .env
|
||||
set +a
|
||||
}
|
||||
28
curl2.sh
Executable file
28
curl2.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
folder=Janvier
|
||||
|
||||
for file in /Users/bruno/Pictures/_Canon/Export/2023/Janvier/*
|
||||
do
|
||||
#curl -u username:password -T ${file} http://www.example.com/folder/${file}
|
||||
|
||||
# crée l'arborescence
|
||||
#/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo --ftp-create-dirs -T ${file} sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/${file}
|
||||
|
||||
/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -T ${file} sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/${folder}/${file}/
|
||||
|
||||
done
|
||||
|
||||
|
||||
#ok
|
||||
#find /Users/bruno/Pictures/_Canon/Export/2023/Janvier/ -type f | xargs -L 1 bash -c '/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -T $1 sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/${1##*/}' \;
|
||||
|
||||
# ok
|
||||
# /opt/homebrew/opt/curl/bin/curl -i -v --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -O sftp://ftp.cluster011.ovh.net:22/home/funnymac/8_2022.jpg
|
||||
|
||||
# OK
|
||||
# /opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo -T '{2023-01-31_RuBlanc_0627,2023-01-31_RuBlanc_0623}.jpg' sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/ \;
|
||||
|
||||
# ok
|
||||
# find /Users/bruno/Desktop/Juin -type f | xargs -L 1 bash -c '/opt/homebrew/opt/curl/bin/curl --user funnymac:a3XELN4PHTYF9fFHtsY97eshXBxxFo --ftp-create-dirs --output-dir 'juin' -T $1 sftp://ftp.cluster011.ovh.net:22/home/funnymac/www/ftp/juin/${1##*/}' \;
|
||||
|
||||
68
exiftool.sh
Executable file
68
exiftool.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#! /bin/bash
|
||||
function usage {
|
||||
echo "usage: $0 -ms path_of_file"
|
||||
echo " -m to remove useless exif entries"
|
||||
echo " -s to show current exif entries"
|
||||
exit -1
|
||||
}
|
||||
if [ $# != 2 ]; then
|
||||
usage
|
||||
fi
|
||||
OP=$1
|
||||
SRC=$2
|
||||
if [ ! -f $SRC ]; then
|
||||
echo "error: file not found"
|
||||
exit -2
|
||||
fi
|
||||
if [ $OP = "-m" ]; then
|
||||
cp "$SRC" "$SRC"."_tmp"
|
||||
exiftool -all= "$SRC"
|
||||
exiftool -overwrite_original
|
||||
-TagsFromFile "$SRC"."_tmp"
|
||||
-ExposureTime
|
||||
-FNumber
|
||||
-ExposureProgram
|
||||
-ISO
|
||||
-DateTimeOriginal
|
||||
-CreateDate
|
||||
-ExposureCompensation
|
||||
-MaxApertureValue
|
||||
-MeteringMode
|
||||
-LightSource
|
||||
-Flash
|
||||
-FocalLength
|
||||
-SubSecTime
|
||||
-SubSecTimeOriginal
|
||||
-SubSecTimeDigitized
|
||||
-ColorSpace
|
||||
-ExifImageWidth
|
||||
-ExifImageHeight
|
||||
-SensingMethod
|
||||
-CustomRendered
|
||||
-ExposureMode
|
||||
-WhiteBalance
|
||||
-DigitalZoomRatio
|
||||
-FocalLengthIn35mmFormat
|
||||
-SceneCaptureType
|
||||
-GainControl
|
||||
-Contrast
|
||||
-Saturation
|
||||
-Sharpness
|
||||
-SubjectDistanceRange
|
||||
-GPSVersionID
|
||||
-GPSLatitudeRef
|
||||
-GPSLatitude
|
||||
-GPSLongitudeRef
|
||||
-GPSLongitude
|
||||
-Make
|
||||
-Model
|
||||
"$SRC"
|
||||
exiftool -delete_original! "$SRC"
|
||||
rm -f "$SRC"."_tmp"
|
||||
else
|
||||
if [ $OP = "-s" ]; then
|
||||
exiftool "$SRC"
|
||||
else
|
||||
usage
|
||||
fi
|
||||
fi
|
||||
10
git-sparse.sh
Executable file
10
git-sparse.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function git-scp() (
|
||||
URL="$1" && shift 1
|
||||
svn export ${URL/blob\/master/trunk}
|
||||
)
|
||||
|
||||
# svn export --force https://github.com/jaysalvat/vegas/trunk/dist
|
||||
|
||||
git-scp https://github.com/jaysalvat/vegas/trunk/dist
|
||||
16
git_reachable.sh
Executable file
16
git_reachable.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#url="git@gitea.maboiteverte.fr:shell/bash_mbv.git"
|
||||
url="https://clicclac.synology.me:3000/shell/bash.git"
|
||||
url="bruno@dsm916e:/volume1/Repositories/bash.git"
|
||||
url="https://Bruno21@github.com/Bruno21/kymsu.git"
|
||||
|
||||
## Returns errlvl 0 if $1 is a reachable git remote url
|
||||
git-remote-url-reachable() {
|
||||
git ls-remote "$1" CHECK_GIT_REMOTE_URL_REACHABILITY >/dev/null 2>&1
|
||||
}
|
||||
|
||||
if git-remote-url-reachable "$url"; then
|
||||
## code
|
||||
echo "reachable !"
|
||||
fi
|
||||
83
gitea.service
Normal file
83
gitea.service
Normal file
@@ -0,0 +1,83 @@
|
||||
[Unit]
|
||||
Description=Gitea (Git with a cup of tea)
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
###
|
||||
# Don't forget to add the database service dependencies
|
||||
###
|
||||
#
|
||||
#Wants=mysql.service
|
||||
#After=mysql.service
|
||||
#
|
||||
#Wants=mariadb.service
|
||||
#After=mariadb.service
|
||||
#
|
||||
#Wants=postgresql.service
|
||||
#After=postgresql.service
|
||||
#
|
||||
#Wants=memcached.service
|
||||
#After=memcached.service
|
||||
#
|
||||
#Wants=redis.service
|
||||
#After=redis.service
|
||||
#
|
||||
###
|
||||
# If using socket activation for main http/s
|
||||
###
|
||||
#
|
||||
#After=gitea.main.socket
|
||||
#Requires=gitea.main.socket
|
||||
#
|
||||
###
|
||||
# (You can also provide gitea an http fallback and/or ssh socket too)
|
||||
#
|
||||
# An example of /etc/systemd/system/gitea.main.socket
|
||||
###
|
||||
##
|
||||
## [Unit]
|
||||
## Description=Gitea Web Socket
|
||||
## PartOf=gitea.service
|
||||
##
|
||||
## [Socket]
|
||||
## Service=gitea.service
|
||||
## ListenStream=<some_port>
|
||||
## NoDelay=true
|
||||
##
|
||||
## [Install]
|
||||
## WantedBy=sockets.target
|
||||
##
|
||||
###
|
||||
|
||||
[Service]
|
||||
# Modify these two values and uncomment them if you have
|
||||
# repos with lots of files and get an HTTP error 500 because
|
||||
# of that
|
||||
###
|
||||
#LimitMEMLOCK=infinity
|
||||
#LimitNOFILE=65535
|
||||
RestartSec=2s
|
||||
Type=simple
|
||||
User=git
|
||||
Group=users
|
||||
WorkingDirectory=/var/lib/gitea/
|
||||
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
|
||||
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
|
||||
#RuntimeDirectory=gitea
|
||||
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
|
||||
Restart=always
|
||||
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
|
||||
# If you install Git to directory prefix other than default PATH (which happens
|
||||
# for example if you install other versions of Git side-to-side with
|
||||
# distribution version), uncomment below line and add that prefix to PATH
|
||||
# Don't forget to place git-lfs binary on the PATH below if you want to enable
|
||||
# Git LFS support
|
||||
#Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin
|
||||
# If you want to bind Gitea to a port below 1024, uncomment
|
||||
# the two values below, or use socket activation to pass Gitea its ports as above
|
||||
###
|
||||
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||
#AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
###
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
587
handbrake_for_plex.sh
Executable file
587
handbrake_for_plex.sh
Executable file
@@ -0,0 +1,587 @@
|
||||
#!/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
|
||||
|
||||
# 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 (> 30Mo)
|
||||
MAXSIZE=30000000
|
||||
#MAXSIZE=300
|
||||
|
||||
# Open converted video file in an application
|
||||
APP="Subler"
|
||||
|
||||
SUBTITLE_LIST="eng,fre"
|
||||
|
||||
# log
|
||||
# this reduce handbrake verbosity
|
||||
#logfile=/tmp/HandBrake.log
|
||||
logfolder=/var/log/handbrake_for_plex
|
||||
logfile="$logfolder"/HandBrake.log
|
||||
|
||||
if [ ! -w "$logfile" ]; then
|
||||
sudo mkdir "$logfolder"
|
||||
sudo chown bruno:staff "$logfolder"
|
||||
sudo touch "$logfile"
|
||||
sudo chown bruno:staff "$logfile"
|
||||
sudo chmod 640 "$logfile"
|
||||
fi
|
||||
|
||||
logsize=$(wc -c <"$logfile")
|
||||
|
||||
if [ $logsize -ge 1000 ]; then
|
||||
cp "$logfile" "$logfile.old"
|
||||
truncate -s 0 "$logfile"
|
||||
fi
|
||||
|
||||
|
||||
#Move to trash after conversion
|
||||
trash=true
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
)
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
installation() {
|
||||
#long_path=`pwd`"/"`basename "$0"`
|
||||
long_path=$(realpath "$0")
|
||||
|
||||
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")
|
||||
install_path=${choice:5}
|
||||
|
||||
else
|
||||
read -e -p "Choose the install's path: " install_path
|
||||
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}This folder does not exist !${reset}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
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: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
|
||||
done
|
||||
|
||||
# Reset OPTIND
|
||||
shift $((OPTIND-1))
|
||||
|
||||
|
||||
|
||||
|
||||
###
|
||||
|
||||
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:
|
||||
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
|
||||
# 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%.*}
|
||||
|
||||
declare -a ft=()
|
||||
declare -a ct=()
|
||||
declare -a tt=()
|
||||
declare -a lt=()
|
||||
declare -a dt=()
|
||||
|
||||
: <<'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
|
||||
|
||||
# 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"
|
||||
# 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
|
||||
|
||||
#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
|
||||
nb_text=$(echo "$general" | jq -j '.TextCount')
|
||||
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
|
||||
|
||||
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 )')
|
||||
fi
|
||||
|
||||
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 )')
|
||||
format_commercial=$(echo "$audio" | jq -j '.Format_Commercial_IfAny | select( . != null )')
|
||||
codec_audio=$(echo "$audio" | jq -j '.CodecID | select( . != null )')
|
||||
title_audio=$(echo "$audio" | jq -j '.Title | select( . != null )')
|
||||
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
|
||||
|
||||
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 )')
|
||||
language_text=$(echo "$text" | jq -j '.Language | select( . != null )')
|
||||
default_text=$(echo "$text" | jq -j '.Default | select( . != null )')
|
||||
|
||||
ft+=("$format_text")
|
||||
ct+=("$codec_text")
|
||||
tt+=("$title_text")
|
||||
lt+=("$language_text")
|
||||
dt+=("$default_text")
|
||||
|
||||
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",
|
||||
|
||||
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
|
||||
|
||||
t=$(echo "$line" | awk -F": " '{print $1}')
|
||||
c=$(echo "$line" | awk -F": " '{print $2}')
|
||||
#echo "t: $t"
|
||||
#echo "c: $c"
|
||||
# L'apparition
|
||||
# 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.*//')
|
||||
#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"
|
||||
#echo "cc: $cc"
|
||||
# L'apparition
|
||||
# tt: 00h07mm57
|
||||
# cc: en:00:07:57.920
|
||||
|
||||
#m+=("$n:$tt")
|
||||
m+=("$n:$cc ($tt)")
|
||||
((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}"
|
||||
printf " %-20s %-35s \n" "Duree:" "${duree}"
|
||||
|
||||
echo -e "\n${bold}Video:${reset}"
|
||||
printf " %-20s %-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" "Format commercial:" "${format_commercial}"
|
||||
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" -ge 1 ]; then
|
||||
# echo -e "\n${bold}Text:${reset}"
|
||||
# printf " %-20s %-35s \n" "Titre:" "${title_text}"
|
||||
# printf " %-20s %-35s \n" "Format:" "${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_text" -ge 1 ]; then
|
||||
|
||||
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]}"
|
||||
printf " %-20s %-35s \n" "Codec:" "${ct[$val]}"
|
||||
printf " %-20s %-35s \n" "Language:" "${lt[$val]}"
|
||||
printf " %-20s %-35s \n" "Defaut:" "${dt[$val]}"
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if [ "$nb_menu" -ge 1 ]; then
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
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}"
|
||||
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 ""
|
||||
|
||||
else
|
||||
echo -e "\n${green}$file_export already transcoded !${reset}\n"
|
||||
((already_transcoded+=1))
|
||||
fi
|
||||
|
||||
|
||||
FILESIZE=
|
||||
|
||||
done
|
||||
|
||||
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}"
|
||||
fi
|
||||
|
||||
|
||||
46
iconv.sh
Executable file
46
iconv.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
red="\033[1;31m"
|
||||
greenbold="\033[1;32m"
|
||||
green="\033[0;32m"
|
||||
yellow="\033[0;33m"
|
||||
bold="\033[1m"
|
||||
#bold_under="\033[1;4m"
|
||||
underline="\033[4m"
|
||||
reset="\033[0m"
|
||||
|
||||
|
||||
insta=false # #Becasseauvariable #LeTeich #Bird
|
||||
flickr=true # "Bécasseau variable" "Le Teich" Bird
|
||||
ccpx=true # Bécasseau variable, Le Teich, Bird
|
||||
|
||||
# Tags automatically added
|
||||
# You can add tags to this 4 arrays
|
||||
|
||||
wild=("wildlife" "wildlifephoto" "wildlifephotographer")
|
||||
nat=("naturelovers" "natureshot" "naturephotography")
|
||||
reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or")
|
||||
#cinqcent=("Bécasseau variable" "Le Teich" "Bird")
|
||||
|
||||
|
||||
|
||||
for i in "${reg[@]}"
|
||||
do
|
||||
if [[ "$i" = *" "* ]]; then
|
||||
region_flickr+="\"${i}\" "
|
||||
#region_ccpx+="${i},"
|
||||
else
|
||||
region_flickr+="${i} "
|
||||
#region_ccpx+="${i},"
|
||||
fi
|
||||
|
||||
###
|
||||
region_ccpx+="${i},"
|
||||
|
||||
#region_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
|
||||
region_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ASCII//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
|
||||
done
|
||||
|
||||
echo "$region_flickr"
|
||||
echo "$region_insta"
|
||||
echo "$region_ccpx"
|
||||
24
install_adobe_apps.sh
Executable file
24
install_adobe_apps.sh
Executable 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"
|
||||
18
latest_release_on_github.sh
Executable file
18
latest_release_on_github.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Usage: ./latest_release_on_github.sh trunk-rs/trunk
|
||||
|
||||
a=$(curl --silent "https://api.github.com/repos/$1/releases/latest")
|
||||
|
||||
body=$(echo "$a" | grep '"body":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
echo -e "$body"
|
||||
tag=$(echo "$a" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
echo -e "$tag"
|
||||
|
||||
get_latest_release() {
|
||||
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
|
||||
#grep '"tag_name":' | # Get tag line
|
||||
grep '"body":' #|
|
||||
#sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
|
||||
}
|
||||
|
||||
127
mkbuild.sh
127
mkbuild.sh
@@ -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,113 @@ 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
|
||||
# Failed to resolve "ftp.cluster011.ovh.net".
|
||||
# WARNING: No targets were specified, so 0 hosts scanned.
|
||||
|
||||
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
|
||||
|
||||
138
ovh_api.sh
Executable file
138
ovh_api.sh
Executable file
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ovh_secrets.txt
|
||||
|
||||
HTTP_QUERY="https://api.ovh.com/1.0/domain"
|
||||
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
|
||||
|
||||
ZONE_FILE="zone.photos-nas.ovh"
|
||||
ZONE="photos-nas.ovh"
|
||||
|
||||
# zone export
|
||||
|
||||
export_zone() {
|
||||
HTTP_METHOD="GET"
|
||||
HTTP_BODY=""
|
||||
HTTP_QUERY="https://eu.api.ovh.com/v1/domain/zone/$ZONE/export"
|
||||
|
||||
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
|
||||
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
|
||||
|
||||
curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY | sed 's/\\n/\n/g' | sed 's/\"//g' | grep 'CNAME'> $ZONE_FILE
|
||||
#curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY | sed 's/\\n/\n/g' | grep 'CNAME'
|
||||
# |sed 's/,//g' |sed 's/\\n/\'$'\n''/g'
|
||||
# | sed 's/\\n/\n/g'
|
||||
echo $?
|
||||
if [ $? == 0 ]; then
|
||||
echo "$ZONE_FILE have been created !"
|
||||
fi
|
||||
}
|
||||
|
||||
#export_zone
|
||||
cat $ZONE_FILE
|
||||
|
||||
refresh() {
|
||||
HTTP_BODY=""
|
||||
HTTP_QUERY="https://eu.api.ovh.com/v1/domain/zone/$ZONE/refresh"
|
||||
|
||||
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
|
||||
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
|
||||
|
||||
curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY
|
||||
echo $? # 0
|
||||
if [ $? == 0 ]; then
|
||||
echo "Zone $ZONE have been successfully refresh !"
|
||||
else
|
||||
echo "Error while refreshing zone $ZONE !"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# ajout d'un cname
|
||||
|
||||
add_cname() {
|
||||
HTTP_METHOD="POST"
|
||||
HTTP_BODY="{\"fieldType\": \"CNAME\",\"subDomain\": \"$1\",\"target\": \"photos-nas.ovh.\",\"ttl\": 0}"
|
||||
HTTP_QUERY="https://eu.api.ovh.com/v1/domain/zone/$ZONE/record"
|
||||
|
||||
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
|
||||
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
|
||||
|
||||
curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY
|
||||
echo $? # null
|
||||
if [ $? == 0 ]; then
|
||||
echo "CNAME $1 have been successfully added !"
|
||||
else
|
||||
echo "Error adding CNAME $1 !"
|
||||
fi
|
||||
|
||||
HTTP_BODY=""
|
||||
HTTP_QUERY="https://eu.api.ovh.com/v1/domain/zone/$ZONE/refresh"
|
||||
|
||||
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
|
||||
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
|
||||
|
||||
curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY
|
||||
echo $? # 0
|
||||
if [ $? == 0 ]; then
|
||||
echo "Zone $ZONE have been successfully refresh !"
|
||||
else
|
||||
echo "Error while refreshing zone $ZONE !"
|
||||
fi
|
||||
}
|
||||
|
||||
add_cname "ntfy"
|
||||
|
||||
|
||||
remove_cname() {
|
||||
record=""
|
||||
|
||||
HTTP_METHOD="GET"
|
||||
HTTP_BODY=""
|
||||
HTTP_QUERY="https://eu.api.ovh.com/v1/domain/zone/$ZONE/record?fieldType=CNAME&subDomain=$1"
|
||||
|
||||
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
|
||||
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
|
||||
|
||||
record=$(curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY | sed 's/.//;s/.$//')
|
||||
#echo $? # 0
|
||||
if [ $? == 0 ] && [ -n "$record" ]; then
|
||||
echo "Record number for CNAME $1 is $record !"
|
||||
|
||||
HTTP_METHOD="DELETE"
|
||||
HTTP_BODY=""
|
||||
HTTP_QUERY="https://eu.api.ovh.com/v1/domain/zone/$ZONE/record/$record"
|
||||
|
||||
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
|
||||
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
|
||||
|
||||
curl --silent -X $HTTP_METHOD -H "Content-Type:application/json;charset=utf-8" -H "X-Ovh-Application:$OVH_APP_KEY" -H "X-Ovh-Timestamp:$TIME" -H "X-Ovh-Signature:$SIG" -H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" --data "$HTTP_BODY" $HTTP_QUERY
|
||||
#echo $? # 0
|
||||
if [ $? == 0 ]; then
|
||||
echo "CNAME $1 have been successfully deleted !"
|
||||
else
|
||||
echo "Error while deleting CNAME $1 !"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "No record number found for CNAME $1 !"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#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"
|
||||
208
photo_du_mois.sh
Executable file
208
photo_du_mois.sh
Executable file
@@ -0,0 +1,208 @@
|
||||
#!/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
|
||||
|
||||
|
||||
# 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"
|
||||
|
||||
# Server
|
||||
|
||||
server=( "ftp.cluster011.ovh.net" "sur-le-sentier.fr" "photos-nas.ovh" )
|
||||
user=( "funnymac" "sentier" "bruno" )
|
||||
dest=( "www/zenphoto/albums/photos-du-mois/" "httpdocs/photos/img/" "/volume1/web/photos/img/" )
|
||||
port=( "22" "22" "42667" )
|
||||
|
||||
|
||||
: <<'END_COMMENT'
|
||||
user=sentier
|
||||
server="sur-le-sentier.fr"
|
||||
path="httpdocs/photos/img/"
|
||||
port=22 # ssh, scp
|
||||
|
||||
user=bruno
|
||||
server="clicclac.synology.me"
|
||||
path="/volume1/web/"
|
||||
port=42666
|
||||
|
||||
user=funnymac
|
||||
server=ftp.cluster011.ovh.net
|
||||
path="www/zenphoto/albums/photos-du-mois/"
|
||||
port=22
|
||||
|
||||
END_COMMENT
|
||||
|
||||
last_remote_files() {
|
||||
current_year=$(date +"%Y")
|
||||
last_year=$(( current_year-1 ))
|
||||
|
||||
for ((i=0 ; i<"${#server[@]}" ; i++))
|
||||
do
|
||||
#rsync sentier@sur-le-sentier.fr:httpdocs/photos/img/'*' | grep -E "$last_year.jpg|$current_year.jpg"
|
||||
|
||||
# rsync -e "/usr/bin/ssh -p 42666" --rsync-path=/bin/rsync -zarvh "bruno@clicclac.synology.me:/volume1/web/photos/img/*"
|
||||
echo -e "${bold}${server[$i]}${reset}:${dest[$i]}"
|
||||
|
||||
if [ "${server[$i]}" == "clicclac.synology.me" ]; then
|
||||
lrf=$(rsync -e "/usr/bin/ssh -p ${port[$i]}" --rsync-path=/bin/rsync -zarvh "${user[$i]}"@"${server[$i]}":"${dest[$i]}*" | grep -E "$last_year.jpg|$current_year.jpg")
|
||||
else
|
||||
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"
|
||||
|
||||
l=$(echo "$lrf" | awk '{print $NF}' | awk -F"." '{print $1}') # 1_2022
|
||||
|
||||
e=""
|
||||
while IFS= read -r line; do
|
||||
|
||||
m=$(echo "${line}" | awk -F"_" '{printf "%02d\n", $1}')
|
||||
y=$(echo "${line}" | awk -F"_" '{print $2}')
|
||||
d="$y-$m-01"
|
||||
ts=$(date --date="$d" +"%s")
|
||||
e+="$ts\n"
|
||||
|
||||
done <<< "$l"
|
||||
|
||||
echo
|
||||
g=$(echo -e "$e" | sort -n | sed -n '$p')
|
||||
last=$(date -d "@$g" +"%B %Y")
|
||||
|
||||
echo -e "More recent picture on ${server[$i]}: ${bold}$last${reset}"
|
||||
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 2022-12-31
|
||||
REGEX="(([0-9]{4,}|[Y]{4,})-([0-9]{2,}|[M]{2,})-([0-9]{2,}|[D]{2,}))"
|
||||
|
||||
# http://patorjk.com/software/taag/#p=display&f=Calvin%20S&t=photo_du_mois.sh
|
||||
|
||||
echo -e "┌─┐┬ ┬┌─┐┌┬┐┌─┐ ┌┬┐┬ ┬ ┌┬┐┌─┐┬┌─┐ ┌─┐┬ ┬"
|
||||
echo -e "├─┘├─┤│ │ │ │ │ │││ │ ││││ ││└─┐ └─┐├─┤"
|
||||
echo -e "┴ ┴ ┴└─┘ ┴ └─┘─────┴┘└─┘────┴ ┴└─┘┴└─┘o└─┘┴ ┴"
|
||||
echo
|
||||
|
||||
echo -e "\n${bold}0. Verify last uploads on remote servers ${reset}\n"
|
||||
|
||||
last_remote_files
|
||||
|
||||
echo -e "\n${bold}1. From Lightroom Classic, export ${italic}collection 'Photo du mois'${reset}${bold} => $SRC${reset}\n"
|
||||
|
||||
echo -e "Done ! <Press Enter>"
|
||||
read -r -p ""
|
||||
|
||||
echo -e "\n${bold}2. Renaming Photos files...${reset}"
|
||||
|
||||
for FILE in "${SRC}"/**/*.{jpg,jpeg}
|
||||
do
|
||||
filename=$(basename "$FILE")
|
||||
#extension=${filename##*.}
|
||||
filename=${filename%.*}
|
||||
if [[ $filename =~ $REGEX ]]; then
|
||||
MATCH="${BASH_REMATCH[0]}"
|
||||
y=$(echo "${MATCH}" | awk -F"-" '{print $1}')
|
||||
m=$(echo "${MATCH}" | awk -F"-" '{print $2}')
|
||||
if [ "${m:0:1}" = "0" ]; then m=${m:1:7}; fi
|
||||
filepath=$(dirname "$FILE")
|
||||
newname="$m"_"$y".jpg
|
||||
newfilename="$filepath/$m"_"$y".jpg
|
||||
|
||||
echo -e "Rename ${bold}$filename${reset} to ${bold}$newname${reset}..."
|
||||
mv "${FILE}" "$newfilename"
|
||||
movies+=("${newfilename}")
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
if [ "${#movies[@]}" -gt 0 ]; then
|
||||
echo -e "\n${bold}${#movies[@]} new images found !${reset}\n"
|
||||
|
||||
for ((i=0 ; i<"${#server[@]}" ; i++))
|
||||
do
|
||||
j=$((i++))
|
||||
echo -e "\n\n${bold}3.$j Transfert Photos files to ${italic}${server[$i]}${reset}${bold}...${reset}"
|
||||
|
||||
if nmap "${server[$i]}" -PN -p "${port[$i]}" | grep open &>/dev/null; then
|
||||
|
||||
for new in "${movies[@]}"
|
||||
do
|
||||
echo -e "Transfering ${bold}$new${reset} to ${bold}${server[$i]}${reset}..."
|
||||
filename=$(basename "$new")
|
||||
#extension=${filename##*.}
|
||||
filename=${filename%.*}
|
||||
|
||||
if [ "${server[$i]}" == "photos-nas.ovh" ]; then
|
||||
scp -O -P "${port[$i]}" "$new" "${user[$i]}"@"${server[$i]}":"${dest[$i]}"
|
||||
else
|
||||
scp -P "${port[$i]}" "$new" "${user[$i]}"@"${server[$i]}":"${dest[$i]}"
|
||||
fi
|
||||
result=$?
|
||||
[ "$result" -eq 0 ] && echo -e "${green}Successful transfert...${reset}\n" || echo -e "${red}Error during transfert !${reset}\n"
|
||||
|
||||
done
|
||||
|
||||
else
|
||||
echo -e "\n${bold}${red}Server ${server[$i]} down !${reset}\n"
|
||||
fi
|
||||
done
|
||||
|
||||
else
|
||||
echo -e "\n${bold}${red}No new images !${reset}"
|
||||
#echo -e "${bold}Quit.${reset}\n"
|
||||
#exit
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
for ((i=0 ; i<"${#server[@]}" ; i++))
|
||||
do
|
||||
|
||||
# scp 5_2022_mozcjpeg.jpg sentier@sur-le-sentier.fr:httpdocs/photos/img/
|
||||
# scp 1_2022.jpg funnymac@ftp.cluster011.ovh.net:www/zenphoto/albums/photos-du-mois/
|
||||
|
||||
echo -e "\n\n${bold}4. Synchronise Local folder to ${server[$i]}${reset}..."
|
||||
|
||||
if nmap "${server[$i]}" -PN -p "${port[$i]}" | grep open &>/dev/null; then
|
||||
|
||||
if [ "${server[$i]}" == "photos-nas.ovh" ]; then
|
||||
rsync -e "/usr/bin/ssh -p ${port[$i]}" --rsync-path=/bin/rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh --stats --progress "$SRC/" "${user[$i]}"@"${server[$i]}":"${dest[$i]}"
|
||||
else
|
||||
rsync --exclude-from="$HOME/.exclude-rsync.txt" -zarvh --stats --progress "$SRC/" "${user[$i]}"@"${server[$i]}":"${dest[$i]}"
|
||||
fi
|
||||
result=$?
|
||||
[ "$result" -eq 0 ] && echo -e "\n${green}Successful synchronization...${reset}" || echo -e "\n${red}Error during synchronization !${reset}"
|
||||
|
||||
#notification "MkDocs: sending Docs to ${server3[server]}..." "${server3[server]}" $result
|
||||
|
||||
if [ "$i" -eq 0 ]; then
|
||||
# Dans zenphoto, mettre en cache les photos
|
||||
echo -e "\n${bold}5. Go to ${italic}https://clicclac.info/zenphoto/${reset}${bold} and update cache manager...${reset}\n"
|
||||
open https://clicclac.info/zenphoto/zp-core/zp-extensions/cacheManager/cacheImages.php?album=photos-du-mois
|
||||
|
||||
#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
|
||||
fi
|
||||
|
||||
else
|
||||
echo -e "\n${bold}${red}Server ${server[$i]} down !${reset}\n"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
53
purge_server.sh
Executable file
53
purge_server.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
italic="\033[3m"
|
||||
#underline="\033[4m"
|
||||
#ita_under="\033[3;4m"
|
||||
#bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
green="\033[1;32m"
|
||||
yellow="\033[1;33m"
|
||||
bold="\033[1m"
|
||||
#box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
host=$(hostname)
|
||||
# status change XX*24 hours ago.
|
||||
ago=30 # 30 jours
|
||||
|
||||
if [ "$host" == "localhost" ]; then
|
||||
ip=$(hostname -I | awk '{print $1}')
|
||||
|
||||
if [ "$ip" = "212.227.191.167" ]; then
|
||||
|
||||
echo -e "\n${red}Running df -h /...${reset}"
|
||||
|
||||
df -h /
|
||||
|
||||
echo -e "\n${green}Remove backup logfiles ...${reset}"
|
||||
|
||||
sudo find /var/log/plesk/PMM/ -name 'backup*' -type d -ctime +$ago -exec rm -rf {} +;
|
||||
#find /var/log/plesk/PMM/ -name 'backup*' -type d -ctime +$ago -exec rm -rf {} +;
|
||||
|
||||
echo -e "\n${green}Remove backup files ...${reset}"
|
||||
|
||||
sudo find /var/lib/psa/dumps -name 'backup*' -type f -ctime +$ago -exec rm -rf {} +;
|
||||
#find /var/lib/psa/dumps -name 'backup*' -type f -ctime +$ago -exec rm -rf {} +;
|
||||
|
||||
echo -e "\n${green}Find files bigger than 200Mo ...${reset}"
|
||||
|
||||
sudo find / -type f -size +200M -exec du -h {} + 2>/dev/null | sort -r -h
|
||||
|
||||
echo -e "\n${green}Voir la place occupée par les logs ...${reset}"
|
||||
|
||||
journalctl --disk-usage -q
|
||||
|
||||
echo -e "\n${green}Décommenter la ligne SystemMaxUse dans /etc/systemd/journald.conf${reset}"
|
||||
|
||||
echo -e "\n${green}Running df -h /...${reset}"
|
||||
|
||||
df -h /
|
||||
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
59
reachable.sh
Executable file
59
reachable.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
host1=maboiteverte.fr
|
||||
port1=22
|
||||
|
||||
host2=clicclac.synology.me
|
||||
port2=42666
|
||||
|
||||
echo -e "\nnc\n"
|
||||
|
||||
if nc -z -G 2 $host1 $port1 &>/dev/null; then
|
||||
echo $?
|
||||
echo "server $host1 up"
|
||||
else
|
||||
echo $?
|
||||
echo "server $host1 down"
|
||||
fi
|
||||
|
||||
if nc -z -G 2 $host2 $port2 &>/dev/null; then
|
||||
echo $?
|
||||
echo "server $host2 up"
|
||||
else
|
||||
echo $?
|
||||
echo "server $host2 down"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo -e "\nnmap\n"
|
||||
|
||||
if nmap maboiteverte.fr -PN -p 22 | grep open &>/dev/null; then
|
||||
echo $?
|
||||
echo "server $host1 up"
|
||||
else
|
||||
echo $?
|
||||
echo "server $host1 down"
|
||||
fi
|
||||
|
||||
if nmap clicclac.synology.me -PN -p 42666 | grep open &>/dev/null; then
|
||||
echo $?
|
||||
echo "server $host2 up"
|
||||
else
|
||||
echo $?
|
||||
echo "server $host2 down"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo -e "\nping\n"
|
||||
|
||||
ping -c1 -W1 -q maboiteverte.fr 2>/dev/null;
|
||||
echo $?
|
||||
|
||||
ping -c1 -W1 -q clicclac.synology.me 2>/dev/null;
|
||||
echo $?
|
||||
|
||||
|
||||
|
||||
|
||||
48
remote_scripts.sh
Executable file
48
remote_scripts.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
# remote scripts
|
||||
|
||||
ssh -t bruno@maboiteverte.fr ./purge_server.sh
|
||||
|
||||
ssh -t bruno@maboiteverte.fr ./upgrade_joplin.sh
|
||||
|
||||
ssh -t bruno@maboiteverte.fr ./mbv-gitea-upd.sh
|
||||
|
||||
# sudo: /opt/plesk/php/7.2/bin/php: command not found
|
||||
#ssh -t bruno@maboiteverte.fr ./upgrade_nextcloud.sh
|
||||
|
||||
printf './upgrade_nextcloud.sh' | ssh -t bruno@maboiteverte.fr 'bash -l'
|
||||
|
||||
# pb with ssh keys
|
||||
ssh -t bruno@maboiteverte.fr ./backup_vps.sh
|
||||
|
||||
|
||||
|
||||
# ssh bruno@maboiteverte.fr 'source ~/.bash_profile && php -v'
|
||||
#PHP 7.2.24
|
||||
|
||||
# echo "php -v" | mbv
|
||||
# PHP 8.2.6
|
||||
|
||||
# php -v | ssh 'bruno@maboiteverte.fr'
|
||||
#-bash: line 1: syntax error near unexpected token `('
|
||||
#-bash: line 1: `PHP 8.2.10 (cli) (built: Sep 1 2023 00:17:29) (NTS)'
|
||||
|
||||
# php -v | ssh bruno@maboiteverte.fr 'bash -l'
|
||||
# bash: line 1: syntax error near unexpected token `('
|
||||
# bash: line 1: `PHP 8.2.10 (cli) (built: Sep 1 2023 00:17:29) (NTS)'
|
||||
|
||||
# printf 'php -v' | ssh bruno@maboiteverte.fr 'bash -l'
|
||||
# PHP 8.2.6 (cli) (built: May 15 2023 06:37:47) (NTS)
|
||||
# Copyright (c) The PHP Group
|
||||
# Zend Engine v4.2.6, Copyright (c) Zend Technologies
|
||||
# with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies
|
||||
|
||||
# printf 'php -v' | ssh bruno@maboiteverte.fr
|
||||
# Pseudo-terminal will not be allocated because stdin is not a terminal.
|
||||
|
||||
# PHP 8.2.6 (cli) (built: May 15 2023 06:37:47) (NTS)
|
||||
# Copyright (c) The PHP Group
|
||||
# Zend Engine v4.2.6, Copyright (c) Zend Technologies
|
||||
# with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies
|
||||
67
rename_series.sh
Executable file
67
rename_series.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
green="\033[1;32m"
|
||||
yellow="\033[1;33m"
|
||||
bold="\033[1m"
|
||||
box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
shopt -s globstar
|
||||
|
||||
SRC="$HOME/Downloads"
|
||||
DEST="$HOME/Movies"
|
||||
DEST_EXT=mp4
|
||||
#HANDBRAKE_CLI=HandBrakeCLI
|
||||
PRESET="Apple 720p30 Surround"
|
||||
MAXSIZE=30000000
|
||||
|
||||
REGEX="([sS]([0-9]{2,}|[X]{2,})[eE]([0-9]{2,}|[Y]{2,}))"
|
||||
#REGEX2="[0-9]{4}"
|
||||
REGEX2="2[0-9]{3}"
|
||||
|
||||
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}
|
||||
do
|
||||
echo "$FILE"
|
||||
filename=$(basename "$FILE")
|
||||
#echo "$filename" # Arctic.Circle.S01E02.iNTERNAL.MULTi.720p.WEB.H264-CiELOS.mkv
|
||||
|
||||
extension=${filename##*.}
|
||||
#echo "$extension" # mkv
|
||||
|
||||
filename=${filename%.*} # sans extension
|
||||
#echo "$filename" # Arctic.Circle.S01E02.iNTERNAL.MULTi.720p.WEB.H264-CiELOS
|
||||
|
||||
# Get file size
|
||||
FILESIZE=$(stat -c%s "$FILE")
|
||||
|
||||
if (( FILESIZE > MAXSIZE )); then
|
||||
|
||||
if [[ $filename =~ $REGEX ]]; then
|
||||
MATCH="${BASH_REMATCH[1]}"
|
||||
e=$(echo ${filename%$MATCH*} | sed 's/\./\ /g' | xargs)
|
||||
new_name="$e - $MATCH.$DEST_EXT"
|
||||
echo "$new_name"
|
||||
elif [[ $filename =~ $REGEX2 ]]; then
|
||||
MATCH2="${BASH_REMATCH[0]}"
|
||||
e=$(echo ${filename%$MATCH2*} | sed 's/\./\ /g' | xargs)
|
||||
new_name="$e ($MATCH2).$DEST_EXT"
|
||||
echo "$new_name"
|
||||
else
|
||||
echo "Could not find SXXEYY pattern in new format"
|
||||
echo " "
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "--------------"
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
|
||||
74
rsync-retry.sh
Executable file
74
rsync-retry.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
### ABOUT: See: http://gist.github.com/366269
|
||||
### Runs rsync, retrying on errors up to a maximum number of tries.
|
||||
### On failure script waits for internect connection to come back up by pinging google.com before continuing.
|
||||
###
|
||||
### Usage: $ ./rsync-retry.sh source destination
|
||||
### Example: $ ./rsync-retry.sh user@server.example.com:~/* ~/destination/path/
|
||||
###
|
||||
### INPORTANT:
|
||||
### To avoid repeated password requests use public key authentication instead of passwords
|
||||
### "ssh-keygen" (with no password), then "ssh-copy-id user@server.example.com"
|
||||
|
||||
# ----------------------------- rSync Options ------------------------------------------------
|
||||
|
||||
OPT="--inplace -vzP"
|
||||
|
||||
# -------------------- Shouldn't need to change anything bellow -------------------------------
|
||||
echo -n "Enter No. of retries to attempt... "
|
||||
read MAX_RETRIES
|
||||
|
||||
echo -n "Recursive flag ON? (y/n) "
|
||||
read YN
|
||||
if [[ $YN == "y" || $YN == "Y" ]]; then
|
||||
RFLAG=r
|
||||
fi
|
||||
|
||||
COM="rsync $OPT$RFLAG -e 'ssh -o \"ServerAliveInterval 10\"' $1 $2"
|
||||
|
||||
echo
|
||||
echo "Using command: $COM"
|
||||
|
||||
# Trap interrupts and exit instead of continuing the loop
|
||||
trap "echo Ctl+C Detected... Exiting!; exit;" SIGINT SIGTERM
|
||||
|
||||
COUNT=0
|
||||
START=$SECONDS
|
||||
|
||||
# Set the initial exit value to failure
|
||||
false
|
||||
while [ $? -ne 0 -a $COUNT -lt $MAX_RETRIES ]; do
|
||||
COUNT=$(($COUNT+1))
|
||||
if [ $COUNT -ne 1 ]; then
|
||||
echo
|
||||
echo "Waiting for Internet connection..."
|
||||
false
|
||||
until [ $? -eq 0 ]; do
|
||||
wget -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
|
||||
done
|
||||
fi
|
||||
echo
|
||||
echo "Attempt No. $COUNT / $MAX_RETRIES"
|
||||
echo
|
||||
## Havn't got the quoting quite right above to just have $COM here.
|
||||
#$COM
|
||||
rsync -vzP$RFLAG --inplace -e 'ssh -o "ServerAliveInterval 10"' $1 $2
|
||||
done
|
||||
|
||||
FINISH=$SECONDS
|
||||
if [[ $(($FINISH - $START)) -gt 3600 ]]; then
|
||||
ELAPSED="$((($FINISH - $START)/3600))hrs, $(((($FINISH - $START)/60)%60))min, $((($FINISH - $START)%60))sec"
|
||||
elif [[ $(($FINISH - $START)) -gt 60 ]]; then
|
||||
ELAPSED="$(((($FINISH - $START)/60)%60))min, $((($FINISH - $START)%60))sec"
|
||||
else
|
||||
ELAPSED="$(($FINISH - $START))sec"
|
||||
fi
|
||||
|
||||
if [ $COUNT -eq $MAX_RETRIES -a $? -ne 0 ]; then
|
||||
echo "Hit maximum number of retries($MAX_RETRIES), giving up. Elapsed time: $ELAPSED"
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Finished after $COUNT retries!! Elapsed time: $ELAPSED"
|
||||
fi
|
||||
41
run.sh
Executable file
41
run.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
bold="\033[1m"
|
||||
box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
# Main menu
|
||||
menu(){
|
||||
|
||||
options=(
|
||||
"(u)pdates.sh (Update websites)"
|
||||
"mk(s)erve (Serve MkDocs)"
|
||||
"mk(b)uild.sh (Transfer MkDocs to servers)"
|
||||
"photo_du_mois.sh (Transfer photo_du_mois.jpg to servers)"
|
||||
"(Q)uit"
|
||||
)
|
||||
|
||||
|
||||
echo -e "\n\033[1mScripts menu: \033[0m\n"
|
||||
|
||||
select option in "${options[@]}"; do
|
||||
case "$REPLY" in
|
||||
1|u|U) ./updates.sh ;;
|
||||
2|s|S) cd $HOME/Documents/docs ; mkdocs serve ;;
|
||||
3|b|B) ./mkbuild.sh ;;
|
||||
4|m|M) ./photo_du_mois.sh ;;
|
||||
4|q|Q) exit 0 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
menu
|
||||
|
||||
|
||||
|
||||
47
server.sh
Executable file
47
server.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
: <<'END_COMMENT'
|
||||
|
||||
# server1: clicclac.synology.me
|
||||
declare -A server1
|
||||
server1[user]="bruno"
|
||||
server1[server]="clicclac.synology.me"
|
||||
server1[dest]="/volume1/web/$folder/"
|
||||
server1[port]=42666
|
||||
|
||||
# server2: ovh.net
|
||||
declare -A server2
|
||||
server2[user]="funnymac"
|
||||
server2[server]="ftp.cluster011.ovh.net"
|
||||
server2[dest]="www/$folder/"
|
||||
server2[port]=22
|
||||
|
||||
# server3: maboiteverte.fr
|
||||
declare -A server3
|
||||
server3[user]="bruno"
|
||||
server3[server]="ftp.maboiteverte.fr"
|
||||
server3[dest]="httpdocs/$folder/"
|
||||
server3[port]=22
|
||||
|
||||
END_COMMENT
|
||||
|
||||
|
||||
server=( "ftp.cluster011.ovh.net" "sur-le-sentier.fr" "ftp.maboiteverte.fr" "clicclac.synology.me" )
|
||||
user=( "funnymac" "sentier" "bruno" "bruno" )
|
||||
dest=( "www/zenphoto/albums/photos-du-mois/" "httpdocs/photos/img/" "httpdocs/" "/volume1/web/" )
|
||||
port=( "22" "22" "22" "42666" )
|
||||
|
||||
for new in "${server[@]}"
|
||||
do
|
||||
echo "${new}"
|
||||
done
|
||||
|
||||
|
||||
echo ""
|
||||
|
||||
for ((i=0 ; i<"${#server[@]}" ; i++))
|
||||
do
|
||||
echo ${server[$i]} - ${user[$i]} - ${dest[$i]} - ${port[$i]}
|
||||
|
||||
done
|
||||
126
sphp_php-fpm.sh
Executable file
126
sphp_php-fpm.sh
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
underline="\033[4m"
|
||||
red="\033[1;31m"
|
||||
green="\033[1;32m"
|
||||
yellow="\033[1;33m"
|
||||
bold="\033[1m"
|
||||
reset="\033[0m"
|
||||
|
||||
if [ "$1" == "-h" ]; then
|
||||
echo -e "\\033[4msphp_php-fpm.sh \\033[0m"
|
||||
echo "Change php version (php-fpm)"
|
||||
echo
|
||||
echo "USAGE: sphp_php-fpm.sh version (8.1 8.2 8.3)"
|
||||
echo
|
||||
echo " -h display this help"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
|
||||
#
|
||||
|
||||
homebrew_path=$(brew --prefix)
|
||||
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
|
||||
|
||||
protocol="http"
|
||||
apache_conf_path=$(httpd -V | grep 'SERVER_CONFIG_FILE' | awk -F '\"' '{print $2}')
|
||||
document_root=$(grep -e '^DocumentRoot' "$apache_conf_path" | awk '{print $2}' | sed 's/\"//g')
|
||||
server_name=$(grep -e '^ServerName' "$apache_conf_path" | awk '{print $2}')
|
||||
h=$(hostname)
|
||||
|
||||
vhost_conf=$(grep -e 'httpd-vhosts.conf' $apache_conf_path | awk '{print $2}')
|
||||
#ssl_conf=$(grep -e 'httpd-ssl.conf' $homebrew_path/etc/httpd/httpd.conf | awk '{print $2}')
|
||||
ssl_conf=$(grep -e 'httpd-ssl.conf' $apache_conf_path | awk '{print $2}')
|
||||
if [ -f "$ssl_conf" ]; then
|
||||
apache_port=$(cat $ssl_conf | grep -e '^Listen' | awk '{print $2}')
|
||||
a=$(nmap --script http-methods -p$apache_port --script-args http-methods.url-path=’/page’ $h | grep -A1 "^PORT" | tail -1 | awk '{print $3}')
|
||||
if [[ "$a" == "http" ]] || [[ "$a" == "https" ]]; then protocol=$a; fi
|
||||
fi
|
||||
|
||||
brew_array=("8.1","8.2","8.3")
|
||||
php_array=("php@8.1" "php@8.2" "php@8.3")
|
||||
php_installed_array=()
|
||||
php_version="php@$1"
|
||||
php_opt_path="$brew_prefix\/opt\/"
|
||||
|
||||
simple_php_version=$(echo "$php_version" | sed 's/^php@//' | sed 's/\.//')
|
||||
|
||||
|
||||
# Current php version (from httpd.conf)
|
||||
ip=$(grep -E SetHandler $apache_conf_path | grep -v \# | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}:[0-9]{4}")
|
||||
x=${ip: -2}
|
||||
current__simple_php_version="$x"
|
||||
current_php_version="php@${x:0:1}.${x:1}"
|
||||
echo -e "${underline}Current${reset} php version: ${bold}$current_php_version${reset}"
|
||||
|
||||
# What versions of php are installed via brew
|
||||
# /opt/homebrew/etc/php/8.0/php-fpm.d/www.conf - listen = 127.0.0.1:9081
|
||||
echo -e "\nPHP version ${underline}installed${reset}:"
|
||||
for i in ${php_array[*]}; do
|
||||
version=$(echo "$i" | sed 's/^php@//')
|
||||
if [[ -d "$homebrew_path/etc/php/$version" ]]; then
|
||||
php_installed_array+=("$i")
|
||||
#php_port=$(sed -n "/^listen/p" $homebrew_path/etc/php/$version/php-fpm.d/www.conf)
|
||||
php_ipport=$(grep -E ^listen $homebrew_path/etc/php/$version/php-fpm.d/www.conf | awk -F" = " '{print $2}')
|
||||
php_running=$(lsof -i -n -P | grep php-fpm | grep $php_ipport)
|
||||
|
||||
[ -n "$php_running" ] && echo -e " ● php-fpm version: ${bold}$i${reset} ($php_ipport)" "${green}Running...${reset}" || echo -e "php-fpm version: $version ($php_ipport)" "${red}Stopped.${reset}"
|
||||
|
||||
echo -e " ● php (cli): /opt/homebrew/opt/$i/bin/php"
|
||||
fi
|
||||
done
|
||||
|
||||
proxy_pass_match_string="ProxyPassMatch \"^/(.*\.php(/.*)?)$\" \"fcgi://127.0.0.1:90$simple_php_version/opt/homebrew/local/var/www/\$1\""
|
||||
set_handler_string="SetHandler \"proxy:fcgi://127.0.0.1:90$simple_php_version\""
|
||||
|
||||
# Check that the requested version is supported
|
||||
if [[ " ${php_array[*]} " == *"$php_version"* ]]; then
|
||||
# Check that the requested version is installed
|
||||
if [[ " ${php_installed_array[*]} " == *"$php_version"* ]]; then
|
||||
|
||||
if [[ "$php_version" == "$current_php_version" ]]; then
|
||||
echo -e "\nPHP already running version ${bold}$php_version${reset} !"
|
||||
echo "Exiting..."
|
||||
exit 0
|
||||
else
|
||||
|
||||
version=$(echo "$php_version" | sed 's/^php@//')
|
||||
|
||||
echo -e "\nSwitching to ${bold}$php_version${reset}..."
|
||||
echo "Edit your Apache conf..."
|
||||
|
||||
#sed -i.bak "s/ProxyPassMatch.*/ProxyPassMatch \"^/(.*\.php(/.*)?)$\" \"fcgi:\/\/127.0.0.1:90$simple_php_version\/opt\/homebrew\/local\/var\/www\/\$1\"/" $apache_conf_path
|
||||
#sed -i.bak "s/SetHandler \"proxy:fcgi.*/SetHandler \"proxy:fcgi:\/\/127.0.0.1:90$simple_php_version\"/" $apache_conf_path
|
||||
|
||||
sed -i.bak "s/fcgi:\/\/127.0.0.1:90$current__simple_php_version/fcgi:\/\/127.0.0.1:90$simple_php_version/" $apache_conf_path
|
||||
|
||||
echo "Restarting Apache server..."
|
||||
|
||||
#brew services restart httpd
|
||||
sudo apachectl -k restart
|
||||
|
||||
echo "Loading PHP info..."
|
||||
echo '<?php echo phpinfo(); ?>' > $document_root/php-info.php && open "$protocol://$server_name/php-info.php"
|
||||
|
||||
echo "All done!"
|
||||
|
||||
echo -e "\n${underline}Apache conf files:${reset}"
|
||||
echo "$apache_conf_path"
|
||||
echo "$vhost_conf"
|
||||
echo "$ssl_conf"
|
||||
echo -e "${underline}PHP conf files:${reset}"
|
||||
echo "$homebrew_path/etc/php/$version/php.ini"
|
||||
echo "$homebrew_path/etc/php/$version/php-fpm.d/www.conf"
|
||||
find "$homebrew_path/etc/php/$version/conf.d" -name "*.ini" -print | sort -n
|
||||
|
||||
fi
|
||||
else
|
||||
echo -e "\nSorry, but $php_version is not installed via brew. Install by running: brew install $php_version"
|
||||
fi
|
||||
else
|
||||
echo -e "\nUnknown version of PHP. PHP Switcher can only handle arguments of:" ${brew_array[@]}
|
||||
fi
|
||||
|
||||
37
thumbsup-npm.sh
Normal file
37
thumbsup-npm.sh
Normal 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 ""
|
||||
42
update_container.sh
Executable file
42
update_container.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Our function to update containers based on their base image
|
||||
update_container() {
|
||||
local image=$1
|
||||
docker pull $image
|
||||
local updated_containers=0
|
||||
|
||||
# Loop through all running containers
|
||||
for container in $(docker ps --format "{{.Names}}"); do
|
||||
local container_image=$(docker inspect --format '{{.Config.Image}}' "$container")
|
||||
|
||||
# We check if the current container's image matches the updated image
|
||||
if [[ "$container_image" == "$image" ]]; then
|
||||
local latest=$(docker inspect --format "{{.Id}}" $image)
|
||||
local running=$(docker inspect --format "{{.Image}}" $container)
|
||||
|
||||
if [[ "$running" != "$latest" ]]; then
|
||||
echo "Upgrading $container"
|
||||
#docker rm -f $container
|
||||
# docker run --name $container $image
|
||||
((updated_containers++))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $updated_containers -eq 0 ]]; then
|
||||
echo "No containers updated for $image"
|
||||
else
|
||||
echo "$updated_containers container(s) updated for $image"
|
||||
fi
|
||||
}
|
||||
|
||||
# Our main script starts here
|
||||
# Check for updates to all images used by running containers
|
||||
for image in $(docker ps --format '{{.Image}}' | sort | uniq); do
|
||||
echo "Checking updates for $image"
|
||||
update_container $image
|
||||
done
|
||||
|
||||
echo "Container update check complete."
|
||||
55
upgrade_nextcloud.sh
Executable file
55
upgrade_nextcloud.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
host=$(hostname)
|
||||
|
||||
if [ "$host" = "DS916" ]; then
|
||||
|
||||
#php_version=81
|
||||
php_version=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")
|
||||
php_version=${php_version/.}
|
||||
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 db:add-missing-indices
|
||||
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=8.1
|
||||
php_version=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")
|
||||
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 -d memory_limit=-1 occ maintenance:mode --on
|
||||
sudo -u bruno $php_bin -d memory_limit=-1 occ maintenance:repair
|
||||
sudo -u bruno $php_bin -d memory_limit=-1 updater/updater.phar
|
||||
|
||||
sudo -u bruno $php_bin -d memory_limit=-1 occ upgrade
|
||||
sudo -u bruno $php_bin -d memory_limit=-1 occ db:add-missing-indices
|
||||
sudo -u bruno $php_bin -d memory_limit=-1 occ maintenance:mode --off
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
76
urls_check.sh
Executable file
76
urls_check.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/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
|
||||
60
urls_list.txt
Normal file
60
urls_list.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
https://clicclac.info
|
||||
https://clicclac.info/wordpress
|
||||
https://sur-le-sentier.fr
|
||||
https://maboiteverte.fr
|
||||
https://photos-nas.ovh
|
||||
https://airdrop.photos-nas.ovh
|
||||
https://asus.photos-nas.ovh
|
||||
https://books.photos-nas.ovh
|
||||
https://change.photos-nas.ovh
|
||||
https://chibisafe.photos-nas.ovh
|
||||
https://dcommander.photos-nas.ovh
|
||||
https://dockge.photos-nas.ovh
|
||||
https://docspell.photos-nas.ovh
|
||||
https://dozzle.photos-nas.ovh
|
||||
https://drive.photos-nas.ovh
|
||||
https://ds916.photos-nas.ovh
|
||||
https://ds923.photos-nas.ovh
|
||||
https://files.photos-nas.ovh
|
||||
https://git.photos-nas.ovh
|
||||
https://gitea.photos-nas.ovh
|
||||
https://glances.photos-nas.ovh
|
||||
https://gokapi.photos-nas.ovh
|
||||
https://gotify.photos-nas.ovh
|
||||
https://home-assistant.photos-nas.ovh
|
||||
https://homebridge.photos-nas.ovh
|
||||
https://igotify.photos-nas.ovh
|
||||
https://immich.photos-nas.ovh/photos
|
||||
https://invidious.photos-nas.ovh
|
||||
https://it-tools.photos-nas.ovh
|
||||
https://kuma.photos-nas.ovh
|
||||
https://maloja.photos-nas.ovh
|
||||
https://maps-server.photos-nas.ovh
|
||||
https://maps.photos-nas.ovh
|
||||
https://menu.photos-nas.ovh
|
||||
https://musiiic.photos-nas.ovh
|
||||
https://navidrome.photos-nas.ovh
|
||||
https://nextcloud.photos-nas.ovh
|
||||
https://notif.photos-nas.ovh
|
||||
https://paperlessngx.photos-nas.ovh
|
||||
https://pastebin.photos-nas.ovh
|
||||
https://photos.photos-nas.ovh
|
||||
https://pihole1.photos-nas.ovh/admin/login.php
|
||||
https://pihole2.photos-nas.ovh/admin/login.php
|
||||
https://pingvin.photos-nas.ovh
|
||||
https://portainer.photos-nas.ovh
|
||||
https://psitransfer.photos-nas.ovh
|
||||
https://seafile.photos-nas.ovh
|
||||
https://search.photos-nas.ovh
|
||||
https://send.photos-nas.ovh
|
||||
https://snippet.photos-nas.ovh
|
||||
https://syno-dashboard.photos-nas.ovh
|
||||
https://tautulli.photos-nas.ovh
|
||||
https://test.photos-nas.ovh
|
||||
https://tube.photos-nas.ovh
|
||||
https://tunes.photos-nas.ovh
|
||||
https://uptime.photos-nas.ovh
|
||||
https://vault.photos-nas.ovh
|
||||
https://wg.photos-nas.ovh
|
||||
https://yacy.photos-nas.ovh
|
||||
https://yatch.photos-nas.ovh
|
||||
117
venv_solus.sh
Executable file
117
venv_solus.sh
Executable 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
|
||||
Reference in New Issue
Block a user