forked from saez0pub/Marvin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chuck.sh
executable file
·38 lines (37 loc) · 888 Bytes
/
chuck.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
#!/bin/bash
export LANG="fr_FR.UTF-8"
cd $(dirname $0)
dir=$(pwd)
script=$dir/chuck.ircBot.py
python=python3
log=$dir/chuck.log
commande="$python $script"
nbLigneLog=$(wc -l $log 2>/dev/null| sed -e 's/ .*//')
ligneWarning=5
case $1 in
"start")
$commande >$log 2>&1 &
;;
"stop")
pid=$(ps -ef | grep "$python.*$script" | grep -v grep | awk '{print $2}')
[[ -z $pid ]] && echo "Pas de process trouvé" || kill $pid
;;
"status")
echo processus :
ps -ef | grep "$python.*$script" | grep -v grep
[[ "$nbLigneLog" -le $ligneWarning ]] && [[ -r $log ]] && echo Le process IRC semble bloque
;;
"restart")
$0 stop
$0 start
;;
"restartifneeded")
if [ $($0 status|wc -l) -le 1 -o "$nbLigneLog" -le $ligneWarning ]
then
$0 restart
fi
;;
*)
echo "Usage : $0 stop|start|status|restart|restartifneeded"
;;
esac