From f9351861bd692011a54298fda38e61dfb11f91e9 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Wed, 14 Feb 2024 16:55:47 +0000 Subject: [PATCH] Updating entrypoint.sh updating to version 1.1.2 --- entrypoint.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++----- version.txt | 2 +- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 993e07b..c2364d0 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,53 @@ #!/bin/bash -if [[ -z "${HOME_USER}" ]]; then - HOME_USER="vscode" +#if [[ -z "${HOME_USER}" ]]; then + #HOME_USER="vscode" +#fi + +set -e + +# use specified user name or use `vscode` if not specified +HOME_USER="${HOME_USER:-vscode}" + +# use specified group name or use the same user name also as the group name +MY_GROUP="${MY_GROUP:-${HOME_USER}}" + +# use the specified UID for the user +MY_UID="${MY_UID:-1000}" + +# use the specified GID for the user +MY_GID="${MY_GID:-${MY_UID}}" + + +# check to see if group exists; if not, create it +if grep -q -E "^${MY_GROUP}:" /etc/group > /dev/null 2>&1 +then + echo "INFO: Group exists; skipping creation" +else + echo "INFO: Group doesn't exist; creating..." + # create the group + addgroup -g "${MY_GID}" "${MY_GROUP}" || (echo "INFO: Group exists but with a different name; renaming..."; groupmod -g "${MY_GID}" -n "${MY_GROUP}" "$(awk -F ':' '{print $1":"$3}' < /etc/group | grep ":${MY_GID}$" | awk -F ":" '{print $1}')") fi -addgroup nonroot -adduser --disabled-password --gecos "" ${HOME_USER} -echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + +# check to see if user exists; if not, create it +if id -u "${HOME_USER}" > /dev/null 2>&1 +then + echo "INFO: User exists; skipping creation" +else + echo "INFO: User doesn't exist; creating..." + # create the user + adduser -u "${MY_UID}" -G "${MY_GROUP}" -h "/home/${HOME_USER}" -s /bin/sh -D "${HOME_USER}" +fi + +# make the directories needed to run my app +mkdir -p /opt/myapp + +# change ownership of any directories needed to run my app as the proper UID/GID +chown -R "${HOME_USER}:${MY_GROUP}" "/opt/myapp" + +# addgroup nonroot +#adduser --disabled-password --gecos "" ${HOME_USER} +# echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers #Creating extensions folder sudo mkdir /home/${HOME_USER}/.config/Code diff --git a/version.txt b/version.txt index 8cfbc90..8428158 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.1 \ No newline at end of file +1.1.2 \ No newline at end of file