From 01a0036064141b1031fe3d06162eec10d81aa135 Mon Sep 17 00:00:00 2001
From: Stephen Soltesz <soltesz@cs.princeton.edu>
Date: Sun, 20 Sep 2009 01:44:56 +0000
Subject: [PATCH] coapi doesn't have site_ids? so getpersons should node depend
 on this field make scripts exec on install use RT_HOST name rather than
 localhost for RT mailgate configuration

---
 getpersons.py | 18 +++++++++++-------
 plcrt.init    |  8 ++++----
 plcrt.spec    |  6 ++++--
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/getpersons.py b/getpersons.py
index 4ed2427..6525a1f 100644
--- a/getpersons.py
+++ b/getpersons.py
@@ -7,10 +7,14 @@ p = GetPersons(None, ['email', 'first_name', 'last_name', 'roles', 'site_ids'])
 admins = filter(lambda x: sys.argv[1] in x['roles'], p)
 
 for a in admins:
-	s = GetSites(a['site_ids'], ['name'])
-	if len(s) > 0:
-		organization = s[0]['name']
-	else:
-		organization = "Unknown"
-	a['name'] = organization
-	print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a
+    if 'site_ids' in a:
+        s = GetSites(a['site_ids'], ['name'])
+        if len(s) > 0:
+            organization = s[0]['name']
+        else:
+            organization = "Unknown"
+    else:
+        organization = "Unknown"
+
+    a['name'] = organization
+    print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a
diff --git a/plcrt.init b/plcrt.init
index f72810b..bd66b59 100644
--- a/plcrt.init
+++ b/plcrt.init
@@ -167,10 +167,10 @@ function check_rt_aliases ()
 		sed -i -e "s/^security.*root//g" /etc/aliases
         cat <<EOF >> /etc/aliases
 # added by RT init scripts for default queues.
-support: "|/usr/sbin/rt-mailgate --queue support --action correspond --url http://localhost/rt3/"
-monitor: "|/usr/sbin/rt-mailgate --queue monitor --action correspond --url http://localhost/rt3/"
-security: "|/usr/sbin/rt-mailgate --queue security --action correspond --url http://localhost/rt3/"
-legal: "|/usr/sbin/rt-mailgate --queue legal --action correspond --url http://localhost/rt3/"
+support: "|/usr/sbin/rt-mailgate --queue support --action correspond --url http://$PLC_RT_HOST/rt3/"
+monitor: "|/usr/sbin/rt-mailgate --queue monitor --action correspond --url http://$PLC_RT_HOST/rt3/"
+security: "|/usr/sbin/rt-mailgate --queue security --action correspond --url http://$PLC_RT_HOST/rt3/"
+legal: "|/usr/sbin/rt-mailgate --queue legal --action correspond --url http://$PLC_RT_HOST/rt3/"
 EOF
 		/usr/bin/newaliases
 	fi
diff --git a/plcrt.spec b/plcrt.spec
index 53fabb8..b67565d 100644
--- a/plcrt.spec
+++ b/plcrt.spec
@@ -47,10 +47,12 @@ install -D -m 755 plcrt.init $RPM_BUILD_ROOT/%{_sysconfdir}/plc.d/plcrt
 echo " * Installing core scripts"
 rsync -a ./ $RPM_BUILD_ROOT/%{_datadir}/%{name}/
 
-echo " * Installing cron scripts"
 install -D -m 644 rt.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/rt.cron
+install -D -m 755 getpersons.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/getpersons.py
+install -D -m 755 callplcsh.py $RPM_BUILD_ROOT/%{_datadir}/%{name}/callplcsh.py
+install -D -m 755 adduserstort.pl $RPM_BUILD_ROOT/%{_datadir}/%{name}/adduserstort.pl
 
-chmod 755 $RPM_BUILD_ROOT/%{_datadir}/%{name}/adduserstort.pl
+echo " * Installing cron scripts"
 chmod 755 $RPM_BUILD_ROOT/%{_datadir}/%{name}/cron.d/*.sh
 
 %clean
-- 
2.47.0