File: nagios4-cgi.prerm

package info (click to toggle)
nagios4 4.3.4-3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 21,592 kB
  • sloc: ansic: 94,759; sh: 12,454; perl: 2,624; makefile: 1,184; php: 365; ruby: 95
file content (48 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download
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
#!/bin/sh -e

. /usr/share/nagios4/debian/httpd.webapps-common

apacheconf="/etc/nagios4/apache2.conf"

setperm() {
    local user="${1}"
    local group="${2}"
    local mode="${3}"
    local file="${4}"
    shift 4
    # only do something when no setting exists
    if ! dpkg-statoverride --list "${file}" >/dev/null 2>&1
    then
	if [ -e "${file}" ]
	then
	    chown "${user}":"${group}" "${file}"
	    chmod "${mode}" "${file}"
	fi
    fi
}

if [ -f "${apacheconf}" ]
then
    case "${1}" in
	remove)
	    # find the configured servers
	    configured_servers=`wc_httpd_apache_configured "${apacheconf}" nagios4`
	    if [ "${configured_servers}" ]
	    then
		# deconfigure them
		wc_httpd_apache_uninclude "${apacheconf}" nagios4 "${configured_servers}"
		# reload the configured servers if they are running 
		running_servers="$(wc_httpd_running "${configured_servers}")"
		if [ "${running_servers}" ]
		then
		      wc_httpd_invoke "reload" ${running_servers}
		fi
	    fi
	    if [ -e /var/lib/nagios4/rw ]
	    then setperm nagios www-data 0700 /var/lib/nagios4/rw
	    fi
	    ;;
    esac
fi

#DEBHELPER#