Subversion Repositories ALCASAR

Rev

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

Rev 3272 Rev 3273
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 3272 2025-04-23 14:33:51Z rexy $
2
#  $Id: alcasar.sh 3273 2025-04-27 09:26:14Z rexy $
3
 
3
 
4
# ALCASAR is a Free and open source NAC (Network Access Controler) created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
4
# ALCASAR is a Free and open source NAC (Network Access Controler) created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
5
# ALCASAR is based on a stripped Mageia (LSB) with the following open source softwares Coovachilli, freeradius, mariaDB, apache, php, netfilter, e2guardian, ntpd, openssl, unbound, gammu, Ulog, fail2ban, vnstat, wkhtml2pdf, ipt_NETFLOW, NFsen and NFdump
5
# ALCASAR is based on a stripped Mageia (LSB) with the following open source softwares Coovachilli, freeradius, mariaDB, apache, php, netfilter, e2guardian, ntpd, openssl, unbound, gammu, Ulog, fail2ban, vnstat, wkhtml2pdf, ipt_NETFLOW, NFsen and NFdump
6
# contact : info@alcasar.net
6
# contact : info@alcasar.net
7
 
7
 
Line 206... Line 206...
206
			read response
206
			read response
207
		done
207
		done
208
		if [ "$response" = "2" ]
208
		if [ "$response" = "2" ]
209
		then
209
		then
210
			rm -f /var/tmp/alcasar-conf*
210
			rm -f /var/tmp/alcasar-conf*
211
		else
211
		else 
212
# Create the archive of conf files
212
# Create the archive of conf files
-
 
213
			[ ! -e /usr/bin/mariadb_install_db ] && ln -s /usr/bin/mariadb-install-db /usr/bin/mariadb_install_db # avoid Mageia bug (https://bugs.mageia.org/show_bug.cgi?id=34200)
-
 
214
			[ ! -e /usr/sbin/mysqld-prepare-db-dir ] && ln -s /usr/sbin/mariadb-prepare-db-dir /usr/sbin/mysqld-prepare-db-dir # avoid Mageia bug (https://bugs.mageia.org/show_bug.cgi?id=34200)
-
 
215
			$DIR_DEST_BIN/alcasar-daemon.sh
213
			$DIR_DEST_BIN/alcasar-conf.sh --create
216
			$DIR_DEST_BIN/alcasar-conf.sh --create
214
# avoid lack of local DNS resolution when unbound is updated (alcasar <= V5.3)
-
 
215
			local_unbound_unit=`ls /etc/systemd/system/unbound* 2>/dev/null | wc -w`
-
 
216
			if [ $local_unbound_unit -ne 4 ]; then
-
 
217
				cp -f /lib/systemd/system/unbound*.service /etc/systemd/system/
-
 
218
			fi
-
 
219
			mode="update"
217
			mode="update"
220
		fi
218
		fi
221
	else
219
	else
222
		license
220
		license
223
	fi
221
	fi
Line 1061... Line 1059...
1061
sleep 2 # wait for time server responce
1059
sleep 2 # wait for time server responce
1062
} # End of time_server()
1060
} # End of time_server()
1063
 
1061
 
1064
#####################################################################
1062
#####################################################################
1065
##                           "init_db"                             ##
1063
##                           "init_db"                             ##
1066
## - MariaDb initialization                                          ##
1064
## - MariaDb initialization                                        ##
1067
## - Set admin (root) password                                     ##
1065
## - Set admin (root) password                                     ##
1068
## - Remove unused users & databases                               ##
1066
## - Remove unused users & databases                               ##
1069
## - Radius database creation                                      ##
1067
## - Radius database creation                                      ##
1070
## - Copy of accounting tables (mtotacct, totacct) & userinfo      ##
1068
## - Copy of accounting tables (mtotacct, totacct) & userinfo      ##
1071
#####################################################################
1069
#####################################################################
Line 1089... Line 1087...
1089
	# Create our own systemd unit
