Subversion Repositories ALCASAR

Rev

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

Rev 2558 Rev 2560
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2558 2018-06-05 21:56:34Z rexy $
2
#  $Id: alcasar.sh 2560 2018-06-10 21:04:56Z rexy $
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
# ALCASAR is a Free and open source NAC created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
5
# ALCASAR is a Free and open source NAC created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
#  team@alcasar.net
7
#  team@alcasar.net
Line 179... Line 179...
179
			fi
179
			fi
180
			read response
180
			read response
181
		done
181
		done
182
		if [ "$response" = "2" ]
182
		if [ "$response" = "2" ]
183
		then
183
		then
184
			rm -f /tmp/alcasar-conf*
184
			rm -f /var/tmp/alcasar-conf*
185
		else
185
		else
186
# Retrieve former NICname
186
# Retrieve former NICname
187
			EXTIF_saved=`grep ^EXTIF= $CONF_FILE | cut -d'=' -f2-`	# EXTernal InterFace
187
			EXTIF_saved=`grep ^EXTIF= $CONF_FILE | cut -d'=' -f2-`	# EXTernal InterFace
188
			INTIF_saved=`grep ^INTIF= $CONF_FILE | cut -d'=' -f2-`	# INTernal InterFace
188
			INTIF_saved=`grep ^INTIF= $CONF_FILE | cut -d'=' -f2-`	# INTernal InterFace
189
			[ $(/usr/sbin/ip link | grep -c " $EXTIF_saved:") -ne 0 ] && EXTIF=$EXTIF_saved || echo "Warning: Network card \"$EXTIF_saved\" is not connected, so \"$EXTIF\" will be used for external network."
189
			[ $(/usr/sbin/ip link | grep -c " $EXTIF_saved:") -ne 0 ] && EXTIF=$EXTIF_saved || echo "Warning: Network card \"$EXTIF_saved\" is not connected, so \"$EXTIF\" will be used for external network."
Line 193... Line 193...
193
			mode="update"
193
			mode="update"
194
		fi
194
		fi
195
	fi
195
	fi
196
	if [[ ( $unknown_os != 3 ) || ("$DISTRIBUTION" != "Mageia" ) || ( "$CURRENT_VERSION" != "6" ) ]]
196
	if [[ ( $unknown_os != 3 ) || ("$DISTRIBUTION" != "Mageia" ) || ( "$CURRENT_VERSION" != "6" ) ]]
197
		then
197
		then
198
		if [ -e /tmp/alcasar-conf.tar.gz ] # update
198
		if [ -e /var/tmp/alcasar-conf.tar.gz ] # update
199
			then
199
			then
200
			echo
200
			echo
201
			if [ $Lang == "fr" ]
201
			if [ $Lang == "fr" ]
202
				then
202
				then
203
				echo "La mise à jour automatique d'ALCASAR ne peut pas être réalisée."
203
				echo "La mise à jour automatique d'ALCASAR ne peut pas être réalisée."
Line 1688... Line 1688...
1688
	chmod -R g+rw $DIR_DG $DIR_DEST_SHARE
1688
	chmod -R g+rw $DIR_DG $DIR_DEST_SHARE
1689
# adapt the Toulouse BL to ALCASAR architecture
1689
# adapt the Toulouse BL to ALCASAR architecture
1690
	$DIR_DEST_BIN/alcasar-bl.sh --adapt
1690
	$DIR_DEST_BIN/alcasar-bl.sh --adapt
1691
# enable the default categories
1691
# enable the default categories
1692
	$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
1692
	$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
-
 
1693
	rm -rf /tmp/blacklists
1693
} # End BL()
1694
} # End BL()
1694
 
1695
 
1695
#######################################################
1696
#######################################################
1696
##                  Function "cron"                  ##
1697
##                  Function "cron"                  ##
1697
## - write all cron & anacron files                  ##
1698
## - write all cron & anacron files                  ##
Line 2117... Line 2118...
2117
		$DIR_DEST_BIN/alcasar-conf.sh --apply
2118
		$DIR_DEST_BIN/alcasar-conf.sh --apply
