1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Properly set up traps

Also don't attempt to delete the temporary file twice.
This commit is contained in:
Moritz Grimm 2015-06-08 23:57:17 +02:00
parent ccaa2fddc3
commit 87275ca223

View File

@ -49,6 +49,10 @@ LOGFILE="ezstream.log"
_myname="$(basename $0)" _myname="$(basename $0)"
# Ignore SIGHUP, and exit 1 on SIGINT and SIGTERM
trap '' 1
trap 'exit 1' 2 15
# Check configuration above: # Check configuration above:
if [ -z "${STATE_DIR}" -o ! -d "${STATE_DIR}" ]; then if [ -z "${STATE_DIR}" -o ! -d "${STATE_DIR}" ]; then
echo "${_myname}: STATE_DIR is not configured, does not exist or is not a directory." >&2 echo "${_myname}: STATE_DIR is not configured, does not exist or is not a directory." >&2
@ -67,8 +71,8 @@ if [ $? -ne 0 ]; then
echo "${_myname}: Unable to create temporary file." >&2 echo "${_myname}: Unable to create temporary file." >&2
exit 1 exit 1
fi fi
# Delete temporary file on exit
trap 'rm -f ${_playlist}' 0 trap 'rm -f ${_playlist}' 0
trap 'rm -f ${_playlist}; exit 1' 2 15
# Strip comments and empty lines from PLAYLIST, to support .m3u: # Strip comments and empty lines from PLAYLIST, to support .m3u:
sed -e 's,#.*,,g' < ${PLAYLIST} | grep -v '^[[:space:]]*$' >> ${_playlist} sed -e 's,#.*,,g' < ${PLAYLIST} | grep -v '^[[:space:]]*$' >> ${_playlist}