summaryrefslogtreecommitdiff
path: root/system/adelie-base/adduser
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2017-09-30 18:08:56 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2017-09-30 18:08:56 -0500
commitc372315963b47c1ed1d365ae9a792edfe00bcfeb (patch)
tree4895f40a0caef0a2b660ca4b83fad3edc6988b22 /system/adelie-base/adduser
parente12a1cb1b348ca0a2c940839bd66ae14850f3fc7 (diff)
downloadpackages-c372315963b47c1ed1d365ae9a792edfe00bcfeb.tar.gz
packages-c372315963b47c1ed1d365ae9a792edfe00bcfeb.tar.bz2
packages-c372315963b47c1ed1d365ae9a792edfe00bcfeb.tar.xz
packages-c372315963b47c1ed1d365ae9a792edfe00bcfeb.zip
system/adelie-base: add bbshim crap to it
Diffstat (limited to 'system/adelie-base/adduser')
-rwxr-xr-xsystem/adelie-base/adduser90
1 files changed, 90 insertions, 0 deletions
diff --git a/system/adelie-base/adduser b/system/adelie-base/adduser
new file mode 100755
index 000000000..ba9d90a61
--- /dev/null
+++ b/system/adelie-base/adduser
@@ -0,0 +1,90 @@
+#!/bin/sh
+# adduser - BusyBox compatibility shim
+# bbshim
+#
+# Copyright © 2017 A. Wilcox. All rights reserved.
+# Licensed under the terms of the NCSA Open Source license.
+#
+
+# The GECOS for the new user.
+GECOS="Linux User,,,"
+
+# Additional groups in which to add the new user.
+MYGROUPS=
+
+# Path to the home directory for the new user.
+HOMEDIR=
+
+# Don't call passwd(1) for the new user afterwards.
+NOPASSWD=0
+
+# The new user's shell.
+MYSHELL=$SHELL
+
+# An alternative skeleton directory for the new user's home directory.
+SKEL=/etc/skel
+
+# The new user is a system user.
+SYSTEM=0
+
+# Use this UID number for the new user.
+MYUID=
+
+
+ARG=
+
+while getopts h:g:s:G:SDHu:k: ARG
+do
+ case $ARG in
+ h) HOMEDIR=$OPTARG ;;
+ g) GECOS=$OPTARG ;;
+ s) MYSHELL=$OPTARG ;;
+ G) MYGROUPS=$OPTARG ;;
+ S) SYSTEM=1
+ MYSHELL="/bin/false";;
+ D) NOPASSWD=1 ;;
+ H) unset HOMEDIR ;;
+ u) MYUID=$OPTARG ;;
+ k) SKEL=$OPTARG ;;
+ :) exit 1 ;;
+ \?) exit 1 ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+if [ -z "$*" ]; then
+ echo "$0: user name is required" >&2
+ exit 1
+fi
+
+set "$@"
+
+
+CMDLINE="-s $MYSHELL"
+
+if [ -n "$MYGROUPS" ]; then
+ CMDLINE="$CMDLINE -g $MYGROUPS"
+fi
+
+if [ -n "$HOMEDIR" ]; then
+ CMDLINE="$CMDLINE -m -d \"$HOMEDIR\" -k \"$SKEL\""
+fi
+
+if [ $SYSTEM -ne 0 ]; then
+ CMDLINE="$CMDLINE -r"
+fi
+
+if [ -n "$MYUID" ]; then
+ CMDLINE="$CMDLINE -u $MYUID"
+fi
+
+if [ -n "$2" ]; then
+ CMDLINE="$CMDLINE -g $2"
+fi
+
+useradd -c "$GECOS" $CMDLINE $1
+
+#if [ $NOPASSWD -eq 0 ]; then
+# passwd $1
+#fi