View | Details | Raw Unified | Return to bug 169918
Collapse All | Expand All

(-)./Makefile (+2 lines)
Lines 30-35 Link Here
30
NAGIOSUSER?=	nagios
30
NAGIOSUSER?=	nagios
31
NAGIOSGROUP?=	nagios
31
NAGIOSGROUP?=	nagios
32
NAGIOSDIR?=	/var/spool/nagios
32
NAGIOSDIR?=	/var/spool/nagios
33
USERS=		${NAGIOSUSER}
34
GROUPS=		${NAGIOSGROUP}
33
35
34
NAGIOSUID=	181
36
NAGIOSUID=	181
35
NAGIOSGID=	${NAGIOSUID}
37
NAGIOSGID=	${NAGIOSUID}
(-)./files/pkg-deinstall.in (-10 lines)
Lines 4-21 Link Here
4
#
4
#
5
5
6
NAGIOSDIR=%%NAGIOSDIR%%
6
NAGIOSDIR=%%NAGIOSDIR%%
7
NAGIOSUSER=%%NAGIOSUSER%%
8
NAGIOSGROUP=%%NAGIOSGROUP%%
9
7
10
if [ "$2" = "POST-DEINSTALL" ]; then
8
if [ "$2" = "POST-DEINSTALL" ]; then
11
  if /usr/sbin/pw group show "${NAGIOSGROUP}" 2>&1 >/dev/null; then
12
    echo "You should manually remove the \"${NAGIOSGROUP}\" group."
13
  fi
14
15
  if /usr/sbin/pw user show "${NAGIOSUSER}" 2>&1 >/dev/null; then
16
    echo "You should manually remove the \"${NAGIOSUSER}\" user."
17
  fi
18
19
  if [ -e "${NAGIOSDIR}" ]; then
9
  if [ -e "${NAGIOSDIR}" ]; then
20
    echo "You should manually remove the \"${NAGIOSDIR}\" directory."
10
    echo "You should manually remove the \"${NAGIOSDIR}\" directory."
21
  fi
11
  fi
(-)./files/pkg-install.in (-63 / +1 lines)
Lines 9-77 Link Here
9
NAGIOSUID=%%NAGIOSUID%%
9
NAGIOSUID=%%NAGIOSUID%%
10
NAGIOSGID=%%NAGIOSGID%%
10
NAGIOSGID=%%NAGIOSGID%%
11
11
12
ask() {
12
if [ "$2" = "POST-INSTALL" ]; then
13
  local question default answer
14
15
  question=$1
16
  default=$2
17
  if [ -z "${PACKAGE_BUILDING}" ]; then
18
    read -p "${question} [${default}]? " answer
19
  fi
20
  if [ "x${answer}" = "x" ]; then
21
    answer=${default}
22
  fi
23
  echo ${answer}
24
}
25
26
yesno() {
27
  local default question answer
28
29
  question=$1
30
  default=$2
31
  while :; do
32
    answer=$(ask "${question}" "${default}")
33
    case "${answer}" in
34
      [Yy][Ee][Ss]|[Yy])
35
        return 0
36
        ;;
37
      [Nn][Oo]|[Nn])
38
        return 1
39
        ;;
40
    esac
41
    echo "Please answer yes or no."
42
  done
43
}
44
45
if [ "$2" = "PRE-INSTALL" ]; then
46
  if /usr/sbin/pw group show "${NAGIOSGROUP}" 2>&1 >/dev/null; then
47
    echo "You already have a \"${NAGIOSGROUP}\" group, so I will use it."
48
  else
49
    echo "You need a \"${NAGIOSGROUP}\" group."
50
    if yesno "Would you like me to create it" "YES"; then
51
      /usr/sbin/pw groupadd "${NAGIOSGROUP}" -g "${NAGIOSGID}" -h - || \
52
        /usr/sbin/pw groupadd "${NAGIOSGROUP}" -h - || exit
53
      echo "Done."
54
    else
55
      echo "Please create the \"${NAGIOSGROUP}\" group manually and try again."
56
      exit 1
57
    fi
58
  fi
59
60
  if /usr/sbin/pw user show "${NAGIOSUSER}" 2>&1 >/dev/null; then
61
    echo "You already have a \"${NAGIOSUSER}\" user, so I will use it."
62
  else
63
    echo "You need a \"${NAGIOSUSER}\" user."
64
    if yesno "Would you like me to create it" "YES"; then
65
      /usr/sbin/pw useradd "${NAGIOSUSER}" -u "${NAGIOSUID}" -g "${NAGIOSGROUP}" -h - -d "${NAGIOSDIR}" \
66
        -s /sbin/nologin -c "Nagios pseudo-user" || \
67
        /usr/sbin/pw useradd "${NAGIOSUSER}" -g "${NAGIOSGROUP}" -h - -d "${NAGIOSDIR}" \
68
        -s /sbin/nologin -c "Nagios pseudo-user" || exit
69
    else
70
      echo "Please create the \"${NAGIOSUSER}\" user manually and try again."
71
      exit 1
72
    fi
73
  fi
74
elif [ "$2" = "POST-INSTALL" ]; then
75
  if [ ! -e "${NAGIOSDIR}" ]; then
13
  if [ ! -e "${NAGIOSDIR}" ]; then
76
    /bin/mkdir -p "${NAGIOSDIR}"
14
    /bin/mkdir -p "${NAGIOSDIR}"
77
    /bin/chmod 775 "${NAGIOSDIR}"
15
    /bin/chmod 775 "${NAGIOSDIR}"

Return to bug 169918