Skip to content

Commit

Permalink
Merge branch 'feature/VOSA-257-sse-proxy' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmudul Hassan Rony committed Aug 18, 2017
2 parents 3e15698 + f84a7a2 commit 0c29e6b
Show file tree
Hide file tree
Showing 11 changed files with 397 additions and 27 deletions.
55 changes: 55 additions & 0 deletions usr/local/src/unit-tests/ece-install-conf-file-reader-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,61 @@ EOF
rm -rf "${yaml_file}"
}

test_can_parse_yaml_conf_sse_proxy() {
local exposed_port=80
local exposed_host=proxy.example.com
local sse_proxy_ece_port=8083
local sse_proxy_ece_redirect=8443
local sse_proxy_backend1_uri=http://foo
local sse_proxy_backend1_user=foo
local sse_proxy_backend1_password=p
local sse_proxy_backend2_uri=http://bar
local sse_proxy_backend2_user=bar
local sse_proxy_backend2_password=b

local yaml_file=
yaml_file=$(mktemp)
cat > "${yaml_file}" <<EOF
---
profiles:
sse_proxy:
install: yes
exposed_host: ${exposed_host}
exposed_port: ${exposed_port}
ece_port: ${sse_proxy_ece_port}
ece_redirect: ${sse_proxy_ece_redirect}
backends:
- uri: ${sse_proxy_backend1_uri}
user: ${sse_proxy_backend1_user}
password: ${sse_proxy_backend1_password}
- uri: ${sse_proxy_backend2_uri}
user: ${sse_proxy_backend2_user}
password: ${sse_proxy_backend2_password}
EOF

unset fai_sse_proxy_backends
unset fai_sse_proxy_ece_port
unset fai_sse_proxy_ece_redirect
unset fai_sse_proxy_exposed_host
unset fai_sse_proxy_exposed_port
unset fai_sse_proxy_install

sse_proxy_backends="${sse_proxy_backend2_uri} ${sse_proxy_backend2_user} ${sse_proxy_backend2_password}
${sse_proxy_backend1_uri} ${sse_proxy_backend1_user} ${sse_proxy_backend1_password}
"

parse_yaml_conf_file_or_source_if_sh_conf "${yaml_file}"
assertNotNull "Should set fai_sse_install" "${fai_sse_proxy_install}"
assertEquals "Should set fai_sse_proxy_install" 1 "${fai_sse_proxy_install}"
assertEquals "Should set fai_sse_proxy_exposed_host" "${exposed_host}" "${fai_sse_proxy_exposed_host}"
assertEquals "Should set fai_sse_proxy_exposed_port" "${exposed_port}" "${fai_sse_proxy_exposed_port}"
assertEquals "Should set fai_sse_proxy_ece_port" "${sse_proxy_ece_port}" "${fai_sse_proxy_ece_port}"
assertEquals "Should set fai_sse_proxy_ece_redirect" "${sse_proxy_ece_redirect}" "${fai_sse_proxy_ece_redirect}"
assertEquals "Should set fai_sse_proxy_backends" "${sse_proxy_backends}" "${fai_sse_proxy_backends}"

rm -rf "${yaml_file}"
}

