Merge pull request #1907 from gpazo/fixent-install
[xtuple] / update.sh
1 #!/bin/bash
2 PRODUCTION=''
3 HOST='localhost'
4
5 usage()
6 {
7    cat << EOF
8    usage: $0 options
9    update the environment
10    OPTIONS:
11    -h target host
12    -p production mode
13 EOF
14 }
15 while getopts ":ph:" opt; do
16   case $opt in
17     p)
18       PRODUCTION=true
19       echo 'production mode'
20       ;;
21     h)
22       HOST=$OPTARG
23       ;;
24     ?)
25       usage
26       exit
27       ;;
28   esac
29 done
30
31 # update source
32
33 git checkout master
34 if [ $? != 0  ]
35   then
36     echo "error checking out master"
37     exit $?
38 fi
39
40 git pull
41 if [ $? != 0  ]
42   then
43     echo "error pulling master"
44     exit $?
45 fi
46
47 if [ $PRODUCTION ]
48   then
49   git checkout `git describe --abbrev=0`
50   if [ $? != 0  ]
51     then
52       echo "error checking out latest tag"
53       exit $?
54   fi
55 fi
56
57 # update libraries
58 git submodule update --init --recursive
59 if [ $? != 0  ]
60   then
61     echo "error updating submodules"
62     exit $?
63 fi
64
65 # remove all npm packages and reinstall them to get the latest.
66 rm -rf node_modules
67 npm install
68
69 # rebuild the client and database sides of the app
70 ./scripts/build_app.js