Skip to content

Commit

Permalink
config.d.sh: fix so that if any configs error, the script itself retu…
Browse files Browse the repository at this point in the history
…rns an error. Add timing for each individual config.
  • Loading branch information
Thomas Wiest committed Sep 7, 2024
1 parent c8ca2a4 commit 8ac4616
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion silverblue-base/files/config.d/config.d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

configd_dirs="/etc/config.d /usr/local/etc/config.d/all /usr/local/etc/config.d/$(hostname)"

script_exit_code=0
for configd_dir in $configd_dirs; do
if [ ! -d "$configd_dir" ]; then
echo "Skipping [$configd_dir]... directory doesn't exist."
Expand All @@ -23,6 +24,13 @@ for configd_dir in $configd_dirs; do
echo " Running [$script]"

# Run the script and pre-pend padding so that it looks good in journald
bash -c "${script}" | sed 's/^/ /'
/usr/bin/time -p bash -c "${script} 2>&1" 2>&1 | sed 's/^/ /'
retval=${PIPESTATUS[0]}

if [ $retval != 0 ]; then
script_exit_code=$retval
fi
done
done

exit $script_exit_code

0 comments on commit 8ac4616

Please sign in to comment.