deploy_test.sh 1.2 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
# /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'