summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2013-08-13 23:25:52 +0200
committerSimon Rettberg2013-08-13 23:25:52 +0200
commit6dbe346fdb79658a5d0d590f52e820331a6ad029 (patch)
tree90de0edb5c746c1a9dced179e3b5aba1dac85216
parent[dnbd3] update requested git commit of dnbd3 (diff)
downloadtm-scripts-6dbe346fdb79658a5d0d590f52e820331a6ad029.tar.gz
tm-scripts-6dbe346fdb79658a5d0d590f52e820331a6ad029.tar.xz
tm-scripts-6dbe346fdb79658a5d0d590f52e820331a6ad029.zip
[rootfs-stage32] Properly generate and update /etc/issue with version information
-rw-r--r--remote/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service9
-rw-r--r--remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue12
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx84
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.build8
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.conf1
-rw-r--r--remote/rootfs/rootfs-stage32/templates/issue.template9
6 files changed, 67 insertions, 56 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service
new file mode 100644
index 00000000..c4f45a3c
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Update /etc/issue
+Before=sysinit.target shutdown.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/openslx-create_issue
+RemainAfterExit=no
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
new file mode 100644
index 00000000..c09162dc
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
@@ -0,0 +1,12 @@
+#/bin/sh
+
+# Set greeting and add information on booted system
+# Fixme (add version string and distro name)
+len=$(expr length "$(cat /etc/hostname)")
+while [ $len -le 52 ] ; do
+ space="$space "
+ len=$(($len + 1))
+done
+
+sed "s/%space%/$space/g" /opt/openslx/etc/issue.template > /etc/issue
+
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx
index b49e2207..fd88ca30 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx
@@ -43,12 +43,12 @@ case "$1" in
if [ -n "$router" ]; then
ip route add default via "$router"
fi
-
+
# Update resolver configuration file
CONF=""
if [ -n "$domain" ]; then
printf -v CONF "domain $domain\nsearch $domain\n"
- elif [ -n "$SLX_NET_DOMAIN" ]; then
+ elif [ -n "$SLX_NET_DOMAIN" ]; then
printf -v CONF "domain $SLX_NET_DOMAIN\nsearch $SLX_NET_DOMAIN\n"
fi
for i in $dns; do
@@ -71,55 +71,29 @@ case "$1" in
# Update IP
sed -i "s/^\(SLX_PXE_CLIENT_IP=\).*$/\1'$ip'/" /opt/openslx/config
- # Update hostname
- dns_host=$(rdns "$ip")
- if [ -z "$dns_host" ]; then
- # fallback to what the dhcp told us
- dns_host="$hostname"
- fi
- # Avoid empty hostnames
- [ -z "$dns_host" ] && dns_host="slx-client"
- echo "$dns_host" > "/proc/sys/kernel/hostname"
- echo "$dns_host" > "/etc/hostname"
- if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then
- sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_host'/" /opt/openslx/config
- else
- echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config
- echo "SLX_HOSTNAME='$dns_host'" >> /opt/openslx/config
+ # Only if network is not ready yet
+ if [ ! -e "/run/udhcpc/network-ready" ]; then
+ # Update hostname
+ dns_host=$(rdns "$ip")
+ if [ -z "$dns_host" ]; then
+ # fallback to what the dhcp told us
+ dns_host="$hostname"
+ fi
+ # Avoid empty hostnames
+ [ -z "$dns_host" ] && dns_host="slx-client"
+ echo "$dns_host" > "/proc/sys/kernel/hostname"
+ echo "$dns_host" > "/etc/hostname"
+ if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then
+ sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_host'/" /opt/openslx/config
+ else
+ echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config
+ echo "SLX_HOSTNAME='$dns_host'" >> /opt/openslx/config
+ fi
+ # Update /etc/issue for proper spacing
+ /opt/openslx/scripts/openslx-create_issue
fi
- # Set greeting and add information on booted system
- # Fixme (add version string and distro name)
- version="bwLehrpools/<distro-name>-<version>"
- len=$(expr length ${version})
- if [ $len -le 28 ] ; then
- vdstr="Stateless Workstation (${version})"
- smax=52
- else
- vdstr="${version}"
- smax=76
- fi
- while [ $len -le $smax ] ; do
- vdstr="$vdstr "
- len=$(($len + 1))
- done
- len=$(expr length ${dns_host})
- while [ $len -le 52 ] ; do
- space="$space "
- len=$(($len + 1))
- done
- echo "
- WELCOME TO $space \n (\l)
- _____ ______ ______ __ __ _______ __ __ __ __ __ ______
- / _ | _ | ___| | | | | ____| | | | | | | | | |/ ____|
- | | | | |_| | |_ | | | | |___ | | / / __ | | | | | ___
- | | | | ___/| _| | | ____ | | | | |__| | | | |_ |
- | |_| | | | |___| | | | ____| | |___ / / | | | | |___ |
- _____/|__| |______|__| |__| |_______|______|__| |__| |__| |__| ______/
-
- $vdstr (c) <OpenSLX.ORG>
-" > /etc/issue
fi
-
+
# Hostname in /etc/hosts
touch /etc/hosts
if [ -n "$dns_host" ]; then
@@ -145,7 +119,7 @@ case "$1" in
fi
fi
sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts
-
+
# We consider the network setup to be complete if an interface is being configured that
# has a default route and some dns servers set.
if [ -n "$router" ] && [ -n "$dns" ] && [ ! -e "/run/udhcpc/network-ready" ]; then
@@ -174,7 +148,7 @@ case "$1" in
else
echo "NFS is active, not removing old ip adress. warning: lease may expire after a while."
fi
-
+
if [ -x /sbin/resolvconf ]; then
# Automatic handling :-)
resolvconf -d "${interface}.udhcpc"
@@ -183,23 +157,23 @@ case "$1" in
rm -f "$THISFILE"
rebuild_resolv_conf
fi
-
+
;;
leasefail)
echo "$0: Lease failed: $message"
-
+
;;
nak)
echo "$0: Received a NAK: $message"
-
+
;;
*)
echo "$0: Unknown udhcpc command: $1";
exit 1;
-
+
;;
esac
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build
index 596d8deb..66805660 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build
@@ -53,6 +53,7 @@ build() {
local NUMFILES=$(cat "${FILELIST}" | wc -l)
if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then
pinfo "File list generated at ${MODULE_BUILD_DIR}/${FILELIST} ($NUMFILES entries)"
+ pinfo "If something fails here, try to clean this module first."
tarcopy "$(cat "${FILELIST}")" "${MODULE_BUILD_DIR}"
fi
}
@@ -126,6 +127,13 @@ post_copy() {
pwarning "Could not determine distribution"
fi
fi
+ # Create issue.template
+ local DIST=$(lsb_release -sd)
+ local GITC=$(git rev-parse --short HEAD)
+ local DATE=$(date "+%Y-%m-%d")
+ local VERSION=$(echo "bwLehrpool/$DIST built $DATE (git: $GITC)" | escape_replace)
+ mkdir "$TARGET_BUILD_DIR/opt/openslx/etc"
+ sed "s/%version%/$VERSION/g" templates/issue.template > "$TARGET_BUILD_DIR/opt/openslx/etc/issue.template" || perror "Could not create issue template"
}
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
index fb56f7d9..dcdcd347 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
@@ -53,7 +53,6 @@ REQUIRED_LIBRARIES=" libcap
libresolv
libau"
REQUIRED_FILES="
- /etc/issue
/etc/inputrc
/etc/localtime
/etc/login.defs
diff --git a/remote/rootfs/rootfs-stage32/templates/issue.template b/remote/rootfs/rootfs-stage32/templates/issue.template
new file mode 100644
index 00000000..e15c19d5
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/templates/issue.template
@@ -0,0 +1,9 @@
+ WELCOME TO %space% \n (\l)
+ _____ ______ ______ __ __ _______ __ __ __
+ / _ | _ | ___| | | | | ____| | | | | |
+ | | | | |_| | |_ | | | | |___ | | / /
+ | | | | ___/| _| | | ____ | | | |
+ | |_| | | | |___| | | | ____| | |___ / /
+ _____/|__| |______|__| |__| |_______|______|__| |__| - NG
+
+ %version% (c) <OpenSLX.ORG>