summaryrefslogtreecommitdiff
path: root/mk/install/usergroupfuncs.FreeBSD
diff options
context:
space:
mode:
Diffstat (limited to 'mk/install/usergroupfuncs.FreeBSD')
-rw-r--r--mk/install/usergroupfuncs.FreeBSD58
1 files changed, 58 insertions, 0 deletions
diff --git a/mk/install/usergroupfuncs.FreeBSD b/mk/install/usergroupfuncs.FreeBSD
new file mode 100644
index 00000000000..e5b0ee0e465
--- /dev/null
+++ b/mk/install/usergroupfuncs.FreeBSD
@@ -0,0 +1,58 @@
+# $NetBSD: usergroupfuncs.FreeBSD,v 1.1 2005/11/06 19:45:08 joerg Exp $
+#
+# Platform-specific adduser and addgroup functionality
+# on top of pw(8).
+
+# 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
+
+ PW="@PW@"
+
+ : ${descr:="${PKGNAME%-[0-9]*} $user user"}
+ : ${home:="@PKG_USER_HOME@"}
+ : ${shell:="@PKG_USER_SHELL@"}
+
+ if ${TEST} -n "${PW}" -a -x "${PW}"; then
+ ${ECHO} "Creating user: $user"
+ case $userid in
+ "")
+ ${PW} useradd \
+ $user \
+ -c "$descr" -d "$home" -s "$shell" \
+ -g $group
+ ;;
+ *)
+ ${PW} useradd \
+ $user \
+ -c "$descr" -d "$home" -s "$shell" \
+ -g $group -u $userid
+ ;;
+ esac
+ fi
+ return 0
+}
+
+# adduser group [groupid]
+addgroup()
+{
+ group="$1"; groupid="$2"
+ ${TEST} $# -eq 2 || return 1
+ ${TEST} -n "$group" || return 2
+
+ PW="@PW@"
+
+ if ${TEST} -n "${PW}" -a -x "${PW}"; then
+ ${ECHO} "Creating group: $group";
+ case $groupid in
+ "") ${PW} groupadd $group ;;
+ *) ${PW} groupadd $group -g $groupid ;;
+ esac
+ fi
+ return 0
+}