forked from OS2web/os2web-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreroll-dev.sh
executable file
·80 lines (63 loc) · 2.19 KB
/
reroll-dev.sh
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
#!/bin/sh
##### Drupal deploy script made in shell
# - Makes build with drush make
# - Moves latest build to dev-latest
# - Backup database
# - Update database with drush updb
# - Clear cache
#
# ## Multisite?
# Run the script with URI infront:
# URI=http://domain.tld ./reroll.sh
#
# Author: Anders Bryrup ([email protected])
DATE=`date +%Y%m%d%H%M`
# The newly builed dir
BUILD_DIR=dev-$DATE
# The previous build dir
BUILD_DIR_PREV=dev-previous
# The build dir with latest build
BUILD_DIR_LATEST=dev-latest
# The Source Profile name
# This is a special case, where multiple profiles are in same dir.
# [name].install
# [name].profile
# [name].info
PROFILE_SRC=os2web
# The destination Profile name
PROFILE_DST=os2web
# The root dir of your drupal instance. Used by drush!
DRUPAL_ROOT=$(dirname `pwd`)/public_html
mkdir -p build/$BUILD_DIR
drush make --no-gitinfofile -y --no-core --working-copy --contrib-destination=build/$BUILD_DIR $PROFILE_SRC.dev.make
### Code below can be in seperate file. source execute file from here. ###
# . ./deploy.sh
if [ -d "build/$BUILD_DIR/modules" ]; then
# Drush make completed without errors. If modules doesnt exist, drush make failed.
# Lets copy our drupal profile files
cp $PROFILE_SRC.info build/$BUILD_DIR/$PROFILE_DST.info
cp $PROFILE_SRC.profile build/$BUILD_DIR/$PROFILE_DST.profile
cp $PROFILE_SRC.install build/$BUILD_DIR/$PROFILE_DST.install
# Move old build to previous
unlink build/$BUILD_DIR_PREV
mv build/$BUILD_DIR_LATEST build/$BUILD_DIR_PREV
# Make new build the latest
ln -sf $BUILD_DIR build/$BUILD_DIR_LATEST
echo "Updating database... Site will go in maintenance mode!"
drush --root=$DRUPAL_ROOT --uri=$URI vset maintenance_mode 1
drush --root=$DRUPAL_ROOT --uri=$URI updb
# # Any additionally drush commands?
# Finnally clear the cache
echo "Clearing cache..."
drush --root=$DRUPAL_ROOT --uri=$URI cc registry
drush --root=$DRUPAL_ROOT --uri=$URI cc all
drush --root=$DRUPAL_ROOT --uri=$URI vset maintenance_mode 0
echo "Deploy Complete. End of maintenance mode!"
# Cleanup old builds.
echo "Deleting old build dirs..."
. ./cleanup.sh
else
# Build failed, remove build
rm -rf build/$BUILD_DIR
echo "Build Failed. Deploy terminated"
fi