[lxc-devel] [PATCH 4/4] Update for consistent indent

Stéphane Graber stgraber at ubuntu.com
Wed Dec 5 21:47:19 UTC 2012


This commit updates all scripts using mixed indent to a consistent
4 spaces indent.

In the past quite a few of those scripts used tabs to instead of 8 spaces or
instead of 4 spaces, sometimes mixing those in the same line and sometimes
changing the tab width within the same file.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 README                     |   4 +-
 runapitests.sh             |  18 +--
 src/lxc/lxc-checkconfig.in |  12 +-
 src/lxc/lxc-clone.in       |  10 +-
 src/lxc/lxc-destroy.in     |  81 ++++++------
 src/lxc/lxc-netstat.in     | 130 +++++++++----------
 src/lxc/lxc-ps.in          | 169 +++++++++++++------------
 src/lxc/lxc-setcap.in      |  26 ++--
 src/lxc/lxc-setuid.in      |  30 ++---
 templates/lxc-altlinux.in  | 113 ++++++++---------
 templates/lxc-busybox.in   |  76 ++++++-----
 templates/lxc-debian.in    |  98 +++++++--------
 templates/lxc-fedora.in    |  94 +++++++-------
 templates/lxc-lenny.in     | 104 ++++++++-------
 templates/lxc-opensuse.in  | 100 ++++++++-------
 templates/lxc-oracle.in    | 308 ++++++++++++++++++++++-----------------------
 templates/lxc-sshd.in      |  10 +-
 17 files changed, 686 insertions(+), 697 deletions(-)

diff --git a/README b/README
index d7dacfd..9d4360c 100644
--- a/README
+++ b/README
@@ -76,10 +76,10 @@ cat > seccomp.full << EOF
 whitelist
 EOF
 for i in `seq 0 300`; do
-	echo $i >> secomp.full
+    echo $i >> secomp.full
 done
 for i in `seq 1024 1079`; do
-	echo $i >> seccomp.full
+    echo $i >> seccomp.full
 done
 
  -- Serge Hallyn <serge.hallyn at ubuntu.com>  Fri, 27 Jul 2012 15:47:02 +0600
diff --git a/runapitests.sh b/runapitests.sh
index 65bee6c..1169387 100644
--- a/runapitests.sh
+++ b/runapitests.sh
@@ -6,8 +6,8 @@ cleanup() {
 }
 
 if [ `id -u` -ne 0 ]; then
-	echo "Run as root"
-	exit 1
+    echo "Run as root"
+    exit 1
 fi
 
 cat > /etc/lxc/test-busybox.conf << EOF
@@ -20,13 +20,13 @@ EOF
 export LD_LIBRARY_PATH=.
 TESTS="lxc-test-containertests lxc-test-locktests lxc-test-startone"
 for curtest in $TESTS; do
-	echo "running $curtest"
-	./src/tests/$curtest
-	if [ $? -ne 0 ]; then
-		echo "Test $curtest failed.  Stopping"
-		cleanup
-		exit 1
-	fi
+    echo "running $curtest"
+    ./src/tests/$curtest
+    if [ $? -ne 0 ]; then
+        echo "Test $curtest failed.  Stopping"
+        cleanup
+        exit 1
+    fi
 done
 echo "All tests passed"
 cleanup
diff --git a/src/lxc/lxc-checkconfig.in b/src/lxc/lxc-checkconfig.in
index d17bb95..13dbf3b 100644
--- a/src/lxc/lxc-checkconfig.in
+++ b/src/lxc/lxc-checkconfig.in
@@ -21,13 +21,13 @@ is_enabled() {
     RES=$?
 
     if [ $RES -eq 0 ]; then
-	$SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
+        $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
     else
-	if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
-	    $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL
-	else
-	    $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL
-	fi
+        if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
+            $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL
+        else
+            $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL
+        fi
     fi
 }
 
diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in
index 7c649a6..c9cc5c7 100644
--- a/src/lxc/lxc-clone.in
+++ b/src/lxc/lxc-clone.in
@@ -272,11 +272,11 @@ c=$lxc_path/$lxc_new/config
 mv ${c} ${c}.old
 (
 while read line; do
-	if [ "${line:0:18}" = "lxc.network.hwaddr" ]; then
-		echo "lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')"
-	else
-		echo "$line"
-	fi
+    if [ "${line:0:18}" = "lxc.network.hwaddr" ]; then
+        echo "lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')"
+    else
+        echo "$line"
+    fi
 done
 ) < ${c}.old > ${c}
 rm -f ${c}.old
diff --git a/src/lxc/lxc-destroy.in b/src/lxc/lxc-destroy.in
index ecff083..c72f18a 100644
--- a/src/lxc/lxc-destroy.in
+++ b/src/lxc/lxc-destroy.in
@@ -54,26 +54,27 @@ eval set -- "$getopt"
 
 while true; do
         case "$1" in
-	    -h|--help)
-		help
-		exit 1
-		;;
-	    -n|--name)
-		shift
-		lxc_name=$1
-		shift
-		;;
-	    -f)
-		force=1
-		shift
-		;;
+            -h|--help)
+                help
+                exit 1
+            ;;
+            -n|--name)
+                shift
+                lxc_name=$1
+                shift
+            ;;
+            -f)
+                force=1
+                shift
+            ;;
             --)
-		shift
-		break;;
+                shift
+                break
+            ;;
             *)
-		usage
-		exit 1
-		;;
+            usage
+            exit 1
+            ;;
         esac
 done
 
@@ -96,13 +97,13 @@ fi
 # make sure the container isn't running
 lxc-info -n $lxc_name 2>/dev/null | grep -q RUNNING
 if [ $? -eq 0 ]; then
-	if [ $force -eq 1 ]; then
-		lxc-stop -n $lxc_name
-		lxc-wait -n $lxc_name -s STOPPED
-	else
-		echo "$(basename $0): '$lxc_name' is running; aborted" >&2
-		exit 1
-	fi
+    if [ $force -eq 1 ]; then
+        lxc-stop -n $lxc_name
+        lxc-wait -n $lxc_name -s STOPPED
+    else
+        echo "$(basename $0): '$lxc_name' is running; aborted" >&2
+        exit 1
+    fi
 fi
 
 # Deduce the type of rootfs
@@ -110,21 +111,21 @@ fi
 # else, ignore it. We'll support deletion of others later.
 rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
 if [ -n "$rootdev" ]; then
-	if [ -b "$rootdev" -o -h "$rootdev" ]; then
-		lvdisplay $rootdev > /dev/null 2>&1
-		if [ $? -eq 0 ]; then
-			echo "removing backing store: $rootdev"
-			lvremove -f $rootdev
-		fi
-	elif [ -h "$rootdev" -o -d "$rootdev" ]; then
-		if which btrfs >/dev/null 2>&1 &&
-		   btrfs subvolume list "$rootdev" >/dev/null 2>&1; then
-			btrfs subvolume delete "$rootdev"
-		else
-			# In case rootfs is not under $lxc_path/$lxc_name, remove it
-			rm -rf --one-file-system --preserve-root $rootdev
-		fi
-	fi
+    if [ -b "$rootdev" -o -h "$rootdev" ]; then
+        lvdisplay $rootdev > /dev/null 2>&1
+        if [ $? -eq 0 ]; then
+            echo "removing backing store: $rootdev"
+            lvremove -f $rootdev
+        fi
+    elif [ -h "$rootdev" -o -d "$rootdev" ]; then
+        if which btrfs >/dev/null 2>&1 &&
+           btrfs subvolume list "$rootdev" >/dev/null 2>&1; then
+            btrfs subvolume delete "$rootdev"
+        else
+            # In case rootfs is not under $lxc_path/$lxc_name, remove it
+            rm -rf --one-file-system --preserve-root $rootdev
+        fi
+    fi
 fi
 
 # recursively remove the container to remove old container configuration
diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in
index 4abe25f..df18620 100644
--- a/src/lxc/lxc-netstat.in
+++ b/src/lxc/lxc-netstat.in
@@ -18,110 +18,110 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 usage() {
-	echo "usage: $(basename $0) -n|--name <name> -- [netstat_options]" >&2
+    echo "usage: $(basename $0) -n|--name <name> -- [netstat_options]" >&2
 }
 
 help() {
-	usage
-	echo >&2
-	echo "Execute 'netstat' for the specified container." >&2
-	echo >&2
-	echo "  --name NAME       specify the container name" >&2
-	echo "  NETSTAT_OPTIONS   netstat command options (see \`netstat --help')" >&2
+    usage
+    echo >&2
+    echo "Execute 'netstat' for the specified container." >&2
+    echo >&2
+    echo "  --name NAME       specify the container name" >&2
+    echo "  NETSTAT_OPTIONS   netstat command options (see \`netstat --help')" >&2
 }
 
 get_parent_cgroup()
 {
-	local hierarchies hierarchy fields subsystems init_cgroup mountpoint
-
-	parent_cgroup=""
-
-	# Obtain a list of hierarchies that contain one or more subsystems
-	hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
-
-	# Iterate through the list until a suitable hierarchy is found
-	for hierarchy in $hierarchies; do
-		# Obtain information about the init process in the hierarchy
-		fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
-		if [ -z "$fields" ]; then continue; fi
-		fields=${fields#*:}
-
-		# Get a comma-separated list of the hierarchy's subsystems
-		subsystems=${fields%:*}
-
-		# Get the cgroup of the init process in the hierarchy
-		init_cgroup=${fields#*:}
-
-		# Get the filesystem mountpoint of the hierarchy
-		mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
-		if [ -z "$mountpoint" ]; then continue; fi
-
-		# Return the absolute path to the containers' parent cgroup
-		# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
-		if [[ ",$subsystems," == *,ns,* ]]; then
-			parent_cgroup="${mountpoint}${init_cgroup%/}"
-		else
-			parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
-		fi
-		break
-	done
+    local hierarchies hierarchy fields subsystems init_cgroup mountpoint
+
+    parent_cgroup=""
+
+    # Obtain a list of hierarchies that contain one or more subsystems
+    hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
+
+    # Iterate through the list until a suitable hierarchy is found
+    for hierarchy in $hierarchies; do
+        # Obtain information about the init process in the hierarchy
+        fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
+        if [ -z "$fields" ]; then continue; fi
+        fields=${fields#*:}
+
+        # Get a comma-separated list of the hierarchy's subsystems
+        subsystems=${fields%:*}
+
+        # Get the cgroup of the init process in the hierarchy
+        init_cgroup=${fields#*:}
+
+        # Get the filesystem mountpoint of the hierarchy
+        mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
+        if [ -z "$mountpoint" ]; then continue; fi
+
+        # Return the absolute path to the containers' parent cgroup
+        # (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
+        if [[ ",$subsystems," == *,ns,* ]]; then
+            parent_cgroup="${mountpoint}${init_cgroup%/}"
+        else
+            parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
+        fi
+        break
+    done
 }
 
 exec=""
 
 while true; do
-	case $1 in
-		-h|--help)
-			help; exit 1;;
-		-n|--name)
-			name=$2; shift 2;;
-		--exec)
-			exec="exec"; shift;;
-		--)
-			shift; break;;
-		*)
-			break;;
-	esac
+    case $1 in
+        -h|--help)
+            help; exit 1;;
+        -n|--name)
+            name=$2; shift 2;;
+        --exec)
+            exec="exec"; shift;;
+        --)
+            shift; break;;
+        *)
+            break;;
+    esac
 done
 
 if [ "$(id -u)" != "0" ]; then
-	echo "$(basename $0): must be run as root" >&2
-	exit 1
+    echo "$(basename $0): must be run as root" >&2
+    exit 1
 fi
 
 if [ -z "$name" ]; then
-	usage
-	exit 1
+    usage
+    exit 1
 fi
 
 if [ -z "$exec" ]; then
-	exec @BINDIR@/lxc-unshare -s MOUNT -- $0 -n $name --exec "$@"
+    exec @BINDIR@/lxc-unshare -s MOUNT -- $0 -n $name --exec "$@"
 fi
 
 lxc-info -n $name 2>&1 | grep -q 'STOPPED'
 if [ $? -eq 0 ]; then
-	echo "$(basename $0): container '$name' is not running" >&2
-	exit 1
+    echo "$(basename $0): container '$name' is not running" >&2
+    exit 1
 fi
 
 get_parent_cgroup
 if [ ! -d "$parent_cgroup" ]; then
-	echo "$(basename $0): no cgroup mount point found" >&2
-	exit 1
+    echo "$(basename $0): no cgroup mount point found" >&2
+    exit 1
 fi
 
 pid=$(head -1 $parent_cgroup/$name/tasks)
 
 if [ -z "$pid" ]; then
-	echo "$(basename $0): no process found for '$name'" >&2
-	exit 1
+    echo "$(basename $0): no process found for '$name'" >&2
+    exit 1
 fi
 
 tmpdir=$(mktemp -d)
 
 if [ -z "$tmpdir" -o ! -d "$tmpdir" ]; then
-	echo "$(basename $0): unable to create temporary directory" >&2
-	exit 1
+    echo "$(basename $0): unable to create temporary directory" >&2
+    exit 1
 fi
 
 # Bind mount /proc/$pid/net onto /proc/net before calling 'netstat'.
diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in
index cf3f1e9..1f45044 100644
--- a/src/lxc/lxc-ps.in
+++ b/src/lxc/lxc-ps.in
@@ -19,125 +19,124 @@
 
 usage()
 {
-	echo "usage: $(basename $0) [--lxc | --name NAME] [--] [PS_OPTIONS...]" >&2
+    echo "usage: $(basename $0) [--lxc | --name NAME] [--] [PS_OPTIONS...]" >&2
 }
 
 help() {
-	usage
-	echo >&2
-	echo "List current processes with container names." >&2
-	echo >&2
-	echo "  --lxc         show processes in all containers" >&2
-	echo "  --name NAME   show processes in the specified container" >&2
-	echo "                 (multiple containers can be separated by commas)" >&2
-	echo "  PS_OPTIONS    ps command options (see \`ps --help')" >&2
+    usage
+    echo >&2
+    echo "List current processes with container names." >&2
+    echo >&2
+    echo "  --lxc         show processes in all containers" >&2
+    echo "  --name NAME   show processes in the specified container" >&2
+    echo "                 (multiple containers can be separated by commas)" >&2
+    echo "  PS_OPTIONS    ps command options (see \`ps --help')" >&2
 }
 
 get_parent_cgroup()
 {
-	local hierarchies hierarchy fields subsystems init_cgroup mountpoint
-
-	parent_cgroup=""
-
-	# Obtain a list of hierarchies that contain one or more subsystems
-	hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
-
-	# Iterate through the list until a suitable hierarchy is found
-	for hierarchy in $hierarchies; do
-		# Obtain information about the init process in the hierarchy
-		fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
-		if [ -z "$fields" ]; then continue; fi
-		fields=${fields#*:}
-
-		# Get a comma-separated list of the hierarchy's subsystems
-		subsystems=${fields%:*}
-
-		# Get the cgroup of the init process in the hierarchy
-		init_cgroup=${fields#*:}
-
-		# Get the filesystem mountpoint of the hierarchy
-		mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
-		if [ -z "$mountpoint" ]; then continue; fi
-
-		# Return the absolute path to the containers' parent cgroup
-		# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
-		if [[ ",$subsystems," == *,ns,* ]]; then
-			parent_cgroup="${mountpoint}${init_cgroup%/}"
-		else
-			parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
-		fi
-		break
-	done
+    local hierarchies hierarchy fields subsystems init_cgroup mountpoint
+
+    parent_cgroup=""
+
+    # Obtain a list of hierarchies that contain one or more subsystems
+    hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
+
+    # Iterate through the list until a suitable hierarchy is found
+    for hierarchy in $hierarchies; do
+        # Obtain information about the init process in the hierarchy
+        fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
+        if [ -z "$fields" ]; then continue; fi
+        fields=${fields#*:}
+
+        # Get a comma-separated list of the hierarchy's subsystems
+        subsystems=${fields%:*}
+
+        # Get the cgroup of the init process in the hierarchy
+        init_cgroup=${fields#*:}
+
+        # Get the filesystem mountpoint of the hierarchy
+        mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
+        if [ -z "$mountpoint" ]; then continue; fi
+
+        # Return the absolute path to the containers' parent cgroup
+        # (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
+        if [[ ",$subsystems," == *,ns,* ]]; then
+            parent_cgroup="${mountpoint}${init_cgroup%/}"
+        else
+            parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
+        fi
+        break
+    done
 }
 
 containers=""
 list_container_processes=0
 while true; do
-	case $1 in
-		-h|--help)
-			help; exit 1;;
-		-n|--name)
-			containers=$2; list_container_processes=1; shift 2;;
-		--lxc)
-			list_container_processes=1; shift;;
-		--)
-			shift; break;;
-		*)
-			break;;
+    case $1 in
+        -h|--help)
+            help; exit 1;;
+        -n|--name)
+            containers=$2; list_container_processes=1; shift 2;;
+        --lxc)
+            list_container_processes=1; shift;;
+        --)
+            shift; break;;
+        *)
+            break;;
         esac
 done
 
 if [ "$list_container_processes" -eq "1" ]; then
-	set -- -e $@
+    set -- -e $@
 fi
 
 get_parent_cgroup
 if [ ! -d "$parent_cgroup" ]; then
-	echo "$(basename $0): no cgroup mount point found" >&2
-	exit 1
+    echo "$(basename $0): no cgroup mount point found" >&2
+    exit 1
 fi
 
 declare -a container_of_pid
 container_field_width=9
 IFS=","
 if [ -z "$containers" ]; then
-	containers=( $(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d -printf "%f," 2>/dev/null) )
+    containers=( $(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d -printf "%f," 2>/dev/null) )
 else
-	containers=( $containers )
+    containers=( $containers )
 fi
 
 declare -i pid
 IFS=$'\n'
 for container in ${containers[@]}; do
