NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#!/bin/bash

# OpenCPS is the open source Core Public Services software
# Copyright (C) 2016-present OpenCPS community

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# 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 Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

set -e
set -u

#########################################################
# Check in the loop (every 1s) if the database backend
# service is already available for connections.
#########################################################
function terminate_db() {
local pid=$(cat $VOLUME_HOME/mysql.pid)
echo "Caught SIGTERM signal, shutting down DB..."
kill -TERM $pid

while true; do
if tail $ERROR_LOG | grep -s -E "mysqld .+? ended" $ERROR_LOG; then break; else sleep 0.5; fi
done
}


#########################################################
# Cals `mysql_install_db` if empty volume is detected.
# Globals:
# $VOLUME_HOME
# $ERROR_LOG
#########################################################
function install_db() {
if [ ! -d $VOLUME_HOME/mysql ]; then
echo "=> An empty/uninitialized MariaDB volume is detected in $VOLUME_HOME"
echo "=> Installing MariaDB..."
mysql_install_db --user=mysql > /dev/null 2>&1
echo "=> Installing MariaDB... Done!"
else
echo "=> Using an existing volume of MariaDB."
fi

# Move previous error log (which might be there from previously running container
# to different location. We do that to have error log from the currently running
# container only.
if [ -f $ERROR_LOG ]; then
echo "----------------- Previous error log -----------------"
tail -n 20 $ERROR_LOG
echo "----------------- Previous error log ends -----------------" && echo
mv -f $ERROR_LOG "${ERROR_LOG}.old";
fi

touch $ERROR_LOG && chown mysql $ERROR_LOG
}

function gen_config() {

PATH_CONFIG=/opt/server

DB_HOST=${DB_HOST:-localhost}
DB_PORT=${DB_PORT:-3306}
DB_USERNAME=${DB_USERNAME:-opencps}
DB_PASSWORD=${DB_PASSWORD:-lab@secret}
DB_DATABASE=${DB_DATABASE:-opencps10}

# generate file config
cp ${PATH_CONFIG}/portal-setup-wizard.properties.default ${PATH_CONFIG}/portal-setup-wizard.properties

sed -i s/DB_HOST/${DB_HOST}/ ${PATH_CONFIG}/portal-setup-wizard.properties
sed -i s/DB_PORT/${DB_PORT}/ ${PATH_CONFIG}/portal-setup-wizard.properties
sed -i s/DB_USERNAME/${DB_USERNAME}/ ${PATH_CONFIG}/portal-setup-wizard.properties
sed -i s/DB_PASSWORD/${DB_PASSWORD}/ ${PATH_CONFIG}/portal-setup-wizard.properties
sed -i s/DB_DATABASE/${DB_DATABASE}/ ${PATH_CONFIG}/portal-setup-wizard.properties

# User-provided env variables
MARIADB_USER=${MARIADB_USER:="admin"}
MARIADB_PASS=${MARIADB_PASS:-$(pwgen -s 12 1)}

# Other variables
VOLUME_HOME="/var/lib/mysql"
ERROR_LOG="$VOLUME_HOME/error.log"
MYSQLD_PID_FILE="$VOLUME_HOME/mysql.pid"

# Trap INT and TERM signals to do clean DB shutdown
trap terminate_db SIGINT SIGTERM

install_db
tail -F $ERROR_LOG & # tail all db logs to stdout

/usr/bin/mysqld_safe & # Launch DB server in the background
sleep 5
mysql -u root -e "CREATE DATABASE opencps10 CHARACTER SET utf8 COLLATE utf8_general_ci"
mysql -u root -e "grant all on opencps10.* to opencps@localhost identified by 'lab@secret'"
mysql -u root opencps10 < /docker-entrypoint-initdb.d/opencpsdb15.sql

}
gen_config
if [ "$1" = 'start-tomcat' ]; then
##################### start application #####################
# start tomcat
/opt/server/jboss-7.1.1/bin/standalone.sh &

fi

#exec "$@"
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.