build/build.sh
author ymh <ymh.work@gmail.com>
Mon, 31 Oct 2016 14:24:23 +0100
changeset 386 c731ab9b934d
parent 368 5f79f31ca9a2
child 388 202b6f209b9a
permissions -rwxr-xr-x
implement first version of sparql client interface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env bash
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
set -e
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
## option --prod/--dev
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
VAGRANT_STARTED=false
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
green="\x1B[0;32m" # '\e[1;32m' is too bright for white bg.
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
blue="\x1B[1;34m"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
endColor="\x1B[0m"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
function echoblue() {
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    echo -e "${blue}$1${endColor}"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
}
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
function install() {
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    pushd "$DIR"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    echoblue "---> preparing bo client"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    pushd ../server/bo_client
367
e0fb97c1e9c6 correct build script + rpm hook scripts
ymh <ymh.work@gmail.com>
parents: 346
diff changeset
    23
    /usr/local/bin/npm install
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    ./node_modules/.bin/bower install
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
    echoblue "---> preparing bo client done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
    echoblue "---> preparing back"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    pushd ../server/src
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
    php composer.phar install
367
e0fb97c1e9c6 correct build script + rpm hook scripts
ymh <ymh.work@gmail.com>
parents: 346
diff changeset
    31
    /usr/local/bin/npm install
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    ./node_modules/.bin/bower install
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
    echoblue "---> preparing back done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
    echoblue "---> preparing app-client"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
    pushd ../cms/app-client
367
e0fb97c1e9c6 correct build script + rpm hook scripts
ymh <ymh.work@gmail.com>
parents: 346
diff changeset
    38
    /usr/local/bin/npm install
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
    ./node_modules/.bin/bower install
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
    popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
    echoblue "---> preparing app-client done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
    echoblue "---> preparing module"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
    pushd ../cms
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
    npm install
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
    echoblue "---> checking vagrant"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    if vagrant status | grep -q "running"; then
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
        echoblue "---> starting vagrant"
368
5f79f31ca9a2 Add some doc. Improve auto documentation of build script
ymh <ymh.work@gmail.com>
parents: 367
diff changeset
    51
        if [ type workon ]; then
5f79f31ca9a2 Add some doc. Improve auto documentation of build script
ymh <ymh.work@gmail.com>
parents: 367
diff changeset
    52
            workon ansible
5f79f31ca9a2 Add some doc. Improve auto documentation of build script
ymh <ymh.work@gmail.com>
parents: 367
diff changeset
    53
        fi
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
        vagrant up
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
        VAGRANT_STARTED=true
368
5f79f31ca9a2 Add some doc. Improve auto documentation of build script
ymh <ymh.work@gmail.com>
parents: 367
diff changeset
    56
        if [ type deactivate ]; then
5f79f31ca9a2 Add some doc. Improve auto documentation of build script
ymh <ymh.work@gmail.com>
parents: 367
diff changeset
    57
            deactivate
5f79f31ca9a2 Add some doc. Improve auto documentation of build script
ymh <ymh.work@gmail.com>
parents: 367
diff changeset
    58
        fi
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
    fi
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
    echoblue "---> done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
    popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
}
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
function usage() {
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
    cat <<EOF
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
Usage: $0 [-I] [-p|-d] [-h]
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
    -I : do not run install
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
    -h : print this message
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
    -p : build for production
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
    -d : build for development
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
EOF
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
}
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
environment=""
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
do_install=true
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
while getopts "Ihpd" opt; do
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
  case $opt in
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
    I) do_install=false ;;
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
    h) usage; exit 0 ;;
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
    p) [[ -n "$environment" ]] && { usage >&2; exit 1; } || environment='production' ;;
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    d) [[ -n "$environment" ]] && { usage >&2; exit 1; } || environment='development' ;;
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
    \?) usage >&2; exit 1 ;;
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
  esac
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
done
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
shift $((OPTIND-1))
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
[[ -z "$environment" ]] && environment='production'
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
case $environment in
386
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
    95
    development)
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
    96
        build_option='--dev'
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
    97
        build_option_back='--development'
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
    98
        ;;
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
    99
    *)
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
   100
        build_option='--prod'
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
   101
        build_option_back='--production'
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
   102
        ;;
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
esac
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
echo "environment: $environment"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
echo "do_install: $do_install"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
[[ "$do_install" == true ]] && echoblue "DO INSTALL" && install;
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
pushd "$DIR"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
echoblue "---> cleaning build folder"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
rm -fr root
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
echoblue "---> creating build folder"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
mkdir -p root/var/www/corpusdelaparole/corpus-back
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
mkdir -p root/var/www/corpusdelaparole/drupal/sites/all/modules
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
echoblue "---> buiding back"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
pushd ../server/src
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
version=$(sed -n "s/[[:space:]]*\'version\'[[:space:]]*=>[[:space:]]*\'\([\.0-9]*\)\'/\1/p" config/version.php)
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
version=${version:-0.0.0}
386
c731ab9b934d implement first version of sparql client interface
ymh <ymh.work@gmail.com>
parents: 368
diff changeset
   122
./node_modules/.bin/gulp copy-build ${build_option_back}
346
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
echoblue "---> buiding back done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
echoblue "---> building app-client"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
pushd ../cms/app-client
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
./node_modules/.bin/ember build ${build_option}
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
echoblue "---> building app-client done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
echoblue "---> building module"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
pushd ../cms
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
./node_modules/.bin/gulp copy-build ${build_option} --version="$version"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
popd
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
echoblue "---> building package"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
vagrant ssh -c "/vagrant/build_rpm.sh"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
echoblue "---> done"
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
4cd0f8c936ed upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
popd