2118
		$DIR_DEST_BIN/alcasar-file-clean.sh # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
2119
		$DIR_DEST_BIN/alcasar-file-clean.sh # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
2119
		$SED "s?^INSTALL_DATE=.*?INSTALL_DATE=$DATE?g" $CONF_FILE
2120
		$SED "s?^INSTALL_DATE=.*?INSTALL_DATE=$DATE?g" $CONF_FILE
2120
		$SED "s?^VERSION=.*?VERSION=$VERSION?g" $CONF_FILE
2121
		$SED "s?^VERSION=.*?VERSION=$VERSION?g" $CONF_FILE
2121
	fi
2122
	fi
2122
	rm -f /tmp/alcasar-conf*
2123
	rm -f /var/tmp/alcasar-conf*
2123
	chown -R root:apache $DIR_DEST_ETC/*
2124
	chown -R root:apache $DIR_DEST_ETC/*
2124
	chmod -R 660 $DIR_DEST_ETC/*
2125
	chmod -R 660 $DIR_DEST_ETC/*
2125
	chmod ug+x $DIR_DEST_ETC/digest
2126
	chmod ug+x $DIR_DEST_ETC/digest
2126
	cd $DIR_INSTALL
2127
	cd $DIR_INSTALL
2127
	echo ""
2128
	echo ""
Line 2157... Line 2158...
2157
		echo "- The ALCASAR Control Center (ACC) is at http://alcasar.localdomain"
2158
		echo "- The ALCASAR Control Center (ACC) is at http://alcasar.localdomain"
2158
		echo
2159
		echo
2159
		echo "                   Hit 'Enter' to continue"
2160
		echo "                   Hit 'Enter' to continue"
2160
	fi
2161
	fi
2161
	sleep 2
2162
	sleep 2
2162
	if [ "$mode" != "update" ] && [ "$DEBUG_ALCASAR" != "on" ]
2163
	if [ "$mode" == "install" ] || [ "$DEBUG_ALCASAR" == "on" ]
2163
	then
2164
	then
2164
		read a
2165
		read a
2165
	fi
2166
	fi
2166
	clear
2167
	clear
2167
	reboot
2168
	reboot
Line 2212... Line 2213...
2212
		if [ -e $CONF_FILE ]
2213
		if [ -e $CONF_FILE ]
2213
		then
2214
		then
2214
# Uninstall or update the running version
2215
# Uninstall or update the running version
2215
			if [ "$mode" == "update" ]
2216
			if [ "$mode" == "update" ]
2216
			then
2217
			then
2217
				$DIR_SCRIPTS/alcasar-uninstall.sh -update
2218
				$DIR_DEST_BIN/alcasar-uninstall.sh -update
2218
			else
2219
			else
2219
				$DIR_SCRIPTS/alcasar-uninstall.sh -full
2220
				$DIR_DEST_BIN/alcasar-uninstall.sh -full
2220
			fi
2221
			fi
2221
		fi
2222
		fi
2222
	if [ $DEBUG_ALCASAR == "on" ]
2223
	if [ $DEBUG_ALCASAR == "on" ]
2223
	then
2224
	then
2224
		echo "*** 'debug' : end of cleaning ***"
2225
		echo "*** 'debug' : end of cleaning ***"
2225
		read a
2226
		read a
2226
	fi
2227
	fi
2227
# Test if manual update
2228
# Test if manual update
2228
		if [ -e /tmp/alcasar-conf*.tar.gz ] && [ "$mode" == "install" ]
2229
		if [ -e /var/tmp/alcasar-conf*.tar.gz ] && [ "$mode" == "install" ]
2229
		then
2230
		then
2230
			header_install
2231
			header_install
2231
			if [ $Lang == "fr" ]
2232
			if [ $Lang == "fr" ]
2232
				then echo "Le fichier de configuration d'une ancienne version a été trouvé";
2233
				then echo "Le fichier de configuration d'une ancienne version a été trouvé";
2233
				else echo "The configuration file of an old version has been found";
2234
				else echo "The configuration file of an old version has been found";
Line 2240... Line 2241...
2240
					then echo -n "Voulez-vous l'utiliser (O/n)? ";
2241
					then echo -n "Voulez-vous l'utiliser (O/n)? ";
2241
					else echo -n "Do you want to use it (Y/n)?";
2242
					else echo -n "Do you want to use it (Y/n)?";
2242
				 fi
2243
				 fi
2243
				read response
2244
				read response
2244
				if [ "$response" = "n" ] || [ "$response" = "N" ]
2245
				if [ "$response" = "n" ] || [ "$response" = "N" ]
2245
				then rm -f /tmp/alcasar-conf*
2246
				then rm -f /var/tmp/alcasar-conf*
2246
				fi
2247
				fi
2247
			done
2248
			done
2248
		fi
2249
		fi
2249
# Test if update
2250
# Test if update
2250
		if [ -e /tmp/alcasar-conf* ]
2251
		if [ -e /var/tmp/alcasar-conf* ]
2251
		then
2252
		then
2252
			if [ $Lang == "fr" ]
2253
			if [ $Lang == "fr" ]
2253
				then echo "#### Installation avec mise à jour ####";
2254
				then echo "#### Installation avec mise à jour ####";
2254
				else echo "#### Installation with update     ####";
2255
				else echo "#### Installation with update     ####";
2255
			fi
2256
			fi
2256
# Extract the central configuration file
2257
# Extract some info from the previous configuration file
2257
			tar -xf /tmp/alcasar-conf* conf/etc/alcasar.conf
2258
			tar -xf /var/tmp/alcasar-conf* conf/etc/alcasar.conf
2258
			ORGANISME=`grep ^ORGANISM= conf/etc/alcasar.conf|cut -d"=" -f2`
2259
			ORGANISME=`grep ^ORGANISM= conf/etc/alcasar.conf|cut -d"=" -f2`
2259
			PREVIOUS_VERSION=`grep ^VERSION= conf/etc/alcasar.conf|cut -d"=" -f2`
2260
			PREVIOUS_VERSION=`grep ^VERSION= conf/etc/alcasar.conf|cut -d"=" -f2`
2260
			MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
2261
			MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
2261
			MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2|cut -c1`
2262
			MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2`
2262
			UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3`
2263
			UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3|cut -c1`
2263
			mode="update"
2264
			mode="update"
2264
		fi
2265
		fi
2265
		for func in init network ACC CA time_server init_db freeradius chilli e2guardian antivirus tinyproxy ulogd nfsen vnstat dnsmasq BL cron fail2ban gammu_smsd msec letsencrypt post_install
2266
		for func in init network ACC CA time_server init_db freeradius chilli e2guardian antivirus tinyproxy ulogd nfsen vnstat dnsmasq BL cron fail2ban gammu_smsd msec letsencrypt post_install
2266
		do
2267
		do
2267
			$func
2268
			$func
Line 2293... Line 2294...
2293
		done
2294
		done
2294
		if [ "$response" = "o" ] || [ "$response" = "O" ] || [ "$response" = "Y" ] || [ "$response" = "y" ]
2295
		if [ "$response" = "o" ] || [ "$response" = "O" ] || [ "$response" = "Y" ] || [ "$response" = "y" ]
2295
		then
2296
		then
2296
			$DIR_SCRIPTS/alcasar-conf.sh --create
2297
			$DIR_SCRIPTS/alcasar-conf.sh --create
2297
		else
2298
		else
2298
			rm -f /tmp/alcasar-conf*
2299
			rm -f /var/tmp/alcasar-conf*
2299
		fi
2300
		fi
2300
# Uninstall the running version
2301
# Uninstall the running version
2301
		$DIR_SCRIPTS/alcasar-uninstall.sh -full
2302
		$DIR_DEST_BIN/alcasar-uninstall.sh -full
2302
		;;
2303
		;;
2303
	*)
2304
	*)
2304
		echo "Argument inconnu :$1";
2305
		echo "Argument inconnu :$1";
2305
		echo "Unknown argument :$1";
2306
		echo "Unknown argument :$1";
2306
		echo "$usage"
2307
		echo "$usage"