rename convenience scripts so they start with plc-
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 19 May 2009 08:56:34 +0000 (08:56 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 19 May 2009 08:56:34 +0000 (08:56 +0000)
build.sh
myplc.spec
plc-check-ssl-peering.py [moved from check-ssl-peering.py with 100% similarity]
plc-orphan-accounts.py [new file with mode: 0755]

index a2155fc..60011c5 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -35,7 +35,8 @@ install -D -m 755 plc-kml.py ${RPM_BUILD_ROOT}/usr/bin/plc-kml.py
 install -D -m 755 refresh-peer.py ${RPM_BUILD_ROOT}/usr/bin/refresh-peer.py
 install -D -m 755 clean-empty-dirs.py ${RPM_BUILD_ROOT}/usr/bin/clean-empty-dirs.py
 install -D -m 755 mtail.py ${RPM_BUILD_ROOT}/usr/bin/mtail.py
-install -D -m 755 check-ssl-peering.py ${RPM_BUILD_ROOT}/usr/bin/check-ssl-peering.py
+install -D -m 755 plc-check-ssl-peering.py ${RPM_BUILD_ROOT}/usr/bin/plc-check-ssl-peering.py
+install -D -m 755 plc-orphan-accounts.py ${RPM_BUILD_ROOT}/usr/bin/plc-orphan-accounts.py
 # Extra scripts (mostly for mail and dns) not installed by myplc by default.  Used in production
 echo "* myplc-native: installing scripts in /etc/support-scripts"
 mkdir -p ${RPM_BUILD_ROOT}/etc/support-scripts
index 839ea24..76b5dec 100644 (file)
@@ -191,7 +191,8 @@ fi
 /usr/bin/refresh-peer.py*
 /usr/bin/clean-empty-dirs.py*
 /usr/bin/mtail.py*
-/usr/bin/check-ssl-peering.py*
+/usr/bin/plc-check-ssl-peering.py*
+/usr/bin/plc-orphan-accounts.py.py*
 /usr/share/myplc
 
 %changelog
diff --git a/plc-orphan-accounts.py b/plc-orphan-accounts.py
new file mode 100755 (executable)
index 0000000..83f6901
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env plcsh
+
+# searches and displays any local orphan account (not attached to a site)
+# remote accounts with identical emails are displayed as well
+
+import time
+
+def get_orphans ():
+    return [p for p in GetPersons({'peer_id':None,'-SORT':'date_created'}) if not p['site_ids'] ]
+
+def list_person (margin,p):
+    print margin,'%6d'%p[person_id], time.asctime(time.gmtime(p['date_created'])),
+    if not p['peer_id']: print 'LOCAL',
+    else: print 'pr=',p['peer_id'],
+    print p['email']
+
+def get_related(email):
+    return GetPersons ({'email':email,'~peer_id':None})
+
+def main ():
+    
+    orphans = get_orphans()
+    print 'Found',len(orphans),'orphan accounts'
+    index=1
+    for p in orphans:
+        list_person ("%3d"%index++,p)
+        for related in get_related(p['email']):
+            list_person("---",related)
+    
+if __name__ == '__main__':
+    main()