aboutsummaryrefslogtreecommitdiff
path: root/mutt/entrypoint.sh
blob: 31966299dbfdcc4a7212fd978dd7b7bf1bf75e9d (plain)
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
#!/bin/sh

set -e

export TERM=${TERM:-xterm-256color}
export BROWSER=${DOCKER_BROWSER:-elinks}
export EDITOR=${DOCKER_EDITOR:-vim}

USERNAME="mutt"
DATA_DIR="/home/mutt/Mail"

# Default UID/GID to owner of the data directory
PROG_UID=${PROG_UID:-$(stat -L -c "%u" $DATA_DIR)}
PROG_GID=${PROG_GID:-$(stat -L -c "%u" $DATA_DIR)}

if [ "$PROG_GID" = 0 -o "$PROG_GID" = 0 ]; then
    echo "Set PROG_UID and PROG_GID in environment"
    exit 1
else
    echo "UID/GID: $PROG_UID $PROG_GID"
fi

# Create the user and group
addgroup -g ${PROG_GID} -S ${USERNAME}
adduser -u ${PROG_UID} -S -h /home/${USERNAME} -H -D -G ${USERNAME} ${USERNAME}

# Allow running a shell in the container
/sbin/su-exec ${USERNAME} "$@"