-	if [ "${#container}" -gt "$container_field_width" ]; then
-		container_field_width=${#container}
-	fi
-
-	if [ -f "$parent_cgroup/$container/tasks" ]; then
-		while read pid; do
-			container_of_pid[$pid]=$container
-		done < "$parent_cgroup/$container/tasks"
-	fi
+    if [ "${#container}" -gt "$container_field_width" ]; then
+        container_field_width=${#container}
+    fi
+
+    if [ -f "$parent_cgroup/$container/tasks" ]; then
+        while read pid; do
+            container_of_pid[$pid]=$container
+        done < "$parent_cgroup/$container/tasks"
+    fi
 done
 
 declare -i line_pid_end_position
 while read line; do
-	if [ -z "$line_pid_end_position" ]; then
-		if [[ "$line" != *" PID"* ]]; then
-			echo "$(basename $0): no PID column found in \`ps' output" >&2
-			exit 1
-		fi
-
-		buffer=${line%" PID"*}
-		let line_pid_end_position=${#buffer}+4
-		printf "%-${container_field_width}s %s\n" "CONTAINER" "$line"
-		continue
-	fi
-
-	buffer=${line:0:$line_pid_end_position}
-	pid=${buffer##* }
-	if [ "$list_container_processes" -eq "0" -o ! -z "${container_of_pid[pid]}" ]; then
-		printf "%-${container_field_width}s %s\n" "${container_of_pid[pid]}" "$line"
-	fi
+    if [ -z "$line_pid_end_position" ]; then
+        if [[ "$line" != *" PID"* ]]; then
+            echo "$(basename $0): no PID column found in \`ps' output" >&2
+            exit 1
+        fi
+
+        buffer=${line%" PID"*}
+        let line_pid_end_position=${#buffer}+4
+        printf "%-${container_field_width}s %s\n" "CONTAINER" "$line"
+        continue
+    fi
+
+    buffer=${line:0:$line_pid_end_position}
+    pid=${buffer##* }
+    if [ "$list_container_processes" -eq "0" -o ! -z "${container_of_pid[pid]}" ]; then
+        printf "%-${container_field_width}s %s\n" "${container_of_pid[pid]}" "$line"
+    fi
 done < <(ps "$@")
-
diff --git a/src/lxc/lxc-setcap.in b/src/lxc/lxc-setcap.in
index 02c1e09..fcbe2be 100644
--- a/src/lxc/lxc-setcap.in
+++ b/src/lxc/lxc-setcap.in
@@ -97,16 +97,16 @@ while [ $# -gt 0 ]; do
     opt="$1"
     shift
     case "$opt" in
-	-d)
-	    LXC_DROP_CAPS="yes"
-	    ;;
-	-h|--help)
-	    help
-	    exit 0
-	    ;;
-	--)
-	    break
-	    ;;
+        -d)
+            LXC_DROP_CAPS="yes"
+            ;;
+        -h|--help)
+            help
+            exit 0
+            ;;
+        --)
+            break
+            ;;
         -?)
             usage_err "unknown option '$opt'"
             ;;
@@ -115,9 +115,9 @@ while [ $# -gt 0 ]; do
             set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
             ;;
          *)
-	    usage
-	    exit 1
-	    ;;
+            usage
+            exit 1
+            ;;
     esac
 done;
 
diff --git a/src/lxc/lxc-setuid.in b/src/lxc/lxc-setuid.in
index e6a7b96..4e92bb0 100644
--- a/src/lxc/lxc-setuid.in
+++ b/src/lxc/lxc-setuid.in
@@ -41,9 +41,9 @@ help() {
 setuid()
 {
     if [ "$1" = "-r" ]; then
-	chmod -s $2
+        chmod -s $2
     else
-	chmod +s $1
+        chmod +s $1
     fi
 }
 
@@ -94,16 +94,16 @@ while [ $# -gt 0 ]; do
     opt="$1"
     shift
     case "$opt" in
-	-d)
-	    LXC_DROP_CAPS="yes"
-	    ;;
-	-h|--help)
-	    help
-	    exit 0
-	    ;;
-	--)
-	    break
-	    ;;
+        -d)
+            LXC_DROP_CAPS="yes"
+            ;;
+        -h|--help)
+            help
+            exit 0
+            ;;
+        --)
+            break
+            ;;
         -?)
             usage_err "unknown option '$opt'"
             ;;
@@ -112,9 +112,9 @@ while [ $# -gt 0 ]; do
             set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
             ;;
          *)
-	    usage
-	    exit 1
-	    ;;
+            usage
+            exit 1
+            ;;
     esac
 done;
 
diff --git a/templates/lxc-altlinux.in b/templates/lxc-altlinux.in
index 174af6a..eab473c 100644
--- a/templates/lxc-altlinux.in
+++ b/templates/lxc-altlinux.in
@@ -17,7 +17,7 @@
 
 # This library 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 
 # You should have received a copy of the GNU Lesser General Public
@@ -151,8 +151,8 @@ download_altlinux()
     INSTALL_ROOT=$cache/partial
     mkdir -p $INSTALL_ROOT
     if [ $? -ne 0 ]; then
-	echo "Failed to create '$INSTALL_ROOT' directory"
-	return 1
+        echo "Failed to create '$INSTALL_ROOT' directory"
+        return 1
     fi
 
     # download a mini altlinux into a cache
@@ -166,8 +166,8 @@ download_altlinux()
     $APT_GET install $PKG_LIST
 
     if [ $? -ne 0 ]; then
-	echo "Failed to download the rootfs, aborting."
-	return 1
+        echo "Failed to download the rootfs, aborting."
+        return 1
     fi
 
     mv "$INSTALL_ROOT" "$cache/rootfs"
@@ -198,39 +198,37 @@ install_altlinux()
 {
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -x 200
-	if [ $? -ne 0 ]; then
-	    echo "Cache repository is busy."
-	    return 1
-	fi
-
-	echo "Checking cache download in $cache/rootfs ... "
-	if [ ! -e "$cache/rootfs" ]; then
-	    download_altlinux
-	    if [ $? -ne 0 ]; then
-		echo "Failed to download 'altlinux base'"
-		return 1
-	    fi
+        flock -x 200
+        if [ $? -ne 0 ]; then
+            echo "Cache repository is busy."
+            return 1
+        fi
+
+        echo "Checking cache download in $cache/rootfs ... "
+        if [ ! -e "$cache/rootfs" ]; then
+            download_altlinux
+            if [ $? -ne 0 ]; then
+                echo "Failed to download 'altlinux base'"
+                return 1
+            fi
         else
-	    echo "Cache found. Updating..."
+            echo "Cache found. Updating..."
             update_altlinux
-	    if [ $? -ne 0 ]; then
-		echo "Failed to update 'altlinux base', continuing with last known good cache"
+            if [ $? -ne 0 ]; then
+                echo "Failed to update 'altlinux base', continuing with last known good cache"
             else
                 echo "Update finished"
-	    fi
-	fi
-
-	echo "Copy $cache/rootfs to $rootfs_path ... "
-	copy_altlinux
-	if [ $? -ne 0 ]; then
-	    echo "Failed to copy rootfs"
-	    return 1
-	fi
-
-	return 0
-
-	) 200>@LOCALSTATEDIR@/lock/subsys/lxc
+            fi
+        fi
+
+        echo "Copy $cache/rootfs to $rootfs_path ... "
+        copy_altlinux
+        if [ $? -ne 0 ]; then
+            echo "Failed to copy rootfs"
+            return 1
+        fi
+        return 0
+    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 
     return $?
 }
@@ -302,8 +300,8 @@ sysfs           $rootfs_path/sys          sysfs defaults  0 0
 EOF
 
     if [ $? -ne 0 ]; then
-	echo "Failed to add configuration"
-	return 1
+        echo "Failed to add configuration"
+        return 1
     fi
 
     return 0
@@ -313,21 +311,20 @@ clean()
 {
 
     if [ ! -e $cache ]; then
-	exit 0
+        exit 0
     fi
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -x 200
-	if [ $? != 0 ]; then
-	    echo "Cache repository is busy."
-	    exit 1
-	fi
-
-	echo -n "Purging the download cache for ALTLinux-$release..."
-	rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
-	exit 0
-
+        flock -x 200
+        if [ $? != 0 ]; then
+            echo "Cache repository is busy."
+            exit 1
+        fi
+
+        echo -n "Purging the download cache for ALTLinux-$release..."
+        rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
+        exit 0
     ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 }
 
@@ -370,17 +367,17 @@ eval set -- "$options"
 while true
 do
     case "$1" in
