|
|
@ -16,21 +16,19 @@
|
|
|
|
# limitations under the License. #
|
|
|
|
# limitations under the License. #
|
|
|
|
#--------------------------------------------------------------------------- #
|
|
|
|
#--------------------------------------------------------------------------- #
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "${USERNAME}" ]; then
|
|
|
|
# defaults
|
|
|
|
USERNAME=root
|
|
|
|
USERNAME=${USERNAME:-root}
|
|
|
|
fi
|
|
|
|
USERNAME_SHELL=${USERNAME_SHELL:-/bin/bash}
|
|
|
|
|
|
|
|
USERNAME_SUDO=${USERNAME_SUDO:-${GRANT_SUDO:-YES}}
|
|
|
|
|
|
|
|
USERNAME_SUDO=$(echo "${USERNAME_SUDO}" | tr '[:lower:]' '[:upper:]')
|
|
|
|
|
|
|
|
USERNAME_PASSWORD_RESET=${USERNAME_PASSWORD_RESET:-YES}
|
|
|
|
|
|
|
|
USERNAME_PASSWORD_RESET=$(echo "${USERNAME_PASSWORD_RESET}" | tr '[:lower:]' '[:upper:]')
|
|
|
|
|
|
|
|
|
|
|
|
if ! getent passwd "${USERNAME}" > /dev/null 2>&1; then
|
|
|
|
if ! getent passwd "${USERNAME}" > /dev/null 2>&1; then
|
|
|
|
useradd -m "${USERNAME}"
|
|
|
|
useradd -m "${USERNAME}" -s "${USERNAME_SHELL}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
GRANT_SUDO=${GRANT_SUDO:-YES}
|
|
|
|
if [ "${USERNAME_SUDO}" == "YES" ] && [ "${USERNAME}" != "root" ]; then
|
|
|
|
GRANT_SUDO=$(echo "${GRANT_SUDO}" | tr '[:lower:]' '[:upper:]')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PASSWORD_RESET=${PASSWORD_RESET:-YES}
|
|
|
|
|
|
|
|
PASSWORD_RESET=$(echo "${PASSWORD_RESET}" | tr '[:lower:]' '[:upper:]')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${GRANT_SUDO}" == "YES" ] && [ "${USERNAME}" != "root" ]; then
|
|
|
|
|
|
|
|
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/one-context
|
|
|
|
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/one-context
|
|
|
|
chmod 0440 /etc/sudoers.d/one-context
|
|
|
|
chmod 0440 /etc/sudoers.d/one-context
|
|
|
|
elif [ -f /etc/sudoers.d/one-context ]; then
|
|
|
|
elif [ -f /etc/sudoers.d/one-context ]; then
|
|
|
@ -61,6 +59,6 @@ ${PASSWORD}
|
|
|
|
${PASSWORD}
|
|
|
|
${PASSWORD}
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
elif [ "${PASSWORD_RESET}" = 'YES' ]; then
|
|
|
|
elif [ "${USERNAME_PASSWORD_RESET}" = 'YES' ]; then
|
|
|
|
usermod -p '*' "${USERNAME}"
|
|
|
|
usermod -p '*' "${USERNAME}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|