From 0958d23852d17a8c3c8f8d4bf9e02c83587bf579 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Sun, 5 Jul 2009 00:02:23 +0000 Subject: [PATCH] changed getadmins into a generic function for both for admins and other roles. added callplcsh to allow both plcsh invocation locally or using a remote plc changed default password updated plcrt.init to take additional steps to configure the httpd/conf.d/rt3.conf updated RT_SiteConfig to only use http --- RT_SiteConfig.pm | 2 +- adduserstort.pl | 2 +- callplcsh.py | 29 +++++++++++++++++++++++++++++ cron.d/syncadmins.sh | 2 +- getadmins.py => getpersons.py | 0 plcrt.init | 12 +++++++++++- plcrt.spec | 17 ++++++++++++++--- 7 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 callplcsh.py rename getadmins.py => getpersons.py (100%) diff --git a/RT_SiteConfig.pm b/RT_SiteConfig.pm index 5c2f530..2daff7f 100644 --- a/RT_SiteConfig.pm +++ b/RT_SiteConfig.pm @@ -47,7 +47,7 @@ Set($DatabaseRTHost , 'localhost'); Set($WebPath , "/rt3"); # e.g. Set($WebPath , ""); #URL -Set($WebBaseURL , "https://PLC_RT_HOSTNAME"); # Set($WebBaseURL , "http://rt.PLC_RT_HOSTNAME"); +Set($WebBaseURL , "http://PLC_RT_HOSTNAME"); # Set($WebBaseURL , "http://rt.PLC_RT_HOSTNAME"); #Adding plugins #Set(@Plugins,qw(RT::FM)); diff --git a/adduserstort.pl b/adduserstort.pl index a826499..e2bd527 100755 --- a/adduserstort.pl +++ b/adduserstort.pl @@ -46,7 +46,7 @@ foreach $bc_user (@raw_data) $UserObj->Create(Name => $email_address, RealName => $realname, EmailAddress => $email_address, - Password => 'tpdemo2009', + Password => 'default2009', Organization => $organization, Privileged => $priv); #Address1 => $address1, diff --git a/callplcsh.py b/callplcsh.py new file mode 100644 index 0000000..6d18625 --- /dev/null +++ b/callplcsh.py @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import os +import sys + +#NOTE: I'm so sorry for this. +try: + # if this file deos not exist, then we will jump to the exception and use + # the local PLCSH without passing any additional arguments. + + os.stat("/etc/planetlab/master.py") + sys.path.append("/etc/planetlab") + import master + + # Use the values given to us in the /etc/planetlab/master.py file taken from + # the master PLC and use them to construct the proper arguments to plcsh so + # that we can get a user list from managing, CoPLC + + user=master.PLC_ROOT_USER + passwd=master.PLC_ROOT_PASSWORD + url = "https://" + master.PLC_API_HOST + ":" \ + + master.PLC_API_PORT + master.PLC_API_PATH + + cmd = "plcsh --user=%s --password=%s --url=%s %s" % (user, + passwd, url, " ".join(sys.argv[1:])) +except: + cmd = "plcsh %s" % " ".join(sys.argv[1:]) + +os.system(cmd) diff --git a/cron.d/syncadmins.sh b/cron.d/syncadmins.sh index 3d41b5a..534f65e 100755 --- a/cron.d/syncadmins.sh +++ b/cron.d/syncadmins.sh @@ -1,4 +1,4 @@ #!/bin/bash RTDIR=/usr/share/plcrt -${RTDIR}/getadmins.py | ${RTDIR}/adduserstort.pl priv - +${RTDIR}/callplcsh.py ${RTDIR}/getadmins.py admin | ${RTDIR}/adduserstort.pl priv - diff --git a/getadmins.py b/getpersons.py similarity index 100% rename from getadmins.py rename to getpersons.py diff --git a/plcrt.init b/plcrt.init index eb91888..7a55d9b 100644 --- a/plcrt.init +++ b/plcrt.init @@ -73,6 +73,11 @@ function check_rt_siteconfig () for f in $PLCRTPATH/conf.d/*.pl ; do update_config PLC_RT_HOSTNAME $PLC_RT_HOST $f done + + # TODO: need a better approach for this. + if [ -f /etc/httpd/conf.d/rt3.conf ] ; then + update_config PLC_RT_HOST $PLC_RT_HOST /etc/httpd/conf.d/rt3.conf + fi # if the templates are newer than the actual config, then replace them. if [ $PLCRTPATH/RT_SiteConfig.pm -nt /etc/rt3/RT_SiteConfig.pm ] ; @@ -115,6 +120,7 @@ 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. @@ -211,6 +217,9 @@ case "$1" in check_pg_hba $RT3_DB_NAME $RT3_DB_USER #check_user_and_db $RT3_DB_NAME $RT3_DB_USER check_rt_siteconfig + # TODO: make this dependent on whether a change was made! + service plc restart httpd + check_rt_pghba if [ -n "$WROTE_PG_CONFIG" ] ; then # NOTE: restart db to enable access by users granted above. @@ -223,6 +232,8 @@ case "$1" in check_rt_sendmail check_rt_custom # todo: restart httpd if needed. + # TODO: remove external permission + result "$MESSAGE" ;; @@ -237,7 +248,6 @@ case "$1" in dropuser -U postgres $RT3_DB_USER rm -f /etc/rt3/RT_SiteConfig.pm rm -f /etc/rt3/initialdata - PATTERN="host all postgres 127.0.0.1/32 trust" 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 6b48d54..ca95675 100644 --- a/plcrt.spec +++ b/plcrt.spec @@ -69,12 +69,23 @@ 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 \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 \n |' /etc/planetlab/default_config.xml fi mkdir -p /etc/planetlab/configs -plc-config --save /etc/planetlab/configs/site.xml \ - --category plc_rt --variable enabled --value true +plc-config --category plc_rt --variable enabled --value true \ + --save /etc/planetlab/configs/site.xml /etc/planetlab/default_config.xml + +# NOTE: setup default values until myplc includes them by default. +plc-config --category plc_rt --variable host --value localhost.localdomain \ + --save /etc/planetlab/configs/site.xml /etc/planetlab/configs/site.xml +plc-config --category plc_rt --variable ip --value "" \ + --save /etc/planetlab/configs/site.xml /etc/planetlab/configs/site.xml +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 + mkdir -p /var/log/rt3 touch /var/log/rt3/rt.log -- 2.43.0