-	-h|--help)      usage $0 && exit 0;;
-	-p|--path)      path=$2; shift 2;;
-	-n|--name)      name=$2; shift 2;;
-	-P|--profile)   profile=$2; shift 2;;
-	-c|--clean)     clean=$2; shift 2;;
-	-R|--release)   release=$2; shift 2;;
-	-4|--ipv4)      ipv4=$2; shift 2;;
-	-6|--ipv6)      ipv6=$2; shift 2;;
-	-g|--gw)        gw=$2; shift 2;;
-	-d|--dns)       dns=$2; shift 2;;
-	--)             shift 1; break ;;
+        -h|--help)      usage $0 && exit 0;;
+        -p|--path)      path=$2; shift 2;;
+        -n|--name)      name=$2; shift 2;;
+        -P|--profile)   profile=$2; shift 2;;
+        -c|--clean)     clean=$2; shift 2;;
+        -R|--release)   release=$2; shift 2;;
+        -4|--ipv4)      ipv4=$2; shift 2;;
+        -6|--ipv6)      ipv6=$2; shift 2;;
+        -g|--gw)        gw=$2; shift 2;;
+        -d|--dns)       dns=$2; shift 2;;
+        --)             shift 1; break ;;
         *)              break ;;
     esac
 done
diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
index a8af4b2..f2751d8 100644
--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -108,36 +108,34 @@ EOF
 
     cat <<EOF >> $rootfs/usr/share/udhcpc/default.script
 #!/bin/sh
-
 case "\$1" in
-	deconfig)
-		ip addr flush dev \$interface
-                ;;
-
-	renew|bound)
-
-                # flush all the routes
-		if [ -n "\$router" ]; then
-                        ip route del default 2> /dev/null
-		fi
-
-                # check broadcast
-                if [ -n "\$broadcast" ]; then
-                        broadcast="broadcast \$broadcast"
-                fi
-
-                # add a new ip address
-		ip addr add \$ip/\$mask \$broadcast dev \$interface
-
-		if [ -n "\$router" ]; then
-                        ip route add default via \$router dev \$interface
-                fi
-
-		[ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
-		for i in \$dns ; do
-			echo nameserver \$i >> /etc/resolv.conf
-		done
-		;;
+    deconfig)
+        ip addr flush dev \$interface
+        ;;
+
+    renew|bound)
+        # flush all the routes
+        if [ -n "\$router" ]; then
+            ip route del default 2> /dev/null
+        fi
+
+        # check broadcast
+        if [ -n "\$broadcast" ]; then
+            broadcast="broadcast \$broadcast"
+        fi
+
+        # add a new ip address
+        ip addr add \$ip/\$mask \$broadcast dev \$interface
+
+        if [ -n "\$router" ]; then
+            ip route add default via \$router dev \$interface
+        fi
+
+        [ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
+        for i in \$dns ; do
+            echo nameserver \$i >> /etc/resolv.conf
+        done
+        ;;
 esac
 exit 0
 EOF
@@ -154,22 +152,22 @@ configure_busybox()
     type busybox >/dev/null
 
     if [ $? -ne 0 ]; then
-	echo "busybox executable is not accessible"
-	return 1
+        echo "busybox executable is not accessible"
+        return 1
     fi
 
     file $(which busybox) | grep -q "statically linked"
     if [ $? -ne 0 ]; then
-	echo "warning : busybox is not statically linked."
-	echo "warning : The template script may not correctly"
-	echo "warning : setup the container environment."
+        echo "warning : busybox is not statically linked."
+        echo "warning : The template script may not correctly"
+        echo "warning : setup the container environment."
     fi
 
     # copy busybox in the rootfs
     cp $(which busybox) $rootfs/bin
     if [ $? -ne 0 ]; then
-	echo "failed to copy busybox in the rootfs"
-	return 1
+        echo "failed to copy busybox in the rootfs"
+        return 1
     fi
 
     # symlink busybox for the commands it supports
@@ -239,8 +237,8 @@ EOF
 
 options=$(getopt -o hp:n: -l help,path:,name: -- "$@")
 if [ $? -ne 0 ]; then
-        usage $(basename $0)
-	exit 1
+    usage $(basename $0)
+    exit 1
 fi
 eval set -- "$options"
 
@@ -249,7 +247,7 @@ do
     case "$1" in
         -h|--help)      usage $0 && exit 0;;
         -p|--path)      path=$2; shift 2;;
-	-n|--name)      name=$2; shift 2;;
+        -n|--name)      name=$2; shift 2;;
         --)             shift 1; break ;;
         *)              break ;;
     esac
diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 56279a8..6b5f2f9 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -13,7 +13,7 @@
 
 # This library 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 
 # You should have received a copy of the GNU Lesser General Public
@@ -31,9 +31,9 @@ configure_debian()
     # squeeze only has /dev/tty and /dev/tty0 by default,
     # therefore creating missing device nodes for tty1-4.
     for tty in $(seq 1 4); do
-	if [ ! -e $rootfs/dev/tty$tty ]; then
-	    mknod $rootfs/dev/tty$tty c 4 $tty
-	fi
+        if [ ! -e $rootfs/dev/tty$tty ]; then
+            mknod $rootfs/dev/tty$tty c 4 $tty
+        fi
     done
 
     # configure the inittab
@@ -78,11 +78,11 @@ EOF
 
     # reconfigure some services
     if [ -z "$LANG" ]; then
-	chroot $rootfs locale-gen en_US.UTF-8 UTF-8
-	chroot $rootfs update-locale LANG=en_US.UTF-8
+        chroot $rootfs locale-gen en_US.UTF-8 UTF-8
+        chroot $rootfs update-locale LANG=en_US.UTF-8
     else
-	chroot $rootfs locale-gen $LANG $(echo $LANG | cut -d. -f2)
-	chroot $rootfs update-locale LANG=$LANG
+        chroot $rootfs locale-gen $LANG $(echo $LANG | cut -d. -f2)
+        chroot $rootfs update-locale LANG=$LANG
     fi
 
     # remove pointless services in a container
@@ -123,18 +123,18 @@ openssh-server
     # check the mini debian was not already downloaded
     mkdir -p "$cache/partial-$SUITE-$arch"
     if [ $? -ne 0 ]; then
-	echo "Failed to create '$cache/partial-$SUITE-$arch' directory"
-	return 1
+        echo "Failed to create '$cache/partial-$SUITE-$arch' directory"
+        return 1
     fi
 
     # download a mini debian into a cache
     echo "Downloading debian minimal ..."
     debootstrap --verbose --variant=minbase --arch=$arch \
-	--include=$packages \
-	"$SUITE" "$cache/partial-$SUITE-$arch" $MIRROR
+        --include=$packages \
+        "$SUITE" "$cache/partial-$SUITE-$arch" $MIRROR
     if [ $? -ne 0 ]; then
-	echo "Failed to download the rootfs, aborting."
-	return 1
+        echo "Failed to download the rootfs, aborting."
+        return 1
     fi
 
     mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch"
@@ -166,32 +166,32 @@ install_debian()
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -x 200
-	if [ $? -ne 0 ]; then
-	    echo "Cache repository is busy."
-	    return 1
-	fi
+        flock -x 200
+        if [ $? -ne 0 ]; then
+            echo "Cache repository is busy."
+            return 1
+        fi
 
-	arch=$(dpkg --print-architecture)
+        arch=$(dpkg --print-architecture)
 
-	echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
-	if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
-	    download_debian $cache $arch
-	    if [ $? -ne 0 ]; then
-		echo "Failed to download 'debian base'"
-		return 1
-	    fi
-	fi
+        echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
+        if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
+            download_debian $cache $arch
+            if [ $? -ne 0 ]; then
+                echo "Failed to download 'debian base'"
+                return 1
+            fi
+        fi
 
-	copy_debian $cache $arch $rootfs
-	if [ $? -ne 0 ]; then
-	    echo "Failed to copy rootfs"
-	    return 1
-	fi
+        copy_debian $cache $arch $rootfs
+        if [ $? -ne 0 ]; then
+            echo "Failed to copy rootfs"
+            return 1
+        fi
 
-	return 0
+        return 0
 
-	) 200>@LOCALSTATEDIR@/lock/subsys/lxc
+        ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 
     return $?
 }
@@ -234,8 +234,8 @@ lxc.mount.entry = sysfs sys sysfs defaults  0 0
 EOF
 
     if [ $? -ne 0 ]; then
-	echo "Failed to add configuration"
-	return 1
+        echo "Failed to add configuration"
+        return 1
     fi
 
     return 0
@@ -246,20 +246,20 @@ clean()
     cache="@LOCALSTATEDIR@/cache/lxc/debian"
 
     if [ ! -e $cache ]; then
-	exit 0
+        exit 0
     fi
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -x 200
-	if [ $? != 0 ]; then
-	    echo "Cache repository is busy."
-	    exit 1
-	fi
+        flock -x 200
+        if [ $? != 0 ]; then
+            echo "Cache repository is busy."
+            exit 1
+        fi
 
-	echo -n "Purging the download cache..."
-	rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
-	exit 0
+        echo -n "Purging the download cache..."
+        rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
+        exit 0
 
     ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 }
@@ -275,7 +275,7 @@ EOF
 options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@")
 if [ $? -ne 0 ]; then
         usage $(basename $0)
-	exit 1
+        exit 1
 fi
 eval set -- "$options"
 
