for creole's zephir2 branch

This commit is contained in:
2019-11-23 08:17:35 +01:00
commit 841643e76e
700 changed files with 68183 additions and 0 deletions

112
scripts/ParsePEM.py Executable file
View File

@ -0,0 +1,112 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#####################
# Parse pour Certificat
# Version Alpha
# LB 12/2002
# $Id: ParsePEM.py,v 1.1.1.1 2004/01/05 10:50:56 eole Exp $
#####################
import string,getopt,sys
def Usage():
print "Usage : "
print "ParsePem -i FichierPem -o Repertoire de destination"
print """
Fonction:
Recuperer les 2 Certificats (CA+Serveur)
contenus dans le fichier en entré et creer
deux fichiers CertifCa et CertifServeur
dans le Repertoire de destination
"""
sys.exit
def Option():
global Input , Output
try:
(opt, args) = getopt.getopt(sys.argv[1:], "hi:o:" ,["help","input=","output="])
except:
getopt.GetoptError
Usage()
sys.exit(1)
#print "opt=%s" % opt
for (o , ch) in opt:
if o in ("-h", "--help"):
Usage()
sys.exit()
if o in ("-o","--output"):
if ch == "":
Usage()
Output = ch
if o in ("-i","--intput"):
if ch == "":
Usage()
Input = ch
def CreFic(Nom):
Fichier = Output+"/"+Nom
print "%s" % Fichier
try:
Desc= open(Fichier,"w")
except:
print "Fichier %s Non créé" % Fichier
sys.exit(2)
return(Desc)
def Avance(Cherche):
global ligne
while ( ligne.find(Cherche)== -1 ):
#print "Ligne=%s" % ligne
ligne=Fic.readline()
if ligne=='':
print "Erreur Fichier %s Non conforme" % Input
print "Chaine %s non trouvéé" % Cherche
sys.exit(2)
##################### MAIN ################
Input=Output=""
Option()
print "In=%s Out=%s" % (Input , Output)
if (Input==""):
Fic=sys.stdin
else:
try:
Fic= open(Input,"r")
except:
print "Fichier %s Non trouvé" % Input
sys.exit(2)
C1=CreFic("CertifCa.pem")
ligne=Fic.readline()
Avance("-BEGIN CERTIF")
#Certif CA trouvé "
while (ligne.find("-END CERTIF")==-1):
C1.write(ligne)
ligne=Fic.readline()
if ligne=='':
print "Erreur Cerificat CA "
sys.exit(2)
C1.write(ligne)
Avance("subject=")
(Bid,CN)=ligne.split("CN=")
outf="%s.pem" % CN.strip()
C2=CreFic(outf)
Avance("-BEGIN CERTIF")
#Certif Client trouvé "
while (ligne.find("-END CERTIF")==-1):
C2.write(ligne)
ligne=Fic.readline()
if ligne=='':
print "Erreur Cerificat Serveur "
sys.exit(2)
C2.write(ligne)

51
scripts/Upgrade-Auto Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
#------------------------------------------------------------------------
# Upgrade-Auto - Wrapper to log upgrade of an EOLE server
# Copyright © 2016 Équipe EOLE <eole@ac-dijon.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
#------------------------------------------------------------------------
# Delegate help
#
if echo "$@" | grep -qse '-h\|--help'
then
/usr/share/eole/upgrade/Upgrade-Auto --help
exit 0
fi
#------------------------------------------------------------------------
# Open log
#
LOG_FILE='/var/log/upgrade-auto.log'
PIPE="/run/upgrade-auto.fifo"
[ ! -p "${PIPE}" ] || rm -f "${PIPE}"
mkfifo ${PIPE}
# Use a function to strip ANSI colors from log
tee <${PIPE} "${LOG_FILE}" &
exec 1>&-
exec 2>&-
exec 1> ${PIPE}
exec 2> ${PIPE}
[ ! -p "${PIPE}" ] || rm -f "${PIPE}"
/usr/share/eole/upgrade/Upgrade-Auto $@

90
scripts/manage_schedule Executable file
View File

@ -0,0 +1,90 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from pyeole.schedule import display_schedules, ManageSchedule, \
apply_schedules, add_schedule, del_schedule
from pyeole.ansiprint import print_orange
from optparse import OptionParser, OptionGroup
def main():
parser = OptionParser()
parser.add_option("-l", "--list", dest="list", action="store_true",
default=False, help=u"Liste les scripts activés et désactivés")
parser.add_option("--apply", dest="apply", help=u"Active/désactive les scripts dans le schedule",
action='store_true', default=False)
group = OptionGroup(parser, u"Activer un script (ne pas oublier d'appliquer la configuration)")
group.add_option("-a", "--add", dest="add", help=u"Périodicité : une fois (once), tous les jours (daily), toutes les semaines (weekly) ou tous les mois (monthly)")
group.add_option("-s", "--script", dest="script", help=u"Nom du script")
group.add_option("-m", "--mode", dest="mode", help=u"Mode : avant la sauvegarde (pre) ou après la sauvegarde (post)")
parser.add_option_group(group)
parser.add_option("-d", "--del", dest="delete", help=u"Désactive le script en précisant son nom (ne pas oublier d'appliquer la configuration)")
(option, args) = parser.parse_args()
if option.delete is None and option.add is None and option.list is False and option.apply is False:
parser.print_help()
sys.exit(0)
if (option.delete is not None and option.add is not None) or \
(option.list is True and option.add is not None) or \
(option.delete is not None and option.list is True) or \
(option.apply is True and option.add is not None) or \
(option.apply is True and option.list is True) or \
(option.apply is True and option.delete is True):
parser.print_help()
print "can't list, apply, add or delete together"
print
sys.exit(1)
if option.add is not None and None in [option.script, option.mode]:
print "you should specified -s and -m with -a"
print
parser.print_help()
sys.exit(1)
if option.delete == 'once' and None in [option.script, option.mode]:
print "you must specify mode if you want delete 'once' script"
print
parser.print_help()
sys.exit(1)
if option.delete != 'once' and ((option.script is not None and option.add is None) or \
(option.mode is not None and option.add is None)):
print "you should specified -s and -m only with -a"
print
parser.print_help()
sys.exit(1)
if option.list:
display_schedules()
if option.add is not None:
try:
if option.add == 'once':
add_schedule(option.add, option.mode, option.script)
else:
sch = ManageSchedule()
sch.add(option.script, option.add, option.mode)
sch.save()
except Exception, err:
print_orange(str(err))
sys.exit(1)
if option.delete is not None:
try:
if option.delete == 'once':
del_schedule(option.delete, option.mode, option.script)
else:
sch = ManageSchedule()
sch.delete(option.delete)
sch.save()
except Exception, err:
print_orange(str(err))
sys.exit(1)
if option.apply is not None:
apply_schedules()
if __name__ == '__main__':
main()