blob: d85e3592d18e3c88970753b91d05ec29206f91a8 [file] [log] [blame]
Pamela Dragoshd1728dc2017-02-14 19:57:17 -05001#!/bin/bash
2
3#########################################################################
4##
5## Functions
6##
7#########################################################################
8
9function usage() {
10 echo -n "syntax: $(basename $0) "
11 echo -n "--debug ("
12 echo -n "[--install base|pap|pdp|pypdp|console|mysql|brmsgw|paplp|pdplp] | "
13 echo -n "[--configure base|pap|pdp|pypdp|console|mysql|brmsgw|paplp|pdplp] | "
14}
15
16function check_java() {
17 if [[ $DEBUG == y ]]; then
18 echo "-- ${FUNCNAME[0]} $@ --"
19 set -x
20 fi
21
22 TARGET_JAVA_VERSION=$1
23
24 if [[ -z ${JAVA_HOME} ]]; then
25 echo "error: ${JAVA_HOME} is not set"
26 return 1
27 fi
28
29 if ! check_x_file "${JAVA_HOME}/bin/java"; then
30 echo "error: ${JAVA_HOME}/bin/java is not accessible"
31 return 1
32 fi
33
34 INSTALLED_JAVA_VERSION=$("${JAVA_HOME}/bin/java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
35 if [[ -z $INSTALLED_JAVA_VERSION ]]; then
36 echo "error: ${JAVA_HOME}/bin/java is invalid"
37 return 1
38 fi
39
40 if [[ "${INSTALLED_JAVA_VERSION}" != ${TARGET_JAVA_VERSION}* ]]; then
41 echo "error: java version (${INSTALLED_JAVA_VERSION}) does not"\
42 "march desired version ${TARGET_JAVA_VERSION}"
43 return 1
44 fi
45
46 echo "OK: java ${INSTALLED_JAVA_VERSION} installed"
47
48}
49
50function process_configuration() {
51 if [[ $DEBUG == y ]]; then
52 echo "-- ${FUNCNAME[0]} $@ --"
53 set -x
54 fi
55
56 CONF_FILE=$1
57 while read line || [ -n "${line}" ]; do
58 if [[ -n ${line} ]] && [[ ${line} != \#* ]]; then
59 name=$(echo "${line%%=*}")
60 value=$(echo "${line#*=}")
61 # escape ampersand so that sed does not replace it with the search string
62 value=${value//&/\\&}
63 if [[ -z ${name} ]] || [[ -z $value ]]; then
64 echo "WARNING: ${line} missing name or value"
65 fi
66 export ${name}="${value}"
67 eval "${name}" "${value}" 2> /dev/null
68 fi
69 done < "${CONF_FILE}"
70 return 0
71}
72
73function component_preconfigure() {
74 if [[ $DEBUG == y ]]; then
75 echo "-- ${FUNCNAME[0]} $@ --"
76 set -x
77 fi
78
79 /bin/sed -i -e 's!${{POLICY_HOME}}!'"${POLICY_HOME}!g" \
80 -e 's!${{FQDN}}!'"${FQDN}!g" \
81 *.conf > /dev/null 2>&1
82}
83
84function tomcat_component() {
85 if [[ $DEBUG == y ]]; then
86 echo "-- ${FUNCNAME[0]} $@ --"
87 set -x
88 fi
89
90 TOMCAT_TARGET_INSTALL_DIR=${POLICY_HOME}/servers/${COMPONENT_TYPE}
91 if [[ -d ${TOMCAT_TARGET_INSTALL_DIR} ]]; then
92 echo "error: ${TOMCAT_TARGET_INSTALL_DIR} exists."
93 return 1
94 fi
95
96 TOMCAT_INSTALL_DIR=${POLICY_HOME}/install/3rdparty/${TOMCAT_PACKAGE_NAME}/
97 if [[ -d ${TOMCAT_INSTALL_DIR} ]]; then
98 echo "error: ${TOMCAT_INSTALL_DIR} exists."
99 return 1
100 fi
101
102 tar -C "${POLICY_HOME}/servers" -xf "${POLICY_HOME}/install/3rdparty/${TOMCAT_PACKAGE_NAME}.tar.gz"
103
104 mv "${POLICY_HOME}/servers/${TOMCAT_PACKAGE_NAME}" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
105 /bin/cp "${POLICY_HOME}"/install/servers/common/tomcat/bin/* "${POLICY_HOME}/servers/${COMPONENT_TYPE}/bin"
106 /bin/cp "${POLICY_HOME}"/install/servers/common/tomcat/conf/* "${POLICY_HOME}/servers/${COMPONENT_TYPE}/conf"
107
108 /bin/cp "${POLICY_HOME}/install/servers/common/tomcat/init.d/tomcatd" "${POLICY_HOME}/etc/init.d/${COMPONENT_TYPE}"
109 /bin/sed -i -e "s!\${{COMPONENT_TYPE}}!${COMPONENT_TYPE}!g" "${POLICY_HOME}/etc/init.d/${COMPONENT_TYPE}" >/dev/null 2>&1
110
111
112 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/webapps/* "${POLICY_HOME}/servers/${COMPONENT_TYPE}/webapps"
113 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/bin/* "${POLICY_HOME}/servers/${COMPONENT_TYPE}/bin" >/dev/null 2>&1
114 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/conf/* "${POLICY_HOME}/servers/${COMPONENT_TYPE}/conf" >/dev/null 2>&1
115
116 /bin/rm -fr "${POLICY_HOME}/servers/${COMPONENT_TYPE}/webapps/docs" \
117 "${POLICY_HOME}/servers/${COMPONENT_TYPE}/webapps/examples" \
118 "${POLICY_HOME}/servers/${COMPONENT_TYPE}/webapps/ROOT" \
119 "${POLICY_HOME}/servers/${COMPONENT_TYPE}/webapps/manager" \
120 "${POLICY_HOME}/servers/${COMPONENT_TYPE}/webapps/host-manager"
121
122 if [[ ${COMPONENT_TYPE} == console ]]; then
123 install_ecomp_portal_settings
124 fi
125
126 return 0
127}
128
129function configure_tomcat_component() {
130 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
131}
132
133function configure_component() {
134 if [[ $DEBUG == y ]]; then
135 echo "-- ${FUNCNAME[0]} $@ --"
136 set -x
137 fi
138
139 if ! process_configuration "${COMPONENT_TYPE}.conf"; then
140 echo "error: aborting ${COMPONENT_TYPE} installation: cannot process configuration ${COMPONENT_TYPE}.conf"
141 exit 1
142 fi
143
144 CONF_FILE=$1
145 COMPONENT_ROOT_DIR=$2
146
147 SED_LINE="sed -i"
148 SED_LINE+=" -e 's!\${{POLICY_HOME}}!${POLICY_HOME}!g' "
149 SED_LINE+=" -e 's!\${{POLICY_USER}}!${POLICY_USER}!g' "
150 SED_LINE+=" -e 's!\${{POLICY_GROUP}}!${POLICY_GROUP}!g' "
151 SED_LINE+=" -e 's!\${{KEYSTORE_PASSWD}}!${KEYSTORE_PASSWD}!g' "
152 SED_LINE+=" -e 's!\${{JAVA_HOME}}!${JAVA_HOME}!g' "
153 SED_LINE+=" -e 's!\${{COMPONENT_TYPE}}!${COMPONENT_TYPE}!g' "
154
155 while read line || [ -n "${line}" ]; do
156 if [[ -n $line ]] && [[ $line != \#* ]]; then
157 name=$(echo "${line%%=*}")
158 value=$(echo "${line#*=}")
159 # escape ampersand so that sed does not replace it with the search string
160 value=${value//&/\\&}
161 if [[ -z ${name} ]] || [[ -z ${value} ]]; then
162 echo "WARNING: ${line} missing name or value"
163 fi
164 SED_LINE+=" -e 's!\${{${name}}}!${value}!g' "
165
166 fi
167 done < "$CONF_FILE"
168
169 SED_FILES=""
170 for sed_file in $(find "${COMPONENT_ROOT_DIR}" -name '*.xml' -o -name '*.sh' -o -name '*.properties' -o -name '*.conf' -o -name '*.cfg' -o -name '*.template' -o -name '*.conf' -o -name '*.cron' -o -name '*.json' | grep -v /backup/); do
171 if fgrep -l '${{' ${sed_file} > /dev/null 2>&1; then
172 SED_FILES+="${sed_file} "
173 fi
174 done
175
176 if [[ -f $HOME/.m2/settings.xml ]]; then
177 SED_FILES+="$HOME/.m2/settings.xml "
178 fi
179
180
181 if [[ -z ${SED_FILES} ]]; then
182 echo "WARNING: no xml, sh, properties, or conf files to perform configuration expansion"
183 else
184 SED_LINE+=${SED_FILES}
185 eval "${SED_LINE}"
186 fi
187
188 list_unexpanded_files ${POLICY_HOME}
189}
190
191function install_ecomp_portal_settings() {
192 echo "Install ecomp portal settings"
193
194 # unpack ecomp war file
195 mkdir -p "${POLICY_HOME}"/servers/console/webapps/ecomp
196 cd "${POLICY_HOME}"/servers/console/webapps/ecomp
197 unzip -q ../ecomp.war
198 cd ${INSTALL_DIR}
199
200 # copy over the configured settings
201 /bin/cp -fr "${POLICY_HOME}"/install/servers/ecomp/* "${POLICY_HOME}/servers/console/webapps/ecomp"
202}
203
204function check_r_file() {
205 if [[ $DEBUG == y ]]; then
206 echo "-- ${FUNCNAME[0]} $@ --"
207 set -x
208 fi
209
210 FILE=$1
211 if [[ ! -f ${FILE} || ! -r ${FILE} ]]; then
212 return 1
213 fi
214
215 return 0
216}
217
218function check_x_file() {
219 if [[ $DEBUG == y ]]; then
220 echo "-- ${FUNCNAME[0]} $@ --"
221 set -x
222 fi
223
224 FILE=$1
225 if [[ ! -f ${FILE} || ! -x ${FILE} ]]; then
226 return 1
227 fi
228
229 return 0
230}
231
232function install_prereqs() {
233 if [[ $DEBUG == y ]]; then
234 echo "-- ${FUNCNAME[0]} $@ --"
235 set -x
236 fi
237
238 CONF_FILE=$1
239
240 if ! check_r_file "${CONF_FILE}"; then
241 echo "error: aborting ${COMPONENT_TYPE} installation: ${CONF_FILE} is not accessible"
242 exit 1
243 fi
244
245 if ! process_configuration "${CONF_FILE}"; then
246 echo "error: aborting ${COMPONENT_TYPE} installation: cannot process configuration ${CONF_FILE}"
247 exit 1
248 fi
249
250# if ! check_java "1.8"; then
251# echo "error: aborting ${COMPONENT_TYPE} installation: invalid java version"
252# exit 1
253# fi
254
255 if [[ -z ${POLICY_HOME} ]]; then
256 echo "error: aborting ${COMPONENT_TYPE} installation: ${POLICY_HOME} is not set"
257 exit 1
258 fi
259
260 HOME_OWNER=$(ls -ld "${POLICY_HOME}" | awk '{print $3}')
261 if [[ ${HOME_OWNER} != ${POLICY_USER} ]]; then
262 echo "error: aborting ${COMPONENT_TYPE} installation: ${POLICY_USER} does not own ${POLICY_HOME} directory"
263 exit 1
264 fi
265
266 echo -n "Starting ${OPERATION} of ${COMPONENT_TYPE} under ${POLICY_USER}:${POLICY_GROUP} "
267 echo "ownership with umask $(umask)."
268}
269
270function list_unexpanded_files() {
271 ROOT_DIR=$1
272 SEARCH_LIST=$(find ${ROOT_DIR} -type f -name '*.properties' -o -name '*.sh' -o -name '*.conf' -o -name '*.yml' -o -name '*.template' -o -name '*.xml' -o -name '*.cfg' -o -name '*.json' -o -path "${ROOT_DIR}/etc/init.d/*" | egrep -v '/m2/|/install/|/logs/')
273 NOT_EXPANDED_BASE_FILES=$(grep -l '${{' ${SEARCH_LIST} 2> /dev/null)
274 if [[ -n ${NOT_EXPANDED_BASE_FILES} ]]; then
275 echo "error: component installation has completed but some base files have not been expanded:"
276 echo "${NOT_EXPANDED_BASE_FILES}"
277 return 1
278 fi
279 return 0
280}
281
282function install_base() {
283 if [[ $DEBUG == y ]]; then
284 echo "-- ${FUNCNAME[0]} $@ --"
285 set -x
286 fi
287
288 install_prereqs "${BASE_CONF}"
289
290 if [[ -z ${POLICY_HOME} ]]; then
291 echo "error: ${POLICY_HOME} is not set"
292 exit 1
293 fi
294
295 POLICY_HOME_CONTENTS=$(ls -A "${POLICY_HOME}" 2> /dev/null)
296 if [[ -n ${POLICY_HOME_CONTENTS} ]]; then
297 echo "error: aborting base installation: ${POLICY_HOME} directory is not empty"
298 exit 1
299 fi
300
301 if [[ ! -d ${POLICY_HOME} ]]; then
302 echo "error: aborting base installation: ${POLICY_HOME} is not a directory."
303 exit 1
304 fi
305
306 if ! /bin/mkdir -p "${POLICY_HOME}/servers/" > /dev/null 2>&1; then
307 echo "error: aborting base installation: cannot create ${POLICY_HOME}/servers/"
308 exit 1
309 fi
310
311 if ! /bin/mkdir -p "${POLICY_HOME}/logs/" > /dev/null 2>&1; then
312 echo "error: aborting base installation: cannot create ${POLICY_HOME}/logs/"
313 exit 1
314 fi
315
316 BASE_TGZ=$(ls base-*.tar.gz)
317 if [ ! -r ${BASE_TGZ} ]; then
318 echo "error: aborting base installation: ${POLICY_USER} cannot access tar file: ${BASE_TGZ}"
319 exit 1
320 fi
321
322 tar -tzf ${BASE_TGZ} > /dev/null 2>&1
323 if [[ $? != 0 ]]; then
324 echo >&2 "error: aborting base installation: invalid base package tar file: ${BASE_TGZ}"
325 exit 1
326 fi
327
328 BASH_PROFILE_LINE=". ${POLICY_HOME}/etc/profile.d/env.sh"
329 PROFILE_LINE="ps -p \$\$ | grep -q bash || . ${POLICY_HOME}/etc/profile.d/env.sh"
330
331 tar -C ${POLICY_HOME} -xf ${BASE_TGZ} --no-same-owner
332 if [[ $? != 0 ]]; then
333 # this should not happened
334 echo "error: aborting base installation: base package cannot be unpacked: ${BASE_TGZ}"
335 exit 1
336 fi
337
338 /bin/mkdir -p ${POLICY_HOME}/etc/ssl > /dev/null 2>&1
339 /bin/mkdir -p ${POLICY_HOME}/etc/init.d > /dev/null 2>&1
340 /bin/mkdir -p ${POLICY_HOME}/tmp > /dev/null 2>&1
341 /bin/mkdir -p ${POLICY_HOME}/var > /dev/null 2>&1
342
343 #list_unexpanded_files ${POLICY_HOME}
344}
345
346
347function configure_base() {
348 if [[ $DEBUG == y ]]; then
349 echo "-- ${FUNCNAME[0]} $@ --"
350 set -x
351 fi
352
353 # check if fqdn is set in base.conf and use that value if set
354 if [[ -z ${INSTALL_FQDN} ]]
355 then
356 echo "FQDN not set in config...using the default FQDN ${FQDN}"
357 else
358 echo "Using FQDN ${INSTALL_FQDN} from config"
359 FQDN=${INSTALL_FQDN}
360 fi
361
362 configure_component "${BASE_CONF}" "${POLICY_HOME}"
363
364 BASH_PROFILE_LINE=". ${POLICY_HOME}/etc/profile.d/env.sh"
365 PROFILE_LINE="ps -p \$\$ | grep -q bash || . ${POLICY_HOME}/etc/profile.d/env.sh"
366
367 if ! fgrep -x "${BASH_PROFILE_LINE}" "${HOME}/.bash_profile" >/dev/null 2>&1; then
368 echo "${BASH_PROFILE_LINE}" >> "${HOME}/.bash_profile"
369 fi
370
371 if ! fgrep -x "${PROFILE_LINE}" "${HOME}/.profile" >/dev/null 2>&1; then
372 echo "${PROFILE_LINE}" >> "${HOME}/.profile"
373 fi
374}
375
376function install_tomcat_component() {
377 if [[ $DEBUG == y ]]; then
378 echo "-- ${FUNCNAME[0]} $@ --"
379 set -x
380 fi
381
382 install_prereqs "${BASE_CONF}"
383
384 if ! process_configuration "${COMPONENT_TYPE}.conf"; then
385 echo "error: aborting ${COMPONENT_TYPE} installation: cannot process configuration ${COMPONENT_TYPE}.conf"
386 exit 1
387 fi
388
389 if ! tomcat_component; then
390 echo "error: aborting ${COMPONENT_TYPE} installation: tomcat installation failed."
391 exit 1
392 fi
393
394}
395
396# This function installs mysql related shell scripts and sql files in the proper locations
397# under $POLICY_HOME. It also adds the MySQL client bin to the PATH based on configuration.
398#
399function install_mysql() {
400 if [[ $DEBUG == y ]]; then
401 echo "-- ${FUNCNAME[0]} $@ --"
402 set -x
403 fi
404
405 install_prereqs "${BASE_CONF}"
406
407 if ! process_configuration "${COMPONENT_TYPE}.conf"; then
408 echo "error: aborting ${COMPONENT_TYPE} installation: cannot process configuration ${COMPONENT_TYPE}.conf"
409 exit 1
410 fi
411
412 MYSQL_DATA_PATH=${POLICY_HOME}/data/mysql
413 /bin/mkdir -p ${MYSQL_DATA_PATH} > /dev/null 2>&1
414
415 /bin/cp -f "${POLICY_HOME}"/install/mysql/data/* "${MYSQL_DATA_PATH}"
416 /bin/chmod 555 "${MYSQL_DATA_PATH}"/*
417
418 MYSQL_BIN_SOURCE=${POLICY_HOME}/install/mysql/bin
419 /bin/mkdir -p ${POLICY_HOME}/bin > /dev/null 2>&1
420 for script in $(/bin/ls "${MYSQL_BIN_SOURCE}"); do
421 /bin/cp ${MYSQL_BIN_SOURCE}/${script} ${POLICY_HOME}/bin
422 /bin/chmod 555 "${POLICY_HOME}/bin/${script}"
423 done
424}
425
426function configure_mysql() {
427 if [[ $DEBUG == y ]]; then
428 echo "-- ${FUNCNAME[0]} $@ --"
429 set -x
430 fi
431
432 # nothing to do
433}
434
435# This function installs brmsgw related shell scripts and config files in the proper
436# locations under $POLICY_HOME.
437#
438
439function install_brmsgw() {
440 if [[ $DEBUG == y ]]; then
441 echo "-- ${FUNCNAME[0]} $@ --"
442 set -x
443 fi
444
445 install_prereqs "${BASE_CONF}"
446
447 if ! process_configuration "${COMPONENT_TYPE}.conf"; then
448 echo "error: aborting ${COMPONENT_TYPE} installation: cannot process configuration ${COMPONENT_TYPE}.conf"
449 exit 1
450 fi
451
452 if [ -z "$M2_HOME" ]; then
453 echo "error: aborting ${COMPONENT_TYPE} installation: M2_HOME must be set in brmsgw.conf"
454 exit 1
455 fi
456
457 echo "export M2_HOME=$M2_HOME" >>$POLICY_HOME/etc/profile.d/env.sh
458
459 /bin/cp -f "${POLICY_HOME}/install/servers/brmsgw/init.d/brmsgw" "${POLICY_HOME}/etc/init.d/brmsgw"
460
461 if ! /bin/mkdir -p "${POLICY_HOME}/servers/${COMPONENT_TYPE}" > /dev/null 2>&1; then
462 echo "error: aborting base installation: cannot create ${POLICY_HOME}/servers/${COMPONENT_TYPE}"
463 exit 1
464 fi
465
466 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/BRMSGateway.jar "${POLICY_HOME}/servers/${COMPONENT_TYPE}"
467 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/*.properties "${POLICY_HOME}/servers/${COMPONENT_TYPE}"
468 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/config "${POLICY_HOME}/servers/${COMPONENT_TYPE}"
469
470 /bin/mv $POLICY_HOME/m2 $HOME/.m2
471
472 return 0
473}
474
475
476function install_logparser() {
477 if [[ $DEBUG == y ]]; then
478 echo "-- ${FUNCNAME[0]} $@ --"
479 set -x
480 fi
481
482 install_prereqs "${BASE_CONF}"
483
484 if ! process_configuration "${COMPONENT_TYPE}.conf"; then
485 echo "error: aborting ${COMPONENT_TYPE} installation: cannot process configuration ${COMPONENT_TYPE}.conf"
486 exit 1
487 fi
488
489 LP_TARGET_DIR=${POLICY_HOME}/servers/${COMPONENT_TYPE}
490 /bin/mkdir -p ${LP_TARGET_DIR}/bin > /dev/null 2>&1
491 /bin/mkdir -p ${LP_TARGET_DIR}/logs > /dev/null 2>&1
492
493 # copy binaries, initialization script and configuration
494 /bin/cp "${POLICY_HOME}"/install/servers/common/logparser/bin/*jar "${LP_TARGET_DIR}/bin"
495 /bin/cp "${POLICY_HOME}/install/servers/common/logparser/init.d/logparserd" "${POLICY_HOME}/etc/init.d/${COMPONENT_TYPE}"
496 /bin/cp "${POLICY_HOME}/install/servers/${COMPONENT_TYPE}/bin/parserlog.properties" "${LP_TARGET_DIR}/bin"
497 /bin/cp -fr "${POLICY_HOME}"/install/servers/${COMPONENT_TYPE}/bin/config "${POLICY_HOME}/servers/${COMPONENT_TYPE}/bin"
498
499}
500
501#########################################################################
502##
503## script execution body
504##
505#########################################################################
506
507
508OPERATION=none
509COMPONENT_TYPE=none
510DEBUG=n
511
512BASE_CONF=base.conf
513
514TOMCAT_PACKAGE_NAME=apache-tomcat-8.0.23
515
516INSTALL_DIR="$(pwd)"
517
518export POLICY_USER=$(/usr/bin/id -un)
519
520# command line options parsing
521until [[ -z "$1" ]]; do
522 case $1 in
523 -d|--debug) DEBUG=y
524 set -x
525 ;;
526 -i|--install) OPERATION=install
527 shift
528 COMPONENT_TYPE=$1
529 ;;
530 -c|--configure) OPERATION=configure
531 shift
532 COMPONENT_TYPE=$1
533 ;;
534 *) usage
535 exit 1
536 ;;
537 esac
538 shift
539done
540
541# component-type validation
542case $COMPONENT_TYPE in
543 base) ;;
544 pypdp) ;;
545 pdp) ;;
546 pap) ;;
547 console) ;;
548 mysql) ;;
549 brmsgw) ;;
550 paplp) ;;
551 pdplp) ;;
552 skip) ;;
553 *) echo "invalid component type (${COMPONENT_TYPE}): must be in {base|pypdp|pdp|pap|console|mysql|brmsgw|paplp|pdplp}";
554 usage
555 exit 1
556 ;;
557esac
558
559# operation validation
560case $OPERATION in
561 install|configure) ;;
562 *) echo "invalid operation (${OPERATION}): must be in {install|configure}";
563 usage
564 exit 1
565 ;;
566esac
567
568if [[ -n ${POLICY_GROUP} ]]; then
569 groups=$(groups)
570 if ! echo ${groups} | grep -qP "\b${POLICY_GROUP}"; then
571 echo "error: ${POLICY_GROUP} is not a valid group for account ${POLICY_USER}"
572 exit 1
573 fi
574fi
575
576if [[ -z ${POLICY_GROUP} ]]; then
577 numGroups=$(groups | sed "s/^.*: *//g" | wc -w)
578 if [ ${numGroups} -eq 1 ]; then
579 export POLICY_GROUP=$(groups ${POLICY_USER} | sed "s/^.*: *//g")
580 else
581 echo "error: ${POLICY_USER} belongs to multiple groups, one group \
582 must be provided for the installation"
583 usage
584 exit 1
585 fi
586fi
587
588if [[ -z ${POLICY_GROUP} ]]; then
589 echo "error: installation of root section must not provide the \
590 installation group owner argument."
591 usage
592 exit 1
593fi
594
595FQDN=$(hostname -f 2> /dev/null)
596if [[ $? != 0 || -z ${FQDN} ]]; then
597 echo "error: cannot determine the FQDN for this host $(hostname)."
598 exit 1
599fi
600
601if [[ ${OPERATION} == install ]]; then
602 case $COMPONENT_TYPE in
603 base)
604 install_base
605 ;;
606 pypdp)
607 install_tomcat_component
608 ;;
609 pdp)
610 install_tomcat_component
611 ;;
612 pap)
613 install_tomcat_component
614 ;;
615 console)
616 install_tomcat_component
617 ;;
618 mysql)
619 install_mysql
620 ;;
621 brmsgw)
622 install_brmsgw
623 ;;
624 paplp|pdplp)
625 install_logparser
626 ;;
627 *)
628 echo "invalid component type (${COMPONENT_TYPE}): must be in {base|pypdp|pdp|pap|console|mysql|brmsgw|paplp|pdplp}";
629 usage
630 exit 1
631 ;;
632 esac
633fi
634if [[ ${OPERATION} == configure ]]; then
635
636 install_prereqs "${BASE_CONF}"
637
638 case $COMPONENT_TYPE in
639 base)
640 configure_base
641 component_preconfigure
642 ;;
643 pypdp)
644 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
645 ;;
646 pdp)
647 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
648 ;;
649 pap)
650 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
651 ;;
652 console)
653 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
654 ;;
655 mysql)
656 configure_mysql
657 ;;
658 brmsgw)
659 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
660 ;;
661 paplp|pdplp)
662 configure_component "${COMPONENT_TYPE}.conf" "${POLICY_HOME}/servers/${COMPONENT_TYPE}/"
663 ;;
664 *)
665 echo "invalid component type (${COMPONENT_TYPE}): must be in {base|pypdp|pdp|pap|console|mysql|brmsgw|paplp|pdplp}";
666 usage
667 exit 1
668 ;;
669 esac
670fi
671
672
673echo -n "Successful ${OPERATION} of ${COMPONENT_TYPE} under ${POLICY_USER}:${POLICY_GROUP} "
674echo "ownership with umask $(umask)."