Initial commit

This commit is contained in:
2019-10-25 17:08:00 +02:00
commit dc0dcecdce
5 changed files with 266 additions and 0 deletions

54
apache_tools.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/env bash
version=7.2
echo -e "\033[1mApache Tools: \033[0m"
editeur=/usr/local/bin/bbedit
v_apa=$(httpd -V | grep 'SERVER_CONFIG_FILE')
conf_apa=$(echo "$v_apa" | awk -F "\"" '{print $2}')
log_apa=$(grep -e '^ErrorLog' "$conf_apa" | awk -F "\"" '{print $2}')
access_apa=$(grep -e 'CustomLog' "$conf_apa" | grep -v "#" | awk -F "\"" '{print $2}')
vhost=$(grep -e 'httpd-vhosts.conf' "$conf_apa" | awk '{print $2}')
ssl=$(grep -e 'httpd-ssl.conf' "$conf_apa" | awk '{print $2}')
v_php=$(php --info | grep -E 'usr.*ini')
conf_php=$(echo "$v_php" | grep 'Loaded Configuration File' | awk '{print $NF}')
v_mysql=$(mysql --help | grep -A1 'Default options')
options=(
"Apache (r)estart"
"(E)dit httpd.conf"
"Edit httpd-v(h)osts.conf"
"Edit httpd-(s)sl.conf"
"error_log Apache"
"(a)ccess_log Apache"
"Edit (P)HP.ini"
"Apache/PHP/MySQL (V)ersion"
"Apache/PHP/MySQL (C)onfiguration files"
"Switch to PHP version"
"(Q)uit"
)
select option in "${options[@]}"; do
case "$REPLY" in
1|r|R) sudo apachectl -k restart ;;
2|e|E) "$editeur" "$conf_apa" ;; # httpd.conf
3|h|H) "$editeur" "$vhost" ;; # httpd-vhost.conf
4|s|S) "$editeur" "$ssl" ;; # httpd-ssl.conf
5) tail -f "$log_apa" ;;
6|a|A) tail -f "$access_apa" ;;
7|p|P) "$editeur" "$conf_php" ;; # php.ini
8|v|V) apachectl -v && echo ' ' && php -v && echo ' ' && mysql --version ;;
9|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 ;;
10) read -e -n 3 -p "Which PHP version? (7.2/7.3)" choice
if [[ "$choice" == "7.2" ]] || [[ "$choice" == "7.3" ]]; then echo "$choice" | xargs -p -n 1 sphp ; fi ;;
11|q|Q) break ;;
esac
done
#echo "$i" | awk '{print $1}' | xargs -p -n 1 brew upgrade
#LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so
##LoadModule php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so

45
backup-conf.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
if [ "$1" == "-h" ]; then
echo -e "\033[93mbackup-conf.sh\033[0m"
echo "Backup several files and folders:"
echo
echo " - httpd.conf"
echo " - httpd-vhosts.conf"
echo " - php.ini"
echo " - .bash_profile"
echo " - .gitconfig"
echo " - .wg++"
echo " - .nanorc, .nanosyntax"
echo " - .ssh"
echo " - .vnc"
echo " - .kymsu"
echo
echo "USAGE: backup-conf"
echo
echo " -h display this help"
echo
exit 0
fi
APACHE=$(httpd -v | grep "version" | awk '{print $3}' | awk -F/ '{print $2}')
PHP=$(php -v | grep "cli" | awk '{print $2}')
cd /Users/bruno/Documents/config\ web\ \(homebrew\)/
if [ ! -d "apache $APACHE" ]; then mkdir "apache $APACHE"; fi
cp /usr/local/etc/httpd/httpd.conf /Users/bruno/Documents/config\ web\ \(homebrew\)/apache\ $APACHE/
cp /usr/local/etc/httpd/extra/httpd-vhosts.conf /Users/bruno/Documents/config\ web\ \(homebrew\)/apache\ $APACHE/
if [ ! -d "php $PHP" ]; then mkdir "php $PHP"; fi
cp /usr/local/etc/php/7.2/php.ini /Users/bruno/Documents/config\ web\ \(homebrew\)/php\ $PHP/
cp /Users/bruno/.bash_profile /Users/bruno/Documents/Backups/Bruno/
cp /Users/bruno/.gitconfig /Users/bruno/Documents/Backups/Bruno/
cp /Users/bruno/.wg++/WebGrab++.config.xml /Users/bruno/Documents/Backups/Bruno/
cp /Users/bruno/.nanorc /Users/bruno/Documents/Backups/Bruno/
cp -R /Users/bruno/.nanosyntax /Users/bruno/Documents/Backups/Bruno/
cp -R /Users/bruno/.ssh /Users/bruno/Documents/Backups/Bruno/
cp -R /Users/bruno/.vnc /Users/bruno/Documents/Backups/Bruno/
cp -R /Users/bruno/.kymsu /Users/bruno/Documents/Backups/Bruno/
terminal-notifier -title 'Backups' -message 'Sauvegarde terminée !' -sound 'Glass'

