Subversion Repositories ALCASAR

Rev

Rev 2878 | Rev 3043 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 2878 Rev 2967
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-daemon.sh 2878 2020-11-01 21:48:35Z rexy $
2
# $Id: alcasar-daemon.sh 2967 2021-07-08 09:47:39Z rexy $
3
 
3
 
4
# alcasar-daemon.sh
4
# alcasar-daemon.sh
5
# by Franck BOUIJOUX & Rexy
5
# by Franck BOUIJOUX & 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
# Watchdog of Services
7
# Watchdog of Services
-
 
8
# With the option "-after-update" checks if services or system need to be restarted after a RPM update
8
# See /etc/cron.d/alcasar-daemon-watchdog for config the time
9
# See /etc/cron.d/alcasar-daemon-watchdog for config the time
9
 
10
 
10
conf_file="/usr/local/etc/alcasar.conf"
11
conf_file="/usr/local/etc/alcasar.conf"
11
SSH=`grep ^SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
12
SSH=`grep ^SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
12
SSH=${SSH:=off}
13
SSH=${SSH:=off}
Line 34... Line 35...
34
	else
35
	else
35
		nb_srv=$((nb_srv+1))
36
		nb_srv=$((nb_srv+1))
36
	fi
37
	fi
37
}
38
}
38
 
39
 
-
 
40
usage="Usage: alcasar-daemon.sh {-after-update}"
-
 
41
case $1 in
-
 
42
	-\? | -h* | --h*)
-
 
43
		echo "$usage"
-
 
44
		exit 0
-
 
45
		;;
-
 
46
	-after-update)
-
 
47
		# TODO : check precisely which processes should be restarted (reboot the system or restart alcasar processes)
-
 
48
		# extract processes name : for i in `dnf needs-restarting|cut -d " " -f3|sort -u|tr -d ":"|rev|cut -d"/" -f1|rev`;do;echo $i;done
-
 
49
		# system_processes=`dnf needs-restarting|egrep 'dbus|python|systemd|agetty'|wc -l` # processes to be restarted after glibc update 
-
 
50
		nb_processes=`dnf needs-restarting|wc -l`
-
 
51
		if [ $nb_processes -ne 0 ]; then
-
 
52
			reboot
-
 
53
		fi
-
 
54
		;;
-
 
55
	*)
39
for NIC in $EXTIF $INTIF
56
		for NIC in $EXTIF $INTIF
40
do
57
		do
41
	if [ `/usr/sbin/ip a show $NIC|grep DOWN|wc -l` -eq "1" ]
58
			if [ `/usr/sbin/ip a show $NIC|grep DOWN|wc -l` -eq "1" ]; then
42
	then
-
 
43
		echo "The network interface card '$NIC' is down! Try to enable it"
59
				echo "The network interface card '$NIC' is down! Try to enable it"
44
		/usr/sbin/ifup $NIC
60
				/usr/sbin/ifup $NIC
45
	fi
61
			fi
46
done
62
		done
47
 
63
		
Line 59... Line 75...
59
		fi
75
				fi
60
	fi
76
			fi
61
	ServiceTest $service
77
			ServiceTest $service
62
done
78
		done
63
 
79
		
64
if [ $nb_available_srv -ne $nb_srv ]
80
		if [ $nb_available_srv -ne $nb_srv ]; then
65
then
-
 
66
	echo "Restart this script to know if all is ok"
81
			echo "Restart this script to know if all is ok"
67
else
82
		else
68
	echo "$nb_srv services needed by ALCASAR are started."
83
			echo "$nb_srv services needed by ALCASAR are started."
69
fi
84
		fi
70
 
85
		
71
if [ `cat /proc/modules|grep -c ^ipt_NETFLOW` == 0 ]
86
		if [ `cat /proc/modules|grep -c ^ipt_NETFLOW` == 0 ]; then
72
then
-
 
73
	logger -t alcasar-daemon -i "ipt_netflow is inactive."
87
			logger -t alcasar-daemon -i "ipt_netflow is inactive."
74
	echo "The Log system is disabled! try to know why (modprobe ipt_NETFLOW)"
88
			echo "The Log system is disabled! try to know why (modprobe ipt_NETFLOW)"
75
else
89
		else
76
	echo "The Log system is active"
90
			echo "The Log system is active"
77
fi
91
		fi
78
if [ ! -e /etc/raddb/mods-enabled/ldap ]
92
		if [ ! -e /etc/raddb/mods-enabled/ldap ]; then
79
then
-
 
80
	if [ $LDAP == "ON" ] || [ $LDAP == "on" ] || [ $LDAP == "On" ]
93
			if [ $LDAP == "ON" ] || [ $LDAP == "on" ] || [ $LDAP == "On" ]; then
81
	then
-
 
82
		echo "Enabling LDAP..."
94
				echo "Enabling LDAP..."
83
		/usr/local/bin/alcasar-ldap.sh -on
95
				/usr/local/bin/alcasar-ldap.sh -on
84
	fi
96
			fi
85
fi
97
		fi
86
 
98
	;;
-
 
99
esac