gh-93: New context option USERNAME_SHELL, few user related renamed

Closes #93
pull/100/merge
Vlastimil Holer 7 years ago
parent 752c237a45
commit 97d95628a9
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -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

Loading…
Cancel
Save