@@ -284,8 +284,8 @@ do
     case "$1" in
         -h|--help)      usage $0 && exit 0;;
         -p|--path)      path=$2; shift 2;;
-	-n|--name)      name=$2; shift 2;;
-	-c|--clean)     clean=$2; shift 2;;
+        -n|--name)      name=$2; shift 2;;
+        -c|--clean)     clean=$2; shift 2;;
         --)             shift 1; break ;;
         *)              break ;;
     esac
diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index f93edc9..bc4b264 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -131,8 +131,8 @@ download_fedora()
     INSTALL_ROOT=$cache/partial
     mkdir -p $INSTALL_ROOT
     if [ $? -ne 0 ]; then
-	echo "Failed to create '$INSTALL_ROOT' directory"
-	return 1
+        echo "Failed to create '$INSTALL_ROOT' directory"
+        return 1
     fi
 
     # download a mini fedora into a cache
@@ -170,8 +170,8 @@ download_fedora()
     $YUM install $PKG_LIST
 
     if [ $? -ne 0 ]; then
-	echo "Failed to download the rootfs, aborting."
-	return 1
+        echo "Failed to download the rootfs, aborting."
+        return 1
     fi
 
     mv "$INSTALL_ROOT" "$cache/rootfs"
@@ -202,39 +202,38 @@ install_fedora()
 {
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -x 200
-	if [ $? -ne 0 ]; then
-	    echo "Cache repository is busy."
-	    return 1
-	fi
-
-	echo "Checking cache download in $cache/rootfs ... "
-	if [ ! -e "$cache/rootfs" ]; then
-	    download_fedora
-	    if [ $? -ne 0 ]; then
-		echo "Failed to download 'fedora base'"
-		return 1
-	    fi
+        flock -x 200
+        if [ $? -ne 0 ]; then
+            echo "Cache repository is busy."
+            return 1
+        fi
+
+        echo "Checking cache download in $cache/rootfs ... "
+        if [ ! -e "$cache/rootfs" ]; then
+            download_fedora
+            if [ $? -ne 0 ]; then
+                echo "Failed to download 'fedora base'"
+                return 1
+            fi
         else
-	    echo "Cache found. Updating..."
+            echo "Cache found. Updating..."
             update_fedora
-	    if [ $? -ne 0 ]; then
-		echo "Failed to update 'fedora base', continuing with last known good cache"
+            if [ $? -ne 0 ]; then
+                echo "Failed to update 'fedora base', continuing with last known good cache"
             else
                 echo "Update finished"
-	    fi
-	fi
-
-	echo "Copy $cache/rootfs to $rootfs_path ... "
-	copy_fedora
-	if [ $? -ne 0 ]; then
-	    echo "Failed to copy rootfs"
-	    return 1
-	fi
+            fi
+        fi
 
-	return 0
+        echo "Copy $cache/rootfs to $rootfs_path ... "
+        copy_fedora
+        if [ $? -ne 0 ]; then
+            echo "Failed to copy rootfs"
+            return 1
+        fi
 
-	) 200>@LOCALSTATEDIR@/lock/subsys/lxc
+        return 0
+    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 
     return $?
 }
@@ -277,8 +276,8 @@ proc            proc         proc    nodev,noexec,nosuid 0 0
 sysfs           sys          sysfs defaults  0 0
 EOF
     if [ $? -ne 0 ]; then
-	echo "Failed to add configuration"
-	return 1
+        echo "Failed to add configuration"
+        return 1
     fi
 
     return 0
@@ -288,21 +287,20 @@ clean()
 {
 
     if [ ! -e $cache ]; then
-	exit 0
+        exit 0
     fi
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -x 200
-	if [ $? != 0 ]; then
-	    echo "Cache repository is busy."
-	    exit 1
-	fi
-
-	echo -n "Purging the download cache for Fedora-$release..."
-	rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
-	exit 0
+        flock -x 200
+        if [ $? != 0 ]; then
+            echo "Cache repository is busy."
+            exit 1
+        fi
 
+        echo -n "Purging the download cache for Fedora-$release..."
+        rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
+        exit 0
     ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 }
 
@@ -335,12 +333,12 @@ eval set -- "$options"
 while true
 do
     case "$1" in
-	-h|--help)      usage $0 && exit 0;;
-	-p|--path)      path=$2; shift 2;;
-	-n|--name)      name=$2; shift 2;;
-	-c|--clean)     clean=$2; shift 2;;
+        -h|--help)      usage $0 && exit 0;;
+        -p|--path)      path=$2; shift 2;;
+        -n|--name)      name=$2; shift 2;;
+        -c|--clean)     clean=$2; shift 2;;
         -R|--release)   release=$2; shift 2;;
-	--)             shift 1; break ;;
+        --)             shift 1; break ;;
         *)              break ;;
     esac
 done
diff --git a/templates/lxc-lenny.in b/templates/lxc-lenny.in
index 1792726..afc9321 100644
--- a/templates/lxc-lenny.in
+++ b/templates/lxc-lenny.in
@@ -67,11 +67,11 @@ EOF
 
     # reconfigure some services
     if [ -z "$LANG" ]; then
-	chroot $rootfs locale-gen en_US.UTF-8
-	chroot $rootfs update-locale LANG=en_US.UTF-8
+        chroot $rootfs locale-gen en_US.UTF-8
+        chroot $rootfs update-locale LANG=en_US.UTF-8
     else
-	chroot $rootfs locale-gen $LANG
-	chroot $rootfs update-locale LANG=$LANG
+        chroot $rootfs locale-gen $LANG
+        chroot $rootfs update-locale LANG=$LANG
     fi
 
     # remove pointless services in a container
@@ -104,18 +104,19 @@ openssh-server
     # check the mini debian was not already downloaded
     mkdir -p "$cache/partial-$SUITE-$arch"
     if [ $? -ne 0 ]; then
-	echo "Failed to create '$cache/partial-$SUITE-$arch' directory"
-	return 1
+        echo "Failed to create '$cache/partial-$SUITE-$arch' directory"
+        return 1
     fi
 
     # download a mini debian into a cache
     echo "Downloading debian minimal ..."
     debootstrap --verbose --variant=minbase --arch=$arch \
-	--include $packages \
-	"$SUITE" "$cache/partial-$SUITE-$arch" http://ftp.debian.org/debian
+                --include $packages \
+                "$SUITE" "$cache/partial-$SUITE-$arch" \
+                http://ftp.debian.org/debian
     if [ $? -ne 0 ]; then
-	echo "Failed to download the rootfs, aborting."
-	return 1
+        echo "Failed to download the rootfs, aborting."
+        return 1
     fi
 
     mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch"
@@ -142,32 +143,30 @@ install_debian()
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -x 200
-	if [ $? -ne 0 ]; then
-	    echo "Cache repository is busy."
-	    return 1
-	fi
-
-	arch=$(dpkg --print-architecture)
-
-	echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
-	if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
-	    download_debian $cache $arch
-	    if [ $? -ne 0 ]; then
-		echo "Failed to download 'debian base'"
-		return 1
-	    fi
-	fi
-
-	copy_debian $cache $arch $rootfs
-	if [ $? -ne 0 ]; then
-	    echo "Failed to copy rootfs"
-	    return 1
-	fi
-
-	return 0
-
-	) 200>@LOCALSTATEDIR@/lock/subsys/lxc
+        flock -x 200
+        if [ $? -ne 0 ]; then
+            echo "Cache repository is busy."
+            return 1
+        fi
+
+        arch=$(dpkg --print-architecture)
+
+        echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
+        if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
+            download_debian $cache $arch
+            if [ $? -ne 0 ]; then
+                echo "Failed to download 'debian base'"
+                return 1
+            fi
+        fi
+
+        copy_debian $cache $arch $rootfs
+        if [ $? -ne 0 ]; then
+            echo "Failed to copy rootfs"
+            return 1
+        fi
+        return 0
+    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 
     return $?
 }
@@ -209,8 +208,8 @@ lxc.mount.entry = sysfs sys sysfs defaults  0 0
 EOF
 
     if [ $? -ne 0 ]; then
-	echo "Failed to add configuration"
-	return 1
+        echo "Failed to add configuration"
+        return 1
     fi
 
     return 0
@@ -221,21 +220,20 @@ clean()
     cache="@LOCALSTATEDIR@/cache/lxc/$SUITE"
 
     if [ ! -e $cache ]; then
-	exit 0
+        exit 0
     fi
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -x 200
-	if [ $? != 0 ]; then
-	    echo "Cache repository is busy."
-	    exit 1
-	fi
-
-	echo -n "Purging the download cache..."
-	rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
-	exit 0
-
+        flock -x 200
+        if [ $? != 0 ]; then
+            echo "Cache repository is busy."
+            exit 1
+        fi
+
+        echo -n "Purging the download cache..."
+        rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
+        exit 0
     ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 }
 
@@ -249,8 +247,8 @@ EOF
 
 options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@")
 if [ $? -ne 0 ]; then
-        usage $(basename $0)
-	exit 1
+    usage $(basename $0)
+    exit 1
 fi
 eval set -- "$options"
 
