-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforklift-post-receive
More file actions
executable file
·64 lines (54 loc) · 1.1 KB
/
forklift-post-receive
File metadata and controls
executable file
·64 lines (54 loc) · 1.1 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
#!/bin/sh
repo="$1"
app="$2"
dirAllRepos="$3"
dirAllApps="$4"
dirRepo="$dirAllRepos$repo"
dirApp="$dirAllApps$app"
pathApp="$dirApp/app.js"
pathAppNpmPackage="$dirApp/package.json"
#DUE TO ODD BUG WITH GIT HOOKS - NEED TO SET GIT_DIR TO ".git"
GIT_DIR=".git"
#STOP THE APP
echo "Stopping app $app..."
forever stop $pathApp 2>/dev/null&
wait
if [ -e $dirApp ]
then
#CHECKOUT THE LATEST VERSION OF THE APP
echo "Checking out '$repo' into '$app'..."
cd $dirApp
gitCurrentRevision=`git rev-parse HEAD`
echo "current repo $gitCurrentRevision"
git reset --hard&
wait
git pull origin&
wait
else
#NEW REPO
echo $pwd
echo "Creating new repo '$repo' at '$app'..."
cd $dirAllApps
echo "Cloning repo $dirRepo..."
git clone $dirRepo&
wait
#chmod on the new dir
chmod -R u+w $dirApp&
cd $dirApp
fi
echo "Checking existance of $pathAppNpmPackage..."
if [ -e "$pathAppNpmPackage" ]
then
echo "Installing modules..."
#if [ -e "$dirApp/node_modules" ]
#then
# rm -R -f $dirApp/node_modules
#fi
npm install -d -s&
wait
fi
echo "Restarting app..."
#forever start $pathApp&
start-app $dirApp/
wait
echo "Success!"