Subversion Repositories ALCASAR

Rev

Rev 1376 | Rev 1379 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1376 Rev 1378
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 1376 2014-06-04 21:55:31Z richard $ 
2
#  $Id: alcasar.sh 1378 2014-06-11 07:18:42Z richard $ 
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
 
5
 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
7
# Ce programme est un logiciel libre ; This software is free and open source
7
# Ce programme est un logiciel libre ; This software is free and open source
Line 25... Line 25...
25
# Options :
25
# Options :
26
#       -i or --install
26
#       -i or --install
27
#       -u or --uninstall
27
#       -u or --uninstall
28
 
28
 
29
# Functions :
29
# Functions :
30
#	testing			: connectivity tests and downloading before intall
30
#	testing			: connectivity tests, free space test and mageia version test
31
#	init			: Installation of RPM and scripts
31
#	init			: Installation of RPM and scripts
32
#	network			: Network parameters
32
#	network			: Network parameters
33
#	ACC			: ALCASAR Control Center installation
33
#	ACC			: ALCASAR Control Center installation
34
#	CA			: Certification Authority initialization
34
#	CA			: Certification Authority initialization
35
#	init_db			: Initilization of radius database managed with MariaDB
35
#	init_db			: Initilization of radius database managed with MariaDB
Line 101... Line 101...
101
} # End of header_install ()
101
} # End of header_install ()
102
 
102
 
103
 
103
 
104
##################################################################
104
##################################################################
105
##			Function "testing"			##
105
##			Function "testing"			##
-
 
106
## - Test of Mageia version					##
106
## - Test of free space on /var  (>10G)				##
107
## - Test of free space on /var  (>10G)				##
107
## - Test of Internet access					##
108
## - Test of Internet access					##
108
##################################################################
109
##################################################################
109
testing ()
110
testing ()
110
{
111
{
Line 135... Line 136...
135
			mode="update"
136
			mode="update"
136
		fi
137
		fi
137
	else
138
	else
138
		if [ ! -d /var/log/netflow/porttracker ]
139
		if [ ! -d /var/log/netflow/porttracker ]
139
			then
140
			then
-
 
141
# Test of free space on /var
140
			free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G`
142
			free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G`
141
			if [ $free_space -lt 10 ]
143
			if [ $free_space -lt 10 ]
142
				then
144
				then
143
				if [ $Lang == "fr" ]
145
				if [ $Lang == "fr" ]
144
					then echo "place disponible sur /var insufisante ($free_space Go au lieu de 10 Go au minimum)"
146
					then echo "place disponible sur /var insufisante ($free_space Go au lieu de 10 Go au minimum)"
145
					else echo "not enough free space on /var ($free_space GB instead of at least 10 GB)"
147
					else echo "not enough free space on /var ($free_space GB instead of at least 10 GB)"
146
				fi
148
				fi
147
			exit 0
149
			exit 0
148
			fi
150
			fi
-
 
151
		fi
-
 
152
# Test of Mageia version
-
 
153
# extract the current Mageia version and hardware architecture (i586 ou X64)
-
 
154
		fic=`cat /etc/product.id`
-
 
155
		unknown_os=0
-
 
156
		old="$IFS"
-
 
157
		IFS=","
-
 
158
		set $fic
-
 
159
		for i in $*
-
 
160
		do
-
 
161
			if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
-
 
162
				then 
-
 
163
				DISTRIBUTION=`echo $i|cut -d"=" -f2`
-
 
164
				unknown_os=`expr $unknown_os + 1`
-
 
165
			fi
-
 
166
			if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
-
 
167
				then 
-
 
168
				CURRENT_VERSION=`echo $i|cut -d"=" -f2`
-
 
169
				unknown_os=`expr $unknown_os + 1`
-
 
170
			fi
-
 
171
			if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
-
 
172
				then 
-
 
173
				ARCH=`echo $i|cut -d"=" -f2`
-
 
174
				unknown_os=`expr $unknown_os + 1`
-
 
175
			fi
-
 
176
		done
-
 
177
		IFS="$old"
-
 
178
		if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "4" ) ]]
-
 
179
			then
-
 
180
			if [ $Lang == "fr" ]
-
 
181
				then	
-
 
182
				echo "L'installation ou la mise @ jour d'ALCASAR ne peut pas être réalisée."
-
 
183
				echo "Le système d'exploitation doit être remplacé (Mageia4)"
-
 
184
			else
-
 
185
				echo "The automatic update of ALCASAR can't be performed."
-
 
186
				echo "The OS must be replaced (Mageia4)"
-
 
187
			fi
-
 
188
			if [ -e /tmp/alcasar-conf.tar.gz ]
-
 
189
				then
-
 
190
				echo
-
 
191
				if [ $Lang == "fr" ]
-
 
192
					then	
-
 
193
					echo "1 - Récupérez le fichier de configuration actuel (/tmp/alcasar-conf.tar.gz)."
-
 
194
					echo "2 - Installez Linux-Mageia4 (cf. doc d'installation)"
-
 
195
					echo "3 - copiez le fichier 'alcasar-conf.tar.gz' dans le répertoire '/tmp' avant de lancer l'installation d'ALCASAR"