@@ -259,8 +257,8 @@ do
     case "$1" in
         -h|--help)      usage $0 && exit 0;;
         -p|--path)      path=$2; shift 2;;
-	-n|--name)      name=$2; shift 2;;
-	-c|--clean)     clean=$2; shift 2;;
+        -n|--name)      name=$2; shift 2;;
+        -c|--clean)     clean=$2; shift 2;;
         --)             shift 1; break ;;
         *)              break ;;
     esac
diff --git a/templates/lxc-opensuse.in b/templates/lxc-opensuse.in
index f6bc31c..e0f8e00 100644
--- a/templates/lxc-opensuse.in
+++ b/templates/lxc-opensuse.in
@@ -18,7 +18,7 @@
 
 # This library 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 
 # You should have received a copy of the GNU Lesser General Public
@@ -142,8 +142,8 @@ download_opensuse()
     mkdir -p "$cache/partial-$arch"
 
     if [ $? -ne 0 ]; then
-	echo "Failed to create '$cache/partial-$arch' directory"
-	return 1
+        echo "Failed to create '$cache/partial-$arch' directory"
+        return 1
     fi
 
     # download a mini opensuse into a cache
@@ -187,8 +187,8 @@ EOF
     rm -f $cache/partial-$arch/etc/mtab
     ln -sf /proc/self/mounts $cache/partial-$arch/etc/mtab
     if [ $? -ne 0 ]; then
-	echo "Failed to download the rootfs, aborting."
-	return 1
+        echo "Failed to download the rootfs, aborting."
+        return 1
     fi
 
     rm -fr "$cache/partial-$arch-packages"
@@ -217,33 +217,32 @@ install_opensuse()
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -x 200
-	if [ $? -ne 0 ]; then
-	    echo "Cache repository is busy."
-	    return 1
-	fi
-
-	arch=$(arch)
-
-	echo "Checking cache download in $cache/rootfs-$arch ... "
-	if [ ! -e "$cache/rootfs-$arch" ]; then
-	    download_opensuse $cache $arch
-	    if [ $? -ne 0 ]; then
-		echo "Failed to download 'opensuse base'"
-		return 1
-	    fi
-	fi
-
-	echo "Copy $cache/rootfs-$arch to $rootfs ... "
-	copy_opensuse $cache $arch $rootfs
-	if [ $? -ne 0 ]; then
-	    echo "Failed to copy rootfs"
-	    return 1
-	fi
-
-	return 0
-
-	) 200>@LOCALSTATEDIR@/lock/subsys/lxc
+        flock -x 200
+        if [ $? -ne 0 ]; then
+            echo "Cache repository is busy."
+            return 1
+        fi
+
+        arch=$(arch)
+
+        echo "Checking cache download in $cache/rootfs-$arch ... "
+        if [ ! -e "$cache/rootfs-$arch" ]; then
+            download_opensuse $cache $arch
+            if [ $? -ne 0 ]; then
+                echo "Failed to download 'opensuse base'"
+                return 1
+            fi
+        fi
+
+        echo "Copy $cache/rootfs-$arch to $rootfs ... "
+        copy_opensuse $cache $arch $rootfs
+        if [ $? -ne 0 ]; then
+            echo "Failed to copy rootfs"
+            return 1
+        fi
+
+        return 0
+    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 
     return $?
 }
@@ -289,8 +288,8 @@ sysfs           sys          sysfs	defaults  0 0
 EOF
 
     if [ $? -ne 0 ]; then
-	echo "Failed to add configuration"
-	return 1
+        echo "Failed to add configuration"
+        return 1
     fi
 
     return 0
@@ -301,21 +300,20 @@ clean()
     cache="@LOCALSTATEDIR@/cache/lxc/opensuse"
 
     if [ ! -e $cache ]; then
-	exit 0
+        exit 0
     fi
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -x 200
-	if [ $? != 0 ]; then
-	    echo "Cache repository is busy."
-	    exit 1
-	fi
-
-	echo -n "Purging the download cache..."
-	rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
-	exit 0
-
+        flock -x 200
+        if [ $? != 0 ]; then
+            echo "Cache repository is busy."
+            exit 1
+        fi
+
+        echo -n "Purging the download cache..."
+        rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
+        exit 0
     ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
 }
 
@@ -337,12 +335,12 @@ eval set -- "$options"
 while true
 do
     case "$1" in
-	-h|--help)      usage $0 && exit 0;;
-	-p|--path)      path=$2; shift 2;;
-	-n|--name)      name=$2; shift 2;;
-	-c|--clean)     clean=$2; shift 2;;
-	--)             shift 1; break ;;
-	*)              break ;;
+        -h|--help)      usage $0 && exit 0;;
+        -p|--path)      path=$2; shift 2;;
+        -n|--name)      name=$2; shift 2;;
+        -c|--clean)     clean=$2; shift 2;;
+        --)             shift 1; break ;;
+        *)              break ;;
     esac
 done
 
diff --git a/templates/lxc-oracle.in b/templates/lxc-oracle.in
index 43022d1..90b2bad 100644
--- a/templates/lxc-oracle.in
+++ b/templates/lxc-oracle.in
@@ -41,7 +41,7 @@ is_btrfs_subvolume()
 {
     if which btrfs >/dev/null 2>&1 && \
        btrfs subvolume list "$1" >/dev/null 2>&1; then
-	return 0
+        return 0
     fi
     return 1
 }
@@ -59,9 +59,9 @@ container_rootfs_configure()
     mkdir -p $container_rootfs/selinux
     echo 0 > $container_rootfs/selinux/enforce
     if [ -e $container_rootfs/etc/selinux/config ]; then
-	sed -i 's|SELINUX=enforcing|SELINUX=disabled|' $container_rootfs/etc/selinux/config
+        sed -i 's|SELINUX=enforcing|SELINUX=disabled|' $container_rootfs/etc/selinux/config
     else
-	echo "SELINUX=disabled" >$container_rootfs/etc/selinux/config
+        echo "SELINUX=disabled" >$container_rootfs/etc/selinux/config
     fi
     sed -i 's|session[ ]*required[ ]*pam_selinux.so[ ]*close|#session required pam_selinux.so close|' $container_rootfs/etc/pam.d/login
     sed -i 's|session[ ]*required[ ]*pam_selinux.so[ ]*open|#session required pam_selinux.so open|' $container_rootfs/etc/pam.d/login
@@ -108,15 +108,15 @@ EOF
     # remove module stuff for iptables it just shows errors that are not
     # relevant in a container
     if [ -f "$container_rootfs/etc/sysconfig/iptables-config" ]; then
-	sed -i 's|IPTABLES_MODULES=".*|IPTABLES_MODULES=""|' $container_rootfs/etc/sysconfig/iptables-config
-	sed -i 's|IPTABLES_MODULES_UNLOAD=".*|IPTABLES_MODULES_UNLOAD="no"|' $container_rootfs/etc/sysconfig/iptables-config
+        sed -i 's|IPTABLES_MODULES=".*|IPTABLES_MODULES=""|' $container_rootfs/etc/sysconfig/iptables-config
+        sed -i 's|IPTABLES_MODULES_UNLOAD=".*|IPTABLES_MODULES_UNLOAD="no"|' $container_rootfs/etc/sysconfig/iptables-config
     fi
 
     # disable readahead in the container
     if [ $container_release_major = "6" -a -e $container_rootfs/etc/sysconfig/readahead ]; then
-	rm -f $container_rootfs/etc/init/readahead-collector.conf
-	rm -f $container_rootfs/etc/init/readahead-disable-services.conf
-	sed -i 's|READAHEAD="yes"|READAHEAD="no"|' $container_rootfs/etc/sysconfig/readahead
+        rm -f $container_rootfs/etc/init/readahead-collector.conf
+        rm -f $container_rootfs/etc/init/readahead-disable-services.conf
+        sed -i 's|READAHEAD="yes"|READAHEAD="no"|' $container_rootfs/etc/sysconfig/readahead
     fi
 
     # disable udev in the container
@@ -125,13 +125,13 @@ EOF
 
     # disable nash raidautorun in the container since no /dev/md*
     if [ $container_release_major = "5" ]; then
-	sed -i 's|echo "raidautorun /dev/md0"|echo ""|' $container_rootfs/etc/rc.sysinit
-	sed -i 's|echo "raidautorun /dev/md0"|echo ""|' $container_rootfs/etc/rc.d/rc.sysinit
+        sed -i 's|echo "raidautorun /dev/md0"|echo ""|' $container_rootfs/etc/rc.sysinit
+        sed -i 's|echo "raidautorun /dev/md0"|echo ""|' $container_rootfs/etc/rc.d/rc.sysinit
     fi
 
     # prevent rc.sysinit from attempting to loadkeys
     if [ $container_release_major = "5" -a -e $container_rootfs/etc/sysconfig/keyboard ]; then
-	rm $container_rootfs/etc/sysconfig/keyboard
+        rm $container_rootfs/etc/sysconfig/keyboard
     fi
 
     # dont try to sync the hwclock at shutdown
