Commit 70998f34 authored by Miloš Diviš's avatar Miloš Diviš
Browse files

temp path and index delete fixed

parent 9732d59b
......@@ -7,12 +7,12 @@
#
# setup
server='195.210.29.9'
server='k-architekt.cz'
user='k-architekt.cz'
remote_dir='/web'
remote_dir='web'
key_path='/home/mario/.ssh/websupport_key'
rsync_exclude=('/www/images/uploads/*')
temp_dir='/temp'
temp_dir='temp'
# index.php excluded from project files sync and send last because of maintenance mode
common_exclude=('*.ssh' '/temp/*' '/log/*' '/nbproject' '/.git' 'deploy.sh' '*~'\
......@@ -21,10 +21,11 @@ common_exclude=('*.ssh' '/temp/*' '/log/*' '/nbproject' '/.git' 'deploy.sh' '*~'
# download remote index.php to set maintenance mode
function downloadIndex {
scp -q -i $key_path $user@$server:$remote_dir/www/index.php ./$temp_dir/
scp -q -i $key_path $user@$server:$remote_dir/www/index.php $temp_dir/
}
function displayHelp {
pwd
echo 'Deploy script for Nette application'
echo '-----------------------------------'
echo '-d to delete remote logs and exceptions'
......@@ -34,20 +35,20 @@ function displayHelp {
function toggleMaintenance {
downloadIndex
if [ -f ./$temp_dir/index.php ]
if [ -f $temp_dir/index.php ]
then
state=''
if grep -Eq "require '\.maintenance\.php'" ./$temp_dir/index.php
if grep -Eq "require '\.maintenance\.php'" $temp_dir/index.php
then
sed -ri "/require '\.maintenance\.php';/d" ./$temp_dir/index.php
sed -ri "/require '\.maintenance\.php';/d" $temp_dir/index.php
state='disabled'
else
sed -ri "/^(<\?php|<\?)/a require '.maintenance.php';" ./$temp_dir/index.php
sed -ri "/^(<\?php|<\?)/a require '.maintenance.php';" $temp_dir/index.php
state='enabled'
fi
rsync -az \
./$temp_dir/index.php $user@$server:$remote_dir/www/
rm ./$temp_dir/index.php
$temp_dir/index.php $user@$server:$remote_dir/www/
rm $temp_dir/index.php
echo "*** Maintenance mode $state"
else
echo "!!! No index on remote server ($user@$server:$remote_dir/www/index.php)"
......@@ -75,11 +76,11 @@ while getopts ":dh-:" opt; do
;;
"delete-cache"*)
toggleMaintenance
mkdir ./$temp_dir/empty
mkdir $temp_dir/empty
rsync -az --delete \
./$temp_dir/empty/ $user@$server:$remote_dir/temp/cache/
$temp_dir/empty/ $user@$server:$remote_dir/temp/cache/
toggleMaintenance
rmdir ./$temp_dir/empty
rmdir $temp_dir/empty
echo '*** cache deleted'
exit 0
;;
......@@ -98,16 +99,18 @@ cd $current_dir
# set maintenance mode
echo '* setting maintenance mode on remote app'
downloadIndex
# set maintance mode if app is on remote
if [ -f ./$temp_dir/index.php ]
if [ -f $temp_dir/index.php ]
then
if grep -Eq "require '\.maintenance\.php'" ./$temp_dir/index.php
if grep -Eq "require '\.maintenance\.php'" $temp_dir/index.php
then
toggleMaintenance
else
echo " i maintenance mode was already on"
echo " after deploy state depends on local index."
else
toggleMaintenance
fi
fi
# create exclude text file
......@@ -132,14 +135,13 @@ rsync -az \
rm exclude.txt
if [ -f app/config/config.production.neon ]
then
echo ' * sending production config'
cp app/config/config.production.neon ./$temp_dir/config.local.neon
cp app/config/config.production.neon $temp_dir/config.local.neon
rsync -az \
./$temp_dir/config.local.neon $user@$server:$remote_dir/app/config/
rm ./$temp_dir/config.local.neon
$temp_dir/config.local.neon $user@$server:$remote_dir/app/config/
rm $temp_dir/config.local.neon
else
echo ' i Production config not found'
fi
......
Supports Markdown
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