[SCM] live-debconfig branch, debian-next, updated. debian/4.0_a2-1-8-g9941e2e

Daniel Baumann daniel at debian.org
Thu Aug 16 13:19:11 UTC 2012


The following commit has been merged in the debian-next branch:
commit 9941e2e1d0d39bba0e155683e5e98ffdc9178a07
Author: Daniel Baumann <daniel at debian.org>
Date:   Thu Aug 16 15:19:11 2012 +0200

    Making file operations in ifupdown script atomic.

diff --git a/scripts/debconfig/0020-ifupdown b/scripts/debconfig/0020-ifupdown
index 144e06f..bf93edd 100755
--- a/scripts/debconfig/0020-ifupdown
+++ b/scripts/debconfig/0020-ifupdown
@@ -214,7 +214,7 @@ db_stop
 
 # Create /etc/network/interfaces
 
-cat > /etc/network/interfaces << EOF
+cat > /etc/network/interfaces.tmp << EOF
 # Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
 # /usr/share/doc/ifupdown/examples for more information.
 
@@ -224,10 +224,10 @@ case "${_LO_ENABLE}" in
 	true)
 		if [ -n "${_LO_COMMENT}" ]
 		then
-			echo "# ${_LO_COMMENT}" >> /etc/network/interfaces
+			echo "# ${_LO_COMMENT}" >> /etc/network/interfaces.tmp
 		fi
 
-cat >> /etc/network/interfaces << EOF
+cat >> /etc/network/interfaces.tmp << EOF
 auto lo
 iface lo inet loopback
 EOF
@@ -250,17 +250,17 @@ do
 		continue
 	fi
 
-	echo >> /etc/network/interfaces
+	echo >> /etc/network/interfaces.tmp
 
 	if [ -n "${_COMMENT}" ]
 	then
-		echo "# ${_COMMENT}" >> /etc/network/interfaces
+		echo "# ${_COMMENT}" >> /etc/network/interfaces.tmp
 	fi
 
 	case "${_METHOD}" in
 		none)
 
-cat >> /etc/network/interfaces << EOF
+cat >> /etc/network/interfaces.tmp << EOF
 iface eth${_NUMBER} inet manual
 EOF
 
@@ -268,7 +268,7 @@ EOF
 
 		dhcp)
 
-cat >> /etc/network/interfaces << EOF
+cat >> /etc/network/interfaces.tmp << EOF
 auto eth${_NUMBER}
 iface eth${_NUMBER} inet dhcp
 EOF
@@ -277,7 +277,7 @@ EOF
 
 		static)
 
-cat >> /etc/network/interfaces << EOF
+cat >> /etc/network/interfaces.tmp << EOF
 auto eth${_NUMBER}
 iface eth${_NUMBER} inet static
 	address		${_ADDRESS}
@@ -285,22 +285,22 @@ EOF
 
 			if [ -n "${_BROADCAST}" ]
 			then
-				echo "	broadcast	${_BROADCAST}" >> /etc/network/interfaces
+				echo "	broadcast	${_BROADCAST}" >> /etc/network/interfaces.tmp
 			fi
 
 			if [ -n "${_GATEWAY}" ]
 			then
-				echo "	gateway		${_GATEWAY}" >> /etc/network/interfaces
+				echo "	gateway		${_GATEWAY}" >> /etc/network/interfaces.tmp
 			fi
 
 			if [ -n "${_NETMASK}" ]
 			then
-				echo "	netmask		${_NETMASK}" >> /etc/network/interfaces
+				echo "	netmask		${_NETMASK}" >> /etc/network/interfaces.tmp
 			fi
 
 			if [ -n "${_NETWORK}" ]
 			then
-				echo "	network		${_NETWORK}" >> /etc/network/interfaces
+				echo "	network		${_NETWORK}" >> /etc/network/interfaces.tmp
 			fi
 			;;
 	esac
@@ -308,37 +308,41 @@ EOF
 	_NUMBER="$((${_NUMBER} + 1))"
 done
 
+mv /etc/network/interfaces.tmp /etc/network/interfaces
+
 # Create /etc/resolv.conf
-rm -f /etc/resolv.conf
+rm -f /etc/resolv.conf.tmp
 
 if [ -n "${_NAMESERVER_DOMAIN}" ]
 then
-	echo "domain ${_NAMESERVER_DOMAIN}" >> /etc/resolv.conf
+	echo "domain ${_NAMESERVER_DOMAIN}" >> /etc/resolv.conf.tmp
 fi
 
 if [ -n "${_NAMESERVER_SEARCH}" ]
 then
-	echo "search ${_NAMESERVER_SEARCH}" >> /etc/resolv.conf
+	echo "search ${_NAMESERVER_SEARCH}" >> /etc/resolv.conf.tmp
 fi
 
 if [ -n "${_NAMESERVER_ADDRESSES}" ]
 then
 	for _NAMESERVER_ADDRESS in $(echo ${_NAMESERVER_ADDRESSES} | sed -e 's|,| |g')
 	do
-		echo "nameserver ${_NAMESERVER_ADDRESS}" >> /etc/resolv.conf
+		echo "nameserver ${_NAMESERVER_ADDRESS}" >> /etc/resolv.conf.tmp
 	done
 fi
 
 if [ -n "${_NAMESERVER_OPTIONS}" ]
 then
-	echo "options ${_NAMESERVER_OPTIONS}" >> /etc/resolv.conf
+	echo "options ${_NAMESERVER_OPTIONS}" >> /etc/resolv.conf.tmp
 fi
 
+mv /etc/resolv.conf.tmp /etc/resolv.conf
+
 # Create /etc/hosts
 case "${_ETH0_METHOD}" in
 	none|dhcp)
 
-cat > /etc/hosts << EOF
+cat > /etc/hosts.tmp << EOF
 127.0.0.1	localhost
 
 # The following lines are desirable for IPv6 capable hosts
@@ -353,7 +357,7 @@ EOF
 
 	static)
 
-cat > /etc/hosts << EOF
+cat > /etc/hosts.tmp << EOF
 127.0.0.1	localhost
 ${_ETH0_ADDRESS}	$(cat /etc/hostname)
 
@@ -367,3 +371,5 @@ EOF
 
 		;;
 esac
+
+mv /etc/hosts.tmp /etc/hosts

-- 
live-debconfig



More information about the debian-live-changes mailing list