Compare commits

...

10 Commits

Author SHA1 Message Date
1415706fec handbrake_for_plesk.sh 2024-01-09 17:55:05 +01:00
7ab0771eb9 Bugfix 2023-11-16 16:43:13 +01:00
f37dbcf4d0 upgrade_nextcloud.sh
-some bugfixs
2023-11-14 20:24:20 +01:00
d6439437e1 photo-du-mois.sh
-display more recent picture on each server
2023-11-14 20:23:25 +01:00
17a975effa handbrake_for_plex.sh
bugfix with chapters
2023-07-21 09:57:28 +02:00
ef91f1a68e handbrake_for_plex.sh
-support subtitle track
2023-04-13 11:42:28 +02:00
c2ece3fefc photo_du_mois.sh
-bugfix
2023-04-11 12:36:55 +02:00
d8aa2777be 12-03-2023 2023-03-12 17:56:29 +01:00
ade806d162 handbrake_for_plex.sh
-capitalize series’s name
2022-09-01 15:10:24 +02:00
76bc76a872 handbrake_for_plex.sh
-bugfix delete file on linux
2022-08-07 07:27:52 +02:00
8 changed files with 964 additions and 122 deletions

215
apache_tools_v2.sh Executable file
View 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

5
bash_version.sh Executable file
View File

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

83
gitea.service Normal file
View 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

View File