97
backup_mysql.sh Executable file
View File

@@ -0,0 +1,97 @@
#!/bin/bash
#
####################################################################
## Shell script to backup all MySql database with single User
##
## MySQL Database Backup Script
## Written By: Amol Jhod
## URL: https://www.itsupportwale.com/blog/learn-how-to-backup-up-all-mysql-databases-using-a-single-user-with-a-simple-bash-script
## Last Update: Apr 25, 2019
##
## For more scripts please visit : www.itsupportwale.com
##
#####################################################################
#####################################################################
#### Caution : This script is takes backup of all databases #########
############# on which the given user is having access. ###########
############## And Delete the backups older then BKP_DAYS ##########
#####################################################################
#####################################################################
########### You Have to Update the Below Values #####################
#####################################################################
#
#
BKP_USER="mysqlbackupuser" # Enter the username for backup
BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user
#
BKP_DEST="$HOME/Documents/MySQL" # Enter the Backup directory,change this if you have someother location
#
## Note: Scripts will delete all backup which are older then BKP_DAYS##
#
BKP_DAYS="2" # Enter how many days backup you want,
#
########### Use This for only local server #############################
MYSQL_HOST="localhost"
#
#
########################################################################
########### Thats Enough!! NO NEED TO CHANGE THE BELOW VALUES ##########
########################################################################
#
##################### Get Backup DATE ##################################
#
BKP_DATE="$(date +"%A_%d-%m-%Y_%H-%M-%S")";
#BKP_DATE="$(date +"%A_%d-%m-%Y_%T")";
#
########## Ignore these default databases shen taking backup ############
#
IGNORE_DB="information_schema mysql performance_schema"
#
########## Creating backup dir if not exist #############################
#
[ ! -d $BKP_DEST ] && mkdir -p $BKP_DEST || :
#
################# Autodetect the linux bin path #########################
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
echo "$MYSQL"
#
###################### Get database list ################################
#
DB_LIST="$($MYSQL -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -Bse 'SHOW DATABASES')"
echo "$DB_LIST"
#
for db in $DB_LIST
do
skipdb=-1
if [ "$IGNORE_DB" != "" ];
then
for i in $IGNORE_DB
do
[ "$db" == "$i" ] && skipdb=1 || :
done
fi
if [ "$skipdb" == "-1" ] ; then
BKP_FILENAME="$BKP_DEST/$db.$BKP_DATE.sql"
BKP_GZ_FILENAME="$BKP_DEST/$db.$BKP_DATE.sql.gz"
#
################ Using MYSQLDUMP for bakup and Gzip for compression ###################
#
#$MYSQLDUMP -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS $db | $GZIP -9 > $BKP_FILENAME
$MYSQLDUMP -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -r$BKP_FILENAME $db
$GZIP -9 $BKP_FILENAME
scp "$BKP_GZ_FILENAME" funnymac@ftp.cluster011.ovh.net:www/backup/
fi
done
#########To delete all backup files older then BKP_DAYS #################
#
find $BKP_DEST -type f -mtime +$BKP_DAYS -delete
#
#
#### End of script ####

28
bash_tools.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
echo -e "\033[1mBash Tools: \033[0m"
editeur=/usr/local/bin/bbedit
# 1: ~/.bash_profile
# 2: ~/.bash_login
# 3: ~/.profile
options=(
"(E)dit .bash_profile"
"(S)ource .bash_profile (reload)"
"(B)ackup .bash_profile"
"(R)estore .bash_profile"
"(Q)uit"
)
select option in "${options[@]}"; do
case "$REPLY" in
1|e|E) "$editeur" ~/.bash_profile ;;
2|s|S) source ~/.bash_profile ;;
3|b|B) scp ~/.bash_profile funnymac@ftp.cluster011.ovh.net:www/backup ;;
4|r|R) curl http://clicclac.info/backup/.bash_profile > ~/.bash_profile && reload ;;
5|q|Q) break ;;
esac
done

42
mkbuild.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
if [ "$1" == "-h" ]; then
echo -e "\\033[93mmkbuild.sh\\033[0m"
echo "Build MkDocs project and send him on server"
echo
echo "USAGE: mkbuild"
echo
echo " -h display this help"
echo
exit 0
fi
project_dir=/Users/bruno/project
exe=/usr/local/bin/
user="bruno"
server="clicclac.synology.me"
destination="/volume1/web"
local_folder="central_docs"
cd $project_dir || exit
$exe/mkdocs build --clean
scp -P42666 -pr ./$local_folder $user@$server:$destination
#rsync -avz --stats --progress /Users/bruno/project/central_docs/ $user@$server::$dest
result=$?
titre="MkDocs"
if [ $result -eq 0 ]; then
sound="Glass"
message="Envoi terminé sur $server !"
else
sound="Basso"
message="Echec lors de l'envoi sur $server : erreur $result"
fi
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v zenity)" ]; then
zenity --title="$titre" --notification --text="$message"
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$titre" -message "$message" -sound $sound
fi