Systme de mise jour du site web (dcapage et dplacement)
Powered by Benoit. darcs-hash:20041205162933-41617-d0c2bbec62e62290e74f9b704c1ba1038b62806f.gz
This commit is contained in:
parent
51e475ce10
commit
e91111b425
2 changed files with 115 additions and 0 deletions
96
cvsweb/commit-news.py
Executable file
96
cvsweb/commit-news.py
Executable file
|
@ -0,0 +1,96 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: iso-8859-1 -*-
|
||||||
|
#
|
||||||
|
# Hack par CC 13/07/1999 pour envoyer sur crans.cvs-checkins un
|
||||||
|
# compte-rendu d'activité de ce qui se passe...
|
||||||
|
#
|
||||||
|
# modif par SamK 22/11/99: splitter les lignes, sinon nntplib refuse le message
|
||||||
|
# si ya des lignes trop longues..
|
||||||
|
#
|
||||||
|
# modif par OS 15/05/00 ajout d'un Reply-To...
|
||||||
|
#
|
||||||
|
# Ajouts par NS 13/02/03 : signature qui explique un peu ce qui se passe, et
|
||||||
|
# création automatique d'un lien vers la page webcvs qui présente le diff.
|
||||||
|
#
|
||||||
|
# Modif par Benoit 05/12/04 : changement du repertoire ou sont loggue les
|
||||||
|
# commits
|
||||||
|
#
|
||||||
|
# Intimement lié à CVSROOT/loginfo
|
||||||
|
#
|
||||||
|
|
||||||
|
import nntplib,string,os,StringIO
|
||||||
|
|
||||||
|
def LFsplit(s):
|
||||||
|
res=""
|
||||||
|
while len(s)>80 :
|
||||||
|
pos=string.find(s,' ',65,80)
|
||||||
|
if pos < 0 :
|
||||||
|
res=res+s[0:75]+'\n'
|
||||||
|
s=s[75:len(s)+1]
|
||||||
|
else :
|
||||||
|
res=res+s[0:pos]+'\n'
|
||||||
|
s=s[pos+1:len(s)+1]
|
||||||
|
if len(s)>0:
|
||||||
|
res=res+s
|
||||||
|
return res
|
||||||
|
|
||||||
|
for uid in os.listdir('/var/local/cvsweb/checkins/'):
|
||||||
|
try:
|
||||||
|
so = []
|
||||||
|
fi = open('/var/local/cvsweb/checkins/'+uid,'r')
|
||||||
|
|
||||||
|
so.append("From: CVS admin <root@crans.org>\n" + \
|
||||||
|
("Subject: CVS Commit par %s\n" % uid)+ \
|
||||||
|
"Organization: Crans Internet Site\n" + \
|
||||||
|
"Newsgroups: crans.cvs-checkins\n" + \
|
||||||
|
"Reply-To: Nounous <nounou@crans.org>\n" + \
|
||||||
|
"Followup-To: crans.informatique\n" )
|
||||||
|
|
||||||
|
so.append("MIME-Version: 1.0\n" + \
|
||||||
|
"Content-Type: text/plain\n")
|
||||||
|
so.append("\n")
|
||||||
|
envoie = 0
|
||||||
|
links_base="http://www.crans.org/cgi-bin/cvsweb"
|
||||||
|
while 1:
|
||||||
|
s = fi.readline()
|
||||||
|
if not s: break
|
||||||
|
envoie = 1
|
||||||
|
links=['Liens vers les diffs sur cvsweb :\n']
|
||||||
|
diffok = 0
|
||||||
|
|
||||||
|
# On essaye de créer les liens vers cvsweb automatiquement.
|
||||||
|
try:
|
||||||
|
if s[0:3]=="web":
|
||||||
|
link=string.split(s)
|
||||||
|
for file in link[1:]:
|
||||||
|
file=string.split(file,",")
|
||||||
|
if not string.split(file[0],".")[-1] in ['jpg','jpeg','gif','png']:
|
||||||
|
links.append("%s/%s/%s.diff?r1=%s&r2=%s\n" % (links_base,link[0],file[0],file[1],file[2]))
|
||||||
|
diffok = 1
|
||||||
|
# S'il y a au moins un diff affichable, on donne le lien.
|
||||||
|
if diffok:
|
||||||
|
links.append('\n')
|
||||||
|
s=string.join(links,'')
|
||||||
|
else:
|
||||||
|
s=LFsplit(s)
|
||||||
|
so.append(s)
|
||||||
|
except:
|
||||||
|
so.append(s)
|
||||||
|
# Avec une signature c'est plus propre.
|
||||||
|
so.append("\n" + \
|
||||||
|
"-- \n" + \
|
||||||
|
"Notification automatique des CVS commits sur le site du CR@NS.\n"+ \
|
||||||
|
"Voir http://www.crans.org/cgi-bin/cvsweb/web/ pour accéder aux archives CVS complètes.")
|
||||||
|
|
||||||
|
|
||||||
|
# maintenant, on envoie :
|
||||||
|
|
||||||
|
if envoie:
|
||||||
|
sso = string.join(so,'')
|
||||||
|
fso = StringIO.StringIO(sso)
|
||||||
|
nntplib.NNTP('news.crans.org').post(fso)
|
||||||
|
#print sso
|
||||||
|
os.unlink('/var/local/cvsweb/checkins/'+uid)
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
19
cvsweb/update.sh
Executable file
19
cvsweb/update.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Mise à jour de l'arborescence du site web
|
||||||
|
# Execute toutes les minutes (par root).
|
||||||
|
|
||||||
|
OQP=/var/lock/cvsweb
|
||||||
|
CHEMIN=/var/local/cvsweb
|
||||||
|
REPOSITORY=/home/httpd/CVS-Repository/
|
||||||
|
|
||||||
|
if [ $CHEMIN/commit.todo -nt $CHEMIN/commit.ok ]; then
|
||||||
|
if ! [[ -f $OQP ]]; then
|
||||||
|
chown -R www-data:webcvs $REPOSITORY
|
||||||
|
chmod -R o-rwx $REPOSITORY
|
||||||
|
touch $OQP
|
||||||
|
cd /home/httpd/web
|
||||||
|
su www-data -c "/usr/bin/cvs -d $REPOSITORY update -P -d"
|
||||||
|
test -s $OQP || rm -f $OQP
|
||||||
|
su www-data -c "touch $CHEMIN/commit.ok"
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue