deploy.sh.save 1.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# /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'