-
Notifications
You must be signed in to change notification settings - Fork 21
/
dev
executable file
·119 lines (103 loc) · 2.86 KB
/
dev
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
#!/bin/bash
set -e -x
PWD=`pwd`
source "$PWD/dev.config"
if [ -z "$GIT_URL" ]; then
echo "You need to create a conf file named dev.config"
exit 1
fi
###################
# You usually don't need to change anything here –
# You should modify your dev.config file instead.
#
APP_DIR=/home/meteor
ROOT_URL=http://$APP_HOST
MONGO_URL=mongodb://localhost:27017/$APP_NAME
METEOR_CMD=meteor
METEOR_OPTIONS=''
if [ -z "$EC2_PEM_FILE" ]; then
SSH_HOST="root@$APP_HOST" SSH_OPT=""
else
SSH_HOST="ubuntu@$APP_HOST" SSH_OPT="-i $EC2_PEM_FILE"
fi
SETUP="
sudo apt-get -qq update;
sudo apt-get install -y software-properties-common make g++;
sudo add-apt-repository -y ppa:chris-lea/node.js;
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10;
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list;
sudo apt-get -qq update;
sudo apt-get install -y git mongodb-10gen;
sudo apt-get install -y nodejs npm libfreetype6 fontconfig;
node --version;
sudo npm install -g pm2 --unsafe-perm;
curl https://install.meteor.com | /bin/sh;
sudo npm install -g meteorite;
sudo npm install -g [email protected];
cd /usr/local/share/;
sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2;
sudo tar -xvjf phantomjs-1.9.1-linux-x86_64.tar.bz2;
sudo mv phantomjs-1.9.1-linux-x86_64 phantomjs;
sudo ln -s /usr/local/share/phantomjs/bin/phantomjs /usr/bin/phantomjs;
sudo mkdir -p $APP_DIR;
cd $APP_DIR;
pwd;
sudo ssh-keygen -t rsa;
sudo cat ~/.ssh/id_rsa.pub;
echo 'Add above key to github repo. Press any key to start cloning repo...';
read -p 'Press any key to start cloning repo';
sudo git clone $GIT_URL $APP_NAME;
"
DEPLOY="
cd $APP_DIR;
cd $APP_NAME;
sudo git fetch --all;
sudo git reset --hard origin/$GIT_BRANCH;
sudo git checkout $GIT_BRANCH;
sudo git clean -f -d;
sudo rm -rf ../bundle;
sudo $METEOR_CMD build ../ --debug --directory;
cd ../bundle/programs/server;
npm install;
cd ../../..;
pm2 delete dev;
mongo $APP_NAME $APP_DIR/$APP_NAME/mongo.config;
METEOR_SETTINGS=\$(cat ${APP_DIR}/${APP_NAME}/dev.json) DEBUG=ct:* PORT=80 ROOT_URL=$ROOT_URL MONGO_URL=$MONGO_URL pm2 start bundle/main.js -x --name 'dev';
"
function run {
DEBUG=ct:* meteor run --settings dev.json
}
function mon {
mrt mongo
}
function monrestore {
mongorestore --db meteor --port 3001 dump/coderstv/
}
case "$1" in
setup)
ssh $SSH_OPT $SSH_HOST $SETUP
;;
deploy)
ssh $SSH_OPT $SSH_HOST $DEPLOY
;;
run)
run
;;
mongo)
mon
;;
mongorestore)
monrestore
;;
*)
cat <<ENDCAT
dev [action]
Available actions:
setup - Install a meteor environment on a fresh Ubuntu server
deploy - Deploy the app to the server
run - Run in localhost:3000
mongo - Connect to local mongodb (must run project first)
mongorestore - Restore a dump to local mongodb (must run project first)
ENDCAT
;;
esac