From: Ian Kelling Date: Thu, 3 Oct 2024 10:10:41 +0000 (-0400) Subject: minor fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=54a99e16ea0fbec0f43179566b8827e070d2b707;p=distro-setup minor fixes --- diff --git a/brc b/brc index 6a6565a..97f5c34 100644 --- a/brc +++ b/brc @@ -2804,17 +2804,33 @@ serstat() { # journalctl -f FINAL_ARG, then systemctl $@ . # detects any existing background job so we can -# run multiple times without making duplicate output. +# run multiple times without making duplicate output. todo: not right now. serj() { - local service jr_pid ret jobs_out regex + local service jr_pid ret regex tmpstr found_job + local -a jobs_out ret=0 service="${*: -1}" - jobs_out=$(jobs 2>/dev/null) - regex="^[^[:space]]+[[:space:]]+Running[[:space:]]+ journalctl -qn2 -f -u $service &" + tmpstr=$(jobs 2>/dev/null) + mapfile -t jobs_out <<<"$tmpstr" + found_job=false + regex="^[^[:space:]]+[[:space:]]+Running[[:space:]]+ journalctl --since=now -qn2 -f -u $service &" + for line in "${jobs_out[@]}"; do + if [[ $line =~ $regex ]]; then + found_job=true + fi + done - journalctl -qn2 -f -u "$service" & - sleep 3 - s systemctl "$@" || ret=$? + if ! $found_job; then + journalctl --since=now -qn2 -f -u "$service" & + sleep 3 + fi + if [[ $EUID == 0 ]]; then + systemctl "$@" || ret=$? + else + # it adds like 50 chars of whitespace to each log line without + # --no-block. its some interaction with sudo i guess? + s systemctl --no-block "$@" || ret=$? + fi if (( ret != 0 )); then echo "serj: note: systemctl returned nonzero, but journalctl worked and is running." return $ret diff --git a/system-status b/system-status index d116534..95cf0c0 100755 --- a/system-status +++ b/system-status @@ -444,6 +444,8 @@ write-status() { if [[ ! -e $status_file || -w $status_file ]]; then if [[ -e /a/bin/bash_unpublished/source-state ]]; then cat /a/bin/bash_unpublished/source-state >$status_file + else + sed -i --follow-symlinks '/^ps_char=/d' $status_file fi if [[ ${chars[*]} ]]; then