From: Vincent Le Gallic Date: Mon, 30 Sep 2013 12:46:58 +0000 (+0200) Subject: [bde/old] Des vieux scripts recodés dans bde:/usr/scripts ou déclarés inutiles X-Git-Url: http://gitweb.pimeys.fr/?a=commitdiff_plain;h=402f87153b7ac5a3a6c5e84e447e42edce1d76fb;p=scripts-20-100.git [bde/old] Des vieux scripts recodés dans bde:/usr/scripts ou déclarés inutiles --- diff --git a/bde/old/big_brother.py b/bde/old/big_brother.py new file mode 100644 index 0000000..934b56e --- /dev/null +++ b/bde/old/big_brother.py @@ -0,0 +1,35 @@ +#!/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() diff --git a/bde/old/check_integrity.py b/bde/old/check_integrity.py new file mode 100644 index 0000000..d0c49d9 --- /dev/null +++ b/bde/old/check_integrity.py @@ -0,0 +1,37 @@ +#!/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() diff --git a/bde/old/forwardmail.py b/bde/old/forwardmail.py new file mode 100644 index 0000000..686f64d --- /dev/null +++ b/bde/old/forwardmail.py @@ -0,0 +1,36 @@ +#!/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')