changed getadmins into a generic function for both for admins and other roles.
authorStephen Soltesz <soltesz@cs.princeton.edu>
Sun, 5 Jul 2009 00:02:23 +0000 (00:02 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Sun, 5 Jul 2009 00:02:23 +0000 (00:02 +0000)
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
adduserstort.pl
callplcsh.py [new file with mode: 0644]
cron.d/syncadmins.sh
getpersons.py [moved from getadmins.py with 100% similarity]
plcrt.init
plcrt.spec

index 5c2f530..2daff7f 100644 (file)
@@ -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));
index a826499..e2bd527 100755 (executable)
@@ -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 (file)
index 0000000..6d18625
--- /dev/null
@@ -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)
index 3d41b5a..534f65e 100755 (executable)
@@ -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 -
similarity index 100%
rename from getadmins.py
rename to getpersons.py
index eb91888..7a55d9b 100644 (file)
@@ -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
index 6b48d54..ca95675 100644 (file)
@@ -69,12 +69,23 @@ if grep 'pam_loginuid.so' /etc/pam.d/crond ; then
 fi
 
 if ! grep '<category id="plc_rt">' /etc/planetlab/default_config.xml ; then 
-    sed -i 's|<category id="plc_net">| <category id="plc_rt">\n <name>RT Configuration</name>\n <description>RT</description>\n <variablelist>\n <variable id="enabled" type="boolean">\n <name>Enabled</name>\n <value>false</value>\n <description>Enable on this machine.</description>\n </variable>\n <variable id="host" type="hostname">\n <name>Hostname</name>\n <value>localhost.localdomain</value>\n <description>The fully qualified hostname.</description>\n </variable>\n <variable id="ip" type="ip">\n <name>IP Address</name>\n <value/>\n <description>The IP address of the RT server.</description>\n </variable>\n </variablelist>\n </category>\n <category id="plc_net">|' /etc/planetlab/default_config.xml
+    sed -i 's|<category id="plc_net">| <category id="plc_rt">\n <name>RT Configuration</name>\n <description>RT</description>\n <variablelist>\n <variable id="enabled" type="boolean">\n <name>Enabled</name>\n <value>false</value>\n <description>Enable on this machine.</description>\n </variable>\n <variable id="host" type="hostname">\n <name>Hostname</name>\n <value>localhost.localdomain</value>\n <description>The fully qualified hostname.</description>\n </variable>\n <variable id="ip" type="ip">\n <name>IP Address</name>\n <value/>\n <description>The IP address of the RT server.</description>\n </variable>\n <variable id="web_user" type="string">\n <name>username</name>\n <value>root</value>\n <description>The user name for RT access.</description>\n </variable>\n <variable id="web_password" type="password">\n <name>password</name>\n <value>password</value>\n <description>password to the rt user.</description>\n </variable>\n </variablelist>\n </category>\n <category id="plc_net">|' /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