use a simpler plcsh script rather than monitor's tools to keep package
authorStephen Soltesz <soltesz@cs.princeton.edu>
Fri, 26 Jun 2009 23:23:22 +0000 (23:23 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Fri, 26 Jun 2009 23:23:22 +0000 (23:23 +0000)
independent.

cron.d/syncadmins.sh
getadmins.py [new file with mode: 0644]

index f27243d..3d41b5a 100755 (executable)
@@ -1,7 +1,4 @@
 #!/bin/bash
 
-MDIR=/usr/share/monitor
-source $MDIR/monitorconfig.sh
-${MONITOR_SCRIPT_ROOT}/plcquery.py --type person --withsitename --byrole admin \
-                                       --format="%(email)s,%(first_name)s %(last_name)s,%(name)s" \
-                               | ${MONITOR_SCRIPT_ROOT}/rt3/adduserstort.pl priv -
+RTDIR=/usr/share/plcrt
+${RTDIR}/getadmins.py | ${RTDIR}/adduserstort.pl priv -
diff --git a/getadmins.py b/getadmins.py
new file mode 100644 (file)
index 0000000..062be28
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/env plcsh
+
+p = GetPersons(None, ['email', 'first_name', 'last_name', 'roles', 'site_ids'])
+
+admins = filter(lambda x: 'admin' 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