Exit if the chroot directory already exists
[dev-env-setup.git] / mk-deb-chroot
index 680f024a3a8d773de235c942a17715d06d2b5222..948bd3f95e86d439282ebb9d98de03e8ad1c874f 100755 (executable)
@@ -4,14 +4,20 @@ if [ "$EUID" -ne 0 ]
   exit
 fi
 if [ -z "$1"  ]
-  then echo "need arg $1 for chroot to make"
+  then echo "Need arg $1 for chroot to make"
   exit
 fi
 chrootdir="$1"
-echo "creating chroot '$chrootdir'"
+
+if [ -e /opt/chroot/$chrootdir ]; then
+    echo "/opt/chroot/$chrootdir already exists"
+    exit
+fi
+
+echo "Creating chroot dir '$chrootdir'"
 
 # Create coriolis chroot dir in /opt
-mkdir -p /opt/chroot/$chrootdir
+mkdir /opt/chroot/$chrootdir
 
 # Install debootstrap and schroot
 if [ -e /etc/debian_version ]; then