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

delete remote logs option added (-d)

parent a18966ca
......@@ -7,12 +7,26 @@ 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' \
'.gitignore' 'composer.json' '/www/index.php' \
'config.local.neon' 'config.production.neon')
# check options
while getopts ":d" opt; do
case $opt in
d)
delete_logs=1
;;
\?)
echo 'Invalid option!'
echo '-d to delete remote logs and exceptions'
echo 'exiting with no action'
exit 1
;;
esac
done
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
......@@ -68,5 +82,19 @@ echo ' * sending index.php'
rsync -az \
www/index.php $user@$server:$remote_dir/www/
echo '* rsync completed'
if [ $delete_logs -eq 1 ]
then
echo '* removing logs and stored exceptions'
sftp -q -i $key_path $user@$server >/dev/null 2>&1 << SFTPDELIM
cd $remote_dir
rm log/*.log
rm log/*.html
bye
SFTPDELIM
fi
echo '* maintance mode off. files uploaded! Yeeeeah!!'
exit 0
# /bin/bash
# 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/*')
# index.php excluded and send last because of maintenance mode
common_exclude=('*.ssh' '/temp/*' '/log/*' '/nbproject' '/.git' \
'.gitignore' 'composer.json' '/www/index.php' \
'config.local.neon' 'config.production.neon')
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $current_dir
# set maintenance mode
echo '* setting maintenance mode on remote app'
scp -i $key_path $user@$server:$remote_dir/www/index.php temp/
if [-f temp/index.php)]; then
sed -i "s/\/\/\s*require '.maintenance.php';/require '.maintenance.php';/" temp/index.php
fi
rsync -az \
temp/index.php $user@$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:$remote_dir"
rsync -az \
--delete \
--filter "P log/*.log" --filter "P log/*.html" \
--include ".htaccess" --exclude-from exclude.txt \
. $user@$server:$remote_dir/
rm exclude.txt
echo ' * uploading production config'
rsync -az \
app/config/config.production.neon
echo '* files uploaded.'
rsync -az \
www/index.php $user@$server:$remote_dir/www/
echo '* maintance mode off. files uploaded'
#!/bin/bash
server='195.210.29.9'
user='k-architekt.cz'
remote_dir='/web'
key_path='/home/mario/.ssh/websupport_key'
while getopts ":d" opt; do
case $opt in
d)
delete=1
echo '* remote logs removed'
;;
\?)
echo "Invalid option: -d to delete remote logs" >&2
;;
esac
if [ $delete -eq 1 ]
then
sftp -q -i $key_path $user@$server << SFTPDELIM
cd $remote_dir
rm log/*.log
rm log/*.html
bye
SFTPDELIM
fi
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