14 Star 0 Fork 7

src-openEuler/ypbind

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
nis.sh 2.98 KB
一键复制 编辑 原始数据 按行查看 历史
orange-snn 提交于 2020-01-01 00:13 +08:00 . init
#!/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
SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface}
fix_context() {
if [ -x /sbin/restorecon ]; then
/sbin/restorecon ${1} >/dev/null 2>&1
fi
}
save_config_file() {
if [ ! -d ${SAVEDIR} ]; then
mkdir -p ${SAVEDIR}
fi
if [ -e ${CONF} ]; then
# cp+rm instead of mv: preserve SELinux context
# rhbz#509240
# Do not rely on restorecon.
cp -c ${CONF} ${SAVECONF}
rm ${CONF}
else
echo > ${SAVECONF}
# Try restorecon
fix_context ${SAVECONF}
fi
}
nis_config() {
if [ ! "${PEERNIS}" = "no" ]; then
if [ -n "${new_nis_domain}" ]; then
domainname "${new_nis_domain}"
save_config_file
echo '# generated by /sbin/dhclient-script' > ${CONF}
fix_context ${CONF}
if [ -n "${new_nis_servers}" ]; then
for i in ${new_nis_servers} ; do
echo "domain ${new_nis_domain} server ${i}" >> ${CONF}
done
else
echo "domain ${new_nis_domain} broadcast" >> ${CONF}
fi
elif [ -n "${new_nis_servers}" ]; then
save_config_file
echo '# generated by /sbin/dhclient-script' > ${CONF}
fix_context ${CONF}
for i in ${new_nis_servers} ; do
echo "ypserver ${i}" >> ${CONF}
done
fi
# dimainname or servers changed, restart ypbind
if [ "${old_nis_domain}" != "${new_nis_domain}" ] \
|| [ "${old_nis_servers}" != "${new_nis_servers}" ]
then
service ypbind condrestart >/dev/null 2>&1
fi
fi
}
nis_restore() {
if [ ! "${PEERNIS}" = "no" ]; then
if [ -f ${SAVECONF} ]; then
rm -f ${CONF}
# cp+rm instead of mv: preserve SELinux context
# rhbz#509240
cp -c ${SAVECONF} ${CONF}
rm ${SAVECONF}
fix_context ${CONF} # Restorecon again to be sure.
service ypbind condrestart >/dev/null 2>&1
fi
fi
}
# Local Variables:
# indent-tabs-mode: nil
# sh-basic-offset: 4
# show-trailing-whitespace: t
# End:
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/ypbind.git
git@gitee.com:src-openeuler/ypbind.git
src-openeuler
ypbind
ypbind
master

搜索帮助