From d78255a89eae36de0f90e5fad7005dc3143c2b34 Mon Sep 17 00:00:00 2001 From: vcrhonek Date: Thu, 19 Feb 2009 14:25:46 +0000 Subject: [PATCH] Update helper script for dhclient --- nis.sh | 194 ++++++++++++++++++++++++++-------------------------- ypbind.spec | 5 +- 2 files changed, 101 insertions(+), 98 deletions(-) diff --git a/nis.sh b/nis.sh index 3c18da5..1126746 100755 --- a/nis.sh +++ b/nis.sh @@ -1,97 +1,97 @@ -#!/bin/bash -# -# nis.sh: dhclient-script plugin for NIS settings, -# place in /etc/dhcp/dhclient.d and 'chmod +x nis.sh' to enable -# -# Copyright (C) 2008 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Author(s): David Cantrell -# - -CONF=/etc/yp.conf - -save_config_file() { - origfile="${1}" - savefile="${SAVEDIR}/${origfile##*/}.predhclient.${interface}" - - if [ ! -d ${SAVEDIR} ]; then - mkdir -p ${SAVEDIR} - fi - - if [ -e ${origfile} ]; then - mv ${origfile} ${savefile} - else - echo > ${savefile} - fi - - restorecon ${savefile} >/dev/null 2>&1 -} - -nis_config() { - if [ ! "${PEERNIS}" = "no" ]; then - if [ -n "${new_nis_domain}" ]; then - domainname "${new_nis_domain}" - save_config_file ${CONF} - let contents=0 - echo '# generated by /sbin/dhclient-script' > ${CONF} - - if [ -n "${new_nis_servers}" ]; then - for i in ${new_nis_servers} ; do - echo "domain ${new_nis_domain} server ${i}" >> ${CONF} - let contents=contents+1 - done - else - echo "domain ${new_nis_domain} broadcast" >> ${CONF} - let contents=contents+1 - fi - - if [ ${contents} -gt 0 ]; then - if [ -x /etc/rc.d/init.d/ypbind ] && - [ -r /var/run/ypbind.pid ]; then - service ypbind restart >/dev/null 2>&1 - fi - fi - elif [ -n "${new_nis_servers}" ]; then - save_config_file ${CONF} - echo '# generated by /sbin/dhclient-script' > ${CONF} - let contents=0 - - for i in ${new_nis_servers} ; do - echo "ypserver ${i}" >> ${CONF} - let contents=contents+1 - done - - if [ $contents -gt 0 ]; then - if [ -x /etc/rc.d/init.d/ypbind ] && - [ -r /var/run/ypbind.pid ]; then - service ypbind restart >/dev/null 2>&1 - fi - fi - fi - fi -} - -nis_restore() { - if [ ! "${PEERNIS}" = "no" ]; then - if [ -f ${SAVEDIR}/${CONF}.predhclient.${interface} ]; then - rm -f ${CONF} - mv -f ${SAVEDIR}/${CONF}.predhclient.${interface} ${CONF} - if [ -x /etc/rc.d/init.d/ypbind ] && [ -r /var/run/ypbind.pid ]; then - service ypbind restart >/dev/null 2>&1 - fi - fi - fi -} +#!/bin/bash +# +# nis.sh: dhclient-script plugin for NIS settings, +# place in /etc/dhcp/dhclient.d and 'chmod +x nis.sh' to enable +# +# Copyright (C) 2008 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author(s): David Cantrell +# + +CONF=/etc/yp.conf + +save_config_file() { + origfile="${1}" + savefile="${SAVEDIR}/${origfile##*/}.predhclient.${interface}" + + if [ ! -d ${SAVEDIR} ]; then + mkdir -p ${SAVEDIR} + fi + + if [ -e ${origfile} ]; then + mv ${origfile} ${savefile} + else + echo > ${savefile} + fi + + restorecon ${savefile} >/dev/null 2>&1 +} + +nis_config() { + if [ ! "${PEERNIS}" = "no" ]; then + if [ -n "${new_nis_domain}" ]; then + domainname "${new_nis_domain}" + save_config_file ${CONF} + let contents=0 + echo '# generated by /sbin/dhclient-script' > ${CONF} + + if [ -n "${new_nis_servers}" ]; then + for i in ${new_nis_servers} ; do + echo "domain ${new_nis_domain} server ${i}" >> ${CONF} + let contents=contents+1 + done + else + echo "domain ${new_nis_domain} broadcast" >> ${CONF} + let contents=contents+1 + fi + + if [ ${contents} -gt 0 ]; then + if [ -x /etc/rc.d/init.d/ypbind ] && + [ -r /var/run/ypbind.pid ]; then + service ypbind restart >/dev/null 2>&1 + fi + fi + elif [ -n "${new_nis_servers}" ]; then + save_config_file ${CONF} + echo '# generated by /sbin/dhclient-script' > ${CONF} + let contents=0 + + for i in ${new_nis_servers} ; do + echo "ypserver ${i}" >> ${CONF} + let contents=contents+1 + done + + if [ $contents -gt 0 ]; then + if [ -x /etc/rc.d/init.d/ypbind ] && + [ -r /var/run/ypbind.pid ]; then + service ypbind restart >/dev/null 2>&1 + fi + fi + fi + fi +} + +nis_restore() { + if [ ! "${PEERNIS}" = "no" ]; then + if [ -f ${SAVEDIR}/${CONF}.predhclient.${interface} ]; then + rm -f ${CONF} + mv -f ${SAVEDIR}/${CONF}.predhclient.${interface} ${CONF} + if [ -x /etc/rc.d/init.d/ypbind ] && [ -r /var/run/ypbind.pid ]; then + service ypbind restart >/dev/null 2>&1 + fi + fi + fi +} diff --git a/ypbind.spec b/ypbind.spec index f0248f2..00da784 100644 --- a/ypbind.spec +++ b/ypbind.spec @@ -1,7 +1,7 @@ Summary: The NIS daemon which binds NIS clients to an NIS domain Name: ypbind Version: 1.20.4 -Release: 13%{?dist} +Release: 14%{?dist} License: GPLv2 Group: System Environment/Daemons Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2 @@ -97,6 +97,9 @@ fi %doc README NEWS %changelog +* Thu Feb 19 2009 Vitezslav Crhonek - 3:1.20.4-14 +- Update helper script for dhclient + * Mon Jan 26 2009 Vitezslav Crhonek - 3:1.20.4-13 - Fix ypbind can fail to bind if started soon after NetworkManager Resolves: #480096