B #4792: CONTEXT/USERNAME does not create a user in linux

pull/58/head
Jaime Melis 8 years ago
parent 80951d036f
commit 80e0a44f6d

@ -16,23 +16,22 @@
# limitations under the License. # # limitations under the License. #
#--------------------------------------------------------------------------- # #--------------------------------------------------------------------------- #
[ -n "${PASSWORD}${CRYPTED_PASSWORD}" ] || exit 0 if [ -z "${USERNAME}" ]; then
if [ -z "${USERNAME}" ]
then
USERNAME=root USERNAME=root
fi fi
if ! getent passwd "${USERNAME}" > /dev/null 2>&1 if ! getent passwd "${USERNAME}" > /dev/null 2>&1; then
then useradd -m "${USERNAME}"
echo "User “${USERNAME}” does not exist" >&2
exit 0
fi fi
if [ -n "${PASSWORD}" ] if [ -n "${CRYPTED_PASSWORD_BASE64}" ]; then
then CRYPTED_PASSWORD=$(echo $CRYPTED_PASSWORD_BASE64 | base64 -d)
usermod -p "${CRYPTED_PASSWORD}" "${USERNAME}"
elif [ -n "${PASSWORD_BASE64}" ]; then
PASSWORD=$(echo $PASSWORD_BASE64 | base64 -d)
chpasswd <<< "${USERNAME}:${PASSWORD}" chpasswd <<< "${USERNAME}:${PASSWORD}"
elif [ -n "${CRYPTED_PASSWORD}" ] elif [ -n "${CRYPTED_PASSWORD}" ]; then
then
usermod -p "${CRYPTED_PASSWORD}" "${USERNAME}" usermod -p "${CRYPTED_PASSWORD}" "${USERNAME}"
elif [ -n "${PASSWORD}" ]; then
chpasswd <<< "${USERNAME}:${PASSWORD}"
fi fi

Loading…
Cancel
Save