Skip to content

Commit

Permalink
scripts/upsdrvsvcctl/upsdrvsvcctl.in: adjust SVC_NAME_WIDTH to framew…
Browse files Browse the repository at this point in the history
…ork type too [networkupstools#2567]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Aug 1, 2024
1 parent 30cec0d commit 5d4338b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/upsdrvsvcctl/upsdrvsvcctl.in
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,18 @@ while [ $# -gt 0 ]; do
# Use a common approach below, even if we only got one instance name from list()
if [ -n "$2" ] && [ -n "${SVCINSTS}" ] ; then SVCINSTS="${SVCINSTS} $2" ; fi

# Accomodate svc:/system/power/nut-driver:dummy (SMF)
# or [email protected] (systemd)
case "$SERVICE_FRAMEWORK" in
smf) SVC_STATE_WIDTH="11" ;;
systemd) SVC_STATE_WIDTH="23" ;;
smf) SVC_NAME_WIDTH="39" ; SVC_STATE_WIDTH="11" ;;
systemd) SVC_NAME_WIDTH="30" ; SVC_STATE_WIDTH="23" ;;
esac

echo "$STATUSES" | ( COUNT=0; while IFS='' read LINE ; do
COUNT="`expr $COUNT + 1`"
if [ "$COUNT" = 1 ] ; then
# Header line
printf '%-30s\t%'"${SVC_STATE_WIDTH}"'s\t%s\n' "SVC_NAME" "SVC_STATE" "$LINE"
printf '%-'"${SVC_NAME_WIDTH}"'s\t%'"${SVC_STATE_WIDTH}"'s\t%s\n' "SVC_NAME" "SVC_STATE" "$LINE"
continue
fi
DEV_NAME="`echo "$LINE" | awk '{print $1}'`"
Expand Down Expand Up @@ -224,7 +226,7 @@ while [ $# -gt 0 ]; do
;;
esac
fi
printf '%-30s\t%'"${SVC_STATE_WIDTH}"'s\t%s\n' "$SVC_NAME" "$SVC_STATE" "$LINE"
printf '%-'"${SVC_NAME_WIDTH}"'s\t%'"${SVC_STATE_WIDTH}"'s\t%s\n' "$SVC_NAME" "$SVC_STATE" "$LINE"
done )
exit $RES
;;
Expand Down

0 comments on commit 5d4338b

Please sign in to comment.