ypbind-mt: get parameters from dhcp
PATCH 1/1 ypbind-mt: get parameters from dhcp
From: Li Wang <[email protected]>
the script nis.sh is called by dhcp client,
it can get some parameters from dhcp.
--- .../recipes-support/nis/ypbind-mt/nis.sh | 41 ++++++++++++++++++++++ .../recipes-support/nis/ypbind-mt/yp.conf | 1 + .../recipes-support/nis/ypbind-mt_1.38.bb | 6 ++++ 3 files changed, 48 insertions(+) create mode 100755 meta-networking/recipes-support/nis/ypbind-mt/nis.sh create mode 100644 meta-networking/recipes-support/nis/ypbind-mt/yp.conf
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +41 -0
@@ -0,0 +1,41 @@ +#!/bin/bash +# +# nis.sh: dhclient-script plugin for NIS settings, +# place in /etc/dhcp/dhclient.d and 'chmod +x nis.sh' to enable +# + +CONF=/etc/yp.conf +SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface} + +nis_replace_conf() { + echo "$1" | diff -q ${CONF} - > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "$1" > ${CONF} +# restorecon ${CONF} >/dev/null 2>&1 + service ypbind restart >/dev/null 2>&1 + fi +} + +nis_config() { + if [ -n "${new_nis_domain}" ] && [ -n "${new_nis_servers}" ] && + [ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then + local conf=$(grep -v '^domain .* # added by /sbin/dhclient-script$' < ${CONF}) + + conf=$(echo "$conf" + for s in ${new_nis_servers}; do + echo "domain ${new_nis_domain} server ${s} # added by /sbin/dhclient-script" + done) + + [ -f ${SAVECONF} ] || touch ${SAVECONF} + nis_replace_conf "$conf" + fi +} + +nis_restore() { + if [ -e ${CONF} ] && [ -f ${SAVECONF} ]; then + local conf=$(grep -v '^domain .* # added by /sbin/dhclient-script$' < ${CONF}) + + nis_replace_conf "$conf" + rm -f ${SAVECONF} + fi +}
meta-networking/recipes-support/nis/ypbind-mt/yp.conf new file +1 -0
@@ -0,0 +1 @@ +#
meta-networking/recipes-support/nis/ypbind-mt_1.38.bb +6 -0
@@ -28,6 +28,8 @@ PROVIDES += "ypbind" SRC_URI = "http://www.linux-nis.org/download/ypbind-mt/${BP}.tar.bz2 \ file://ypbind-yocto.init \ file://ypbind.service \ + file://yp.conf \ + file://nis.sh \ " SRC_URI[md5sum] = "094088c0e282fa7f3b3dd6cc51d0a4e1" SRC_URI[sha256sum] = "1930ce19f6ccfe10400f3497b31867f71690d2bcd3f5b575199fa915559b7746"
@@ -44,10 +46,14 @@ do_install_append () { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d + install -m 0744 ${WORKDIR}/yp.conf ${D}${sysconfdir}/ install -m 0755 ${WORKDIR}/ypbind-yocto.init ${D}${sysconfdir}/init.d/ypbind install -d ${D}${systemd_unitdir}/system install -m 0644 ${WORKDIR}/ypbind.service ${D}${systemd_unitdir}/system + + install -d ${D}/${sysconfdir}/dhcp/dhclient.d + install -m 755 ${WORKDIR}/nis.sh ${D}/${sysconfdir}/dhcp/dhclient.d/ }
Signature · 1 line
1.9.1
Quoted 20 lines · [[oe] [PATCH][meta-networking] ypbind-mt: get parameters from dhcp] On…
From: Li Wang <[email protected]>
the script
nis.shis called by dhcp client,
it can get some parameters from dhcp.Signed-off-by Li Wang <[email protected]>--- .../recipes-support/nis/ypbind-mt/nis.sh | 41 ++++++++++++++++++++++ .../recipes-support/nis/ypbind-mt/yp.conf | 1 + .../recipes-support/nis/ypbind-mt_1.38.bb | 6 ++++ 3 files changed, 48 insertions(+) create mode 100755 meta-networking/recipes-support/nis/ypbind-mt/nis.sh create mode 100644 meta-networking/recipes-support/nis/ypbind-mt/yp.confmeta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +0
-0
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 1
Quoted 1 line
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +1
-0@@ -0,0 +1,41 @@ +#!/bin/bash
I wasn't able to find anything bash-specific in this script, can you change this to /bin/sh, please?
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 8
Quoted 7 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +7
-0+# +# nis.sh: dhclient-script plugin for NIS settings, +# place in /etc/dhcp/dhclient.d and 'chmod +x nis.sh' to enable +# + +CONF=/etc/yp.conf +SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface}
Where's SAVEDIR set again? It comes from the calling environment?
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 14
Quoted 6 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +6
-0+ +nis_replace_conf() { + echo "$1" | diff -q ${CONF} - > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "$1" > ${CONF} +# restorecon ${CONF} >/dev/null 2>&1
I'm not sure what to make of this, maybe you want to make a parameter to optionally run restorecon? Or maybe a separate patch for meta-selinux with restorecon stuff in it? Either way, please don't leave this as dead code.
Quoted 12 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +12
-0+ service ypbind restart >/dev/null 2>&1 + fi +} + +nis_config() { + if [ -n "${new_nis_domain}" ] && [ -n "${new_nis_servers}" ] && + [ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then + local conf=$(grep -v '^domain .* # added by /sbin/dhclient-script$' < ${CONF}) + + conf=$(echo "$conf" + for s in ${new_nis_servers}; do + echo "domain ${new_nis_domain} server ${s} # added by /sbin/dhclient-script"
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 36
Quoted 10 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +10
-0+ done) + + [ -f ${SAVECONF} ] || touch ${SAVECONF} + nis_replace_conf "$conf" + fi +} + +nis_restore() { + if [ -e ${CONF} ] && [ -f ${SAVECONF} ]; then + local conf=$(grep -v '^domain .* # added by /sbin/dhclient-script$' < ${CONF})
Would this really be necessary if you saved $CONF to $SAVECONF and restored it later? (See below)
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 39
Quoted 3 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +3
-0+ + nis_replace_conf "$conf" + rm -f ${SAVECONF}
Does anything get copied to $SAVECONF? All I see is the one touch above, but wouldn't it be easier all around if you were making copies of the CONF file to restore later?
meta-networking/recipes-support/nis/ypbind-mt/yp.conf line 1
Quoted 9 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +2
-0+ fi +}meta-networking/recipes-support/nis/ypbind-mt/yp.conf new file +1
-0@@ -0,0 +1 @@ +#
Presumably this is necessary to support the 'nis.sh' script, but since it's just an empty file, why not create it at do_install time (or better still just have the script handle a missing one in some sensible way and thus allow another layer to provide their own yp.conf if they need to)?
I'd encourage you to look at:
since they seem to share a common ancestry anyway and adopt that (or something very like it) instead.
-J.
Quoted 31 lines
meta-networking/recipes-support/nis/ypbind-mt_1.38.bb +6
-0@@ -28,6 +28,8 @@ PROVIDES += "ypbind" SRC_URI = "http://www.linux-nis.org/download/ypbind-mt/${BP}.tar.bz2 \ file://ypbind-yocto.init \ file://ypbind.service \ + file://yp.conf \ + file://nis.sh \ " SRC_URI[md5sum] = "094088c0e282fa7f3b3dd6cc51d0a4e1" SRC_URI[sha256sum] = "1930ce19f6ccfe10400f3497b31867f71690d2bcd3f5b575199fa915559b7746"@@ -44,10 +46,14 @@ do_install_append () { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d + install -m 0744 ${WORKDIR}/yp.conf ${D}${sysconfdir}/ install -m 0755 ${WORKDIR}/ypbind-yocto.init ${D}${sysconfdir}/init.d/ypbind install -d ${D}${systemd_unitdir}/system install -m 0644 ${WORKDIR}/ypbind.service ${D}${systemd_unitdir}/system + + install -d ${D}/${sysconfdir}/dhcp/dhclient.d + install -m 755 ${WORKDIR}/nis.sh ${D}/${sysconfdir}/dhcp/dhclient.d/ }Signature · 1 line
1.9.1
Signature · 2 lines
-Joe MacDonald. :wq
Quoted 98 lines · Joe MacDonald
Quoted 20 lines · [[oe] [PATCH][meta-networking] ypbind-mt: get parameters from dhcp] On…
From: Li Wang <[email protected]>
the script
nis.shis called by dhcp client,
it can get some parameters from dhcp.Signed-off-by Li Wang <[email protected]>--- .../recipes-support/nis/ypbind-mt/nis.sh | 41 ++++++++++++++++++++++ .../recipes-support/nis/ypbind-mt/yp.conf | 1 + .../recipes-support/nis/ypbind-mt_1.38.bb | 6 ++++ 3 files changed, 48 insertions(+)create mode 100755
meta-networking/recipes-support/nis/ypbind-mt/nis.shcreate mode 100644meta-networking/recipes-support/nis/ypbind-mt/yp.confmeta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +0
-0meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 1
Quoted 1 line
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +1
-0@@ -0,0 +1,41 @@ +#!/bin/bashI wasn't able to find anything bash-specific in this script, can you change this to
/bin/sh, please?meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 8
Quoted 7 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +7
-0+# +# nis.sh: dhclient-script plugin for NIS settings, +# place in /etc/dhcp/dhclient.d and 'chmod +x nis.sh' to enable +# + +CONF=/etc/yp.conf +SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface}Where's SAVEDIR set again? It comes from the calling environment?
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 14
Quoted 6 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +6
-0+ +nis_replace_conf() { + echo "$1" | diff -q ${CONF} - > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "$1" > ${CONF} +# restorecon ${CONF} >/dev/null 2>&1I'm not sure what to make of this, maybe you want to make a parameter to optionally run restorecon? Or maybe a separate patch for meta-selinux with restorecon stuff in it? Either way, please don't leave this as dead code.
Quoted 12 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +12
-0+ service ypbind restart >/dev/null 2>&1 + fi +} + +nis_config() { + if [ -n "${new_nis_domain}" ] && [ -n "${new_nis_servers}" ] && + [ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then + local conf=$(grep -v '^domain .* # added by /sbin/dhclient-script$' < ${CONF}) + + conf=$(echo "$conf" + for s in ${new_nis_servers}; do + echo "domain ${new_nis_domain} server ${s} # added by /sbin/dhclient-script"meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 36
Quoted 10 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +10
-0+ done) + + [ -f ${SAVECONF} ] || touch ${SAVECONF} + nis_replace_conf "$conf" + fi +} + +nis_restore() { + if [ -e ${CONF} ] && [ -f ${SAVECONF} ]; then + local conf=$(grep -v '^domain .* # added by /sbin/dhclient-script$' < ${CONF})Would this really be necessary if you saved $CONF to $SAVECONF and restored it later? (See below)
meta-networking/recipes-support/nis/ypbind-mt/nis.sh line 39
Quoted 3 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +3
-0+ + nis_replace_conf "$conf" + rm -f ${SAVECONF}Does anything get copied to $SAVECONF? All I see is the one touch above, but wouldn't it be easier all around if you were making copies of the CONF file to restore later?
meta-networking/recipes-support/nis/ypbind-mt/yp.conf line 1
Quoted 9 lines
meta-networking/recipes-support/nis/ypbind-mt/nis.sh new file +2
-0+ fi +}meta-networking/recipes-support/nis/ypbind-mt/yp.conf new file +1
-0@@ -0,0 +1 @@ +#Presumably this is necessary to support the '
nis.sh' script, but since it's just an empty file, why not create it atdo_installtime (or better still just have the script handle a missing one in some sensible way and thus allow another layer to provide their own yp.conf if they need to)?
Quoted 8 lines
I'd encourage you to look at:
since they seem to share a common ancestry anyway and adopt that (or something very like it) instead.
-J.
thanks, I will adopt it
-Roy
Quoted 32 lines
Quoted 32 lines
meta-networking/recipes-support/nis/ypbind-mt_1.38.bb +6
-1@@ -28,6 +28,8 @@ PROVIDES += "ypbind" SRC_URI = "http://www.linux-nis.org/download/ypbind-mt/${BP}.tar.bz2 \ file://ypbind-yocto.init \ file://ypbind.service \ + file://yp.conf \ + file://nis.sh \ " SRC_URI[md5sum] = "094088c0e282fa7f3b3dd6cc51d0a4e1" SRC_URI[sha256sum] = "1930ce19f6ccfe10400f3497b31867f71690d2bcd3f5b575199fa915559b7746"@@ -44,10 +46,14 @@ do_install_append () { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d + install -m 0744 ${WORKDIR}/yp.conf ${D}${sysconfdir}/ install -m 0755 ${WORKDIR}/ypbind-yocto.init ${D}${sysconfdir}/init.d/ypbind install -d ${D}${systemd_unitdir}/system install -m 0644 ${WORKDIR}/ypbind.service ${D}${systemd_unitdir}/system + + install -d ${D}/${sysconfdir}/dhcp/dhclient.d + install -m 755 ${WORKDIR}/nis.sh ${D}/${sysconfdir}/dhcp/dhclient.d/ } --1.9.1
Signature · 2 lines
Best Reagrds, Roy | RongQing Li