summaryrefslogtreecommitdiffstats
path: root/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
diff options
context:
space:
mode:
Diffstat (limited to 'remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue')
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue44
1 files changed, 37 insertions, 7 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"
+