grml-chroot: write /etc/debian_chroot [Closes: issue953]
authorChristian Hofstaedtler <ch@grml.org>
Mon, 7 Nov 2011 11:56:24 +0000 (12:56 +0100)
committerChristian Hofstaedtler <ch@grml.org>
Mon, 7 Nov 2011 11:56:48 +0000 (12:56 +0100)
usr_sbin/grml-chroot

index b3d1184..e9c1ae3 100755 (executable)
@@ -88,6 +88,14 @@ fi
 mountit "proc"  "proc"
 mountit "sysfs" "sys"
 mountit "/dev"   "dev"   "--bind"
+
+WROTE_DEBIAN_CHROOT=""
+if [ ! -f "$DEST_"/etc/debian_chroot ]; then
+    WROTE_DEBIAN_CHROOT="yes"
+    echo "Writing /etc/debian_chroot ..."
+    cat "$DEST_"/etc/hostname > "$DEST_"/etc/debian_chroot
+fi
+
 if (( $# < 1 )); then
     chroot "$DEST_"
     RC=$?
@@ -97,4 +105,8 @@ else
 fi
 umount_all
 
+if [ ! -z "$WROTE_DEBIAN_CHROOT" ]; then
+    rm "$DEST_"/etc/debian_chroot
+fi
+
 exit $RC