summaryrefslogtreecommitdiffstats
path: root/debian/netdata.postinst.in
blob: 9a86f70bd7285585be552667167413f9c85ff54f (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /bin/sh

set -e

CONFFILE="/etc/netdata/health_alarm_notify.conf"

. /usr/share/debconf/confmodule

new_config=

cleanup() {
  if [ "$new_config" ]; then
    rm -f "$new_config"
  fi
}

case "$1" in
  configure)
        db_get netdata/send_email
        SEND_EMAIL="${RET:-true}" # boolean

        db_stop

        trap cleanup EXIT
        new_config="$(tempfile)"

        cp -a /usr/share/netdata/netdata.conf "$new_config"
        if [ "$permit_root_login" != true ]; then
»·······»·······sed -i 's/^#*PermitRootLogin .*/PermitRootLogin yes/' \
»·······»·······»·······"$new_config"
»·······fi
»·······if [ "$password_authentication" != true ]; then
»·······»·······sed -i 's/^#PasswordAuthentication .*/PasswordAuthentication no/' \
»·······»·······»·······"$new_config"
»·······fi
»·······mkdir -p /etc/ssh
»·······ucf --three-way --debconf-ok \
»·······»·······--sum-file /usr/share/openssh/sshd_config.md5sum \
»·······»·······"$new_config" /etc/ssh/sshd_config
»·······ucfr openssh-server /etc/ssh/sshd_config





        case "${SEND_EMAIL}" in
          true)
            SEND_EMAIL="YES"
            ;;

          *)
            SEND_EMAIL="NO"
            ;;
        esac

        if [ -e "${CONFFILE}" ]; then
          sed -e "s|^ *SEND_EMAIL=.*|SEND_EMAIL=\"${SEND_EMAIL}\"|" \
            < "${CONFFILE}" > "${CONFFILE}.tmp"

          mv -f "${CONFFILE}.tmp" "${CONFFILE}"
        fi

        if [ -z "$2" ]; then
          if ! getent group netdata >/dev/null; then
              addgroup --quiet --system netdata
          fi

          if ! getent passwd netdata >/dev/null; then
              adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
              mkdir -p /var/lib/netdata
          fi

          for dir_name in /var/cache/netdata /var/lib/netdata; do
              if ! dpkg-statoverride --list "$dir_name" >/dev/null 2>&1; then
                  dpkg-statoverride --update --add netdata netdata 0755 "$dir_name"
              fi

          done
        fi

        chown -R root:netdata /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d
        setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d/apps.plugin || \
          chmod 4754 /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d/apps.plugin
        chown netdata:adm /var/log/netdata
        chmod 02750 /var/log/netdata
        ;;
esac

#DEBHELPER#

exit 0