circulartext commited on
Commit
fbafdd6
·
1 Parent(s): 5972a0e

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +13 -9
entrypoint.sh CHANGED
@@ -1,16 +1,20 @@
1
  #!/bin/bash
2
- set -e
3
 
4
- # Set permissive permissions on the /app directory
5
- chmod -R 777 /app
6
 
7
  # Check if the user already exists
8
- if id "$USER_ID" >/dev/null 2>&1; then
9
- echo "User with ID $USER_ID already exists."
10
  else
11
- # Print a message about directory creation being skipped
12
- echo "Skipping directory creation under /app. User will be created if needed."
13
  fi
14
 
15
- # Run the CMD or any other command you want to execute
16
- exec "$@"
 
 
 
 
 
 
1
  #!/bin/bash
 
2
 
3
+ # Get the username from the command line arguments
4
+ USERNAME=$1
5
 
6
  # Check if the user already exists
7
+ if id "$USERNAME" >/dev/null 2>&1; then
8
+ echo "User $USERNAME already exists."
9
  else
10
+ # Create the user with a home directory and a bash shell
11
+ useradd -m -s /bin/bash "$USERNAME"
12
  fi
13
 
14
+ # Set appropriate permissions for the application directory
15
+ chown -R "$USERNAME":"$USERNAME" /app
16
+ chmod -R 755 /app
17
+
18
+ # Switch to the user for improved security
19
+ su "$USERNAME" -c "exec /usr/local/bin/entrypoint-inner.sh"
20
+