From 181654d44ff2db96eac470c9de4b1f6f6125660c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 27 Mar 2018 11:54:55 +0200 Subject: bin/ii-connect: use inotify-wait, interprete "wtf" --- README.md | 1 + bin/ii-connect | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/README.md b/README.md index 334b4bb..d2dbfd2 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This includes scripts to be run on the build master as well as scripts to be run * `git` * `graphviz` * `ii` +* `inotify-tools` * some mysql-server * `nginx` or equivalent * `php-gd` diff --git a/bin/ii-connect b/bin/ii-connect index 5f8aacc..7ac589c 100755 --- a/bin/ii-connect +++ b/bin/ii-connect @@ -37,7 +37,18 @@ fi # watch if asked to if [ "$1" = 'watch' ]; then + done_something=false while pgrep -x 'ii' > /dev/null; do + # this avoids missing modifications during our last execution + if ! ${done_something}; then + # shellcheck disable=SC2046 + inotifywait -e 'CLOSE_WRITE,CLOSE' $( + find "${irc_dir}" \ + -type f \ + -name 'out' + ) + fi + done_something=false find "${irc_dir}" \ -type f \ -name 'out' \ @@ -52,6 +63,7 @@ if [ "$1" = 'watch' ]; then fi regex='^\(\S\+ \)\?\S\+ <\S\+> '"${prefix}"'why[- ]don'"'"'\?t[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) ' if grep -q "${regex}" "${out_file}"; then + done_something=true sed -n ' s/'"${regex}"'/\2 / T @@ -73,6 +85,30 @@ if [ "$1" = 'watch' ]; then done sed -i "/${regex}/d" "${out_file}" fi + regex='^\(\S\+ \)\?\S\+ <\S\+> '"${prefix}"'wtf ' + if grep -q "${regex}" "${out_file}"; then + done_something=true + sed -n ' + s/'"${regex}"'// + T + p + ' "${out_file}" | \ + while read -r line; do + reason=$( + echo "${line}" | \ + xargs "${base_dir}/bin/wtf" 2>&1 + ) + if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then + echo "${reason}" + else + echo "${reason}" | \ + head -n5 + printf '... (%s lines total)\n' "$(echo "${reason}" | wc -l)" + fi | \ + sponge "${out_file%/out}/in" + done + sed -i "/${regex}/d" "${out_file}" + fi done sleep 1 done -- cgit v1.2.3