@@ -169,13 +169,13 @@ EOF
 
     # start a getty on /dev/console, /dev/tty[1-4]
     if [ $container_release_major = "5" ]; then
-	sed -i '/1:2345:respawn/i cns:2345:respawn:/sbin/mingetty console' $container_rootfs/etc/inittab
-	sed -i '/5:2345:respawn/d' $container_rootfs/etc/inittab
-	sed -i '/6:2345:respawn/d' $container_rootfs/etc/inittab
+        sed -i '/1:2345:respawn/i cns:2345:respawn:/sbin/mingetty console' $container_rootfs/etc/inittab
+        sed -i '/5:2345:respawn/d' $container_rootfs/etc/inittab
+        sed -i '/6:2345:respawn/d' $container_rootfs/etc/inittab
     fi
 
     if [ $container_release_major = "6" ]; then
-	cat <<EOF > $container_rootfs/etc/init/console.conf
+        cat <<EOF > $container_rootfs/etc/init/console.conf
 # console - getty
 #
 # This service maintains a getty on the console from the point the system is
@@ -192,18 +192,18 @@ EOF
     # there might be other services that are useless but the below set is a good start
     # some of these might not exist in the image, so we silence chkconfig complaining
     # about the service file not being found
-    for service in						\
-	acpid auditd autofs cpuspeed dund gpm haldaemon hidd	\
-	ip6tables irqbalance iscsi iscsid isdn kdump kudzu	\
-	lm_sensors lvm2-monitor mdmonitor microcode_ctl		\
-	ntpd postfix sendmail udev-post ;
+    for service in \
+        acpid auditd autofs cpuspeed dund gpm haldaemon hidd	\
+        ip6tables irqbalance iscsi iscsid isdn kdump kudzu	\
+        lm_sensors lvm2-monitor mdmonitor microcode_ctl		\
+        ntpd postfix sendmail udev-post ;
     do
-	chroot $container_rootfs chkconfig 2>/dev/null $service off
+        chroot $container_rootfs chkconfig 2>/dev/null $service off
     done
 
     for service in rsyslog ;
     do
-	chroot $container_rootfs chkconfig 2>/dev/null $service on
+        chroot $container_rootfs chkconfig 2>/dev/null $service on
     done
 
     # create required devices. note that /dev/console will be created by lxc
@@ -211,8 +211,8 @@ EOF
     # take care to not nuke /dev in case $container_rootfs isn't set
     dev_path="$container_rootfs/dev"
     if [ $container_rootfs != "/" -a -d $dev_path ]; then
-	rm -rf $dev_path
-	mkdir -p $dev_path
+        rm -rf $dev_path
+        mkdir -p $dev_path
     fi
     mknod -m 666  $dev_path/null c 1 3
     mknod -m 666  $dev_path/zero c 1 5
@@ -252,8 +252,8 @@ container_config_create()
     # generate a hwaddr for the container with a high mac address
     # see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
     local hwaddr="fe:`dd if=/dev/urandom bs=8 count=1 2>/dev/null |od -t x8 | \
-		      head -1 |awk '{print $2}' | cut -c1-10 |\
-		      sed 's/\(..\)/\1:/g; s/.$//'`"
+                      head -1 |awk '{print $2}' | cut -c1-10 |\
+                      sed 's/\(..\)/\1:/g; s/.$//'`"
     mkdir -p $cfg_dir || die "unable to create config dir $cfg_dir"
     cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
 # Container configuration for Oracle Linux $release_major.$release_minor
@@ -270,11 +270,11 @@ EOF
     # see if the network settings were already specified
     lxc_network_type=`grep '^lxc.network.type' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
     if [ -z "$lxc_network_type" -a			\
-	 $host_distribution = "OracleServer" -o		\
-	 $host_distribution = "Fedora" ]; then
-	    echo "lxc.network.type = veth" >>$cfg_dir/config
-	    echo "lxc.network.flags = up" >>$cfg_dir/config
-	    echo "lxc.network.link = virbr0" >>$cfg_dir/config
+         $host_distribution = "OracleServer" -o		\
+         $host_distribution = "Fedora" ]; then
+            echo "lxc.network.type = veth" >>$cfg_dir/config
+            echo "lxc.network.flags = up" >>$cfg_dir/config
+            echo "lxc.network.link = virbr0" >>$cfg_dir/config
     fi
 
     cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
@@ -304,13 +304,13 @@ EOF
 container_rootfs_clone()
 {
     if is_btrfs_subvolume $template_rootfs; then
-	# lxc-create already made $container_rootfs a btrfs subvolume, but
-	# in this case we want to snapshot the original subvolume so we we
-	# have to delete the one that lxc-create made
-	btrfs subvolume delete $container_rootfs
-	btrfs subvolume snapshot $template_rootfs $container_rootfs || die "btrfs clone template"
+        # lxc-create already made $container_rootfs a btrfs subvolume, but
+        # in this case we want to snapshot the original subvolume so we we
+        # have to delete the one that lxc-create made
+        btrfs subvolume delete $container_rootfs
+        btrfs subvolume snapshot $template_rootfs $container_rootfs || die "btrfs clone template"
     else
-	cp -ax $template_rootfs $container_rootfs || die "copy template"
+        cp -ax $template_rootfs $container_rootfs || die "copy template"
     fi
 }
 