1087
	# Create our own systemd unit
1090
	cp /lib/systemd/system/mysqld.service /etc/systemd/system/mariadb.service
1088
	cp /lib/systemd/system/mysqld.service /etc/systemd/system/mariadb.service
1091
	$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/mariadbd?g" /etc/systemd/system/mariadb.service
1089
	$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/mariadbd?g" /etc/systemd/system/mariadb.service
1092
	/usr/bin/systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --skip-networking"
1090
	/usr/bin/systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --skip-networking"
1093
	[ ! -e /usr/bin/mariadb_install_db ] && ln -s /usr/bin/mariadb-install-db /usr/bin/mariadb_install_db # avoid Mageia bug (https://bugs.mageia.org/show_bug.cgi?id=34200)
1091
	[ ! -e /usr/bin/mariadb_install_db ] && ln -s /usr/bin/mariadb-install-db /usr/bin/mariadb_install_db # avoid Mageia bug (https://bugs.mageia.org/show_bug.cgi?id=34200)
-
 
1092
	[ ! -e /usr/sbin/mysqld-prepare-db-dir ] && ln -s /usr/sbin/mariadb-prepare-db-dir /usr/sbin/mysqld-prepare-db-dir # avoid Mageia bug (https://bugs.mageia.org/show_bug.cgi?id=34200)
1094
	/usr/bin/systemctl start mariadb
1093
	/usr/bin/systemctl start mariadb
1095
	nb_round=1
1094
	nb_round=1
1096
	while [ ! -S /var/lib/mysql/mysql.sock ] && [ $nb_round -lt 10 ] # we wait until mariadb is on
1095
	while [ ! -S /var/lib/mysql/mysql.sock ] && [ $nb_round -lt 10 ] # we wait until mariadb is on
1097
	do
1096
	do
1098
		nb_round=`expr $nb_round + 1`
1097
		nb_round=`expr $nb_round + 1`
Line 2516... Line 2515...
2516
		fi
2515
		fi
2517
# Avoid some RPM automatic updates
2516
# Avoid some RPM automatic updates
2518
		echo "/^kernel/" > /etc/urpmi/skip.list
2517
		echo "/^kernel/" > /etc/urpmi/skip.list
2519
		echo "/^wkhtmltopdf/" >> /etc/urpmi/skip.list
2518
		echo "/^wkhtmltopdf/" >> /etc/urpmi/skip.list
2520
		echo "/^freeradius/" >> /etc/urpmi/skip.list
2519
		echo "/^freeradius/" >> /etc/urpmi/skip.list
-
 
2520
		echo "/^mariadb/" >> /etc/urpmi/skip.list
2521
		if [ `grep -E '^exclude=' /etc/dnf/dnf.conf |wc -l` -eq "1" ]; then
2521
		if [ `grep -E '^exclude=' /etc/dnf/dnf.conf |wc -l` -eq "1" ]; then
2522
			$SED "s?^exclude=.*?exclude=kernel\* wkhtmltopdf freeradius?g" /etc/dnf/dnf.conf
2522
			$SED "s?^exclude=.*?exclude=kernel\* wkhtmltopdf freeradius mariadb?g" /etc/dnf/dnf.conf
2523
		else
2523
		else
2524
			echo "exclude=kernel* wkhtmltopdf freeradius" >> /etc/dnf/dnf.conf
2524
			echo "exclude=kernel* wkhtmltopdf freeradius mariadb" >> /etc/dnf/dnf.conf
2525
		fi
2525
		fi
2526
# Test if conf file
2526
# Test if conf file
2527
		if [ -e /var/tmp/alcasar-conf.tar.gz ]
2527
		if [ -e /var/tmp/alcasar-conf.tar.gz ]
2528
		then
2528
		then
2529
# Extract some info from the previous configuration file
2529
# Extract some info from the previous configuration file