diff options
author | Simon Rettberg | 2019-04-10 10:56:33 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-04-10 10:56:33 +0200 |
commit | c98fe08fd43ff378a04deae1c3c0ed5b3c1b17dd (patch) | |
tree | ec15dcea5c99867d2764550f4f4f959f25bba67b /core/modules/slx-issue | |
parent | [kernel-vanilla] Remove temporary hack (diff) | |
download | mltk-c98fe08fd43ff378a04deae1c3c0ed5b3c1b17dd.tar.gz mltk-c98fe08fd43ff378a04deae1c3c0ed5b3c1b17dd.tar.xz mltk-c98fe08fd43ff378a04deae1c3c0ed5b3c1b17dd.zip |
[slx-issue] Force lines to be no longer than console width
Diffstat (limited to 'core/modules/slx-issue')
-rwxr-xr-x | core/modules/slx-issue/data/opt/openslx/scripts/openslx-create_issue | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/core/modules/slx-issue/data/opt/openslx/scripts/openslx-create_issue b/core/modules/slx-issue/data/opt/openslx/scripts/openslx-create_issue index 53fbd0eb..8165d310 100755 --- a/core/modules/slx-issue/data/opt/openslx/scripts/openslx-create_issue +++ b/core/modules/slx-issue/data/opt/openslx/scripts/openslx-create_issue @@ -50,27 +50,35 @@ fi tmpstatus="$(df -P | grep -m1 ' /tmp$' | awk '{printf "%.1f", $2 / 1024 / 1024}')GiB ($tmpstatus)" cat >> "$TMPFILE" <<EOF -System model: %space% $system -Kernel version: %space% $kernel -Temporary directory: %space% $tmpstatus -Boot server: %space% $SLX_PXE_SERVER_IP -Client address: %space% $SLX_PXE_CLIENT_IP +System model:%space% $system +Kernel version:%space% $kernel +Temporary directory:%space% $tmpstatus +Boot server:%space% $SLX_PXE_SERVER_IP +Client address:%space% $SLX_PXE_CLIENT_IP EOF if [ -n "$linkspeed" ]; then - echo "Link speed: %space% ${linkspeed}MBit" >> "$TMPFILE" + echo "Link speed:%space% ${linkspeed}MBit" >> "$TMPFILE" fi if [ -n "$SLX_SHUTDOWN_SCHEDULE" ]; then - echo "Scheduled shutdown: %space% $SLX_SHUTDOWN_SCHEDULE" >> "$TMPFILE" + echo "Scheduled shutdown:%space% $SLX_SHUTDOWN_SCHEDULE" >> "$TMPFILE" fi if [ -n "$SLX_REBOOT_SCHEDULE" ]; then - echo "Scheduled reboot: %space% $SLX_REBOOT_SCHEDULE" >> "$TMPFILE" + echo "Scheduled reboot:%space% $SLX_REBOOT_SCHEDULE" >> "$TMPFILE" fi if [ -n "$player" ]; then - echo "VMware version: %space% ${player//'"'/}" >> "$TMPFILE" + echo "VMware version:%space% ${player//'"'/}" >> "$TMPFILE" fi echo "" >> "$TMPFILE" +# Crop to console width +T=$( tput cols 2> /dev/console ) +if [ -z "$T" ]; then + T=$( stty size < /dev/console ) + T="${T#* }" +fi +[ -n "$T" ] && [ "$T" -le "$MAX" ] && MAX=$(( T - 1 )) + # Fix up spacing for right-aligned text while IFS='' read -r line || [ -n "$line" ]; do tst=${line/"%space%"/} @@ -85,9 +93,9 @@ while IFS='' read -r line || [ -n "$line" ]; do space=" $space" done fi - echo "$line" + echo "${line:0:$MAX}" done < "$TMPFILE" > "$OUTFILE" rm -f -- "$TMPFILE" - +exit 0 |