Permalink
Browse files

Update for consistent indent

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@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information...
1 parent eba7df9 commit 14d9c0f09d1a55d124ef210a4b4e205c9fe7596c @stgraber stgraber committed Dec 5, 2012
View
4 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@ubuntu.com> Fri, 27 Jul 2012 15:47:02 +0600
View
@@ -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
View
@@ -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
}
View
@@ -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
View
@@ -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,35 +97,35 @@ 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
# If LVM partition, destroy it. For btrfs, we delete the subvolue. If anything
# 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
View
@@ -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'.
Oops, something went wrong.

0 comments on commit 14d9c0f

Please sign in to comment.