forked from jeedom/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
health.sh
58 lines (53 loc) · 1.47 KB
/
health.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Vérifie l'espace du système de fichiers..."
USERSPACE=$(df -h . | awk '/[0-9]/{print $(NF-1)}' | sed 's/\%//g')
if [ ${USERSPACE} -gt 95 ]; then
echo 'NOK'
else
echo "OK"
fi
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Vérifie mysql..."
sudo service mysql status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -n "NOK, essaie de le redémarrer..."
sudo service mysql start
sudo service mysql status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "[$(date +%d-%m-%Y\ %H:%M:%S)] Impossible de le démarrer"
exit 1
fi
else
echo "OK"
fi
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Vérifie cron..."
sudo service cron status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -n "NOK, essaie de le redémarrer..."
sudo service cron start
sudo service cron status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "[$(date +%d-%m-%Y\ %H:%M:%S)] Impossible de le démarrer"
exit 1
fi
else
echo "OK"
fi
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Vérifie le cron de jeedom..."
if [ $(crontab -l | grep jeeCron | wc -l) -lt 1 ]; then
if [ ! -f /etc/cron.d/jeedom ]; then
echo 'NOK'
else
echo "OK"
fi
else
echo "OK"
fi
DIR="$( cd "$( dirname "$0" )" && pwd )"
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Vérifie les droits..."
sudo chown -R www-data:www-data ${DIR}/*
sudo chmod -R 775 ${DIR}/*
sudo chown -R www-data:www-data /tmp/jeedom/cache
sudo chmod -R 775 /tmp/jeedom/cache
sudo chown -R www-data:www-data /var/www
sudo chmod -R 775 /var/www
echo "OK"