Spaces:
Sleeping
Sleeping
Commit
·
fbafdd6
1
Parent(s):
5972a0e
Update entrypoint.sh
Browse files- entrypoint.sh +13 -9
entrypoint.sh
CHANGED
|
@@ -1,16 +1,20 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
-
set -e
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
# Check if the user already exists
|
| 8 |
-
if id "$
|
| 9 |
-
|
| 10 |
else
|
| 11 |
-
|
| 12 |
-
|
| 13 |
fi
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|