From c1ae96f4d00327f13ea37666ae95f5957451bd44 Mon Sep 17 00:00:00 2001 From: Bruno21 Date: Wed, 16 Feb 2022 13:21:17 +0100 Subject: [PATCH] 16-02-2022 (2) --- apache_tools.sh | 25 ++++++++++++++----------- backup_mysql.sh | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/apache_tools.sh b/apache_tools.sh index cc90a07..65b87db 100755 --- a/apache_tools.sh +++ b/apache_tools.sh @@ -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 '' > $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 ;; diff --git a/backup_mysql.sh b/backup_mysql.sh index 7502133..01cf848 100755 --- a/backup_mysql.sh +++ b/backup_mysql.sh @@ -159,15 +159,27 @@ done # # Nettoyage serveurs locaux: +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 '(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 +"$BKP_DAYS"d | grep -v -E '(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)|(S\d{2}_\d{4})' | xargs rm -f +find $BKP_DEST -name "*.sql.gz" -mtime +"$d_duration" | grep -v -E '(janvier|fevrier|mars|avril|mai|juin|juillet|aout|septembre|octobre|novembre|decembre)|(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"d | grep -E 'S\d{2}_\d{4}' | xargs rm -f +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 '(January|February|March|April|May|June|July|August|September|October|November|December)' | xargs rm -f -find $BKP_DEST -name "*.sql.gz" -mtime +"$BKP_MONTHS"d | grep -E '(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|decembre)' | 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 # # Nettoyage serveurs distants: