Accepting request 618489 from home:kukuk:branches:network
- Cleanup pre/post install: remove all old code which was needed to update to SLES8. OBS-URL: https://build.opensuse.org/request/show/618489 OBS-URL: https://build.opensuse.org/package/show/network/bind?expand=0&rev=247
This commit is contained in:
parent
530e7d8de1
commit
2b99721cd9
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 22 15:10:39 CEST 2018 - kukuk@suse.de
|
||||
|
||||
- Cleanup pre/post install: remove all old code which was needed to
|
||||
update to SLES8.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 6 12:03:25 UTC 2018 - navin.kukreja@suse.com
|
||||
|
||||
|
132
bind.spec
132
bind.spec
@ -450,30 +450,10 @@ done
|
||||
install -m 0644 bind.keys %{buildroot}%{_localstatedir}/lib/named/named.root.key
|
||||
|
||||
%pre
|
||||
# Are we updating from a package named bind9?
|
||||
if test -d usr/share/doc/packages/bind9 && sbin/chkconfig -c named; then
|
||||
NAMED_ACTIVE_FILE="var/adm/named.was.active"
|
||||
test -f ${NAMED_ACTIVE_FILE} && old ${NAMED_ACTIVE_FILE}
|
||||
ACTIVE_DIR=$( dirname ${NAMED_ACTIVE_FILE})
|
||||
test -d ${ACTIVE_DIR} || mkdir -p ${ACTIVE_DIR}
|
||||
touch ${NAMED_ACTIVE_FILE}
|
||||
fi
|
||||
%{GROUPADD_NAMED}
|
||||
%{USERADD_NAMED}
|
||||
# Might be an update.
|
||||
%{USERMOD_NAMED}
|
||||
# var/run/named is now a sym link pointing to the chroot jail
|
||||
test -L var/run/named || rm -rf var/run/named
|
||||
test -f etc/sysconfig/named && \
|
||||
. etc/sysconfig/named
|
||||
# Store NAMED_RUN_CHROOTED setting to a temp file.
|
||||
TEMP_SYSCONFIG_FILE="var/adm/named-chroot"
|
||||
TEMP_DIR=$( dirname ${TEMP_SYSCONFIG_FILE})
|
||||
test -d ${TEMP_DIR} || \
|
||||
mkdir -p ${TEMP_DIR}
|
||||
test -e ${TEMP_SYSCONFIG_FILE} && \
|
||||
old ${TEMP_SYSCONFIG_FILE}
|
||||
echo "NAMED_RUN_CHROOTED=\"${NAMED_RUN_CHROOTED}\"" >${TEMP_SYSCONFIG_FILE}
|
||||
%if %{with_systemd}
|
||||
%service_add_pre named.service
|
||||
%endif
|
||||
@ -486,117 +466,11 @@ echo "NAMED_RUN_CHROOTED=\"${NAMED_RUN_CHROOTED}\"" >${TEMP_SYSCONFIG_FILE}
|
||||
%endif
|
||||
|
||||
%post
|
||||
%if !%{with_systemd}
|
||||
%{fillup_and_insserv -nf named}
|
||||
%endif
|
||||
%{fillup_only -nsa named named}
|
||||
TEMP_SYSCONFIG_FILE="var/adm/named-chroot"
|
||||
# Are we in update mode?
|
||||
if [ ${FIRST_ARG:-0} -gt 1 ]; then
|
||||
# Is named.conf an old, /var/named configuration?
|
||||
if [ -f etc/named.conf ] && grep -qi '^[[:space:]]*directory[[:space:]]*"%{_localstatedir}/named"[[:space:]]*;' etc/named.conf; then
|
||||
test -d var/log || \
|
||||
mkdir -p var/log
|
||||
CONVLOG="%{_localstatedir}/log/named-move-to-var-lib"
|
||||
# move zone files to new location
|
||||
echo "Moving zone files to new location %{_localstatedir}/lib/named" | tee ${CONVLOG}
|
||||
IFS="
|
||||
"
|
||||
for dir in var/named var/named/slave; do
|
||||
for source in $( find ${dir} -maxdepth 1 ); do
|
||||
case "${source#var/named/}" in
|
||||
localhost.zone|127.0.0.zone|root.hint|slave|var/named) continue ;;
|
||||
esac
|
||||
sourcedir=$( echo "${source%/*}")
|
||||
destdir=$( echo "${sourcedir#var/named}")
|
||||
if [ -e "var/lib/named/${destdir}/${source##*/}" ]; then
|
||||
echo "Warning: %{_localstatedir}/lib/named${destdir}/${source##*/} already exists; skipped." | tee -a ${CONVLOG}
|
||||
else
|
||||
echo "${source#var/named/}" | tee -a ${CONVLOG}
|
||||
mv "${source}" "var/lib/named/${destdir}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
# updating named.conf
|
||||
echo -n "Backup old %{_sysconfdir}/named.conf to " | tee -a ${CONVLOG}
|
||||
oldconfig=$( old etc/named.conf) 2>/dev/null
|
||||
oldconfig=${oldconfig##*/}
|
||||
echo -n "%{_sysconfdir}/${oldconfig}. Conversion " | tee -a ${CONVLOG}
|
||||
sed -e "s@\"%{_localstatedir}/named\"@\"%{_localstatedir}/lib/named\"@" "etc/${oldconfig}" > etc/named.conf 2>/dev/null
|
||||
conv_rc=$?
|
||||
if [ ${conv_rc} -eq 0 ]; then
|
||||
echo "succeded." | tee -a ${CONVLOG}
|
||||
chmod --reference="etc/${oldconfig}" etc/named.conf
|
||||
chown --reference="etc/${oldconfig}" etc/named.conf
|
||||
else
|
||||
echo "failed." | tee -a ${CONVLOG}
|
||||
fi
|
||||
if [ ${conv_rc} -eq 0 ]; then
|
||||
cat << EOF >>${CONVLOG}
|
||||
Result: named.conf conversion succeded. For details check the following
|
||||
diff of the the old and new configuration.
|
||||
EOF
|
||||
diff -u etc/${oldconfig} etc/named.conf >>${CONVLOG}
|
||||
else
|
||||
cat << EOF >>${CONVLOG}
|
||||
Result: Conversion failed. You must check your %{_sysconfdir}/named.conf
|
||||
EOF
|
||||
fi
|
||||
else
|
||||
rm -f var/lib/update-messages/bind.1
|
||||
fi # End of 'Is named.conf an old, %{_localstatedir}/named configuration?'.
|
||||
# Add include files to NAMED_CONF_INCLUDE_FILES if we have already a include
|
||||
# file (SL Standard Server 8) and NAMED_RUN_CHROOTED from the
|
||||
# TEMP_SYSCONFIG_FILE is empty.
|
||||
if [ -f ${TEMP_SYSCONFIG_FILE} ]; then
|
||||
. ${TEMP_SYSCONFIG_FILE}
|
||||
fi
|
||||
if [ -s etc/named.conf.include -a -z "${NAMED_RUN_CHROOTED}" ]; then
|
||||
test -f etc/sysconfig/named && . etc/sysconfig/named
|
||||
if [ "${NAMED_INITIALIZE_SCRIPTS}" = "createNamedConfInclude" -a \
|
||||
-z "${NAMED_CONF_INCLUDE_FILES}" ]; then
|
||||
# Get the included files from an existing meta include file.
|
||||
INCLUDE_LINES=$( grep -e '^[[:space:]]*include' etc/named.conf.include | cut -f 2 -d '"')
|
||||
if [ "${INCLUDE_LINES}" -a -z "${NAMED_CONF_INCLUDE_FILES}" ]; then
|
||||
for file in ${INCLUDE_LINES}; do
|
||||
# don't add a file a second time
|
||||
echo "${INCLUDE_FILES}" | grep -qe "\<${file#%{_sysconfdir}/named.d/}\>" && continue
|
||||
# don't add the meta include file as the init script copy it anyway
|
||||
# to the chroot jail
|
||||
test "${file}" = "%{_sysconfdir}/named.conf.include" && continue
|
||||
test "${INCLUDE_FILES}" && INCLUDE_FILES="${INCLUDE_FILES} "
|
||||
# strip off any leading %{_sysconfdir}/named.d/ as the init script takes care
|
||||
# of relative file names
|
||||
INCLUDE_FILES="${INCLUDE_FILES}${file#%{_sysconfdir}/named.d/}"
|
||||
done
|
||||
TMPFILE=$( mktemp %{_localstatedir}/tmp/named.sysconfig.XXXXXX)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Can't create temp file. Please add your included files from %{_sysconfdir}/named.conf to"
|
||||
echo "NAMED_CONF_INCLUDE_FILES of %{_sysconfdir}/sysconfig/named manually."
|
||||
return
|
||||
fi
|
||||
chmod --reference=etc/sysconfig/named ${TMPFILE}
|
||||
if sed "s+^NAMED_CONF_INCLUDE_FILES.*$+NAMED_CONF_INCLUDE_FILES=\"${INCLUDE_FILES}\"+" etc/sysconfig/named > "${TMPFILE}"; then
|
||||
mv "${TMPFILE}" etc/sysconfig/named
|
||||
else
|
||||
echo "Can't set NAMED_CONF_INCLUDE_FILES of %{_sysconfdir}/sysconfig/named to \"${INCLUDE_FILES}\"."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
rm -f touch var/lib/update-messages/bind.3
|
||||
fi # End of 'Add include files to NAMED_CONF_INCLUDE_FILES'
|
||||
fi # End of 'Are we in update mode?'
|
||||
# Remove TEMP_SYSCONFIG_FILE in any case.
|
||||
rm -f ${TEMP_SYSCONFIG_FILE}
|
||||
%if %{with_systemd}
|
||||
%{fillup_only -nsa named named}
|
||||
%service_add_post named.service
|
||||
%else
|
||||
NAMED_ACTIVE_FILE="var/adm/named.was.active"
|
||||
if [ -f ${NAMED_ACTIVE_FILE} ]; then
|
||||
sbin/insserv named
|
||||
test ! -s ${NAMED_ACTIVE_FILE} && rm -f ${NAMED_ACTIVE_FILE}
|
||||
fi
|
||||
%{fillup_and_insserv -nf named}
|
||||
if [ -x %{_bindir}/systemctl ]; then
|
||||
# make sure systemctl knows about the service even though it's not a systemd service
|
||||
# Without this, systemctl status named would return
|
||||
@ -682,7 +556,7 @@ fi
|
||||
%if %{with_systemd}
|
||||
%config %{_unitdir}/named.service
|
||||
%{_sbindir}/named.init
|
||||
%else
|
||||
%else
|
||||
%config /%{_sysconfdir}/init.d/named
|
||||
%endif
|
||||
%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/bind
|
||||
|
Loading…
Reference in New Issue
Block a user