+MONITOR_DB_USER="monitoruser"
+MONITOR_DB_NAME="monitor"
+
+WROTE_PG_CONFIG=
+
+if [ -z "$PLC_MONITOR_IP" ] ; then
+ PLC_MONITOR_IP=$( gethostbyname $PLC_MONITOR_HOST )
+fi
+
+function check_monitor_schema_and_data()
+{
+ # NOTE: call create_all() to setup the database from the info model.
+ python -c "from monitor.database.info.model import *; from elixir import create_all; create_all()"
+ $MONITORPATH/init-bootman-sequence.py
+}
+
+function check_monitor_conf ()
+{
+ MONITOR_CONFIG=/etc/monitor.conf
+
+ # Using plcsh add default, monitor user
+ plcsh <<EOF &>/dev/null
+AddPerson({'first_name' : 'Monitor', 'last_name' : 'Server', 'password' : '${PLC_MONITOR_DBPASSWORD}', 'email' : '${PLC_MONITOR_EMAIL}'})
+AddRoleToPerson('admin', '${PLC_MONITOR_EMAIL}')
+AddPersonToSite('${PLC_MONITOR_EMAIL}', '${PLC_SLICE_PREFIX}')
+UpdatePerson('${PLC_MONITOR_EMAIL}', { 'enabled' : True, 'password' : '${PLC_MONITOR_DBPASSWORD}' })
+EOF
+
+ if [ ! -f ${MONITOR_CONFIG} ] ; then
+ cat <<EOF > ${MONITOR_CONFIG}
+[monitorconfig]
+# RT Web user account
+RT_WEB_SERVER=http://${PLC_RT_HOST}/
+RT_WEB_TOOLS_PATH=/usr/bin/
+RT_WEB_USER=${PLC_RT_WEB_USER}
+RT_WEB_PASSWORD=${PLC_RT_WEB_PASSWORD}
+RT_WEB_DEBUG=0
+RT_QUEUE=${PLC_MONITOR_RT_QUEUE}
+
+# PLC admin account
+API_SERVER=https://${PLC_API_HOST}:${PLC_API_PORT}/PLCAPI/
+API_AUTH_USER=${PLC_MONITOR_EMAIL}
+API_AUTH_PASSWORD=${PLC_MONITOR_DBPASSWORD}
+
+# SERVER PATHS
+MONITOR_SCRIPT_ROOT=${MONITORPATH}
+MONITOR_DATA_ROOT=/var/lib/monitor
+MONITOR_ARCHIVE_ROOT=/var/lib/monitor/archive-pdb
+MONITOR_BOOTMANAGER_LOG=/var/www/html/monitorlog