aboutsummaryrefslogtreecommitdiff
path: root/newsboat/entrypoint.sh
blob: 0e308cfee2e748e7bedab61413bbfb8cc5fd0700 (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
29
30
31
#!/bin/sh

HOME_DIR="/home/newsboat/.newsboat"
URLS_FILE="${HOME_DIR}/urls"

# No point starting if they don't have config, also we don't
# want to store the actual user data in the container so force
# a mount.
if [ ! -d $HOME_DIR ]; then
    echo "Mount your newsboat config to /home/newsboat/.newsboat"
    exit 1
fi

# Also force a urls file because this newsboat will just fail
# anyhow without it.
if [ ! -f $URLS_FILE ]; then
    echo "Create a urls file in your newsboat config first"
    exit 1
fi

# Allow users to specify the UID/GID in the environment but
# default these to the existing owner of the files in their
# mounted config, which should be sane.
UID=${UID:-$(stat -c "%u" $URLS_FILE)}
GID=${GID:-$(stat -c "%u" $URLS_FILE)}

# Create the user and group
addgroup -g ${GID} -S newsboat
adduser -u ${UID} -S -h /home/newsboat -H -D -G newsboat newsboat

/sbin/su-exec newsboat "$@"