-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice_and_daemon.sh
43 lines (41 loc) · 1.17 KB
/
service_and_daemon.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
#!/bin/bash
###################################################################################
## Nginx-LDAP ##
## Script bash for analyze the daemon ldap and the service of nginx ##
## Author: https://github.com/Iakim ##
## Simplicity is the ultimate degree of sophistication ##
###################################################################################
ngx=`systemctl status nginx | grep running | wc -l`
daemon=`ps aux | grep ldap-auth | wc -l`
if [ $ngx -gt 0 ]
then
if [ $daemon -lt 2 ]
then
rm -rf /etc/nginx/conf.d/nginx-ldap-auth-daemon.pid
sh /etc/nginx/conf.d/nginx-ldap-auth-daemon-ctl-rh.sh start
exit 0
else
exit 0
fi
else
test=`nginx -t -q 2> nginx_result; cat nginx_result | wc -l`
if [ $test = 0 ]
then
fuser -k 80/tcp
fuser -k 80/tcp
service nginx start 2> /dev/null
rm -rf nginx_result
if [ $daemon -lt 2 ]
then
rm -rf /etc/nginx/conf.d/nginx-ldap-auth-daemon.pid
sh /etc/nginx/conf.d/nginx-ldap-auth-daemon-ctl-rh.sh start
exit 0
else
exit 0
fi
else
cat nginx_result
rm -rf nginx_result
exit 0
fi
fi