From d902783336dc51bc5030afe0406a23339777f573 Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Mon, 1 Aug 2022 15:49:27 +0200 Subject: [PATCH] Added scripts for the Server. --- scripts/cfgfiles/mycfg.ini | 1 + scripts/cfgfiles/pfile | 1 + scripts/cleanbackups_and_log.sh | 28 +++++ scripts/copia_db_da_a.sh | 74 ++++++++++++ .../copia_websites_from_freeplanet_to_vps1.sh | 27 +++++ scripts/create_new_cert.sh | 11 ++ scripts/create_new_website_email.sh | 13 +++ scripts/create_new_website_email_parte2.sh | 3 + scripts/create_new_website_email_parte3.sh | 1 + scripts/create_new_website_email_parte4.sh | 2 + scripts/dbbackup_reale.sh | 55 +++++++++ scripts/dbcopia_da_production_a_copiaTemp.sh | 3 + scripts/dbcopia_da_production_a_test.sh | 3 + scripts/dbcopia_da_test_a_production.sh | 3 + scripts/dbrestore_last.sh | 105 ++++++++++++++++++ scripts/esegui_reboot.sh | 3 + scripts/lgcontinuo.sh | 3 + scripts/lista_porte.sh | 3 + scripts/logserver.sh | 3 + scripts/logsrv_nano.sh | 3 + scripts/logtail.sh | 3 + scripts/mongodb_delete_database_production.sh | 11 ++ scripts/mongodb_delete_database_test.sh | 11 ++ scripts/production_restart_server.sh | 9 ++ scripts/restore_backup_all.sh | 8 ++ scripts/startup.sh | 23 ++++ scripts/status.sh | 4 + scripts/testserver_restart.sh | 6 + scripts/unban_ip.sh | 39 +++++++ scripts/uploaddb_remoto.sh | 15 +++ 30 files changed, 474 insertions(+) create mode 100644 scripts/cfgfiles/mycfg.ini create mode 100644 scripts/cfgfiles/pfile create mode 100755 scripts/cleanbackups_and_log.sh create mode 100755 scripts/copia_db_da_a.sh create mode 100755 scripts/copia_websites_from_freeplanet_to_vps1.sh create mode 100755 scripts/create_new_cert.sh create mode 100755 scripts/create_new_website_email.sh create mode 100755 scripts/create_new_website_email_parte2.sh create mode 100755 scripts/create_new_website_email_parte3.sh create mode 100755 scripts/create_new_website_email_parte4.sh create mode 100755 scripts/dbbackup_reale.sh create mode 100755 scripts/dbcopia_da_production_a_copiaTemp.sh create mode 100755 scripts/dbcopia_da_production_a_test.sh create mode 100755 scripts/dbcopia_da_test_a_production.sh create mode 100755 scripts/dbrestore_last.sh create mode 100755 scripts/esegui_reboot.sh create mode 100755 scripts/lgcontinuo.sh create mode 100755 scripts/lista_porte.sh create mode 100755 scripts/logserver.sh create mode 100755 scripts/logsrv_nano.sh create mode 100755 scripts/logtail.sh create mode 100755 scripts/mongodb_delete_database_production.sh create mode 100755 scripts/mongodb_delete_database_test.sh create mode 100755 scripts/production_restart_server.sh create mode 100755 scripts/restore_backup_all.sh create mode 100755 scripts/startup.sh create mode 100755 scripts/status.sh create mode 100755 scripts/testserver_restart.sh create mode 100755 scripts/unban_ip.sh create mode 100755 scripts/uploaddb_remoto.sh diff --git a/scripts/cfgfiles/mycfg.ini b/scripts/cfgfiles/mycfg.ini new file mode 100644 index 0000000..0d78475 --- /dev/null +++ b/scripts/cfgfiles/mycfg.ini @@ -0,0 +1 @@ + diff --git a/scripts/cfgfiles/pfile b/scripts/cfgfiles/pfile new file mode 100644 index 0000000..ff92768 --- /dev/null +++ b/scripts/cfgfiles/pfile @@ -0,0 +1 @@ +configuploadfile diff --git a/scripts/cleanbackups_and_log.sh b/scripts/cleanbackups_and_log.sh new file mode 100755 index 0000000..187981e --- /dev/null +++ b/scripts/cleanbackups_and_log.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# rm ~/backups/* +truncate -s 0 /var/www/www.freeplanet_server/out.log +# truncate -s 0 /var/www/www.freeplanet_server/err.log +truncate -s 0 /var/www/www.freeplanet_server/combined.outerr.log + +truncate -s 0 /var/www/test.freeplanet_server/out.log +truncate -s 0 /var/www/test.freeplanet_server/err.log +truncate -s 0 /var/www/test.freeplanet_server/combined.outerr.log + + +rm /var/log/auth.log.* +rm /var/log/btmp.* +rm /var/log/fail2ban.* +rm /var/log/kern.log.* +rm /var/log/mail.err.* +rm /var/log/mail.log.* +rm /var/log/syslog.* +truncate -s 0 /var/log/syslog +truncate -s 0 /var/log/xrdp.log +truncate -s 0 /var/log/auth.log +truncate -s 0 /var/log/kern.log +truncate -s 0 /var/log/mail.log +truncate -s 0 /var/log/mail.err +truncate -s 0 /var/log/btmp + + diff --git a/scripts/copia_db_da_a.sh b/scripts/copia_db_da_a.sh new file mode 100755 index 0000000..5a93708 --- /dev/null +++ b/scripts/copia_db_da_a.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +if [ "$1" = "" ]; then + read -p "DATABASE INGRESSO (FreePlanet) ? " DBIN +else + DBIN=$1 +fi + +if [ "$2" = "" ]; then + PORTIN="27017" +else + PORTIN=$2 +fi + +if [ "$3" = "" ]; then + read -p "DATABASE USCITA (FreePlanet) ? " DBOUT +else + DBOUT=$3 +fi + +if [ "$4" = "" ]; then + PORTOUT="27017" +else + PORTOUT=$4 +fi + +FILEMONGODB=tmp + +rm -R $FILEMONGODB + +echo "mongodump --db $DBIN --port=$PORTIN --out $FILEMONGODB" +mongodump --db $DBIN --port=$PORTIN --out $FILEMONGODB + +echo "Copia di $DBIN ($PORTIN) Effettuata in $FILEMONGODB !" + +sleep 1 +cd $FILEMONGODB +mv $DBIN $DBOUT +cd .. + + +echo "" +echo "" +echo "*****************************************************************************************************" +echo "*** MONGODB COPIA DATABASE CANCELLANDOLO !!!!! " +echo "***" +echo "----> SEI SICURO DI VOLER ELIMINARE E SCRIVERE IL DATABASE: " +echo "" +echo "'$DBOUT' ? " +echo "" +echo "File = $FILEMONGODB" +echo "" +echo "DBIN=$DBIN PORTIN=$PORTIN" +echo "DBOUT=$DBOUT PORTOUT=$PORTOUT" +echo "*****************************************************************************************************" +echo "" + +OPTDB="$DBOUT"".*" +echo "ESEGUO -> mongo $DBOUT --port=$PORTOUT --eval \"db.dropDatabase()\"" +echo "ESEGUO -> mongorestore --port=$PORTOUT --nsInclude $OPTDB $FILEMONGODB" +echo "" + +read -p "SICURO DI CONTINUARE ? (Y/N) ? " risposta + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + mongo $DBOUT --port=$PORTOUT --eval "db.dropDatabase()" + + mongorestore --port=$PORTOUT --nsInclude $OPTDB $FILEMONGODB + sleep 2 + + rm -R $FILEMONGODB +fi + +echo "Fine" diff --git a/scripts/copia_websites_from_freeplanet_to_vps1.sh b/scripts/copia_websites_from_freeplanet_to_vps1.sh new file mode 100755 index 0000000..2d2c25c --- /dev/null +++ b/scripts/copia_websites_from_freeplanet_to_vps1.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +msg="*** SINCRONIZZARE IL SERVER FREEPLANET SU VPS1 ?? (Y/N) ? " + +if [ "$1" = "" ]; then + read -p "$msg" risposta +else + echo $msg + risposta=$1 +fi + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + echo "Sincronizzazione in corso..." + rsync -avz -e 'ssh -p 5522' /var/www/riso.app/ paolo@vps1:/var/www/riso.app/ + rsync -avz -e 'ssh -p 5522' /var/www/test.riso.app/ paolo@vps1:/var/www/test.riso.app/ + rsync -avz -e 'ssh -p 5522' /var/www/artenergetica.org/ paolo@vps1:/var/www/artenergetica.org/ + rsync -avz -e 'ssh -p 5522' /var/www/associazioneshen.it/ paolo@vps1:/var/www/associazioneshen.it/ + rsync -avz -e 'ssh -p 5522' /var/www/brigittemgdumont.com/ paolo@vps1:/var/www/brigittemgdumont.com/ + rsync -avz -e 'ssh -p 5522' /var/www/comunitanuovomondo.app/ paolo@vps1:/var/www/comunitanuovomondo.app/ + rsync -avz -e 'ssh -p 5522' /var/www/mail/ paolo@vps1:/var/www/mail/ + rsync -avz -e 'ssh -p 5522' /var/www/nextcloud.freeplanet.app/ paolo@vps1:/var/www/nextcloud.freeplanet.app/ + rsync -avz -e 'ssh -p 5522' /var/www/popolodelnuovomondo.app/ paolo@vps1:/var/www/popolodelnuovomondo.app/ + rsync -avz -e 'ssh -p 5522' /var/www/www.freeplanet_server/ paolo@vps1:/var/www/www.freeplanet_server/ + rsync -avz -e 'ssh -p 5522' /var/www/test.freeplanet_server/ paolo@vps1:/var/www/test.freeplanet_server/ + + echo "Sincronizzazione TERMINATA - WEB SERVER!" +fi diff --git a/scripts/create_new_cert.sh b/scripts/create_new_cert.sh new file mode 100755 index 0000000..5736f16 --- /dev/null +++ b/scripts/create_new_cert.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/certbot/cloudflare.ini -d $1,*.$1 --preferred-challenges dns-01 + +read -p "CONTINUARE ? (Y/N) ? " risposta + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + + sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/certbot/cloudflare.ini -d $1,*.$1 --preferred-challenges dns-01 + +fi diff --git a/scripts/create_new_website_email.sh b/scripts/create_new_website_email.sh new file mode 100755 index 0000000..bb894c8 --- /dev/null +++ b/scripts/create_new_website_email.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ "$1" = "" ]; then + read -p "Dominio ? (esempio: riso.app) " MYDOMAIN +else + MYDOMAIN=$1 +fi + +mkdir -p /etc/opendkim/keys/$MYDOMAIN +cd /etc/opendkim/keys/$MYDOMAIN +opendkim-genkey -t -s mail -d $MYDOMAIN +cat /etc/opendkim/keys/$MYDOMAIN/mail.txt +chown opendkim:opendkim /etc/opendkim/keys/$MYDOMAIN/mail.private diff --git a/scripts/create_new_website_email_parte2.sh b/scripts/create_new_website_email_parte2.sh new file mode 100755 index 0000000..184d313 --- /dev/null +++ b/scripts/create_new_website_email_parte2.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +nano /etc/opendkim/SigningTable diff --git a/scripts/create_new_website_email_parte3.sh b/scripts/create_new_website_email_parte3.sh new file mode 100755 index 0000000..2245892 --- /dev/null +++ b/scripts/create_new_website_email_parte3.sh @@ -0,0 +1 @@ +nano /etc/dkim-domains.txt diff --git a/scripts/create_new_website_email_parte4.sh b/scripts/create_new_website_email_parte4.sh new file mode 100755 index 0000000..f84b8cd --- /dev/null +++ b/scripts/create_new_website_email_parte4.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nano /etc/opendkim/KeyTable diff --git a/scripts/dbbackup_reale.sh b/scripts/dbbackup_reale.sh new file mode 100755 index 0000000..943fae4 --- /dev/null +++ b/scripts/dbbackup_reale.sh @@ -0,0 +1,55 @@ +# Back Up Mysql Database phproject By oTTo +#!/bin/bash + +#MONGODB: +# NOWMONGOFILE="SERVERENG_MONGODB_$(date +"%d-%m-%Y-%H-%M")" + +NOWMONGOFILE="SERVERENG_MONGODB_H_$(date +"%H")" + +NOWMONGOFILE_MONTH="SERVERENG_MONGODB_MONTH_$(date +"%m")" + +NOWMONGOFILE_WEEK="SERVERENG_MONGODB_WEEK_$(date +"%u")" + +NOWMONGOFILE_SERVER="SERVERENG_MONGODB_SERVER_H_$(date +"%H")" + + +FILEMONGODB=/root/backups/$NOWMONGOFILE + +echo "Dump del DB..." +mongodump --db FreePlanet --out $FILEMONGODB +sleep 1 +echo "Targz del DB..." +cd /root/backups/ +echo "sudo tar cvfz $NOWMONGOFILE.tar.gz $NOWMONGOFILE/" + +sudo tar cvfz $NOWMONGOFILE.tar.gz $NOWMONGOFILE/ + +sleep 1 + +rm $NOWMONGOFILE.tar.gz.nc + +sleep 1 + +mcrypt -f /root/batch/cfgfiles/mycfg.ini $NOWMONGOFILE.tar.gz + +sleep 1 + +rm -R $NOWMONGOFILE/ +rm $NOWMONGOFILE.tar.gz + +echo "File" $NOWMONGOFILE.tar.gz.mc + +cp -R $NOWMONGOFILE.tar.gz.nc /root/backups/$NOWMONGOFILE_MONTH.tar.gz.nc + +sleep 1 +cp -R $NOWMONGOFILE.tar.gz.nc /root/backups/$NOWMONGOFILE_WEEK.tar.gz.nc + +sleep 1 +cp -R $NOWMONGOFILE.tar.gz.nc /root/backups/$NOWMONGOFILE_SERVER.tar.gz.nc + +cp -R $NOWMONGOFILE.tar.gz.nc /home/paolo/backups/$NOWMONGOFILE.tar.gz.nc + +chown paolo:paolo /home/paolo/backups/$NOWMONGOFILE.tar.gz.nc + +echo "Fine" + diff --git a/scripts/dbcopia_da_production_a_copiaTemp.sh b/scripts/dbcopia_da_production_a_copiaTemp.sh new file mode 100755 index 0000000..63aab71 --- /dev/null +++ b/scripts/dbcopia_da_production_a_copiaTemp.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./copia_db_da_a.sh "FreePlanet" "27017" "copiatemp_FreePlanet" "27017" diff --git a/scripts/dbcopia_da_production_a_test.sh b/scripts/dbcopia_da_production_a_test.sh new file mode 100755 index 0000000..dadff11 --- /dev/null +++ b/scripts/dbcopia_da_production_a_test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./copia_db_da_a.sh "FreePlanet" "27017" "test_FreePlanet" "27018" diff --git a/scripts/dbcopia_da_test_a_production.sh b/scripts/dbcopia_da_test_a_production.sh new file mode 100755 index 0000000..82ec02e --- /dev/null +++ b/scripts/dbcopia_da_test_a_production.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./copia_db_da_a.sh "test_FreePlanet" "27018" "FreePlanet" "27017" diff --git a/scripts/dbrestore_last.sh b/scripts/dbrestore_last.sh new file mode 100755 index 0000000..a468069 --- /dev/null +++ b/scripts/dbrestore_last.sh @@ -0,0 +1,105 @@ +# Back Up Mysql Database phproject By oTTo +#!/bin/bash + +DATABASENAME=FreePlanet + +function getfirstfile { + myresult=$(ls -t | head -1) +} + +cd /root/backups + + +if [ "$1" = "" ]; then + getfirstfile + FF=$myresult +else + FF=$1 +fi + +DIRBACKUP=/root/backups +DIRRESTORE=/root/restore + +FILEMONGODB=$DIRBACKUP/$FF +FILEMONGODBWORK=$DIRRESTORE/$FF + + +echo "" +echo "" +echo "*****************************************************************************************************" +echo "*** MONGODB RESTORE DATABASE !!!!! SEI SICURO DI VOLER RIPRISTINARE IL DATABASE '$DATABASENAME' ? " +echo "File = $FILEMONGODB" +echo "" +echo "DIRBACKUP=$DIRBACKUP" +echo "DIRRESTORE=$DIRRESTORE" +echo "*****************************************************************************************************" + +read -p "SICURO DI CONTINUARE ? (Y/N) ? " risposta + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + + if [[ $DIRRESTORE ]]; then + rm -R $DIRRESTORE/* + fi + + mkdir $DIRRESTORE + + cd $DIRRESTORE + + cp $FILEMONGODB $FILEMONGODBWORK + + echo "1) DECRIPTING : " + $FILEMONGODBWORK + + sleep 1 + + mcrypt -d -f /root/batch/cfgfiles/mycfg.ini $FILEMONGODBWORK + + sleep 1 + + rm $FILEMONGODBWORK + + getfirstfile + FILEENCRYPTED=$myresult + + echo "1-OK) -> FILE ENCRYPTED: " $FILEENCRYPTED + echo "" + + sleep 1 + + if [[ "$FILEENCRYPTED" ]]; then + + echo "2) EXTRACTING " $FILEENCRYPTED + echo "" + + sudo tar xvfz $FILEENCRYPTED + + sleep 1 + + rm $FILEENCRYPTED + + sleep 1 + + getfirstfile + DIRDATABASE=$myresult + + echo "2B) -> Extracted: " $DIRDATABASE + + # Restore + + OPTDB="$DATABASENAME"".*" + echo "OPTDB=" $OPTDB + + echo "3) RESTORE MONGODB DATABASE: " mongorestore --nsInclude $OPTDB $DIRDATABASE + + + sleep 5 + + mongorestore --nsInclude $OPTDB $DIRDATABASE + + fi + + echo "Fine" + +fi + + diff --git a/scripts/esegui_reboot.sh b/scripts/esegui_reboot.sh new file mode 100755 index 0000000..7a10baf --- /dev/null +++ b/scripts/esegui_reboot.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +reboot diff --git a/scripts/lgcontinuo.sh b/scripts/lgcontinuo.sh new file mode 100755 index 0000000..6d21ba2 --- /dev/null +++ b/scripts/lgcontinuo.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +tail -f /var/www/www.freeplanet_server/logs/combined.outerr.log diff --git a/scripts/lista_porte.sh b/scripts/lista_porte.sh new file mode 100755 index 0000000..f67e6ff --- /dev/null +++ b/scripts/lista_porte.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo lsof -iTCP -sTCP:LISTEN -n -P diff --git a/scripts/logserver.sh b/scripts/logserver.sh new file mode 100755 index 0000000..759f57c --- /dev/null +++ b/scripts/logserver.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +tail -50 /var/www/www.freeplanet_server/logs/combined.outerr.log diff --git a/scripts/logsrv_nano.sh b/scripts/logsrv_nano.sh new file mode 100755 index 0000000..163d6ce --- /dev/null +++ b/scripts/logsrv_nano.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +nano /var/www/www.freeplanet_server/logs/combined.outerr.log diff --git a/scripts/logtail.sh b/scripts/logtail.sh new file mode 100755 index 0000000..6d21ba2 --- /dev/null +++ b/scripts/logtail.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +tail -f /var/www/www.freeplanet_server/logs/combined.outerr.log diff --git a/scripts/mongodb_delete_database_production.sh b/scripts/mongodb_delete_database_production.sh new file mode 100755 index 0000000..e6d8d14 --- /dev/null +++ b/scripts/mongodb_delete_database_production.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +db=FreePlanet +port=27017 + +read -p "*** DATABASE MONGODB -------- SEI VERAMENTE SICURO DI CANCELLARE IL DATABASE $db (Y/N) ? " risposta + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + mongo $db --port $port --eval "db.dropDatabase()" +fi + diff --git a/scripts/mongodb_delete_database_test.sh b/scripts/mongodb_delete_database_test.sh new file mode 100755 index 0000000..494df5e --- /dev/null +++ b/scripts/mongodb_delete_database_test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +db=Test_FreePlanet +port=27018 + +read -p "*** DATABASE MONGODB DI TEST -------- SEI SICURO DI CANCELLARE IL DATABASE $db (Y/N) ? " risposta + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + mongo $db --port $port --eval "db.dropDatabase()" +fi + diff --git a/scripts/production_restart_server.sh b/scripts/production_restart_server.sh new file mode 100755 index 0000000..1c4ba23 --- /dev/null +++ b/scripts/production_restart_server.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd /var/www/www.freeplanet_server +./startpm2.sh + +cd /var/www/test.freeplanet_server +./startpm2.test.sh +sleep 5 +./statuspm2.sh diff --git a/scripts/restore_backup_all.sh b/scripts/restore_backup_all.sh new file mode 100755 index 0000000..7f676e5 --- /dev/null +++ b/scripts/restore_backup_all.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +read -p "*** RIPRISTINO BACKUP ! -------- SEI SICURO DI CANCELLARE TUTTO ??? (Y/N) ? " risposta + +if [[ $risposta == "Y" || $risposta == "y" ]]; then + cd / + sudo tar -xzvf /mnt/backup/freeplanet-Sunday.tgz +fi diff --git a/scripts/startup.sh b/scripts/startup.sh new file mode 100755 index 0000000..d514262 --- /dev/null +++ b/scripts/startup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +sudo ufw --force enable +/usr/bin/mongod --config /etc/mongod2.conf & 2> /var/www/test.freeplanet_server/errmongo.txt +sleep 10 +cd /var/www/www.freeplanet_server +./startpm2.sh +cd /var/www/test.freeplanet_server +./startpm2.test.sh + +sleep 7 +cd /var/www/www.freeplanet_server +./stop_pm2.sh +sleep 7 +./startpm2.sh + +sleep 7 +cd /var/www/test.freeplanet_server +./stop_pm2.test.sh +sleep 7 +./startpm2.test.sh +sleep 5 +./statuspm2.sh diff --git a/scripts/status.sh b/scripts/status.sh new file mode 100755 index 0000000..32ea8e3 --- /dev/null +++ b/scripts/status.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd /var/www/test.freeplanet_server +./statuspm2.sh diff --git a/scripts/testserver_restart.sh b/scripts/testserver_restart.sh new file mode 100755 index 0000000..f6e36fe --- /dev/null +++ b/scripts/testserver_restart.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd /var/www/test.freeplanet_server +./startpm2.test.sh +sleep 5 +./statuspm2.sh diff --git a/scripts/unban_ip.sh b/scripts/unban_ip.sh new file mode 100755 index 0000000..8ea7cb0 --- /dev/null +++ b/scripts/unban_ip.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +logfile=’/var/log/fail2ban.log’ +fallbackjail=’sshd’ + +echo “Enter ip to unban:” +read ip + +echo “Checking whether the ip is banned” +if [ 0 -lt `iptables -n -L|grep “REJECT”|grep “\”|wc -l` ] +then +echo “The ip $ip is banned” +else +echo “The ip $ip is not banned, ABORTING” +exit +fi + +echo “Trying to guess the jail name from $logfile” +jail=`grep “Ban $ip$” $logfile|cut -d ‘[‘ -f 3|cut -d ‘]’ -f 1` +if [ 0 -lt ${#jail} ] +then +echo “Found jail $jail for this ip” +else +echo “No jail found assuming $fallbackjail” +jail=$fallbackjail +fi + +echo “Checking that jail exists” +exists=`fail2ban-client status|grep “$jail”` +if [ 0 -lt ${#exists} ] +then +echo “Jail $jail exists” +else +echo “Jail $jail doesn’t exist, ABORTING” +exit +fi + +echo “Unbanning ip $ip from jail $jail” +fail2ban-client set $jail unbanip $ip diff --git a/scripts/uploaddb_remoto.sh b/scripts/uploaddb_remoto.sh new file mode 100755 index 0000000..812f660 --- /dev/null +++ b/scripts/uploaddb_remoto.sh @@ -0,0 +1,15 @@ +# Back Up Mysql Database phproject By oTTo +#!/bin/bash + +DIRBACKUP=/root/backups + +cd $DIRBACKUP + +FF=$(ls -t * | head -1) + +FILE=$DIRBACKUP/$FF + + +echo "Invia il File $FILE" + +sshpass -f "/root/batch/cfgfiles/pfile" scp $FILE student@vps1:~/backups/