diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-02-10 14:05:22 +0300 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-02-10 14:05:22 +0300 |
commit | 70f9e1846d31442eae2a883013ee8f24dd134e91 (patch) | |
tree | 0a0bcbe8926f5a417d790f98206ca01c57c5232c | |
parent | 55ad7e30e35fbf69b5ec48859308dc87d7582204 (diff) |
pkgupdate-watch.sh: make output more useful
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rwxr-xr-x | pkgupdate-watch.sh | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/pkgupdate-watch.sh b/pkgupdate-watch.sh index 64a8ff9..a4393b3 100755 --- a/pkgupdate-watch.sh +++ b/pkgupdate-watch.sh @@ -1,28 +1,29 @@ -#!/bin/bash +#!/usr/bin/env bash . ./shared/functions.sh -sdkdir="$(readlink -f $CACHE_DIR/sdk/)/" +trap 'clear; exit 0' SIGINT SIGTERM + +clear while true; do - out="$( - date - grep -slE "^Uid:\s+$(id -u)\s" /proc/[0-9]*/status | while read pid; do - pid="${pid#/proc/}" - pid="${pid%/status}" + echo -en "\033[0;0f" + fetch_remote_targets | while read target; do ( + cd "$CACHE_DIR/sdk/$target" + log="$(find logs/ -type f -name compile.txt -printf '%C@ %h\n' 2>/dev/null | \ + sort -nr | sed -ne '1s/^[0-9.]\+ //p')" - cwd="$(readlink "/proc/$pid/cwd" 2>/dev/null)" - case "$cwd" in $sdkdir*) - cmd="$(cat "/proc/$pid/cmdline" 2>/dev/null | tr '\0' ' ' | head -n 1)" - #case "$cmd" in "make -C "*) - cwd="${cwd%%/build_dir/*}" - echo "[${cwd:${#sdkdir}}] ${cmd:0:72}" - #;; esac - ;; esac - done | sort - )" + if [ -d "$log" ]; then + msg="$(tail -n1 "$log/compile.txt")" + if [ ${#msg} -gt 80 ]; then + msg="${msg:0:80}" + fi + else + log="-" + msg="" + fi - clear - echo "$out" - sleep 2 + printf "\033[K%-20s %-16s %s\n" "[$target]" "[${log##*/}]" "$msg" + ); done + sleep 1 done |