Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1710 richard 1
#!/bin/bash
2
 
3
# alcasar-defaultcert.sh
4
# by Raphaël, Hugo, Clément, Bettyna
5
 
6
# This script is distributed under Gnu General Public License (GPL)
7
 
8
# Script permettant
9
# - de revenir au certificat par default
10
 
11
# Script allows
12
# - go back to the default certificate
13
 
14
SED="/bin/sed -ri"
15
 
16
DIR_CERT="/etc/pki/tls"
17
 
18
usage="Usage: alcasar-defaultcert.sh. Ce script permet de revenir au certificat par default"
19
 
20
nb_args=$#
21
args=$1
22
 
23
function defaultNdd()
24
{
25
	$SED 's/^DOMAIN=.*/DOMAIN=localdomain/g' /usr/local/etc/alcasar.conf
26
	$SED 's/\.([a-zA-Z][a-zA-Z0-9-]+(\.[a-z]{2,4})?)/.localdomain/g' /etc/hosts
27
	$SED 's/alcasar\.([a-zA-Z0-9-]+(\.[a-z]{2,4})?)/alcasar.localdomain/g' /etc/chilli.conf
28
	$SED 's/^domain.*/domain\t\tlocaldomain/g' /etc/chilli.conf
29
	$SED 's/^ServerName.*/ServerName alcasar.localdomain/g' /etc/httpd/conf/httpd.conf
30
}
31
 
32
function defaultCert()
33
{
34
	cd $DIR_CERT
35
	rm private/alcasar.key
36
	rm certs/alcasar.crt
37
	mv certs/alcasar.crt.old certs/alcasar.crt
38
	mv private/alcasar.key.old private/alcasar.key
39
	if [ -f certs/server-chain.crt.old ]
40
	then
41
		rm certs/server-chain.crt
42
		mv certs/server-chain.crt.old certs/server-chain.crt
43
	fi
44
}
45
 
46
if [ $nb_args != 0 ]
47
then
48
	nb_args=1
49
	args="-h"
50
fi
51
 
52
case $args in
53
	-\? | -h* | --h*)
54
		echo "$usage"
55
		exit 0
56
		;;
57
esac
58
if [ -f "/etc/pki/tls/certs/alcasar.crt.old" -a -f "/etc/pki/tls/private/alcasar.key.old" ]
59
then
60
	echo "Back to the original certificate"
61
	defaultCert
62
	defaultNdd
63
	systemctl restart chilli.service
64
	systemctl restart httpd.service
65
fi