File: zabbix-server-pgsql.postinst

package info (click to toggle)
zabbix 1%3A2.2.7%2Bdfsg-2%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 55,276 kB
  • ctags: 35,240
  • sloc: php: 109,371; ansic: 103,099; sql: 39,203; sh: 5,873; makefile: 1,059; java: 854; cpp: 159; perl: 35; xml: 29
file content (68 lines) | stat: -rw-r--r-- 2,625 bytes parent folder | download | duplicates (3)
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
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

set -e

# If /tmp/ZABBIX_PACKAGE_DEBUG file exists then enable debugging of this script.
#if [ -e /tmp/ZABBIX_PACKAGE_DEBUG ]; then
#    set -x
#fi

if [ "$1" = "configure" ]; then
    if ! getent group zabbix > /dev/null 2>&1 ; then
        addgroup --system --quiet zabbix
    fi

    # Does the user 'zabbix' exist?
    if ! getent passwd zabbix > /dev/null 2>&1 ; then
        # Not yet. Create it.
        adduser --quiet \
            --system --disabled-login --ingroup zabbix \
            --home /var/run/zabbix/ --no-create-home \
            zabbix
    else
        # Yes, user 'zabbix' exists. 
        # [This entire fix can be removed after the Wheezy release.]
        # Change the home directory from /var/run/zabbix-server 
        # to /var/run/zabbix (relates to bug #593458).
        # Check current home directory of the 'zabbix' user.
        if getent passwd zabbix | cut -d: -f6 | grep -q /var/run/zabbix-server; then
            # Home directory is still the old /var/run/zabbix-server directory.
            # All processes run by the 'zabbix' user must be stopped
            # before usermod can change the home directory.
            # "zabbix-server" gets stopped by zabbix-server.preinst automatically.
            echo Moving home directory of user zabbix to /var/run/zabbix/
            for component in proxy agent; do
                if [ -x /etc/init.d/zabbix-$component ]; then
                    invoke-rc.d zabbix-$component stop
                fi
            done
            # Remove an existing /var/run/zabbix directory just in case
            rm -rf /var/run/zabbix
            # Move the home directory
            usermod -m -d /var/run/zabbix zabbix
            # Create the home directory if it did not exist
            # (up to 1.8.5-1 the 'zabbix' user had a non-existing home directory)
            if [ ! -d /var/run/zabbix ]; then
                mkdir /var/run/zabbix
                chown zabbix:zabbix /var/run/zabbix
            fi
            # Change the location of the PID file in the config files
            sed -i 's#/var/run/zabbix-.*/#/var/run/zabbix/#' /etc/zabbix/zabbix_*.conf
            # Start the processes again
            for component in proxy agent; do
                if [ -x /etc/init.d/zabbix-$component ]; then
                    invoke-rc.d zabbix-$component start
                fi
            done
        fi
    fi

    # Remove old/wrong home directory before 1.8.5-2
    if [ -d /var/run/zabbix-proxy ]; then
        rm -rf /var/run/zabbix-proxy
    fi

    chown zabbix:zabbix /var/log/zabbix-server -R
fi

#DEBHELPER#