X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=system-status;h=b3c22e4ea8126f1a24330b039aceef3803ed1d03;hp=d6db7c3eb57b351c01b97c627376f55ad424e33f;hb=79b274fcd8bfa556133ab13270e84b40aebe8468;hpb=313bf2239f766a5a1d060133131b477478873ad7 diff --git a/system-status b/system-status index d6db7c3..b3c22e4 100755 --- a/system-status +++ b/system-status @@ -45,17 +45,30 @@ write-status() { chars+=("MAILPING!") fi - qlen=$(/usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}') + if ! qlen=$(/usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}'); then + # early in install process, we dont have permission yet for exiqgrep + qlen=$(sudo /usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}') + fi if ((qlen)); then chars+=("q $qlen") fi + begin=false cd /b/ds if ! make -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then - chars+=("DISTRO-BEGIN!") + begin=true fi + end=false if ! make -q ~/.local/distro-end || [[ $(<~/.local/distro-end) != 0 ]]; then + end=true + fi + + if $begin && $end; then + chars+=("DISTRO!") + elif $begin; then + chars+=("DISTRO-BEGIN!") + elif $end; then chars+=("DISTRO-END!") fi @@ -64,6 +77,8 @@ write-status() { if [[ -e $f ]]; then now=$(date +%s) fsec=$(stat -c%Y $f) + # the / 60 makes it 0-59 seconds less strict, +1 makes sure we + # dont have any false positives. fmin=$(( (fsec - now ) / 60 + 1 )) fminplus=$(( fmin + 60*24 )) # Filesystem files get copied, so find any newer than the last run. @@ -78,6 +93,7 @@ write-status() { if grep -qxF $HOSTNAME $x; then all_dirs+=( ${x%.hosts} ); fi done + # just because i forget a lot, -mmin -NUM means files modified <= NUM minutes ago if (( $(date -d "$(git log --diff-filter=ACR --format=%aD -1)" +%s) > fsec )) || \ [[ $(find ${all_dirs[@]} -mmin $fmin -type f -print -quit 2>/dev/null) ]]; then v conflink newer git or newer filesystem files @@ -87,6 +103,10 @@ write-status() { for d in /a/bin/distro-setup /p/c; do cd $d + if [[ ! -e .git ]]; then + # some hosts i dont push all of /p/c + continue + fi untracked=$(git ls-files -o --exclude-standard) if [[ $untracked && $(find $untracked -mmin $fminplus -type f -print -quit) ]]; then v conflink: untracked in $d @@ -154,7 +174,7 @@ write-status() { fi done if (( maxtime < now - 60*60 )); then - chars+=("OLD-SNAPSHOT!") + chars+=("OLD-SNAP!") snapshotmsg="/o snapshot older than 1 hour" fi lo -1 old-snapshot $snapshotmsg