diff options
author | Eric Hameleers <alien@slackware.com> | 2020-09-05 21:56:21 +0200 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2020-09-05 21:56:21 +0200 |
commit | 8665fb1422c6f5ef1cd7e094a749f6281b94f168 (patch) | |
tree | f54e9b1a0c629bceb206c073c0e300bbb0358f7b /liveinit.tpl | |
parent | 1268af2d50338331f7fc59fd27f3c6bd22e20f0a (diff) | |
download | liveslak-8665fb1422c6f5ef1cd7e094a749f6281b94f168.tar.gz liveslak-8665fb1422c6f5ef1cd7e094a749f6281b94f168.tar.xz |
Allow a custom domain name for the live host
New boot parameter: "domain=your_custom_domain",
The domain component defaults to 'example.net'.
Diffstat (limited to 'liveinit.tpl')
-rw-r--r-- | liveinit.tpl | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/liveinit.tpl b/liveinit.tpl index 2251553..231c297 100644 --- a/liveinit.tpl +++ b/liveinit.tpl @@ -143,9 +143,18 @@ for ARG in $(cat /proc/cmdline); do dhcpwait=*) DHCPWAIT=$(echo $ARG | cut -f2 -d=) ;; + domain=*) + # generic syntax: sub.domain.some + LIVE_DOMAIN=$(echo $ARG | cut -f2 -d=) + ;; hostname=*) # generic syntax: hostname=newname[,qualifier] LIVE_HOSTNAME=$(echo $ARG | cut -f2 -d= | cut -f1 -d,) + # Allow for the user to (mistakenly) add a domain component: + if [ $(echo $LIVE_HOSTNAME |cut -d. -f1- --output-delimiter ' '|wc -w) -gt 1 ]; then + LIVE_DOMAIN=$(echo $LIVE_HOSTNAME |cut -d. -f2-) + LIVE_HOSTNAME=$(echo $LIVE_HOSTNAME |cut -d. -f1) + fi if [ "$(echo $ARG | cut -f2 -d= | cut -f2 -d,)" = "fixed" ]; then Keep hostname fixed i.e. never add a MAC address suffix: HNMAC_ALLOWED="NO" @@ -1133,15 +1142,20 @@ EOPW fi fi + if [ -z "$LIVE_DOMAIN" ]; then + # No custom domain on the boot commandline: + LIVE_DOMAIN="example.net" + fi + if [ ! -z "$LIVE_HOSTNAME" ]; then # User entered a custom hostname on the boot commandline: echo "${MARKER}: Changing hostname to '$LIVE_HOSTNAME'." - echo "${LIVE_HOSTNAME}.example.net" > /mnt/overlay/etc/HOSTNAME + echo "${LIVE_HOSTNAME}.${LIVE_DOMAIN}" > /mnt/overlay/etc/HOSTNAME if [ -f /mnt/overlay/etc/NetworkManager/NetworkManager.conf ]; then sed -i -e "s/^hostname=.*/hostname=${LIVE_HOSTNAME}/" \ /mnt/overlay/etc/NetworkManager/NetworkManager.conf fi - sed -i -e "s/^\(127.0.0.1\t*\)@DARKSTAR@.*/\1${LIVE_HOSTNAME}.example.net ${LIVE_HOSTNAME}/" /mnt/overlay/etc/hosts + sed -i -e "s/^\(127.0.0.1\t*\)@DARKSTAR@.*/\1${LIVE_HOSTNAME}.${LIVE_DOMAIN} ${LIVE_HOSTNAME}/" /mnt/overlay/etc/hosts fi if [ -n "$NFSHOST" ]; then |