andrius-asterisk/debian-stretch-slim-16-current/docker-entrypoint.sh

25 lines
748 B
Bash
Raw Normal View History

2018-07-13 20:36:33 +08:00
#!/bin/sh
# run as user asterisk by default
ASTERISK_USER=${ASTERISK_USER:-asterisk}
if [ "$1" = "" ]; then
COMMAND="/usr/sbin/asterisk -T -W -U ${ASTERISK_USER} -p -vvvdddf"
else
COMMAND="$@"
fi
if [ "${ASTERISK_UID}" != "" ] && [ "${ASTERISK_GID}" != "" ]; then
# recreate user and group for asterisk
# if they've sent as env variables (i.e. to macth with host user to fix permissions for mounted folders
deluser asterisk && \
2018-10-11 16:16:02 +08:00
adduser --gecos "" --no-create-home --uid ${ASTERISK_UID} --disabled-password ${ASTERISK_USER} || exit
chown -R ${ASTERISK_UID}:${ASTERISK_UID} /etc/asterisk \
/var/*/asterisk \
/usr/*/asterisk
2018-07-13 20:36:33 +08:00
fi
exec ${COMMAND}