From c62b289f9707305ac58cadbdbddc470ca7c3cb71 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Tue, 7 Jul 2009 03:14:43 +0000 Subject: [PATCH] add plc_rt_dbpassword add templates to conf.d directory, rather than a one-shot add access from both localhost and host ip addr to db for configuration copy default logo in spec file. --- plcrt.init | 34 ++++++++++++++++++++++++++++++---- plcrt.spec | 9 +++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/plcrt.init b/plcrt.init index 43d56ad..23f118d 100644 --- a/plcrt.init +++ b/plcrt.init @@ -38,6 +38,17 @@ if [ -z "$PLC_RT_IP" ] ; then PLC_RT_IP=$( gethostbyname $PLC_RT_HOST ) fi +function check_rt_password () +{ + if [[ -z "$PLC_RT_DBPASSWORD" || "$PLC_RT_DBPASSWORD" = "None" ]] ; then + # NOTE: this provides a simpler string than uuidgen + PLC_RT_DBPASSWORD=$( uuidgen | md5sum - | awk '{print $1}' ) + plc-config --category=plc_rt --variable=dbpassword --value="$PLC_RT_DBPASSWORD" --save=$local_config $local_config + service plc reload + CREATED="true" + fi +} + # NOTE: code duplicated from monitor.functions to allow package to be separate # from it. function check_pg_hba () @@ -71,7 +82,15 @@ function check_rt_siteconfig () # TODO: need a better approach for this. for f in $PLCRTPATH/conf.d/*.pl ; do - update_config PLC_RT_HOSTNAME $PLC_RT_HOST $f + mkdir -p /etc/rt3/conf.d + if [ $f -nt /etc/rt3/conf.d/`basename $f` ] ; then + tmp_file=$(mktemp) + cp $f $tmp_file + update_config PLC_RT_HOSTNAME $PLC_RT_HOST $tmp_file + + cp $tmp_file /etc/rt3/conf.d/`basename $f` + rm -f $tmp_file + fi done # TODO: need a better approach for this. @@ -93,7 +112,7 @@ function check_rt_siteconfig () update_config RT_DB_NAME $RT3_DB_NAME $tmp_siteconfig update_config RT_DB_USER $RT3_DB_USER $tmp_siteconfig - update_config RT_DB_PASSWORD $PLC_MONITOR_DBPASSWORD $tmp_siteconfig + update_config RT_DB_PASSWORD $PLC_RT_DBPASSWORD $tmp_siteconfig # setup initialdata update_config PLC_RT_HOSTNAME $PLC_RT_HOST $tmp_initialdata @@ -120,8 +139,13 @@ function check_rt_pghba () USER=$RT3_DB_USER CONF=$PGDATA/pg_hba.conf.d/${NAME}.conf PATTERN="host all postgres 127.0.0.1/32 trust" - PATTERN="host all postgres $PLC_RT_IP/32 trust" + if ! grep -q "$PATTERN" $CONF ; then + #### SETUP ACCESS from postgres user to run init for the first time. + echo "$PATTERN" >> $CONF + WROTE_PG_CONFIG="true" + fi + PATTERN="host all postgres $PLC_RT_IP/32 trust" if ! grep -q "$PATTERN" $CONF ; then #### SETUP ACCESS from postgres user to run init for the first time. echo "$PATTERN" >> $CONF @@ -153,7 +177,7 @@ function check_rt_init () { if [ ! -f /etc/rt3/setup.finished ] ; then /usr/sbin/rt-setup-database --action init --dba postgres - for f in $PLCRTPATH/conf.d/*.pl ; do + for f in /etc/rt3/conf.d/*.pl ; do /usr/sbin/rt-setup-database --action insert --dba postgres --datafile $f done @@ -214,6 +238,7 @@ case "$1" in MESSAGE=$"Bootstrap RT (please wait...)" dialog "$MESSAGE" + check_rt_password check_pg_hba $RT3_DB_NAME $RT3_DB_USER #check_user_and_db $RT3_DB_NAME $RT3_DB_USER check_rt_siteconfig @@ -259,6 +284,7 @@ case "$1" in dropuser -U postgres $RT3_DB_USER rm -f /etc/rt3/RT_SiteConfig.pm rm -f /etc/rt3/initialdata + rm -f /etc/rt3/conf.d/*.pl rm -f $PGDATA/pg_hba.conf.d/${RT3_DB_NAME}.conf sed -i -e "s/.*mailgate.*//g" /etc/aliases diff --git a/plcrt.spec b/plcrt.spec index 05eee86..fa6ef4d 100644 --- a/plcrt.spec +++ b/plcrt.spec @@ -69,7 +69,8 @@ if grep 'pam_loginuid.so' /etc/pam.d/crond ; then fi if ! grep '' /etc/planetlab/default_config.xml ; then - sed -i 's|| \n RT Configuration\n RT\n \n \n Enabled\n false\n Enable on this machine.\n \n \n Hostname\n localhost.localdomain\n The fully qualified hostname.\n \n \n IP Address\n \n The IP address of the RT server.\n \n \n username\n root\n The user name for RT access.\n \n \n password\n password\n password to the rt user.\n \n \n \n |' /etc/planetlab/default_config.xml + sed -i 's|| \n RT Configuration\n RT\n \n \n Enabled\n false\n Enable on this machine.\n \n \n Hostname\n localhost.localdomain\n The fully qualified hostname.\n \n \n IP Address\n \n The IP address of the RT server.\n \n \n username\n root\n The user name for RT access.\n \n \n password\n password\n password to the rt user.\n \n +\n Database Password\n \n Password to use when accessing the RT database.\n \n \n \n |' /etc/planetlab/default_config.xml fi mkdir -p /etc/planetlab/configs @@ -85,12 +86,16 @@ plc-config --category plc_rt --variable web_user --value root \ --save /etc/planetlab/configs/site.xml /etc/planetlab/configs/site.xml plc-config --category plc_rt --variable web_password --value password \ --save /etc/planetlab/configs/site.xml /etc/planetlab/configs/site.xml +plc-config --category plc_rt --variable dbpassword --value "" \ + --save /etc/planetlab/configs/site.xml /etc/planetlab/configs/site.xml - +# NOTE: not sure why these aren't setup by the rt package... mkdir -p /var/log/rt3 touch /var/log/rt3/rt.log chown apache.apache /var/log/rt3/rt.log +cp /usr/share/rt3/html/NoAuth/images/bplogo.gif /var/www/html/misc/logo.gif + %changelog * Sat Jul 04 2009 Stephen Soltesz - PLCRT-1.0-3 - renamed getpersons.py to accept a given 'role' -- 2.43.0