Subversion Repositories ALCASAR

Rev

Rev 3294 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2223 tom.houday 1
#!/bin/bash
958 franck 2
# $Id: alcasar-https.sh 3326 2026-03-01 22:35:33Z rexy $
843 richard 3
 
3225 rexy 4
# alcasar-https.sh
843 richard 5
# by Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
8
# active ou désactive le chiffrement sur les flux d'authentification
9
# enable or disable encryption on authentication flows
10
 
11
SED="/bin/sed -i"
2324 tom.houday 12
CONF_FILE="/usr/local/etc/alcasar.conf"
843 richard 13
CHILLI_CONF_FILE="/etc/chilli.conf"
3293 rexy 14
HTTPD_CONF_FILE="/etc/httpd/conf/sites.d/alcasar.conf"
15
HTTPD_80_CONF_FILE="/etc/httpd/conf/sites.d/00_default_vhosts.conf"
2324 tom.houday 16
HOSTNAME=$(grep ^HOSTNAME= $CONF_FILE | cut -d'=' -f2)
17
DOMAIN=$(grep ^DOMAIN= $CONF_FILE | cut -d'=' -f2)
843 richard 18
 
19
usage="Usage: alcasar-https.sh {--on | -on} | {--off | -off}"
20
nb_args=$#
21
args=$1
22
if [ $nb_args -eq 0 ]
23
then
24
	echo "$usage"
25
	exit 1
26
fi
2324 tom.houday 27
 
843 richard 28
case $args in
29
	-\? | -h* | --h*)
30
		echo "$usage"
31
		exit 0
32
		;;
3293 rexy 33
	--off | -off)	# Chilli : disable HTTPS (it will listen only on 3990 port) + Apache : remove "requireSSL" & redirection directive
2324 tom.houday 34
		$SED "s?^HTTPS_LOGIN=.*?HTTPS_LOGIN=off?" $CONF_FILE
2592 rexy 35
		$SED "s?^uamserver.*?uamserver\thttp://$HOSTNAME.$DOMAIN/intercept.php?" $CHILLI_CONF_FILE
36
		$SED "s?^redirssl.*?#&?" $CHILLI_CONF_FILE
37
		$SED "s?^uamuissl.*?#&?" $CHILLI_CONF_FILE
1617 richard 38
		/usr/bin/systemctl restart chilli
3293 rexy 39
		$SED "/<Directory \/var\/www\/html>/{n;/SSLRequireSSL/{d;};}" $HTTPD_CONF_FILE
40
		$SED "/redirect/d" $HTTPD_80_CONF_FILE
3326 rexy 41
		/usr/bin/systemctl reload httpd
843 richard 42
		;;
3293 rexy 43
	--on | -on)	# Chilli : enable HTTPS (it will listen on ports 3990 (http) and 3991 (https) + apache : add "requireSSL" & redirection directive
2324 tom.houday 44
		$SED "s?^HTTPS_LOGIN=.*?HTTPS_LOGIN=on?" $CONF_FILE
2592 rexy 45
		$SED "s?^uamserver.*?uamserver\thttps://$HOSTNAME.$DOMAIN/intercept.php?" $CHILLI_CONF_FILE
46
		$SED "s?^#redirssl.*?redirssl?" $CHILLI_CONF_FILE
47
		$SED "s?^#uamuissl.*?uamuissl?" $CHILLI_CONF_FILE
1617 richard 48
		/usr/bin/systemctl restart chilli
3294 rexy 49
		$SED "/<Directory \/var\/www\/html>/{n;/SSLRequireSSL/{d;};}" $HTTPD_CONF_FILE # remove if already exist
3293 rexy 50
		$SED "/<Directory \/var\/www\/html>/a\        SSLRequireSSL" $HTTPD_CONF_FILE
3294 rexy 51
		$SED "/redirect/d" $HTTPD_80_CONF_FILE # remove if already exist
3293 rexy 52
		$SED "/<\/VirtualHost>/i\    redirect permanent \/ https:\/\/$HOSTNAME.$DOMAIN" $HTTPD_80_CONF_FILE
3326 rexy 53
		/usr/bin/systemctl reload httpd
843 richard 54
		;;
55
	*)
2324 tom.houday 56
		echo "Argument inconnu : $1"
843 richard 57
		echo "$usage"
58
		exit 1
59
		;;
60
esac