test_can_parse_yaml_conf_nfs_server() {
local nfs_server_address="nfs.example.com"
local nfs_allowed_client_network="10.0.0.1/24"
Expand Down
26 changes: 18 additions & 8 deletions usr/sbin/ece-install
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,14 @@ function install_packages_if_missing() {
if [ $some_are_missing -eq 0 ]; then
return
elif [ $one_time_apt_update_done -eq 0 ]; then
log "First running APT update to ensure fresh package list, " \
"then continuing the above"
run apt-get update
# Systemd may be running an update process on boot of new
# machines. Therefore, if there's a current apt-get process,
# don't do anything.
pgrep apt-get &> /dev/null || {
log "First running APT update to ensure fresh package list, " \
"then continuing the above"
run apt-get update
}
one_time_apt_update_done=1
fi

Expand Down Expand Up @@ -433,10 +438,10 @@ function print_status_and_next_steps()
fi
print_and_log "${message} It took" ${days}d ${hours}h ${minutes}m ${seconds_left}s

if [ $install_profile_number -ne $PROFILE_RESTORE_FROM_BACKUP -a \
$install_profile_number -ne $PROFILE_CACHE_SERVER -a \
$install_profile_number -ne $PROFILE_WIDGET_FRAMEWORK ]; then
add_next_step "UNIX man pages: $(man -k escenic | awk '{print $1;}')"
if [[ ${install_profile_number-42} -ne $PROFILE_RESTORE_FROM_BACKUP &&
${install_profile_number-42} -ne $PROFILE_CACHE_SERVER &&
${install_profile_number-42} -ne $PROFILE_WIDGET_FRAMEWORK ]]; then
add_next_step "UNIX man pages: $(man -k escenic 2>/dev/null | awk '{print $1;}')"
add_next_step "Guide books: http://docs.escenic.com/ece-6.0.html"
fi

Expand All @@ -458,7 +463,7 @@ function check_for_required_downloads()
print_and_log "Asserting that required downloads succeeded ..."
local required_escenic_packages="engine"
# TODO: make assembly tool required if not using an EAR.
if [ $install_profile_number -eq $PROFILE_ANALYSIS_SERVER ]; then
if [ ${install_profile_number-42} -eq $PROFILE_ANALYSIS_SERVER ]; then
required_escenic_packages="analysis-engine"
fi

Expand Down Expand Up @@ -1094,6 +1099,11 @@ function main() {
no_fai_profile=0
fi

if [ "${fai_sse_proxy_install-0}" -eq 1 ]; then
install_sse_proxy
no_fai_profile=0
fi

if [ $no_fai_profile -eq 1 ]; then
print_and_log "No install profile selected, be sure to have one of the "
print_and_log "fai_<profile>_install=1 in your $conf_file"
Expand Down
38 changes: 37 additions & 1 deletion usr/share/doc/escenic/ece-install-conf-reference.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Overview of =ece-install='s configuration options. Generated from the
configuration file parser's unit tests @ Fri May 26 13:20:40 CEST 2017.
configuration file parser's unit tests @ Thu Aug 17 16:02:10 CST 2017.

*** environment

Expand Down Expand Up @@ -194,6 +194,7 @@ profiles:
cue:
install: yes
backend_ece: ${cue_backend_ece}
backend_ece_local: ${cue_backend_ece_local}
backend_ng: ${cue_backend_ng}
cors_origins:
- ${cue_cors_origin1}
Expand All @@ -204,11 +205,46 @@ profiles:

fai_cue_install=
fai_cue_backend_ece=
fai_cue_backend_ece_local=
fai_cue_backend_ng=
fai_cue_cors_origins=

#+end_src

*** sse_proxy

#+begin_src yaml
profiles:
sse_proxy:
install: yes
exposed_host: ${exposed_host}
exposed_port: ${exposed_port}
ece_port: ${sse_proxy_ece_port}
ece_redirect: ${sse_proxy_ece_redirect}
backends:
- uri: ${sse_proxy_backend1_uri}
user: ${sse_proxy_backend1_user}
password: ${sse_proxy_backend1_password}
- uri: ${sse_proxy_backend2_uri}
user: ${sse_proxy_backend2_user}
password: ${sse_proxy_backend2_password}
#+end_src
=ece-install.conf= equivalent:
#+begin_src: text

fai_sse_proxy_backends=
fai_sse_proxy_ece_port=
fai_sse_proxy_ece_redirect=
fai_sse_proxy_exposed_host=
fai_sse_proxy_exposed_port=
fai_sse_proxy_install=

sse_proxy_backends="${sse_proxy_backend2_uri} ${sse_proxy_backend2_user} ${sse_proxy_backend2_password}
${sse_proxy_backend1_uri} ${sse_proxy_backend1_user} ${sse_proxy_backend1_password}
"

#+end_src

*** nfs_server

#+begin_src yaml
Expand Down
5 changes: 2 additions & 3 deletions usr/share/doc/escenic/ece-install-guide.org
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,12 @@ escenic-related purposes.
You can ensure that *ece-install* is not executed accidentally by
creating a *lock file*. Simply create a file with this path:
#+BEGIN_SRC text
/var/lock/ece-install.lock
/var/run/escenic/ece-install.lock
#+END_SRC

If this file is present then *ece-install* will fail fast as follows:
#+BEGIN_SRC text
The lock file is present: /var/lock/ece-install.lock and
ece-install will therefore refuse to run.
/var/run/escenic/ece-install.lock exists, I'll exit.
#+END_SRC

The lock file does not need to contain anything, it just needs to exist.
Expand Down
17 changes: 17 additions & 0 deletions usr/share/escenic/ece-scripts/ece-install.d/app-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,23 @@ EOF
proxyPort="443"
scheme="https"
/>
EOF

if [[ ${fai_editor_install-0} -eq 1 ||
${fai_presentation_install-0} -eq 1 ]]; then
cat >> $tomcat_base/conf/server.xml <<EOF
<Connector port="${fai_sse_proxy_ece_port-8083}"
protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
compression="off"
redirectPort="${fai_sse_proxy_ece_redirect-8443}"
proxyPort="${fai_sse_proxy_exposed_port-80}"
/>
EOF
fi

cat >> $tomcat_base/conf/server.xml <<EOF
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="access."
Expand Down
52 changes: 52 additions & 0 deletions usr/share/escenic/ece-scripts/ece-install.d/conf-file-reader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ parse_yaml_conf_file_or_source_if_sh_conf() {
_parse_yaml_conf_file_assembly_tool "${yaml_file}"
_parse_yaml_conf_file_restore "${yaml_file}"
_parse_yaml_conf_file_cue "${yaml_file}"
_parse_yaml_conf_file_sse_proxy "${yaml_file}"
_parse_yaml_conf_file_nfs_server "${yaml_file}"
_parse_yaml_conf_file_nfs_client "${yaml_file}"
}
Expand Down Expand Up @@ -900,6 +901,57 @@ _parse_yaml_conf_file_cue() {
done
}

_parse_yaml_conf_file_sse_proxy() {
local yaml_file=$1

local install_sse_proxy=no
install_sse_proxy=$(_jq "${yaml_file}" .profiles.sse_proxy.install)
if [[ "${install_sse_proxy}" == "yes" ||
"${install_sse_proxy}" == "true" ]]; then
export fai_sse_proxy_install=1
fi

local install_sse_proxy_exposed_host=
install_sse_proxy_exposed_host=$(_jq "${yaml_file}" .profiles.sse_proxy.exposed_host)
if [ -n "${install_sse_proxy_exposed_host}" ]; then
export fai_sse_proxy_exposed_host=${install_sse_proxy_exposed_host}
fi

local install_sse_proxy_exposed_port=
install_sse_proxy_exposed_port=$(_jq "${yaml_file}" .profiles.sse_proxy.exposed_port)
if [ -n "${install_sse_proxy_exposed_port}" ]; then
export fai_sse_proxy_exposed_port=${install_sse_proxy_exposed_port}
fi

local install_sse_proxy_ece_port=
install_sse_proxy_ece_port=$(_jq "${yaml_file}" .profiles.sse_proxy.ece_port)
if [ -n "${install_sse_proxy_ece_port}" ]; then
export fai_sse_proxy_ece_port=${install_sse_proxy_ece_port}
fi

local install_sse_proxy_ece_redirect=
install_sse_proxy_ece_redirect=$(_jq "${yaml_file}" .profiles.sse_proxy.ece_redirect)
if [ -n "${install_sse_proxy_ece_redirect}" ]; then
export fai_sse_proxy_ece_redirect=${install_sse_proxy_ece_redirect}
fi

local sse_backends=
local sse_backends_count=0
sse_backends_count=$(_jq "${yaml_file}" ".profiles.sse_proxy.backends | length")
for ((i = 0; i < sse_backends_count; i++)); do
local uri=
local user=
local password=
uri=$(_jq "${yaml_file}" .profiles.sse_proxy.backends["${i}"].uri)
user=$(_jq "${yaml_file}" .profiles.sse_proxy.backends["${i}"].user)
password=$(_jq "${yaml_file}" .profiles.sse_proxy.backends["${i}"].password)
sse_backends="${uri} ${user} ${password}
${sse_backends}"
done
export fai_sse_proxy_backends=${sse_backends}

}

_jq() {
local yaml_file=$1
local key=$2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ function install_ece_third_party_packages
xmlstarlet
"

install_sun_java_on_redhat
install_oracle_java
fi

install_packages_if_missing $packages
Expand Down
29 changes: 24 additions & 5 deletions usr/share/escenic/ece-scripts/ece-install.d/java.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
# -*- mode: sh; sh-shell: bash; -*-

oracle_jdk_download_url=http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

function _java_get_oracle_tarball_url() {
if [ -n "${fai_java_download_url-""}" ]; then
echo "${fai_java_download_url}"
return
fi

local url=http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
curl -s "${url}" |
curl -s "${oracle_jdk_download_url}" |
grep "$(uname -s) x64" |
grep .tar.gz |
grep -v demos |
sed -n -r 's#.*filepath":"(.*)", "MD5".*#\1#p'
}

function _java_get_oracle_rpm_url() {
if [ -n "${fai_java_download_url-""}" ]; then
echo "${fai_java_download_url}"
return
fi

curl -s "${oracle_jdk_download_url}" |
grep "$(uname -s) x64" |
grep .rpm |
grep -v demos |
sed -n -r 's#.*filepath":"(.*)", "MD5".*#\1#p'
}

function install_oracle_java() {
if _java_is_sun_java_already_installed; then
print_and_log "Oracle Java is already installed on $HOSTNAME"
Expand Down Expand Up @@ -159,16 +173,21 @@ function _install_oracle_java_debian() {

function _install_oracle_java_redhat() {
print_and_log "Downloading & installing Oracle JDK RPM ..."
local file_name=${download_dir}/${sun_java_bin_url##*/}
_download_oracle_file "${sun_java_bin_url}" "${file_name}"

local oracle_java_rpm_url=
oracle_java_rpm_url=$(_java_get_oracle_rpm_url)

local file_name=${download_dir}/${oracle_java_rpm_url##*/}
_download_oracle_file "${oracle_java_rpm_url}" "${file_name}"

if ! is_rpm_already_installed "${file_name}"; then
run rpm -Uvh "${file_name}"
fi

_java_update_java_env_from_jdk_rpm "${file_name}"

local version=$(java -version 2>&1 | grep version | cut -d'"' -f2)
local version=
version=$(java -version 2>&1 | grep version | cut -d'"' -f2)
print_and_log "Oracle Java $version is now installed"

add_next_step "By using Oracle Java, you must accept this license: " \
Expand Down
3 changes: 2 additions & 1 deletion usr/share/escenic/ece-scripts/ece-install.d/memory-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function install_memory_cache()

install_packages_if_missing "memcached"
if [ $on_redhat_or_derivative -eq 1 ]; then
run service memcached restart
run systemctl enable memcached
run systemctl start memcached
fi

assert_commands_available memcached
Expand Down
Loading

0 comments on commit 0c29e6b

Please sign in to comment.