- # First ensure that the user didn't say his UID is important and
- # then fail to specify one.
- if (( "${SYS_USER_UID}" == -1 )) &&
- [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]]; then
- # Don't make no damn sense.
- die "arbitrary UID requested with SYS_USER_UID_IMPORTANT=true"
- fi
+ # * SYS_USER_NAME
+ # * SYS_USER_UID
+ # * SYS_USER_SHELL
+ # * SYS_USER_HOME
+ # * SYS_USER_GROUPS
+ #
+ # We don't create a group with the same name; that should be the
+ # job of the matching sys-group package.
+ useradd --no-user-group \
+ ${SYS_USER_UID:+--uid }"${SYS_USER_UID}" \
+ ${SYS_USER_GROUPS:+--groups }"${SYS_USER_GROUPS}" \
+ --shell "${SYS_USER_SHELL}" \
+ --home-dir "${SYS_USER_HOME}" \
+ "${SYS_USER_NAME}"
+}
+
+
+sys-user_modify() {
+ # Modify the existing user named $SYS_USER_NAME to match the values
+ # contained in the following variables:
+ #
+ # * SYS_USER_UID
+ # * SYS_USER_SHELL
+ # * SYS_USER_HOME
+ # * SYS_USER_GROUPS
+ #
+ usermod ${SYS_USER_UID:+--uid }"${SYS_USER_UID}" \
+ ${SYS_USER_GROUPS:+--append --groups }"${SYS_USER_GROUPS}" \
+ --shell "${SYS_USER_SHELL}" \
+ --home "${SYS_USER_HOME}" \
+ "${SYS_USER_NAME}"
+}