-
Notifications
You must be signed in to change notification settings - Fork 5
/
entrypoint.sh
executable file
·43 lines (32 loc) · 968 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
#!/bin/bash
set -e
#set -x
TTYD_ARGS="login"
# Check if this is the container's first run
if [ -f /etc/.firstrun ]; then
# Create user account
adduser -D --shell=/bin/bash $USERNAME
# Add a password to the user
echo "$USERNAME:$PASSWORD" | chpasswd
# Allow access to sudo if permitted
if [ $SUDO_OK == "true" ]; then
addgroup $USERNAME wheel
sed -i '/%wheel ALL=(ALL) ALL/s/^# //g' /etc/sudoers
fi
# Prevent this from running again
rm /etc/.firstrun
fi
# Optionally set a timezone
CURRENT_TZ=$(cat /etc/timezone)
if [ "$TZ" != "$CURRENT_TZ" ]; then
echo "Setting timezone to $TZ"
# delete symlink if it exists
[ -f /etc/localtime ] && rm /etc/localtime
# set timezone
ln -s "/usr/share/zoneinfo/$TZ" /etc/localtime
echo $TZ > /etc/timezone
fi
# Auto login the user, if allowed
[ $AUTOLOGIN == "true" ] && TTYD_ARGS="$TTYD_ARGS -f $USERNAME"
# Start ttyd
exec ttyd $TTYD_ARGS "$@"