-
 
196
				else
-
 
197
					echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
-
 
198
					echo "2 - Install Linux-Mageia4 (cf. installation doc)"
-
 
199
					echo "3 - Copy the file 'alcasar-conf.tar.gz' in the folder '/tmp' before launching the installation of ALCASAR"
-
 
200
				fi
-
 
201
			fi
-
 
202
			exit 0
149
		fi	
203
		fi
150
	fi
204
	fi
151
if [ $Lang == "fr" ]
205
	if [ $Lang == "fr" ]
152
		then echo -n "Tests des paramètres réseau : "
206
		then echo -n "Tests des paramètres réseau : "
153
		else echo -n "Network parameters tests : "
207
		else echo -n "Network parameters tests : "
154
	fi
208
	fi
155
# We test EXTIF config files
209
# We test EXTIF config files
156
	PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
210
	PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
Line 697... Line 751...
697
	AuthName $HOSTNAME.$DOMAIN
751
	AuthName $HOSTNAME.$DOMAIN
698
	AuthUserFile $DIR_DEST_ETC/digest/key_backup
752
	AuthUserFile $DIR_DEST_ETC/digest/key_backup
699
	ErrorDocument 404 https://$HOSTNAME.$DOMAIN/
753
	ErrorDocument 404 https://$HOSTNAME.$DOMAIN/
700
</Directory>
754
</Directory>
701
EOF
755
EOF
-
 
756
# Launch after coova
-
 
757
$SED "s?^After=.*?After=network.target remote-fs.target nss-lookup.target chilli.service?g" /lib/systemd/system/httpd.service
702
} # End of ACC()
758
} # End of ACC()
703
 
759
 
704
##########################################################################################
760
##########################################################################################
705
##				Fonction "CA"						##
761
##				Fonction "CA"						##
706
## - Création d'une Autorité de Certification et du certificat serveur pour apache 	##
762
## - Création d'une Autorité de Certification et du certificat serveur pour apache 	##
Line 891... Line 947...
891
[Unit]
947
[Unit]
892
Description=chilli is a captive portal daemon
948
Description=chilli is a captive portal daemon
893
After=network.target
949
After=network.target
894
 
950
 
895
[Service]
951
[Service]
896
Type=forking
952
Type=oneshot
897
ExecStart=/usr/libexec/chilli start
953
ExecStart=/usr/libexec/chilli start
898
ExecStop=/usr/libexec/chilli stop
954
ExecStop=/usr/libexec/chilli stop
899
ExecReload=/usr/libexec/chilli reload
955
ExecReload=/usr/libexec/chilli reload
900
PIDFile=/var/run/chilli.pid
956
PIDFile=/var/run/chilli.pid
901
 
957
 
Line 1666... Line 1722...
1666
	$SED "/^kernel/s/splash quiet //" /boot/grub/menu.lst
1722
	$SED "/^kernel/s/splash quiet //" /boot/grub/menu.lst
1667
	$SED "/^kernel/s/vga=.*/vga=791 nomodeset/" /boot/grub/menu.lst
1723
	$SED "/^kernel/s/vga=.*/vga=791 nomodeset/" /boot/grub/menu.lst
1668
	$SED "/^kernel/s/BOOT_IMAGE=linux /BOOT_IMAGE=linux-nonfb /" /boot/grub/menu.lst
1724
	$SED "/^kernel/s/BOOT_IMAGE=linux /BOOT_IMAGE=linux-nonfb /" /boot/grub/menu.lst
1669
	$SED "/^gfxmenu/d" /boot/grub/menu.lst
1725
	$SED "/^gfxmenu/d" /boot/grub/menu.lst
1670
# Remove unused services and users
1726
# Remove unused services and users
1671
	for svc in sshd.service alsa-state
1727
	for svc in sshd.service
1672
	do
1728
	do
1673
		/bin/systemctl -q disable $svc
1729
		/bin/systemctl -q disable $svc
1674
	done
1730
	done
1675
	for rm_users in games
1731
#	for rm_users in games
1676
	do
1732
#	do
1677
		user=`cat /etc/passwd|grep $rm_users|cut -d":" -f1`
1733
#		user=`cat /etc/passwd|grep $rm_users|cut -d":" -f1`
1678
		if [ "$user" == "$rm_users" ]
1734
#		if [ "$user" == "$rm_users" ]
1679
		then
1735
#		then
1680
			/usr/sbin/userdel -f $rm_users
1736
#			/usr/sbin/userdel -r $rm_users
1681
		fi
1737
#		fi
1682
	done
1738
#	done
1683
# Load and apply the previous conf file
1739
# Load and apply the previous conf file
1684
	if [ "$mode" = "update" ]
1740
	if [ "$mode" = "update" ]
1685
	then
1741
	then
1686
		$DIR_DEST_BIN/alcasar-archive.sh --now # exports current logs in /var/Save/logs
1742
		$DIR_DEST_BIN/alcasar-archive.sh --now # exports current logs in /var/Save/logs
1687
		$DIR_DEST_BIN/alcasar-conf.sh --load
1743
		$DIR_DEST_BIN/alcasar-conf.sh --load