Skip to content

Commit

Permalink
alright: one more
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianNoise committed May 16, 2024
1 parent 695d629 commit be2dcb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 1 addition & 2 deletions dl-downer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ RUN pip install --no-cache-dir -r requirements.txt
# RUN pip install [email protected]
RUN playwright install --with-deps

RUN apt-get install -y sudo
RUN apt-get install -y gosu
RUN apt-get install -y sudo gosu
RUN rm -rf /var/lib/apt/lists/

ENTRYPOINT [ "entry.sh" ]
Expand Down
27 changes: 19 additions & 8 deletions dl-downer/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@
PUID=${PUID:-1000}
PGID=${PGID:-1000}

# Check if group already exists
if ! getent group mygroup > /dev/null 2>&1; then
groupadd -g "$PGID" mygroup
# Create the group if it doesn't exist
if ! getent group "$PGID" > /dev/null 2>&1; then
groupadd -g "$PGID" mygroup
else
existing_group=$(getent group "$PGID" | cut -d: -f1)
echo "Using existing group: $existing_group"
fi

# Check if user already exists
if ! id -u myuser > /dev/null 2>&1; then
useradd -u "$PUID" -g "$PGID" -m -s /bin/bash myuser
# Create the user if it doesn't exist
if ! id -u "$PUID" > /dev/null 2>&1; then
useradd -u "$PUID" -g "$PGID" -m -s /bin/bash myuser
else
existing_user=$(getent passwd "$PUID" | cut -d: -f1)
echo "Using existing user: $existing_user"
fi

# Assign the user to the existing group if the group already existed
if getent passwd myuser > /dev/null 2>&1; then
usermod -aG "$PGID" myuser
fi

# Change ownership of the home directory
chown -R myuser:mygroup /home/myuser
chown -R "$PUID:$PGID" /home/myuser

chown -R myuser:mygroup /downloads
chown -R myuser:mygroup /storage_states

# Run the command as the specified user
exec gosu myuser "$@"
exec gosu "$PUID:$PGID" "$@"

0 comments on commit be2dcb4

Please sign in to comment.