blob: 364ca4f2a69f200794dd5dc92c6335e411925116 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# $NetBSD: usergroupfuncs,v 1.3 2005/10/28 20:05:46 jlam Exp $
#
# Default implementation of adduser() and addgroup() shell functions
# for adding users and groups. This implementation assumes there are
# NetBSD/Solaris-compatible versions of useradd(8) and groupadd(8)
# available through ${USERADD} and ${GROUPADD}, respectively.
#
# Platform-specific replacements for this file should be located at:
#
# pkgsrc/mk/install/usergroupfuncs.${OPSYS}
#
# adduser user group [userid] [descr] [home] [shell]
adduser()
{
user="$1"; group="$2"; userid="$3"
descr="$4"; home="$5" shell="$6"
${TEST} $# -eq 6 || return 1
${TEST} -n "$user" || return 2
${TEST} -n "$group" || return 2
USERADD="@USERADD@"
: ${descr:="${PKGNAME%-[0-9]*} $user user"}
: ${home:="@PKG_USER_HOME@"}
: ${shell:="@PKG_USER_SHELL@"}
if ${TEST} -n "${USERADD}" -a -x "${USERADD}"; then
${ECHO} "Creating user: $user"
case $userid in
"")
${USERADD} \
-c "$descr" -d "$home" -s "$shell" \
-g $group $user
;;
*)
${USERADD} \
-c "$descr" -d "$home" -s "$shell" \
-g $group -u $userid $user
;;
esac
fi
return 0
}
# adduser group [groupid]
addgroup()
{
group="$1"; groupid="$2"
${TEST} $# -eq 2 || return 1
${TEST} -n "$group" || return 2
GROUPADD="@GROUPADD@"
if ${TEST} -n "${GROUPADD}" -a -x "${GROUPADD}"; then
${ECHO} "Creating group: $group";
case $groupid in
"") ${GROUPADD} $group ;;
*) ${GROUPADD} -g $groupid $group ;;
esac
fi
return 0
}
|