Compare commits
2 commits
main
...
samruddhik
Author | SHA1 | Date | |
---|---|---|---|
|
0431ec33f1 | ||
|
0956fb3e74 |
1 changed files with 33 additions and 1 deletions
|
@ -47,6 +47,38 @@ elif [ "${USERNAME}" = "none" ]; then
|
||||||
USER_GID=0
|
USER_GID=0
|
||||||
fi
|
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)"
|
architecture="$(uname -m)"
|
||||||
if [ "${architecture}" != "x86_64" ]; then
|
if [ "${architecture}" != "x86_64" ]; then
|
||||||
echo "(!) Architecture $architecture unsupported"
|
echo "(!) Architecture $architecture unsupported"
|
||||||
|
@ -79,7 +111,7 @@ if ! conda --version &> /dev/null ; then
|
||||||
check_packages wget ca-certificates
|
check_packages wget ca-certificates
|
||||||
|
|
||||||
mkdir -p $CONDA_DIR
|
mkdir -p $CONDA_DIR
|
||||||
chown ${USERNAME}:root $CONDA_DIR
|
chown ${USERNAME}:${USERNAME} $CONDA_DIR
|
||||||
echo "Installing Anaconda..."
|
echo "Installing Anaconda..."
|
||||||
|
|
||||||
CONDA_VERSION=$VERSION
|
CONDA_VERSION=$VERSION
|
||||||
|
|
Loading…
Reference in a new issue