summaryrefslogtreecommitdiff
path: root/sfeed_update
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-03-21 11:47:07 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-03-21 12:04:09 +0100
commit125164fc972b3149aa65db4a839224dbf24ef8aa (patch)
tree6a3bb0fd654581e5fe257260db4589630a5993bc /sfeed_update
parent373cabcf7b96ebafc8cd544de5f08bda3e81b375 (diff)
sfeed_update: set exit status non-zero if any of the feeds failed
In practise this may change the meaning of the examples: sfeed_update && pkill -SIGHUP sfeed_curses An alternative: sfeed_update; pkill -SIGHUP sfeed_curses
Diffstat (limited to 'sfeed_update')
-rwxr-xr-xsfeed_update11
1 files changed, 9 insertions, 2 deletions
diff --git a/sfeed_update b/sfeed_update
index b5f38bc..f2c97ae 100755
--- a/sfeed_update
+++ b/sfeed_update
@@ -41,6 +41,8 @@ log() {
# log_error(name, s)
log_error() {
printf '[%s] %-50.50s %s\n' "$(date +'%H:%M:%S')" "$1" "$2" >&2
+ # set error exit status indicator for parallel jobs.
+ rm -f "${sfeedtmpdir}/ok"
}
# fetch a feed via HTTP/HTTPS etc.
@@ -96,7 +98,7 @@ _feed() {
filename="$(printf '%s' "${name}" | tr '/' '_')"
sfeedfile="${sfeedpath}/${filename}"
- tmpfeedfile="${sfeedtmpdir}/${filename}"
+ tmpfeedfile="${sfeedtmpdir}/feeds/${filename}"
# if file does not exist yet create it.
[ -e "${sfeedfile}" ] || touch "${sfeedfile}" 2>/dev/null
@@ -201,17 +203,22 @@ main() {
loadconfig "$1"
# fetch feeds and store in temporary directory.
sfeedtmpdir="$(mktemp -d '/tmp/sfeed_XXXXXX')"
+ mkdir -p "${sfeedtmpdir}/feeds"
+ touch "${sfeedtmpdir}/ok"
# make sure path exists.
mkdir -p "${sfeedpath}"
# fetch feeds specified in config file.
feeds
# wait till all feeds are fetched (concurrently).
[ ${signo} -eq 0 ] && wait
+ # check error exit status indicator for parallel jobs.
+ test -f "${sfeedtmpdir}/ok"
+ status=$?
# cleanup temporary files etc.
cleanup
# on signal SIGINT and SIGTERM exit with signal number + 128.
[ ${signo} -ne 0 ] && exit $((signo+128))
- return 0
+ return ${status}
}
[ "${SFEED_UPDATE_INCLUDE}" = "1" ] || main "$@"