-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrealDeploy.sh
More file actions
executable file
·126 lines (107 loc) · 3.19 KB
/
realDeploy.sh
File metadata and controls
executable file
·126 lines (107 loc) · 3.19 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
#environnement argument
environnement=$1
srcPath=$2
if [ -z $environnement ]; then
echo "Environnement is missing"
exit -1
elif [ -z $srcPath ]; then
echo "SRC path is missing"
exit -1
elif [ $environnement != 'prod' ] && [ $environnement != 'recette' ]; then
echo "Environnement is wrong, should be prod or recette"
exit -1
fi
source "${srcPath}/variables.prod"
echo "*******************************************************"
echo "Scripts vars"
echo "*******************************************************"
echo "Deploy path : $deployPath "
echo "Config path : $configPath "
echo "Git repo : $gitPath "
echo "Release date : $releaseDate "
echo "Choosen tag: $versionTag "
#change dir to app path
cd $deployPath
pwd
echo "*******************************************************"
echo "Cloning tag into releases directory"
echo "*******************************************************"
if [ -z $versionTag ]; then
git clone --single-branch $gitPath $releaseDate
else
git clone -b ${versionTag} --single-branch $gitPath $releaseDate
fi
cd $releaseDate
pwd
# Install new composer packages
echo "*******************************************************"
echo "INSTALLING COMPOSER PACKAGES"
echo "*******************************************************"
composer install --no-dev --prefer-dist --optimize-autoloader
echo ' '
echo "*******************************************************"
echo "Setup environnement .htaccess"
echo "*******************************************************"
pwd
if [ -f ".htaccess.${environnement}" ]; then
cp ".htaccess.${environnement}" .htaccess
echo "Setting .htaccess.${environnement}"
fi
echo "*******************************************************"
echo "Creating sylinkks for shared folders"
echo "*******************************************************"
pwd
for folder in "${shared[@]}"
do
:
cd ${deployPath}
cd ../
pwd
if [ ! -d "shared/${folder}" ]; then
mkdir -p "shared/${folder}"
chmod -R 0775 "shared/${folder}/"
echo " -> Creating directory: shared/${folder}"
fi
done
cd ${deployPath}
cd $releaseDate
pwd
for folder in "${shared[@]}"
do
:
ln -s "../../shared/${folder}" ${folder}
done
echo "*******************************************************"
echo "Removing old current symlink"
echo "*******************************************************"
cd ${deployPath}
pwd
cd ../
pwd
rm current
echo "*******************************************************"
echo "Creating SymLink current"
pwd
echo "*******************************************************"
ln -s releases/${releaseDate} current
echo "*******************************************************"
echo "Removing previous versions"
echo "*******************************************************"
cd releases/
shopt -s dotglob
shopt -s nullglob
array=(*/)
for dir in "${array[@]}"; do echo "$dir"; done
# Unset shell option after use, if desired. Nullglob
# is unset by default.
shopt -u dotglob
shopt -u nullglob
#if more than 3 folders in releases we will remove olds one
arraySize=${#array[@]}
echo "Array size is ${arraySize} "
if [ "${arraySize}" -gt 3 ]; then
echo "removing old version ${array[0]}"
rm -rf ${array[0]}
fi
exit