This repository has been archived by the owner on Jul 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·129 lines (106 loc) · 3.83 KB
/
package.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
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
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
## packaging tool for OpenOlitor client delivery
# #
# ____ ____ ___ __ #
# / __ \____ ___ ____ / __ \/ (_) /_____ _____ #
# / / / / __ \/ _ \/ __ \/ / / / / / __/ __ \/ ___/ OpenOlitor #
# / /_/ / /_/ / __/ / / / /_/ / / / /_/ /_/ / / contributed by tegonal #
# \____/ .___/\___/_/ /_/\____/_/_/\__/\____/_/ http://openolitor.ch #
# /_/ #
# #
# This program is free software: you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, #
# or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program. If not, see http://www.gnu.org/licenses/ #
# #
# #
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-b|--branch)
BRANCH="$2"
shift
;;
-e|--env)
ENVIRONMENT="$2"
shift
;;
-n|--build-number)
BUILD_NUMBER="$2"
shift
;;
-o|--output)
OUTPUT="$2"
shift
;;
-ncle|--no-clean)
NOCLEAN="true"
;;
-nclo|--no-clone)
NOCLONE="true"
;;
*)
;;
esac
shift
done
BRANCH=${BRANCH:-'master'}
ENVIRONMENT=${ENVIRONMENT:-'test'}
OUTPUT=${OUTPUT:-'openolitor-client.zip'}
NOCLEAN=${NOCLEAN:-"false"}
NOCLONE=${NOCLONE:-"false"}
BUILD_NUMBER=${BUILD_NUMBER:-"noNBR"}
echo "Using branch ${BRANCH} and environment ${ENVIRONMENT}, output file is ${OUTPUT}"
if [ "$NOCLEAN" = "false" ] ; then
echo "Cleaning up .tmp and dist"
rm -rf .tmp
mkdir .tmp
rm -rf dist
mkdir dist
fi
declare -a PROJECTS=($(<projects))
NGINX_CONFIG="$(cat nginx.conf)"
NGINX_LOCATION="$(cat nginx_location.conf)"
LOCATIONS=""
FILES="nginx.conf
mime.types"
for PROJECT in "${PROJECTS[@]}"
do
if [ "$NOCLONE" = "false" ] ; then
( git clone --depth 1 -b $BRANCH https://github.com/OpenOlitor/${PROJECT}.git .tmp/${PROJECT} )
fi
cp ../variables.json .tmp/${PROJECT}
( cd .tmp/${PROJECT} && npm install grunt && npm install --cache-min 99999 && bower install --allow-root && grunt build --env=$ENVIRONMENT --buildnr=$BUILD_NUMBER )
PROJECT_NAME=$(echo $PROJECT | cut -d'-' -f 3)
if [ "kundenportal" = $PROJECT_NAME ]; then
PROJECT_LOCATION="/"
PROJECT_ROOT="$PROJECT_NAME"
else
PROJECT_LOCATION="/$PROJECT_NAME"
PROJECT_ROOT=""
fi
LOCATION="${NGINX_LOCATION/project_location/$PROJECT_LOCATION}"
LOCATION="${LOCATION/project_root/$PROJECT_ROOT}"
LOCATIONS="$LOCATIONS
$LOCATION"
( cd .tmp/ && ln -fs $PROJECT/dist $PROJECT_NAME )
FILES="$FILES
$PROJECT_NAME"
done
NGINX_CONFIG="${NGINX_CONFIG/nginx_locations/$LOCATIONS}"
echo "$NGINX_CONFIG" > .tmp/nginx.conf
cp mime.types .tmp/
( cd .tmp/ && echo "$FILES" | zip -r ../dist/$OUTPUT -@ )
for PROJECT in "${PROJECTS[@]}"
do
( cd .tmp/${PROJECT} && rm dist/dist)
done