summaryrefslogtreecommitdiff
path: root/net/cacti/pkg-install
blob: df78f670ea232ded150d2c64fcde517d38e2c02b (plain) (blame)
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
#!/bin/sh

PW=/usr/sbin/pw

case $2 in

PRE-INSTALL)

	if ${PW} group show "${CACTIGROUP}" 2>/dev/null; then
		echo "You already have a group \"${CACTIGROUP}\", so I will use it."
	else
		if ${PW} groupadd ${CACTIGROUP}; then
			echo "Added group \"${CACTIGROUP}\"."
		else
			echo "Adding group \"${CACTIGROUP}\" failed..."
			exit 1
		fi
	fi

	if ${PW} user show "${CACTIUSER}" 2>/dev/null; then
		echo "You already have a user \"${CACTIUSER}\", so I will use it."
	else
		if ${PW} useradd ${CACTIUSER} -g ${CACTIGROUP} -h - \
			-d "/nonexistent" -s /sbin/nologin -c "Cacti Sandbox"
		then
			echo "Added user \"${CACTIUSER}\"."
		else
			echo "Adding user \"${CACTIUSER}\" failed..."
			exit 1
		fi
	fi
	;;

POST-INSTALL)

	chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/log/
	chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/rra/
	;;
*)
	exit 1
;;
esac
exit