diff --git a/examples/playlist-logger.sh b/examples/playlist-logger.sh index bfe5f52..4f38b2b 100755 --- a/examples/playlist-logger.sh +++ b/examples/playlist-logger.sh @@ -49,6 +49,10 @@ LOGFILE="ezstream.log" _myname="$(basename $0)" +# Ignore SIGHUP, and exit 1 on SIGINT and SIGTERM +trap '' 1 +trap 'exit 1' 2 15 + # Check configuration above: 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 @@ -67,8 +71,8 @@ if [ $? -ne 0 ]; then echo "${_myname}: Unable to create temporary file." >&2 exit 1 fi +# Delete temporary file on exit trap 'rm -f ${_playlist}' 0 -trap 'rm -f ${_playlist}; exit 1' 2 15 # Strip comments and empty lines from PLAYLIST, to support .m3u: sed -e 's,#.*,,g' < ${PLAYLIST} | grep -v '^[[:space:]]*$' >> ${_playlist}