summaryrefslogtreecommitdiffstats
path: root/sysutils/ganglia-monitor-core/pkg-install
blob: 462943114667d18697e45c4a41d8b0bab6fe077e (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
#!/bin/sh

u=ganglia
g=ganglia
ugid=97
homedir=/nonexistent
shell=/sbin/nologin
rrd_rootdir=/var/db/ganglia/rrds

case $2 in
POST-INSTALL)
	if pw group show "${g}" >/dev/null 2>&1; then
		echo "Using existing group \"${g}\"."
	else
		echo "Creating group \"${g}\", (gid: ${ugid})."
		pw groupadd ${g} -g ${ugid}
		if [ $? != 0 ]; then
			echo "Failed to add group \"${g}\"."
			exit 1
		fi
	fi
	if pw user show "${u}" >/dev/null 2>&1; then
		echo "Using existing user \"${u}\"."
	else
		echo "Creating user \"${u}\", (uid: ${ugid})."
		pw useradd ${u} -u ${ugid} -g ${ugid} -h - \
		    -d ${homedir} -s ${shell} -c "Ganglia User"
		if [ $? != 0 ]; then
			echo "Failed to add user \"${u}\"."
			exit 1
		fi
	fi

	mkdir -p ${rrd_rootdir}
	chown -R ${u}:${g} ${rrd_rootdir}
	;;
esac
OpenPOWER on IntegriCloud