@@ -318,121 +318,121 @@ container_rootfs_create()
 {
     cmds="rpm wget yum"
     if [ $release_major = "5" ]; then
-	if [ $host_distribution = "Ubuntu" ]; then
-	    db_dump_cmd="db5.1_dump"
-	    db_load_cmd="db4.3_load"
-	fi
-	if [ $host_distribution = "OracleServer" -o \
-	     $host_distribution = "Fedora" ]; then
-	    db_dump_cmd="db_dump"
-	    db_load_cmd="db43_load"
-	fi
-
-	cmds="$cmds $db_dump_cmd $db_load_cmd file"
+        if [ $host_distribution = "Ubuntu" ]; then
+            db_dump_cmd="db5.1_dump"
+            db_load_cmd="db4.3_load"
+        fi
+        if [ $host_distribution = "OracleServer" -o \
+             $host_distribution = "Fedora" ]; then
+            db_dump_cmd="db_dump"
+            db_load_cmd="db43_load"
+        fi
+
+        cmds="$cmds $db_dump_cmd $db_load_cmd file"
     fi
     for cmd in $cmds; do
-	which $cmd >/dev/null 2>&1
-	if [ $? -ne 0 ]; then
-	    die "The $cmd command is required, please install it"
-	fi
+        which $cmd >/dev/null 2>&1
+        if [ $? -ne 0 ]; then
+            die "The $cmd command is required, please install it"
+        fi
     done
 
     mkdir -p /var/lock/subsys/
     (
-	flock -x 200
-	if [ $? -ne 0 ]; then
-	    die "The template is busy."
-	fi
-
-	echo "Downloading release $release_major.$release_minor for $basearch"
-
-	# get yum repo file
-	public_yum_url=http://public-yum.oracle.com
-	if   [ $release_major = "5" ]; then
-	    repofile=public-yum-el5.repo
-	elif [ $release_major = "6" ]; then
-	    repofile=public-yum-ol6.repo
-	else
-	    die "Unsupported release $release_major"
-	fi
-	mkdir -p $container_rootfs/etc/yum.repos.d
-	wget -q $public_yum_url/$repofile -O $container_rootfs/etc/yum.repos.d/$repofile
-	if [ $? -ne 0 ]; then
-	    die "Failed to download repo file $public_yum_url/$repofile"
-	fi
-
-	# yum will take $basearch from host, so force the arch we want
-	sed -i "s|\$basearch|$basearch|" $container_rootfs/etc/yum.repos.d/$repofile
-
-	# replace url if they specified one
-	if [ -n "$repourl" ]; then
-	    sed -i "s|baseurl=http://public-yum.oracle.com/repo|baseurl=$repourl/repo|" $container_rootfs/etc/yum.repos.d/$repofile
-	    sed -i "s|gpgkey=http://public-yum.oracle.com|gpgkey=$repourl|" $container_rootfs/etc/yum.repos.d/$repofile
-	fi
-
-	# disable all repos, then enable the repo for the version we are installing.
-	if [ $release_minor = "latest" ]; then
-	    if [ $release_major = "5" ]; then
-		repo="el"$release_major"_"$release_minor
-	    else
-		repo="ol"$release_major"_"$release_minor
-	    fi
-	elif [ $release_minor = "0" ]; then
-	    repo="ol"$release_major"_ga_base"
-	else
-	    repo="ol"$release_major"_u"$release_minor"_base"
-	fi
-	sed -i "s|enabled=1|enabled=0|" $container_rootfs/etc/yum.repos.d/$repofile
-	sed -i "/\[$repo\]/,/\[/ s/enabled=0/enabled=1/" $container_rootfs/etc/yum.repos.d/$repofile
-
-	# create rpm db, download and yum install minimal packages
-	mkdir -p $container_rootfs/var/lib/rpm
-	rpm --root $container_rootfs --initdb
-	yum_cmd="yum --installroot $container_rootfs --disablerepo=* --enablerepo=$repo -y --nogpgcheck"
-	min_pkgs="yum initscripts passwd rsyslog vim-minimal openssh-server dhclient chkconfig rootfiles policycoreutils oraclelinux-release"
-
-	$yum_cmd install $min_pkgs
-	if [ $? -ne 0 ]; then
-	    die "Failed to download and install the rootfs, aborting."
-	fi
-
-	# rsyslog and pam depend on coreutils for some common commands in
-	# their POSTIN scriptlets, but coreutils wasn't installed yet. now
-	# that coreutils is installed, reinstall the packages so their POSTIN
-	# runs right. similarly, libutempter depends on libselinux.so.1 when
-	# it runs /usr/sbin/groupadd, so reinstall it too
-	if [ $release_major = "5" ]; then
-	    rpm --root $container_rootfs --nodeps -e rsyslog pam libutempter
-	    $yum_cmd install rsyslog pam libutempter
-	    if [ $? -ne 0 ]; then
-		die "Unable to reinstall packages"
-	    fi
-	fi
-
-	# these distributions put the rpm database in a place the guest is
-	# not expecting it, so move it
-	if [ $host_distribution = "Ubuntu" ]; then
-	    mv $container_rootfs/root/.rpmdb/* $container_rootfs/var/lib/rpm
-	fi
-
-	# if the native rpm created the db with Hash version 9, we need to
-	# downgrade it to Hash version 8 for use with OL5.x
-	db_version=`file $container_rootfs/var/lib/rpm/Packages | \
-		    grep -o 'version [0-9]*' |awk '{print $2}'`
-	if [ $release_major = "5" -a $db_version != "8" ]; then
-	    echo "Fixing (downgrading) rpm database from version $db_version"
-	    rm -f $container_rootfs/var/lib/rpm/__db*
-	    for db in $container_rootfs/var/lib/rpm/* ; do
-		$db_dump_cmd $db |$db_load_cmd $db.new
-		mv $db.new $db
-	    done
-	fi
-
-	# the host rpm may not be the same as the guest, rebuild the db with
-	# the guest rpm version
-	echo "Rebuilding rpm database"
-	rm -f $container_rootfs/var/lib/rpm/__db*
-	chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1
+        flock -x 200
+        if [ $? -ne 0 ]; then
+            die "The template is busy."
+        fi
+
+        echo "Downloading release $release_major.$release_minor for $basearch"
+
+        # get yum repo file
+        public_yum_url=http://public-yum.oracle.com
+        if   [ $release_major = "5" ]; then
+            repofile=public-yum-el5.repo
+        elif [ $release_major = "6" ]; then
+            repofile=public-yum-ol6.repo
+        else
+            die "Unsupported release $release_major"
+        fi
+        mkdir -p $container_rootfs/etc/yum.repos.d
+        wget -q $public_yum_url/$repofile -O $container_rootfs/etc/yum.repos.d/$repofile
+        if [ $? -ne 0 ]; then
+            die "Failed to download repo file $public_yum_url/$repofile"
+        fi
+
+        # yum will take $basearch from host, so force the arch we want
+        sed -i "s|\$basearch|$basearch|" $container_rootfs/etc/yum.repos.d/$repofile
+
+        # replace url if they specified one
+        if [ -n "$repourl" ]; then
+            sed -i "s|baseurl=http://public-yum.oracle.com/repo|baseurl=$repourl/repo|" $container_rootfs/etc/yum.repos.d/$repofile
+            sed -i "s|gpgkey=http://public-yum.oracle.com|gpgkey=$repourl|" $container_rootfs/etc/yum.repos.d/$repofile
+        fi
+
+        # disable all repos, then enable the repo for the version we are installing.
+        if [ $release_minor = "latest" ]; then
+            if [ $release_major = "5" ]; then
+        repo="el"$release_major"_"$release_minor
+            else
+                repo="ol"$release_major"_"$release_minor
+            fi
+        elif [ $release_minor = "0" ]; then
+            repo="ol"$release_major"_ga_base"
+        else
+            repo="ol"$release_major"_u"$release_minor"_base"
+        fi
+        sed -i "s|enabled=1|enabled=0|" $container_rootfs/etc/yum.repos.d/$repofile
+        sed -i "/\[$repo\]/,/\[/ s/enabled=0/enabled=1/" $container_rootfs/etc/yum.repos.d/$repofile
+
+        # create rpm db, download and yum install minimal packages
+        mkdir -p $container_rootfs/var/lib/rpm
+        rpm --root $container_rootfs --initdb
+        yum_cmd="yum --installroot $container_rootfs --disablerepo=* --enablerepo=$repo -y --nogpgcheck"
+        min_pkgs="yum initscripts passwd rsyslog vim-minimal openssh-server dhclient chkconfig rootfiles policycoreutils oraclelinux-release"
+
+        $yum_cmd install $min_pkgs
+        if [ $? -ne 0 ]; then
+            die "Failed to download and install the rootfs, aborting."
+        fi
+
+        # rsyslog and pam depend on coreutils for some common commands in
+        # their POSTIN scriptlets, but coreutils wasn't installed yet. now
+        # that coreutils is installed, reinstall the packages so their POSTIN
+        # runs right. similarly, libutempter depends on libselinux.so.1 when
+        # it runs /usr/sbin/groupadd, so reinstall it too
+        if [ $release_major = "5" ]; then
+            rpm --root $container_rootfs --nodeps -e rsyslog pam libutempter
+            $yum_cmd install rsyslog pam libutempter
+            if [ $? -ne 0 ]; then
+                die "Unable to reinstall packages"
+            fi
+        fi
+
+        # these distributions put the rpm database in a place the guest is
+        # not expecting it, so move it
+        if [ $host_distribution = "Ubuntu" ]; then
+            mv $container_rootfs/root/.rpmdb/* $container_rootfs/var/lib/rpm
+        fi
+
+        # if the native rpm created the db with Hash version 9, we need to
+        # downgrade it to Hash version 8 for use with OL5.x
+        db_version=`file $container_rootfs/var/lib/rpm/Packages | \
+                    grep -o 'version [0-9]*' |awk '{print $2}'`
+        if [ $release_major = "5" -a $db_version != "8" ]; then
+            echo "Fixing (downgrading) rpm database from version $db_version"
+            rm -f $container_rootfs/var/lib/rpm/__db*
+            for db in $container_rootfs/var/lib/rpm/* ; do
+                $db_dump_cmd $db |$db_load_cmd $db.new
+                mv $db.new $db
+            done
+        fi
+
+        # the host rpm may not be the same as the guest, rebuild the db with
+        # the guest rpm version
+        echo "Rebuilding rpm database"
+        rm -f $container_rootfs/var/lib/rpm/__db*
+        chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1
     ) 200>/var/lock/subsys/lxc-oracle-$name
 }
 
@@ -461,14 +461,14 @@ eval set -- "$options"
 while true
 do
     case "$1" in
-	-h|--help)		usage $0 && exit 0;;
-	-p|--path)		cfg_dir=$2; shift 2;;
-	-n|--name)		name=$2; shift 2;;
-	-a|--arch)		arch=$2; shift 2;;
-	-R|--release)		release_version=$2; shift 2;;
-	-u|--url)		repourl=$2; shift;;
-	-t|--templatefs)	template_rootfs=$2; shift 2;;
-	--)             	shift 1; break ;;
+        -h|--help)		usage $0 && exit 0;;
+        -p|--path)		cfg_dir=$2; shift 2;;
+        -n|--name)		name=$2; shift 2;;
+        -a|--arch)		arch=$2; shift 2;;
+        -R|--release)		release_version=$2; shift 2;;
+        -u|--url)		repourl=$2; shift;;
+        -t|--templatefs)	template_rootfs=$2; shift 2;;
+        --)             	shift 1; break ;;
         *)              	break ;;
     esac
 done
diff --git a/templates/lxc-sshd.in b/templates/lxc-sshd.in
index ba64cbf..b704723 100644
--- a/templates/lxc-sshd.in
+++ b/templates/lxc-sshd.in
@@ -43,7 +43,7 @@ $rootfs/lib64"
 
     mkdir -p $tree
     if [ $? -ne 0 ]; then
-	return 1
+        return 1
     fi
 
     return 0
@@ -172,14 +172,14 @@ if [ $0 == "/sbin/init" ]; then
 
     type @LXCINITDIR@/lxc-init
     if [ $? -ne 0 ]; then
-	echo "'lxc-init is not accessible on the system"
-	exit 1
+        echo "'lxc-init is not accessible on the system"
+        exit 1
     fi
 
     type sshd
     if [ $? -ne 0 ]; then
-	echo "'sshd' is not accessible on the system "
-	exit 1
+        echo "'sshd' is not accessible on the system "
+        exit 1
     fi
 
     # run dhcp?
-- 
1.8.0





More information about the lxc-devel mailing list