@@ -13,8 +13,79 @@ 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
@@ -36,6 +107,7 @@ showHelp() {
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
@@ -44,6 +116,43 @@ showHelp() {
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 )
@@ -67,7 +176,7 @@ notification() {
fi
}
while getopts "h?i:o:p:" opt; do
while getopts "h?i:o:p:z" opt; do
case "$opt" in
h|\?)
showHelp
@@ -79,6 +188,9 @@ while getopts "h?i:o:p:" opt; do
;;
p) profile="$OPTARG"
;;
z) installation
exit 0
;;
esac
done
@@ -86,39 +198,6 @@ done
shift $((OPTIND-1))
# https://stackoverflow.com/questions/59895/how-can-i-get-the-directory-where-a-bash-script-is-located-from-within-the-scrip
#DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
#SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
#DIR_SCRIPT=$(dirname -- "$( readlink -f -- "$0"; )")
####
# Configuration
# Source video folder
[[ "$input_path" == "" ]] && SRC="$HOME/Downloads" || SRC="$input_path"
# Destination video folder
[[ "$output_path" == "" ]] && DEST="$HOME/Movies" || DEST="$output_path"
# Extension video file
DEST_EXT=mp4
# Handbrake preset
[[ "$profile" == "" ]] && PRESET="Apple 720p30 Surround" || PRESET="$profile"
# Only files larger than $MAXSIZE will be processed
MAXSIZE=30000000
#MAXSIZE=300
# Open converted video file in an application
APP="Subler"
# log
# this reduce handbrake verbosity
logfile=/tmp/HandBrake.log
#Move to trash after conversion
trash=true
###
@@ -161,10 +240,11 @@ echo -e "HandBrake Profile: ${italic}$PRESET${reset}"
#ls "$SRC"/**/*.{mkv,avi,mp4,m4v}
count=0
# Series: SxxEyy
REGEX="([sS]([0-9]{2,}|[X]{2,})[eE]([0-9]{2,}|[Y]{2,}))"
# Films: 2
REGEX2="[0-9]{4}"
# 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}
@@ -184,7 +264,12 @@ do
#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")
@@ -193,20 +278,38 @@ do
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]}"
e=$(echo "${filename%$MATCH*}" | sed 's/\./\ /g' | xargs)
new_name="$e - $MATCH.$DEST_EXT"
# 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]}"
e=$(echo "${filename%$MATCH2*}" | sed 's/\./\ /g' | xargs)
MATCH2=${MATCH2:1}
e=$(echo "${filename%$MATCH2*}" | sed 's/\./\ /g' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
new_name="$e ($MATCH2).$DEST_EXT"
else
echo "Could not find SXXEYY pattern"
new_name="$filename"
continue
fi
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"
@@ -214,69 +317,138 @@ END_COMMENT
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 -s 'map({ VideoCount: .media.track[0].VideoCount, AudioCount: .media.track[0].AudioCount, TextCount: .media.track[0].TextCount, MenuCount: .media.track[0].MenuCount, FormatFichier: .media.track[0].Format, FileSize: .media.track[0].FileSize, Duration: .media.track[0].Duration, FormatVideo: .media.track[1].Format, Format_Profile: .media.track[1].Format_Profile, Format_Level: .media.track[1].Format_Level, "CodecVideo": .media.track[1].CodecID, Width: .media.track[1].Width, Height: .media.track[1].Height, FormatAudio: .media.track[2].Format, FormatAdditionalFeatures: .media.track[2].Format_AdditionalFeatures, CodecAudio: .media.track[2].CodecID, TitleAudio: .media.track[2].Title, LanguageAudio: .media.track[2].Language, DefaultAudio: .media.track[2].Default, FormatText: .media.track[3].Format, CodecText: .media.track[3].CodecID, LanguageText: .media.track[3].Language, DefaultText: .media.track[3].Default, Menu: .media.track[4].extra})')
# General
#nb_video=$(echo "$infos" | jq -j '.[] | .VideoCount')
nb_audio=$(echo "$infos" | jq -j '.[] | .AudioCount')
if [[ "$nb_audio" == "null" ]]; then nb_audio=0; fi
nb_text=$(echo "$infos" | jq -j '.[] | .TextCount')
if [[ "$nb_text" == "null" ]]; then nb_text=0; fi
nb_menu=$(echo "$infos" | jq -j '.[] | .MenuCount')
if [[ "$nb_menu" == "null" ]]; then nb_menu=0; fi
format_fichier=$(echo "$infos" | jq -j '.[] | .FormatFichier')
filesize=$(echo "$infos" | jq -j '.[] | .FileSize' | numfmt --to=si --format "%8.2f" | xargs)
#fsize=$(numfmt --to iec --format "%8.2f" "$filesize")
duree=$(echo "$infos" | jq -j '.[] | .Duration' | awk -F "." '{print $1}' | awk '{printf "%d:%02d:%02d", $1/3600, ($1/60)%60, $1%60}' | xargs)
# Video
format_video=$(echo "$infos" | jq -j '.[] | .FormatVideo')
format_profile=$(echo "$infos" | jq -j '.[] | .Format_Profile')
format_level=$(echo "$infos" | jq -j '.[] | .Format_Level')
codec_video=$(echo "$infos" | jq -j '.[] | .CodecVideo')
width=$(echo "$infos" | jq -j '.[] | .Width')
height=$(echo "$infos" | jq -j '.[] | .Height')
infos=$(mediainfo "$FILE" --output=JSON | jq '.media.track')
while read row
do
type=$(echo "$row" | jq -r '.["@type"]')
# Audio
format_audio=$(echo "$infos" | jq -j '.[] | .FormatAudio')
format_addition=$(echo "$infos" | jq -j '.[] | .FormatAdditionalFeatures')
if [[ "$format_addition" == "null" ]]; then format_addition=""; fi
codec_audio=$(echo "$infos" | jq -j '.[] | .CodecAudio')
title_audio=$(echo "$infos" | jq -j '.[] | .TitleAudio')
language_audio=$(echo "$infos" | jq -j '.[] | .LanguageAudio')
if [[ "$language_audio" == "null" ]]; then language_audio=""; fi
default_audio=$(echo "$infos" | jq -j '.[] | .DefaultAudio')
if [[ "$default_audio" == "null" ]]; then default_audio=""; fi
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)
# Text
format_text=$(echo "$infos" | jq -j '.[] | .FormatText')
codec_text=$(echo "$infos" | jq -j '.[] | .CodecText')
language_text=$(echo "$infos" | jq -j '.[] | .LanguageText')
default_text=$(echo "$infos" | jq -j '.[] | .DefaultText')
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')
m=""
#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
t=$(echo "$line" | awk -F": " '{print $1}')
c=$(echo "$line" | awk -F": " '{print $2}')
# 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])$"
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/^/ /')
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",
m+="$cc : $tt\n"
done <<< "$menu"
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"
echo -e "\n\n${bold}(${red}$(( count + 1 ))${reset}${bold} / $nb_movies) - $filename${reset}"
((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 " %-21s %-35s \n" "Duree:" "${duree}"
printf " %-20s %-35s \n" "Duree:" "${duree}"
echo -e "\n${bold}Video:${reset}"
printf " %-21s %-35s \n" "Format video:" "${format_video}"
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}"
@@ -285,22 +457,49 @@ END_COMMENT
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" != 0 ]]; then
echo -e "\n${bold}Text:${reset}"
printf " %-20s %-35s \n" "Format text:" "${format_text}"
printf " %-20s %-35s \n" "Codec:" "${codec_text}"
printf " %-20s %-35s \n" "Language:" "${language_text}"
printf " %-20s %-35s \n" "Defaut:" "${default_text}"
fi
#if [ "$nb_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
if [[ "$nb_menu" != 0 ]]; then
echo -e "\n${bold}Menu:${reset}"
echo -e "$m"
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
@@ -309,11 +508,25 @@ END_COMMENT
file_export="$DEST"/"$new_name"
if [ ! -f "$file_export" ]; then
echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}\n"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2> $logfile
#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
@@ -323,7 +536,10 @@ END_COMMENT
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)
#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}"
@@ -336,10 +552,7 @@ END_COMMENT
fi
# Move SRC file to trash
# if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
# gvfs-trash filepath - gio trash some_file
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
@@ -347,28 +560,28 @@ END_COMMENT
if [ "$trash" = true ] && [[ "$OSTYPE" == "linux-gnu"* ]] && [[ $(command -v gio) != "" ]]; then
echo -e "\n${italic}Move ${filename} to trash...${reset}"
gio trash "$FILE" >/dev/null
else
echo -e "\n${italic}Move ${filename} to trash...${reset}"
fi
[ "$(echo "${parent_folder}/"*)" = "${parent_folder}/*" ] && rm -rf "${parent_folder}";
echo ""
((count++))
else
echo -e "\n${green}$file_export already transcoded !${reset}\n"
((already_transcoded+=1))
fi
FILESIZE=
done
transcoded=$((count-already_transcoded))
if [ "$count" -eq 0 ]; then
if [ "$transcoded" -eq 0 ]; then
echo -e "\n${red}No file to transcode !${reset}"
else
echo -e "\n${green}${count} files successfully transcoded !${reset}"
echo -e "\n${green}${transcoded} files successfully transcoded !${reset}"
fi

