Commit fd0c4ee3 authored by Miloš Diviš's avatar Miloš Diviš
Browse files

delete logs option added, coments altered

parent c595b097
# /bin/bash
# Deply script for Nette application
#
# minified nette version expected in ./Nette-minified/nette.min.php
#
# setup
server='195.210.29.9'
user='k-architekt.cz'
remote_dir='/web'
key_path='/home/mario/.ssh/websupport_key'
rsync_exclude=('/www/images/uploads/*')
delete_logs=0
# index.php excluded and send last because of maintenance mode
common_exclude=('*.ssh' '/temp/*' '/log/*' '/nbproject' '/.git' \
# index.php excluded from project files sync and send last because of maintenance mode
common_exclude=('*.ssh' '/temp/*' '/log/*' '/nbproject' '/.git' 'deploy.sh' '*~'\
'.gitignore' 'composer.json' '/www/index.php' \
'config.local.neon' 'config.production.neon')
# check options
delete_logs=0
while getopts ":d" opt; do
case $opt in
d)
......@@ -82,7 +88,7 @@ echo ' * sending index.php'
rsync -az \
www/index.php $user@$server:$remote_dir/www/
echo '* rsync completed'
echo '* rsync completed, maitenance mode off.'
if [ $delete_logs -eq 1 ]
then
......@@ -95,6 +101,6 @@ if [ $delete_logs -eq 1 ]
SFTPDELIM
fi
echo '* maintance mode off. files uploaded! Yeeeeah!!'
echo '*** Deploy completed! Yeeeeah! ***'
exit 0
# /bin/bash
# setup
server='aaaa'
remote_dir='/www/'
rsync_exclude=('/www/images/uploads/*')
# index.php excluded and send last because of maintenance mode
common_exclude=('*.ssh' '/temp/*' '/log/*' '/nbproject' '/.git' '.gitignore' 'composer.json' '/www/index.php')
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $current_dir
# set maintenance mode
echo '* setting maintenance mode on remote app'
rsync -v --dry-run \
"$server:$remote_dir/www/index.php temp/"
sed -i "s/\/\/\s*require '.maintenance.php';/require '.maintenance.php';/" index.php
rsync -v --dry-run \
"temp/index.php $server:$remote_dir/www/"
rm temp/index.php
# create exclude text file
for i in "${rsync_exclude[@]}"
do
echo $i >> exclude.txt
done
for i in "${common_exclude[@]}"
do
echo $i >> exclude.txt
done
echo '* Starting rsync to $server:$target_dir/test/'
rsync -v --dry-run \
-r --delete \
--filter "P log/*.log" --filter "P log/*.html" \
--include ".htaccess" --exclude-from exclude.txt \
"." "moved/"
# . "$server:$target_dir/test/"
rm exclude.txt
echo '* files uploaded. Sending index.php'
rsync -v --dry-run \
www/index.php "$server:$remote_dir/www/"
echo '* maintance mode off. files uploaded'
#!/bin/bash
while getopts ":d" opt; do
case $opt in
d)
echo "-d was triggered!"
;;
\?)
echo "Invalid option: -d to delete remote logs" >&2
;;
esac
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment