Marco Oliveira
Well-Known Member
- Joined
- Jan 5, 2019
- Messages
- 76
- Solutions
- 3
- Reaction score
- 78
- Location
- Minas Gerais - Brazil
- GitHub
- omarcopires
- Twitch
- omarcopires
The script does nothing more than a git pull from your server when it's called reloading or crashing.
In the root mass of your repository create a file called startserver.sh and a folder named logs inside the root mass of your site.
Still in the root folder of your server create a folder called backup and inside it create a file called backup.sh
Do not and do not allow 777 permission on all files, and also connect the server with the command ./startserver.sh
NOTE: you must configure the ssh key in your git so you do not ask for the email and password every reload, the git clone must also be done through ssh and not https
In the root mass of your repository create a file called startserver.sh and a folder named logs inside the root mass of your site.
Bash:
pastaOt="server directory"
comandoBackup="server directory/backup/backup.sh"
echo "Iniciando o programa"
cd $pastaOt
mkdir -p /logs
mkdir -p build
while true
do
cd $pastaOt
./tfs 2>&1 | awk '{ print strftime("%F %T - "), $0; fflush(); }' | tee "/var/www/html/logs/$(date +"%F %H-%M-%S.log")"
exitcode=${PIPESTATUS[0]}
if [ $exitcode -eq 0 ]; then
echo "Clean close"
git pull
cd build
cmake ..
make
if [$? -ne 0]; then
echo "Compilation failed!"
else
echo "Compilation successful!"
mv tfs ..
fi
cd ..
else
echo "Server Crash!!! (O arquivo de log está guardado na pasta logs)"
fi
echo "Server Down, backup database..."
$comandoBackup
sleep 2
done;
Still in the root folder of your server create a folder called backup and inside it create a file called backup.sh
Bash:
CAMINHO="server directory/backup/"
NOMEBACKUP="backup file name"
USER="root"
SENHA="phpmyadmin password"
BANCO="database name"
TEMPO="$(date +'%d-%m-%Y-%H-%M')"
if [[ -z "$USER" || -z "$SENHA" || -z "$BANCO" ]]; then
echo "Please fill in the username, password and database in the configurations."
else
mysqldump -u$USER -p$SENHA $BANCO > $CAMINHO"/"$NOMEBACKUP"-"$TEMPO".sql"
Do not and do not allow 777 permission on all files, and also connect the server with the command ./startserver.sh
NOTE: you must configure the ssh key in your git so you do not ask for the email and password every reload, the git clone must also be done through ssh and not https
Last edited by a moderator: