-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·46 lines (39 loc) · 1.25 KB
/
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
44
45
46
#!/bin/bash
set -eo pipefail
if [ -z "$ACCEPT_ORACLE_LICENSE" ]; then
echo >&2 'You need to include ACCEPT_ORACLE_LICENSE=true in order to start this container.'
echo >&2 'Visit http://www.oracle.com/technetwork/java/javase/terms/license/index.html'
exit 1
fi
if [[ "$ACCEPT_ORACLE_LICENSE" =~ "yes" ]]; then
echo >&2 'You need to include ACCEPT_ORACLE_LICENSE=true in order to start this container.'
echo >&2 'Visit http://www.oracle.com/technetwork/java/javase/terms/license/index.html'
exit 1
fi
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 id -u $USER_NAME >/dev/null 2>&1; then
echo "$USER_NAME already exists."
else
useradd -Ms /bin/false $USER_NAME
echo "$USER_NAME:$USER_PASSWORD" | chpasswd
echo >&2 "Created user: $USER_NAME"
fi
if [ ! -f /etc/ssl/certs/mineos.crt ]; then
echo >&2 "Generating Self-Signed SSL..."
sh /usr/games/minecraft/generate-sslcert.sh
update-ca-certificates -f
fi
exec "$@"