forked from bkconrad/pleiades
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·55 lines (45 loc) · 1.08 KB
/
deploy.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
#!/bin/bash
# you should configure this stuff
MYSQL_USER=root
MYSQL_DB=pleiades
REMOTE_MYSQL_USER=bf_pleiades
REMOTE_MYSQL_DB=pleiades
PUSH_REPOSITORY=origin
REMOTE_HOST=bitfighter.org
REMOTE_DIRECTORY=/var/www/html/pleiades
# find base path
pushd `dirname $0` > /dev/null
project_root=`pwd`
popd > /dev/null
if [ "$1" == "-s" ]
then
echo 'updating schema'
UPDATE_SCHEMA=yes
fi
if [ $UPDATE_SCHEMA ]
then
# make schema, add a commit
echo 'Creating schema dump, please enter local MySQL password'
mysqldump -u $MYSQL_USER -p $MYSQL_DB --add-drop-database --no-data > $project_root/schema.sql
git add $project_root/schema.sql
git commit
# get MySQL pass
read -s -p "Remote MySQL Password: " REMOTE_PASSWORD
fi
git push $PUSH_REPOSITORY
ssh_commands=`cat <<EOF
cd $REMOTE_DIRECTORY
git pull
git submodule init
git submodule update
cd app/tmp/cache
for file in \\\`find .\\\`
do
rm \\\$file
done
EOF`
if [ $UPDATE_SCHEMA ]
then
ssh_commands="$ssh_commands ; mysql -u $REMOTE_MYSQL_USER -p$REMOTE_PASSWORD $REMOTE_MYSQL_DB < $REMOTE_DIRECTORY/schema.sql"
fi
ssh $REMOTE_HOST "$ssh_commands"