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