forked from hexparrot/mineos-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·43 lines (37 loc) · 1021 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -eo pipefail
if [ -z "$USER_PASSWORD" ]; then
echo >&2 'You need to specify USER_PASSWORD'
exit 1
fi
if [ "$USER_NAME" ]; then
# username specifically provided, will overwrite 'mc'
if [[ "$USER_NAME" =~ [^a-zA-Z0-9] ]]; then
echo >&2 'USER_NAME must contain only alphanumerics [a-zA-Z0-9]'
exit 1
fi
else
echo >&2 'USER_NAME not provided; defaulting to "mc"'
USER_NAME=mc
fi
if [ "$USER_UID" ]; then
# uid specifically provided, will overwrite 1000 default
if [[ "$USER_UID" =~ [^0-9] ]]; then
echo >&2 'USER_UID must contain only numerics [0-9]'
exit 1
fi
else
USER_UID=1000
fi
if id -u $USER_NAME >/dev/null 2>&1; then
echo "$USER_NAME already exists."
else
useradd -Ms /bin/false -u $USER_UID $USER_NAME
echo "$USER_NAME:$USER_PASSWORD" | chpasswd
echo >&2 "Created user: $USER_NAME (uid: $USER_UID)"
fi
if [ ! -f /etc/ssl/certs/mineos.crt ]; then
echo >&2 "Generating Self-Signed SSL..."
sh /usr/games/minecraft/generate-sslcert.sh
fi
exec "$@"