forked from nameinmaking/memory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·43 lines (34 loc) · 843 Bytes
/
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
#!/bin/bash
export PORT=5100
export MIX_ENV=prod
export GIT_PATH=/home/memory/src/memory
PWD=`pwd`
if [ $PWD != $GIT_PATH ]; then
echo "Error: Must check out git repo to $GIT_PATH"
echo " Current directory is $PWD"
exit 1
fi
if [ $USER != "memory" ]; then
echo "Error: must run as user 'memory'"
echo " Current user is $USER"
exit 2
fi
mix deps.get
(cd assets && npm install)
(cd assets && ./node_modules/brunch/bin/brunch b -p)
mix phx.digest
mix release --env=prod
mkdir -p ~/www
mkdir -p ~/old
NOW=`date +%s`
if [ -d ~/www/memory ]; then
echo mv ~/www/memory ~/old/$NOW
mv ~/www/memory ~/old/$NOW
fi
mkdir -p ~/www/memory
REL_TAR=~/src/memory/_build/prod/rel/memory/releases/0.0.1/memory.tar.gz
(cd ~/www/memory && tar xzvf $REL_TAR)
crontab - <<CRONTAB
@reboot bash /home/memory/src/memory/start.sh
CRONTAB
#. start.sh