--- /dev/null
+#!/usr/bin/python
+# -*- coding:utf8 -*-
+
+# vieilles version de big_brother, la version propre et à jour est dans /usr/script/gestion
+
+from commands import getstatusoutput as ex
+import os
+
+# liste des supremes connus
+known = "(2430,1767,2821,2221,2863,2882,3019,1230,2969,2804,1206,250,2837,2832,2850)"
+
+message = "\nDroits supreme :\n"
+supremes=ex("psql bde -c 'SELECT numcbde,prenom,nom,pseudo FROM adherents WHERE supreme=true AND NOT numcbde IN %s;'"%(known))[1]
+
+i=supremes.split()[-2]
+if i=="(0":
+ message+="(Seulement des gens connus)\n"
+else:
+ message+="!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"+supremes
+
+
+message+= "\n\nDroits invités :\n"
+droits_invites=ex('psql bde -c"SELECT numcbde,prenom,nom,pseudo FROM adherents WHERE droits&128!=0 AND supreme=false AND numcbde!=0;"')[1]
+i=droits_invites.split()[-2]
+if i=="(0":
+ message+="(Personne à part les supreme)"
+else:
+ message+="!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"+droits_invites
+
+
+header = "From: note-bigbrother@bde.crans.org\nTo: root\n"
+header += "Subject: Résumé des droits\n"
+mailer=os.popen("/usr/sbin/sendmail -t", "w")
+mailer.write(header+message+'\n.')
+mailer.close()
--- /dev/null
+#!/usr/bin/python
+# -*- coding:utf8 -*-
+
+from commands import getstatusoutput as ex
+import os
+
+req="""SELECT numcbde,pseudo,gagne-perdu as calcul,effectif,effectif-(gagne-perdu) as a_enlever
+FROM
+ (SELECT numcbde,pseudo,
+ (SELECT sum(montant*quantite)
+ FROM transactions
+ WHERE destinataire=main.numcbde AND valide='t') as gagne,
+ (SELECT sum(montant*quantite)
+ FROM transactions
+ WHERE emetteur=main.numcbde AND valide='t') as perdu,
+ (SELECT solde
+ FROM adherents WHERE numcbde=main.numcbde) as effectif
+ FROM adherents as main)
+AS calculs
+WHERE gagne-perdu!=effectif AND numcbde!=0 ORDER BY numcbde;"""
+
+message = "Vérification de l'intégrité\n"
+integrite=ex('psql bde -c "%s"'%(req))[1]
+
+i=integrite.split()[-2]
+if i=="(0":
+ oups=False
+ message += "La base est intègre (sauf pour le compte du Bde)"
+else:
+ oups=True
+ message += integrite
+
+header = "From: note-integrity@bde.crans.org\nTo: root\n"
+header += "Subject: Integrity Check"+" ARG !"*oups+"\n\n"
+mailer=os.popen("/usr/sbin/sendmail -t", "w")
+mailer.write(header+message+'\n.')
+mailer.close()
--- /dev/null
+#!/usr/bin/python
+# -*- coding:utf8 -*-
+
+# Codé par 20-100 pour essayer de forwarder les mails de root@bde.crans.org
+# legallic@crans.org
+
+import re
+from commands import getstatusoutput as ex
+
+import sys
+
+def change_header(mail,header,addvalue,delete=False):
+ """Cherche header dans mail.
+ S'il le trouve, le remplace par lui*(not delete)+addvalue et le renvoie.
+ S'il ne le trouve pas, renvoie None"""
+ found=re.search("\n"+header+"(.*)",mail)
+ if found:
+ deb,fin=found.span()
+ newmail=mail[:deb]
+ newmail+="\n"+header+((found.group(1)).replace("\n",''))*(not delete)+addvalue
+ newmail+=mail[fin:]
+ return newmail
+
+
+def lit_input():
+ inp = sys.stdin.read()
+ return inp
+
+if __name__=="__main__":
+ mail=lit_input()
+ newmail=change_header(mail,"To:",", respo-info.bde@lists.crans.org")
+ f=open("/home/mail-transferer/scripts/trymail.txt","w")
+ f.write(newmail)
+ f.close()
+ ex('cat /home/mail-transferer/scripts/trymail.txt | /usr/sbin/sendmail respo-info.bde@lists.crans.org')
+ ex('echo "essai envoi à `date +%Y-%m-%d_%T`" >> /home/mail-transferer/scripts/trymail.txt')