Compare commits

...

2 commits

Author SHA1 Message Date
Samruddhi Khandale
0431ec33f1 add user 2022-05-31 16:21:29 +00:00
Samruddhi Khandale
0956fb3e74 fix anaconda test 2022-05-31 16:13:46 +00:00

View file

@ -47,6 +47,38 @@ elif [ "${USERNAME}" = "none" ]; then
USER_GID=0
fi
# Create or update a non-root user to match UID/GID.
group_name="${USERNAME}"
if id -u ${USERNAME} > /dev/null 2>&1; then
# User exists, update if needed
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
group_name="$(id -gn $USERNAME)"
groupmod --gid $USER_GID ${group_name}
usermod --gid $USER_GID $USERNAME
fi
if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
usermod --uid $USER_UID $USERNAME
fi
else
# Create user
if [ "${USER_GID}" = "automatic" ]; then
groupadd $USERNAME
else
groupadd --gid $USER_GID $USERNAME
fi
if [ "${USER_UID}" = "automatic" ]; then
useradd -s /bin/bash --gid $USERNAME -m $USERNAME
else
useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
fi
fi
# Add add sudo support for non-root user
if [ "${USERNAME}" != "root" ]; then
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
chmod 0440 /etc/sudoers.d/$USERNAME
fi
architecture="$(uname -m)"
if [ "${architecture}" != "x86_64" ]; then
echo "(!) Architecture $architecture unsupported"
@ -79,7 +111,7 @@ if ! conda --version &> /dev/null ; then
check_packages wget ca-certificates
mkdir -p $CONDA_DIR
chown ${USERNAME}:root $CONDA_DIR
chown ${USERNAME}:${USERNAME} $CONDA_DIR
echo "Installing Anaconda..."
CONDA_VERSION=$VERSION