From f523e96169e358a0e6408cba68d4d5c3ad43131b Mon Sep 17 00:00:00 2001 From: Ethan Kromhout Date: Thu, 4 Apr 2019 11:56:58 -0400 Subject: [PATCH] Standalone Sentrifugo commit --- Sources/HR/README | 8 ++ Sources/HR/docker-compose.yml | 30 +++++++ Sources/HR/sentrifugo_data/Dockerfile | 14 ++++ Sources/HR/sentrifugo_server/000-default.conf | 41 ++++++++++ Sources/HR/sentrifugo_server/Dockerfile | 79 +++++++++++++++++++ Sources/HR/sentrifugo_server/README | 23 ++++++ .../application_constants.php | 4 + Sources/HR/sentrifugo_server/banderson.sql | 1 + Sources/HR/sentrifugo_server/email.sql | 10 +++ Sources/HR/sentrifugo_server/entrypoint.sh | 25 ++++++ .../mail_settings_constants.php | 8 ++ Sources/HR/sentrifugo_server/step3.sql | 1 + Sources/HR/sentrifugo_server/step4.sql | 2 + Sources/HR/sentrifugo_server/step5.sql | 1 + Sources/HR/sentrifugo_server/trigger.sql | 5 ++ 15 files changed, 252 insertions(+) create mode 100644 Sources/HR/README create mode 100644 Sources/HR/docker-compose.yml create mode 100644 Sources/HR/sentrifugo_data/Dockerfile create mode 100644 Sources/HR/sentrifugo_server/000-default.conf create mode 100644 Sources/HR/sentrifugo_server/Dockerfile create mode 100644 Sources/HR/sentrifugo_server/README create mode 100755 Sources/HR/sentrifugo_server/application_constants.php create mode 100644 Sources/HR/sentrifugo_server/banderson.sql create mode 100644 Sources/HR/sentrifugo_server/email.sql create mode 100644 Sources/HR/sentrifugo_server/entrypoint.sh create mode 100755 Sources/HR/sentrifugo_server/mail_settings_constants.php create mode 100644 Sources/HR/sentrifugo_server/step3.sql create mode 100644 Sources/HR/sentrifugo_server/step4.sql create mode 100644 Sources/HR/sentrifugo_server/step5.sql create mode 100644 Sources/HR/sentrifugo_server/trigger.sql diff --git a/Sources/HR/README b/Sources/HR/README new file mode 100644 index 0000000..0cccff8 --- /dev/null +++ b/Sources/HR/README @@ -0,0 +1,8 @@ +# A preconfigured Sentrifugo container set +# +# After building with docker-compose up +# Sentrifugo should be available at localhost:8080 +# You can login with banderson/password or +# empp0001/59887e9a7cb85 to be a super +# user in Sentrifugo + diff --git a/Sources/HR/docker-compose.yml b/Sources/HR/docker-compose.yml new file mode 100644 index 0000000..9e3872f --- /dev/null +++ b/Sources/HR/docker-compose.yml @@ -0,0 +1,30 @@ +version: "3.3" + +services: + sentrifugo_server: + build: ./sentrifugo_server/ + container_name: sentrifugo_server + networks: + - net + depends_on: + - sentrifugo_data + ports: + - "8080:80" + devices: + - "/dev/tty:/dev/tty" + links: + - "sentrifugo_data:sentrifugo_data" + + sentrifugo_data: + build: ./sentrifugo_data/ + container_name: sentrifugo_data + networks: + - net + volumes: + - sentrifugo_data:/var/lib/mysql +networks: + net: + driver: bridge + +volumes: + sentrifugo_data: diff --git a/Sources/HR/sentrifugo_data/Dockerfile b/Sources/HR/sentrifugo_data/Dockerfile new file mode 100644 index 0000000..c840eec --- /dev/null +++ b/Sources/HR/sentrifugo_data/Dockerfile @@ -0,0 +1,14 @@ +from mariadb:latest +RUN apt-get update +RUN apt-get install wget gcc libmysql++-dev librabbitmq-dev pkg-config libbsd-dev -y +#ENV MYSQL_RANDOM_ROOT_PASSWORD=true +ENV MYSQL_ROOT_PASSWORD=54y6RxN7GfC7aes3 +ENV MYSQL_DATABASE=sentrifugo +ENV MYSQL_USER=sentrifugo +ENV MYSQL_PASSWORD=54y6RxN7GfC7aes3 +WORKDIR /tmp +RUN wget https://github.com/ssimicro/lib_mysqludf_amqp/releases/download/v2.0.0/lib_mysqludf_amqp-2.0.0.tar.gz +RUN tar zxf lib_mysqludf_amqp-2.0.0.tar.gz +WORKDIR /tmp/lib_mysqludf_amqp-2.0.0 +RUN ./configure && make && make install #mysql -u root --password=54y6RxN7GfC7aes3 < installdb.sql +EXPOSE 3306 diff --git a/Sources/HR/sentrifugo_server/000-default.conf b/Sources/HR/sentrifugo_server/000-default.conf new file mode 100644 index 0000000..309068a --- /dev/null +++ b/Sources/HR/sentrifugo_server/000-default.conf @@ -0,0 +1,41 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + + DocumentRoot "/var/www/html/sentrifugo" + DirectoryIndex index.php index.html + # php_value include_path "/var/www/html/include" + + Options All +MultiViews -ExecCGI -Indexes + + DAV Off + + AllowOverride All + + LogLevel warn + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/Sources/HR/sentrifugo_server/Dockerfile b/Sources/HR/sentrifugo_server/Dockerfile new file mode 100644 index 0000000..b699348 --- /dev/null +++ b/Sources/HR/sentrifugo_server/Dockerfile @@ -0,0 +1,79 @@ +FROM ubuntu:16.04 +MAINTAINER Sreekanth G S +#ENV http_proxy=http://sysfp0t.its.unc.edu:80 +#ENV https_proxy=http://sysfp0t.its.unc.edu:80 +#RUN DEBIAN_FRONTEND=noninteractive \ +# apt-get -o Acquire::http::Proxy="http://sysfp0t.its.unc.edu:80" update && \ +# apt-get -o Acquire::http::Proxy="http://sysfp0t.its.unc.edu:80" install -y language-pack-en-base &&\ +# export LC_ALL=en_US.UTF-8 && \ +#` export LANG=en_US.UTF-8 + + +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y software-properties-common +#RUN cat /etc/locale.gen +#RUN cat /etc/environment +#RUN LANG=en_US.UTF-8 locale-gen --purge en_US.UTF-8 && echo -e 'LANG="en_US.UTF-8"\nLANGUAGE="en_US:en"\n' > /etc/default/locale && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && echo "LC_ALL=en_US.UTF-8" > /etc/environment && echo "LANG=en_US.UTF-8" >> /etc/environment && locale-gen "en_US.UTF-8" && export LC_ALL=en_US.UTF-8 && export LANG=en_US.UTF-8 && add-apt-repository ppa:ondrej/php + +#RUN apt-get -o Acquire::http::Proxy="http://sysfp0t.its.unc.edu:80" update && apt-get -o Acquire::http::Proxy="http://sysfp0t.its.unc.edu:80" install -y software-properties-common language-pack-en-base && \ +#LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php && apt-get -o Acquire::http::Proxy="http://sysfp0t.its.unc.edu:80" update && apt-get -o Acquire::http::Proxy="http://sysfp0t.its.unc.edu:80" install -y \ +RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" >> /etc/apt/sources.list && echo "deb-src http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" >> /etc/apt/sourceis.list && apt-get update --allow-unauthenticated +RUN cat /etc/apt/sources.list && ls -l /etc/apt/ +RUN apt-get install -y --allow-unauthenticated apache2-bin libapache2-mod-php php-curl php-ldap php-mysql php-mcrypt \ +php-gd php-xml patch curl vim git mysql-client wget unzip lynx + +RUN phpenmod mcrypt && phpenmod gd +RUN a2enmod xml2enc && a2enmod rewrite + +RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php/7.2/apache2/php.ini +RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php/7.2/cli/php.ini + +RUN useradd --uid 1000 --gid 50 docker + +RUN echo export APACHE_RUN_USER=docker >> /etc/apache2/envvars +RUN echo export APACHE_RUN_GROUP=staff >> /etc/apache2/envvars + +COPY 000-default.conf /etc/apache2/sites-enabled/000-default.conf + +RUN chown -R docker /var/www/html + +WORKDIR /var/www/html + +RUN wget -q "http://www.sentrifugo.com/home/downloadfile?file_name=Sentrifugo.zip" -O Sentrifugo.zip +#COPY Sentrifugo.zip /var/www/html/ +RUN unzip Sentrifugo.zip && mv Sentrifugo_3.2 sentrifugo + +WORKDIR /var/www/html/sentrifugo +RUN chown -R docker . + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +RUN chmod 777 -R public/downloads public/uploads public/email_constants.php \ +public/emptabconfigure.php \ +public/site_constants.php \ +public/db_constants.php \ +public/application_constants.php \ +public/mail_settings_constants.php \ +logs/application.log \ +application/modules/default/plugins/AccessControl.php \ +install + + +VOLUME /var/www/html/sentrifugo/public/uploads + +VOLUME /var/www/html/sentrifugo/public/downloads +#VOLUME /var/www/html/sentrifugo +#RUN apachectl start && sleep 2 && curl -d "host=mariadb&username=sentrifugo&password=54y6RxN7GfC7aes3&dbname=sentrifugo" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:80/install/step2.php && curl -data-raw "app_name=sentrifugo" -data-raw "email=sentrifugo.container@gmail.com" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:80/install/step3.php +#RUN apachectl stop +COPY application_constants.php /var/www/html/sentrifugo/public +COPY mail_settings_constants.php /var/www/html/sentrifugo/public +COPY step3.sql /tmp +COPY step4.sql /tmp +COPY step5.sql /tmp +COPY trigger.sql /tmp +COPY banderson.sql /tmp + +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 80 diff --git a/Sources/HR/sentrifugo_server/README b/Sources/HR/sentrifugo_server/README new file mode 100644 index 0000000..4284789 --- /dev/null +++ b/Sources/HR/sentrifugo_server/README @@ -0,0 +1,23 @@ +# Sentrifugo and Mariadb Docker Containers + +This is a set of docker files to create +an instance of sentrifugo for testing +along with a mariadb to support it + +You can build and run the needed containers via + +docker-compose up -d + +If this successful you should be albe to +walk though the configuration wizard via + +http://localhost:8080 + +Substituting your docker host for localhost as required + +When the wizard asks for database configuraton, use +mariadb for the hostname, sentrifugo for both the +database name and username, and 54y6RxN7GfC7aes3 for +the password. Username, database name, and password can +be changed to your own values by editing Dockerfile-sentrifugo +before running docker-compose diff --git a/Sources/HR/sentrifugo_server/application_constants.php b/Sources/HR/sentrifugo_server/application_constants.php new file mode 100755 index 0000000..43f37a4 --- /dev/null +++ b/Sources/HR/sentrifugo_server/application_constants.php @@ -0,0 +1,4 @@ + diff --git a/Sources/HR/sentrifugo_server/banderson.sql b/Sources/HR/sentrifugo_server/banderson.sql new file mode 100644 index 0000000..1f9c917 --- /dev/null +++ b/Sources/HR/sentrifugo_server/banderson.sql @@ -0,0 +1 @@ +insert into main_users (id,emprole,userstatus,firstname,lastname,userfullname,emailaddress,backgroundchk_status,emppassword,isactive,employeeId) values (2,1,'old','Brian','Anderson','Brian Anderson','sentrifugo.container@gmail.com','Not Applicable','5f4dcc3b5aa765d61d8327deb882cf99',1,'banderson'); diff --git a/Sources/HR/sentrifugo_server/email.sql b/Sources/HR/sentrifugo_server/email.sql new file mode 100644 index 0000000..8d99949 --- /dev/null +++ b/Sources/HR/sentrifugo_server/email.sql @@ -0,0 +1,10 @@ +root@a6cf7d197dd3:/var/www/html/sentrifugo/install.old# grep -i update step3.php + $query = "update main_users set emailaddress = '".$email."' where id = ".SUPERADMIN." and emprole = ".SUPERADMINROLE; +root@a6cf7d197dd3:/var/www/html/sentrifugo/install.old# grep -i insert step4.php + insert_into_db($tls,$smtpserver,$username,$password,$port,$auth); +function insert_into_db($tls,$smtpserver,$username,$password,$port,$auth) + $query1 = "INSERT INTO main_mail_settings (tls,auth, port,username,password,server_name,createddate,modifieddate) VALUES ('".$tls."','".$auth." ',".$port.",'".$username."','".$password."','".$smtpserver."','".$date."','".$date."') "; +}//end of insert_into_db function. +root@a6cf7d197dd3:/var/www/html/sentrifugo/install.old# grep -i update step4.php + $query1 = "UPDATE main_mail_settings SET tls='".$tls."', port=".$port.", auth='".$auth."', username='".$username."', password='".$password."', server_name='".$smtpserver."', createddate='".$date."', modifieddate='".$date."' "; + diff --git a/Sources/HR/sentrifugo_server/entrypoint.sh b/Sources/HR/sentrifugo_server/entrypoint.sh new file mode 100644 index 0000000..0df0982 --- /dev/null +++ b/Sources/HR/sentrifugo_server/entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh +cd /var/www/html + +. /etc/apache2/envvars +if [ ! -s /var/www/html/sentrifugo/public/db_constants.php ] +then +sleep 15 +apachectl start && sleep 2 && curl -d "host=sentrifugo_data&username=sentrifugo&password=54y6RxN7GfC7aes3&dbname=sentrifugo" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:80/install/step2.php && curl -data-raw "app_name=sentrifugo" -data-raw "email=sentrifugo.container@gmail.com" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:80/install/step3.php +apachectl stop +mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step3.sql +mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step4.sql +mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step5.sql +mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/banderson.sql +cd /tmp/ +/tmp +wget https://github.com/ssimicro/lib_mysqludf_amqp/releases/download/v2.0.0/lib_mysqludf_amqp-2.0.0.tar.gz +tar zxf lib_mysqludf_amqp-2.0.0.tar.gz +cd /tmp/lib_mysqludf_amqp-2.0.0 +mysql -h sentrifugo_data -u root --password=54y6RxN7GfC7aes3 < installdb.sql +mysql -h sentrifugo_data -u root --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/trigger.sql +mv /var/www/html/sentrifugo/install /var/www/html/sentrifugo/install.old +echo database initialization complete +fi + +exec apache2 -DNO_DETACH < /dev/null diff --git a/Sources/HR/sentrifugo_server/mail_settings_constants.php b/Sources/HR/sentrifugo_server/mail_settings_constants.php new file mode 100755 index 0000000..7d2eade --- /dev/null +++ b/Sources/HR/sentrifugo_server/mail_settings_constants.php @@ -0,0 +1,8 @@ + diff --git a/Sources/HR/sentrifugo_server/step3.sql b/Sources/HR/sentrifugo_server/step3.sql new file mode 100644 index 0000000..41c09c2 --- /dev/null +++ b/Sources/HR/sentrifugo_server/step3.sql @@ -0,0 +1 @@ +update main_users set emailaddress = 'sentrifugo.container@gmail.com' where id = '1' and emprole = '1'; diff --git a/Sources/HR/sentrifugo_server/step4.sql b/Sources/HR/sentrifugo_server/step4.sql new file mode 100644 index 0000000..1def435 --- /dev/null +++ b/Sources/HR/sentrifugo_server/step4.sql @@ -0,0 +1,2 @@ +#$query1 = "UPDATE main_mail_settings SET tls='".$tls."', port=".$port.", auth='".$auth."', username='".$username."', password='".$password."', server_name='".$smtpserver."', createddate='".$date."', modifieddate='".$date."' "; +INSERT INTO main_mail_settings (tls,auth, port,username,password,server_name,createddate,modifieddate) VALUES ('true','true',587,'sentrifugo.container@gmail.com','GzQaVm7kxFm6sF65','smtp.gmail.com',now(),now()); diff --git a/Sources/HR/sentrifugo_server/step5.sql b/Sources/HR/sentrifugo_server/step5.sql new file mode 100644 index 0000000..6f05952 --- /dev/null +++ b/Sources/HR/sentrifugo_server/step5.sql @@ -0,0 +1 @@ +update main_users set emppassword = 'af31300a65ad8e2668302dab2e6e7908' where id = 1; diff --git a/Sources/HR/sentrifugo_server/trigger.sql b/Sources/HR/sentrifugo_server/trigger.sql new file mode 100644 index 0000000..3f0caea --- /dev/null +++ b/Sources/HR/sentrifugo_server/trigger.sql @@ -0,0 +1,5 @@ +DELIMITER ;; + +CREATE TRIGGER after_insert_on_main_users AFTER INSERT ON main_users FOR EACH ROW BEGIN SET @message_id = (SELECT lib_mysqludf_amqp_sendjson('amqp://mysql:5ecr3t@mq', 'sor', 'sor_person', json_object('payload',json_object('id',NEW.employeeId,'names',json_array(json_object('givenName',NEW.firstname,'familyName',NEW.lastname,'formatted',NEW.userfullname)),'emails',json_array(json_object('value',NEW.emailaddress,'type','primary')),'phoneNumbers',json_array(json_object('value','9194450056')))))); END;; + +DELIMITER ;