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}" |