File: preinstall

package info (click to toggle)
monitoring-plugins 2.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,772 kB
  • sloc: ansic: 76,213; sh: 13,717; perl: 7,655; makefile: 490
file content (35 lines) | stat: -rwxr-xr-x 813 bytes parent folder | download | duplicates (19)
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
#!/usr/bin/sh

user="nagios"
uid=-1
group="nagios"
gid=-1

/usr/bin/getent group $group > /dev/null 2> /dev/null
result=$?
if [ $result -eq 2 ] ; then
	echo "Group $group does not exist. Creating..."
	if [ $gid -ne -1 ] ; then
		/usr/sbin/groupadd -g $gid $group
	else
		/usr/sbin/groupadd $group
	fi
elif [ $result -ne 0 ] ; then
	echo "An error occurred determining the existence of the groug $group. Terminating."
	exit 1;
fi

/usr/bin/getent passwd $user > /dev/null 2> /dev/null
result=$?
if [ $result -eq 2 ] ; then
	echo "User $user does not exist. Creating..."
	if [ $uid -ne -1 ] ; then
		/usr/sbin/useradd -u $uid -g $group $user
	else
		/usr/sbin/useradd -g $group $user
	fi
elif [ $result -ne 0 ] ; then
	echo "An error occurred determining the existence of the user $user. Terminating."
	exit 1;
fi