16-02-2022
This commit is contained in:
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"
|
||||
|
||||
275
convert-videos-for-plex.sh
Executable file
275
convert-videos-for-plex.sh
Executable file
@@ -0,0 +1,275 @@
|
||||
#!/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
|
||||
|
||||
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}
|
||||
|
||||
# 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
|
||||
23
mkbuild.sh
23
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,6 +20,16 @@ if [ "$1" == "-h" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
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" ]]; then
|
||||
@@ -62,11 +81,15 @@ notification() {
|
||||
}
|
||||
|
||||
cd $project_dir || exit
|
||||
mkdocs build --clean
|
||||
|
||||
: <<'END_COMMENT'
|
||||
if [[ "$device" == "airbook" ]]; then
|
||||
$HOME/Documents/venv/mkdocs/bin/mkdocs build --clean
|
||||
else
|
||||
mkdocs build --clean
|
||||
fi
|
||||
END_COMMENT
|
||||
|
||||
echo ""
|
||||
echo "*********************************************"
|
||||
|
||||
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 ""
|
||||
50
upgrade_nextcloud.sh
Executable file
50
upgrade_nextcloud.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
host=$(hostname)
|
||||
|
||||
if [ "$host" = "DS916" ]; then
|
||||
|
||||
php_version=74
|
||||
php_bin=/usr/local/bin/php$php_version
|
||||
nc_dir=/volume1/web/nextcloud
|
||||
|
||||
cd $nc_dir || exit
|
||||
|
||||
sudo -u http $php_bin -d memory_limit=1024M occ maintenance:mode --on
|
||||
sudo -u http $php_bin -d memory_limit=1024M occ maintenance:repair
|
||||
#echo ""
|
||||
#echo -e "\033[4mWhen the message 'Should the \"occ upgrade\" command be executed? [Y/n]' is displayed, you must choice 'n' (no)\033[0m"
|
||||
#echo ""
|
||||
sudo -u http $php_bin -d memory_limit=1024M updater/updater.phar
|
||||
|
||||
# Should the "occ upgrade" command be executed? [Y/n] n
|
||||
# non
|
||||
|
||||
#echo ""
|
||||
#echo -e "\033[4mLa version par défaut de PHP est la 5.6.11, ce qui est insuffisant (7.2 requis). On relance la suite avec la bonne version de php\033[0m"
|
||||
#echo ""
|
||||
#sudo -u http $php_bin -d memory_limit=1024M occ maintenance:mode --on
|
||||
sudo -u http $php_bin -d memory_limit=1024M occ upgrade
|
||||
sudo -u http $php_bin -d memory_limit=1024M occ maintenance:mode --off
|
||||
|
||||
elif [ "$host" == "localhost" ]; then
|
||||
ip=$(hostname -I | awk '{print $1}')
|
||||
|
||||
if [ "$ip" = "212.227.191.167" ]; then
|
||||
|
||||
php_version=7.4
|
||||
php_bin=/opt/plesk/php/$php_version/bin/php
|
||||
nc_dir=/var/www/vhosts/maboiteverte.fr/httpdocs/nextcloud
|
||||
|
||||
cd $nc_dir || exit
|
||||
|
||||
sudo -u bruno $php_bin occ maintenance:mode --on
|
||||
sudo -u bruno $php_bin occ maintenance:repair
|
||||
sudo -u bruno $php_bin updater/updater.phar
|
||||
|
||||
sudo -u bruno $php_bin occ upgrade
|
||||
sudo -u bruno $php_bin occ maintenance:mode --off
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
Reference in New Issue
Block a user