Add GRANT_SUDO parameter to context

If use a $GRANT_SUDO variable with $USERNAME,
    the regular user will have a sudo privileges
pull/89/head
Dmitry Tyzhnenko 7 years ago
parent d37b04c84d
commit 92ae5c022a

@ -24,6 +24,13 @@ if ! getent passwd "${USERNAME}" > /dev/null 2>&1; then
useradd -m "${USERNAME}"
fi
if [ "${GRANT_SUDO}" == "YES" -a "${USERNAME}" != "root" ]; then
if [ ! -f /etc/sudoers.d/${USERNAME} ]; then
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME}
chmod 644 /etc/sudoers.d/${USERNAME}
fi
fi
if [ -n "${CRYPTED_PASSWORD_BASE64}" ]; then
CRYPTED_PASSWORD=$(echo $CRYPTED_PASSWORD_BASE64 | base64 -d)
usermod -p "${CRYPTED_PASSWORD}" "${USERNAME}"

Loading…
Cancel
Save