diff --git a/fhoss/Dockerfile b/fhoss/Dockerfile new file mode 100644 index 0000000..011fc7e --- /dev/null +++ b/fhoss/Dockerfile @@ -0,0 +1,71 @@ +# THIRD PARTY SOFTWARE NOTICES AND INFORMATION +# Do Not Translate or Localize +# +# This repository includes Oracle Java 7 JDK downloaded from Oracle website, which is distributed +# under Oracle Binary Code License Agreement for Java SE. By using this repository you agree to +# have reviewed and accepted the Oracle Binary Code License Agreement for Java SE and hold +# no liability. +# +# ========================================= + +# BSD 2-Clause License + +# Copyright (c) 2020, Supreeth Herle +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +FROM ubuntu:bionic + +ENV DEBIAN_FRONTEND=noninteractive + +# Install updates and dependencies +RUN apt-get update && \ + apt-get -y install git vim wget subversion mysql-server + +# Install Oracle Java 7 SE JDK +RUN mkdir -p /usr/lib/jvm/ && \ + cd / && wget https://files-cdn.liferay.com/mirrors/download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz && \ + tar -zxf /jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm/ && \ + update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_80/bin/java 100 && \ + update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 100 + +# Install Ant +RUN cd / && wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.14-bin.tar.gz && \ + tar xvfvz apache-ant-1.9.14-bin.tar.gz && \ + mv apache-ant-1.9.14 /usr/local/ && \ + ln -s /usr/local/apache-ant-1.9.14/bin/ant /usr/bin/ant + +RUN mkdir -p /opt/OpenIMSCore && \ + cd /opt/OpenIMSCore && \ + git clone https://github.com/herlesupreeth/FHoSS + +ENV JAVA_HOME="/usr/lib/jvm/jdk1.7.0_80" +ENV CLASSPATH="/usr/lib/jvm/jdk1.7.0_80/jre/lib/" +ENV ANT_HOME="/usr/local/apache-ant-1.9.14" +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +RUN cd /opt/OpenIMSCore/FHoSS && \ + ant compile deploy | tee ant_compile_deploy.txt + +CMD /mnt/fhoss/fhoss_init.sh diff --git a/fhoss/configurator.sh b/fhoss/configurator.sh new file mode 100755 index 0000000..8dca84a --- /dev/null +++ b/fhoss/configurator.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Initialization & global vars +# if you execute this script for the second time +# you should change these variables to the latest +# domain name and ip address +DDOMAIN="open-ims\.test" +DSDOMAIN="open-ims\\\.test" +DEFAULTIP="127\.0\.0\.1" +CONFFILES=`ls *.cfg *.xml *.sql *.properties 2>/dev/null` + +# Interaction +domainname=$1 +ip_address=$2 + +# input domain is to be slashed for cfg regexes +slasheddomain=`echo $domainname | sed 's/\./\\\\\\\\\./g'` + +printf "changing: " +for i in $CONFFILES +do +sed -i -e "s/$DDOMAIN/$domainname/g" $i +sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $i +sed -i -e "s/$DEFAULTIP/$ip_address/g" $i + +printf "$i " +done +echo diff --git a/fhoss/fhoss_init.sh b/fhoss/fhoss_init.sh new file mode 100755 index 0000000..731bc99 --- /dev/null +++ b/fhoss/fhoss_init.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# BSD 2-Clause License + +# Copyright (c) 2020, Supreeth Herle +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cp /mnt/fhoss/configurator.sh /opt/OpenIMSCore/FHoSS/deploy +cp /mnt/fhoss/configurator.sh /opt/OpenIMSCore/FHoSS/scripts +cp /mnt/fhoss/configurator.sh /opt/OpenIMSCore/FHoSS/config + +cd /opt/OpenIMSCore/FHoSS/deploy && ./configurator.sh ${IMS_DOMAIN} ${FHOSS_IP} +sed -i 's|open-ims.org|'$IMS_DOMAIN'|g' /opt/OpenIMSCore/FHoSS/deploy/webapps/hss.web.console/WEB-INF/web.xml +sed -i 's|'$FHOSS_IP'|'$MYSQL_IP'|g' /opt/OpenIMSCore/FHoSS/deploy/hibernate.properties +cd /opt/OpenIMSCore/FHoSS/scripts && ./configurator.sh ${IMS_DOMAIN} ${FHOSS_IP} +cd /opt/OpenIMSCore/FHoSS/config && ./configurator.sh ${IMS_DOMAIN} ${FHOSS_IP} +sed -i 's|open-ims.org|'$IMS_DOMAIN'|g' /opt/OpenIMSCore/FHoSS/src-web/WEB-INF/web.xml + +while ! mysqladmin ping -h ${MYSQL_IP} --silent; do + sleep 5; +done + +# Sleep until permissions are set +sleep 5; + +# Create FHoSS database, populate tables and grant privileges +if [[ -z "`mysql -u root -h ${MYSQL_IP} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='pcscf'" 2>&1`" ]]; +then + mysql -u root -h ${MYSQL_IP} -e "create database hss_db;" + mysql -u root -h ${MYSQL_IP} hss_db < /opt/OpenIMSCore/FHoSS/scripts/hss_db.sql + mysql -u root -h ${MYSQL_IP} hss_db < /opt/OpenIMSCore/FHoSS/scripts/userdata.sql + mysql -u root -h ${MYSQL_IP} -e "grant delete,insert,select,update on hss_db.* to hss@$FHOSS_IP identified by 'hss';" + mysql -u root -h ${MYSQL_IP} -e "grant delete,insert,select,update on hss_db.* to hss@'%' identified by 'hss';" + mysql -u root -h ${MYSQL_IP} -e "FLUSH PRIVILEGES;" +fi + +cp /mnt/fhoss/hss.sh / +cd / && ./hss.sh \ No newline at end of file diff --git a/fhoss/hss.sh b/fhoss/hss.sh new file mode 100755 index 0000000..fca4dcd --- /dev/null +++ b/fhoss/hss.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# -------------------------------------------------------------- +# Include JAR Files +# -------------------------------------------------------------- + +cd /opt/OpenIMSCore/FHoSS/deploy +JAVA_HOME="/usr/lib/jvm/jdk1.7.0_80" +CLASSPATH="/usr/lib/jvm/jdk1.7.0_80/jre/lib/" +echo "Building Classpath" +CLASSPATH=$CLASSPATH:log4j.properties:. +for i in lib/*.jar; do CLASSPATH="$i":"$CLASSPATH"; done +echo "Classpath is $CLASSPATH." + +# -------------------------------------------------------------- +# Start-up +# -------------------------------------------------------------- + +$JAVA_HOME/bin/java -cp $CLASSPATH de.fhg.fokus.hss.main.HSSContainer $1 $2 $3 $4 $5 $6 $7 $8 $9