Ship helper script for dhclient

This commit is contained in:
vcrhonek 2009-01-05 14:55:47 +00:00
parent 53da42f4fa
commit 9d7d259002
2 changed files with 105 additions and 2 deletions

97
nis.sh Executable file
View File

@ -0,0 +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 <http://www.gnu.org/licenses/>.
#
# Author(s): David Cantrell <dcantrell@redhat.com>
#
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
}

View File

@ -1,12 +1,13 @@
Summary: The NIS daemon which binds NIS clients to an NIS domain
Name: ypbind
Version: 1.20.4
Release: 11%{?dist}
Release: 12%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
Url: http://www.linux-nis.org/nis/ypbind-mt/index.html
Source1: ypbind.init
Source2: nis.sh
Patch1: ypbind-1.11-broadcast.patch
Patch2: ypbind-1.11-gettextdomain.patch
Patch3: ypbind-mt-1.19-port-leak.patch
@ -59,9 +60,10 @@ make
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_initrddir} $RPM_BUILD_ROOT/var/yp/binding
mkdir -p $RPM_BUILD_ROOT/%{_initrddir} $RPM_BUILD_ROOT/var/yp/binding $RPM_BUILD_ROOT/etc/dhcp/dhclient.d/
install -m 644 etc/yp.conf $RPM_BUILD_ROOT/etc/yp.conf
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/ypbind
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/dhcp/dhclient.d/nis.sh
%{find_lang} %{name}
@ -87,11 +89,15 @@ fi
/sbin/ypbind
%{_mandir}/*/*
%{_initrddir}/*
/etc/dhcp/dhclient.d/*
%config(noreplace) /etc/yp.conf
%dir /var/yp/binding
%doc README NEWS
%changelog
* Mon Jan 5 2009 Vitezslav Crhonek <vcrhonek@redhat.com> - 3:1.20.4-12
- Ship helper script for dhclient
* Wed Dec 3 2008 Vitezslav Crhonek <vcrhonek@redhat.com> - 3:1.20.4-11
- Fix verbose option man page entry
- Add description of port option to man page