X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor-server.init;h=32d12093555d2f2c6a4cd53f44cff83d75024421;hb=4fdb3f1a73ed9a8f48c120670cd6e0533bcb9741;hp=265a80344c40eb466d7008d23032530f3932a8fe;hpb=b6c1d56d3d49c18fff2f1a0a6114cacb82b3c3ec;p=monitor.git diff --git a/monitor-server.init b/monitor-server.init index 265a803..32d1209 100644 --- a/monitor-server.init +++ b/monitor-server.init @@ -18,6 +18,8 @@ local_config=/etc/planetlab/configs/site.xml MONITORPATH=/usr/share/monitor +WEB_ROOT_PATH=web/MonitorWeb/monitorweb +WEB_XML_PATH=static/xml # Be verbose set -x @@ -40,10 +42,45 @@ if [ -z "$PLC_MONITOR_IP" ] ; then PLC_MONITOR_IP=$( gethostbyname $PLC_MONITOR_HOST ) fi -function check_monitor_schema_and_data() +function update_config () { - # 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()" + pattern=$1 + with=$2 + file=$3 + sed -i -e "s/$pattern/$with/g" $file +} +function apply_template () +{ + TEMPLATE=$1 + DESTFILE=$2 + + tmp_file=$(mktemp) + cp $TEMPLATE $tmp_file + + update_config PLC_NAME "$PLC_NAME" $tmp_file + update_config PLC_WWW_HOSTNAME $PLC_WWW_HOST $tmp_file + update_config MONITOR_HOSTNAME $PLC_MONITOR_HOST $tmp_file + + cp $tmp_file $DESTFILE + rm -f $tmp_file +} + +function check_gadget_config () +{ + for input_file in $MONITORPATH/$WEB_ROOT_PATH/$WEB_XML_PATH/*.in ; do + output_file=$MONITORPATH/$WEB_ROOT_PATH/$WEB_XML_PATH/`basename $input_file | sed -e 's/.in\$//'` + if [ $input_file -nt $output_file ] ; then + apply_template $input_file $output_file + fi + done +} + +function check_monitor_schema_and_data_init() +{ + # from monitor.functions + check_monitor_schema_and_data + + $MONITORPATH/config.d/init-bootman-sequence.py } function check_monitor_conf () @@ -149,6 +186,7 @@ function create_httpd_conf () # NOTE: redirect path without trailing '/' to path with. Favor SSL. Redirect /monitor https://${PLC_MONITOR_HOST}:${PLC_WWW_SSL_PORT}/monitor/ +#RedirectMatch ^/$ https://${PLC_MONITOR_HOST}:${PLC_WWW_SSL_PORT}/monitor # NOTE: this directive strips '/monitor/' from the requested path and pastes # the remaining part to the end of the ProxyPass url below. All TG urls @@ -200,6 +238,8 @@ case "$1" in # WRITE default /etc/monitor.conf check_monitor_conf + check_gadget_config + if [ -n "$WROTE_PG_CONFIG" ] ; then # NOTE: restart db to enable access by users granted above. service plc restart postgresql @@ -208,7 +248,7 @@ case "$1" in dialog "$MESSAGE" fi - check_monitor_schema_and_data + check_monitor_schema_and_data_init # create /etc/httpd/conf.d/monitorweb.conf create_httpd_conf