summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-17 19:05:56 +0200
committerSimon Rettberg2016-10-17 19:05:56 +0200
commit529bb1c4b20dc6264a0978b0130657c6f8b61425 (patch)
tree6bb1150e3d570ad1375155e2256c68c3dd1fd486
parent[hardware-stats] Fix /tmp check... (diff)
downloadtm-scripts-529bb1c4b20dc6264a0978b0130657c6f8b61425.tar.gz
tm-scripts-529bb1c4b20dc6264a0978b0130657c6f8b61425.tar.xz
tm-scripts-529bb1c4b20dc6264a0978b0130657c6f8b61425.zip
[rfs-stage32] Improve /etc/issue generator
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue44
-rw-r--r--remote/rootfs/rootfs-stage32/templates/issue.template6
2 files changed, 41 insertions, 9 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
index 4d2de8b7..d3086176 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
@@ -1,4 +1,5 @@
-#!/bin/ash
+#!/bin/bash
+# Needs bash for string manipulation
# Copyright (c) 2013, 2014 - bwLehrpool Projekt
# Copyright (c) 2012 - OpenSLX GmbH
#
@@ -14,11 +15,40 @@
#############################################################################
# Set greeting and add information about the booted system
-len=$(expr length "$(cat /etc/hostname)")
-while [ $len -le 56 ] ; do
- space="$space "
- len=$(($len + 1))
-done
-sed "s/%space%/$space/g" /opt/openslx/etc/issue.template > /etc/issue
+declare -rg INFILE=/opt/openslx/etc/issue.template
+declare -rg TMPFILE=$(mktemp)
+declare -rg OUTFILE=/etc/issue
+
+. /opt/openslx/config
+
+# Replace known variables and determine maximum line length
+MAX=0
+while IFS='' read -r line || [ -n "$line" ]; do
+ line="${line/"%ip%"/"$SLX_PXE_CLIENT_IP"}"
+ line="${line/"%hostname%"/"$SLX_HOSTNAME"}"
+ len=${#line}
+ [ "$len" -gt "$MAX" ] && MAX=$len
+ echo "$line"
+done < "$INFILE" > "$TMPFILE"
+
+# Fix up spacing for right-aligned text
+while IFS='' read -r line || [ -n "$line" ]; do
+ tst=${line/"%space%"/}
+ if [ "$(( ${#line} - ${#tst} ))" -eq 7 ]; then
+ space=
+ while true; do
+ tst=${line/"%space%"/"$space"}
+ if [ "${#tst}" -ge "$MAX" ]; then
+ line="$tst"
+ break
+ fi
+ space=" $space"
+ done
+ fi
+ echo "$line"
+done < "$TMPFILE" > "$OUTFILE"
+
+rm -f -- "$TMPFILE"
+
diff --git a/remote/rootfs/rootfs-stage32/templates/issue.template b/remote/rootfs/rootfs-stage32/templates/issue.template
index a79797ad..adf1f38e 100644
--- a/remote/rootfs/rootfs-stage32/templates/issue.template
+++ b/remote/rootfs/rootfs-stage32/templates/issue.template
@@ -1,4 +1,5 @@
- WELCOME TO %space% \n (\l)
+-- \l
+ WELCOME TO %space% %hostname% [%ip%]
_____ ______ ______ __ __ _______ __ __ __
/ _ | _ | ___| | | | | ____| | | | | |
| | | | |_| | |_ | | | | |___ | | / /
@@ -6,4 +7,5 @@
| |_| | | | |___| | | | ____| | |___ / /
_____/|__| |______|__| |__| |_______|______|__| |__| - NG
- %version% (c) <OpenSLX.ORG>
+ %version% %space% (c) <OpenSLX.ORG>
+