28 lines
791 B
Bash
Executable File
28 lines
791 B
Bash
Executable File
#!/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 && \
|
|
adduser --gecos "" --no-create-home --uid ${ASTERISK_UID} --disabled-password ${ASTERISK_USER} \
|
|
|| exit
|
|
fi
|
|
|
|
mkdir -p /var/run/asterisk
|
|
|
|
chown -R ${ASTERISK_USER}: /var/log/asterisk \
|
|
/var/lib/asterisk \
|
|
/var/run/asterisk \
|
|
/var/spool/asterisk; \
|
|
exec ${COMMAND}
|