View File

@@ -136,6 +136,8 @@ 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}********************************************"

193
photo_du_mois.sh Executable file
View File

@@ -0,0 +1,193 @@
#!/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" "clicclac.synology.me" )
user=( "funnymac" "sentier" "bruno" )
dest=( "www/zenphoto/albums/photos-du-mois/" "httpdocs/photos/img/" "/volume1/web/photos/img/" )
port=( "22" "22" "42666" )
: <<'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"
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
echo -e "\n\n${bold}3. 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]}" == "clicclac.synology.me" ]; 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
# 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/
if [ "${server[$i]}" == "clicclac.synology.me" ]; 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}4. 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
echo -e "\n${bold}4. 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

126
sphp_php-fpm.sh Executable file
View 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

View File

@@ -4,7 +4,9 @@ host=$(hostname)
if [ "$host" = "DS916" ]; then
php_version=74
#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
@@ -25,6 +27,7 @@ if [ "$host" = "DS916" ]; then
#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
@@ -32,18 +35,20 @@ elif [ "$host" == "localhost" ]; then
if [ "$ip" = "212.227.191.167" ]; then
php_version=7.4
#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 occ maintenance:mode --on
sudo -u bruno $php_bin occ maintenance:repair
sudo -u bruno $php_bin updater/updater.phar
sudo -u bruno $php_bin -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 occ upgrade
sudo -u bruno $php_bin occ maintenance:mode --off
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