Commit 14d9c0f0 by Stéphane Graber

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent eba7df9e
...@@ -76,10 +76,10 @@ cat > seccomp.full << EOF ...@@ -76,10 +76,10 @@ cat > seccomp.full << EOF
whitelist whitelist
EOF EOF
for i in `seq 0 300`; do for i in `seq 0 300`; do
echo $i >> secomp.full echo $i >> secomp.full
done done
for i in `seq 1024 1079`; do for i in `seq 1024 1079`; do
echo $i >> seccomp.full echo $i >> seccomp.full
done done
-- Serge Hallyn <serge.hallyn@ubuntu.com> Fri, 27 Jul 2012 15:47:02 +0600 -- Serge Hallyn <serge.hallyn@ubuntu.com> Fri, 27 Jul 2012 15:47:02 +0600
...@@ -6,8 +6,8 @@ cleanup() { ...@@ -6,8 +6,8 @@ cleanup() {
} }
if [ `id -u` -ne 0 ]; then if [ `id -u` -ne 0 ]; then
echo "Run as root" echo "Run as root"
exit 1 exit 1
fi fi
cat > /etc/lxc/test-busybox.conf << EOF cat > /etc/lxc/test-busybox.conf << EOF
...@@ -20,13 +20,13 @@ EOF ...@@ -20,13 +20,13 @@ EOF
export LD_LIBRARY_PATH=. export LD_LIBRARY_PATH=.
TESTS="lxc-test-containertests lxc-test-locktests lxc-test-startone" TESTS="lxc-test-containertests lxc-test-locktests lxc-test-startone"
for curtest in $TESTS; do for curtest in $TESTS; do
echo "running $curtest" echo "running $curtest"
./src/tests/$curtest ./src/tests/$curtest
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Test $curtest failed. Stopping" echo "Test $curtest failed. Stopping"
cleanup cleanup
exit 1 exit 1
fi fi
done done
echo "All tests passed" echo "All tests passed"
cleanup cleanup
...@@ -21,13 +21,13 @@ is_enabled() { ...@@ -21,13 +21,13 @@ is_enabled() {
RES=$? RES=$?
if [ $RES -eq 0 ]; then if [ $RES -eq 0 ]; then
$SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
else else
if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
$SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL
else else
$SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL
fi fi
fi fi
} }
......
...@@ -272,11 +272,11 @@ c=$lxc_path/$lxc_new/config ...@@ -272,11 +272,11 @@ c=$lxc_path/$lxc_new/config
mv ${c} ${c}.old mv ${c} ${c}.old
( (
while read line; do while read line; do
if [ "${line:0:18}" = "lxc.network.hwaddr" ]; then if [ "${line:0:18}" = "lxc.network.hwaddr" ]; then
echo "lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" echo "lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')"
else else
echo "$line" echo "$line"
fi fi
done done
) < ${c}.old > ${c} ) < ${c}.old > ${c}
rm -f ${c}.old rm -f ${c}.old
......
...@@ -54,26 +54,27 @@ eval set -- "$getopt" ...@@ -54,26 +54,27 @@ eval set -- "$getopt"
while true; do while true; do
case "$1" in case "$1" in
-h|--help) -h|--help)
help help
exit 1 exit 1
;; ;;
-n|--name) -n|--name)
shift shift
lxc_name=$1 lxc_name=$1
shift shift
;; ;;
-f) -f)
force=1 force=1
shift shift
;; ;;
--) --)
shift shift
break;; break
;;
*) *)
usage usage
exit 1 exit 1
;; ;;
esac esac
done done
...@@ -96,13 +97,13 @@ fi ...@@ -96,13 +97,13 @@ fi
# make sure the container isn't running # make sure the container isn't running
lxc-info -n $lxc_name 2>/dev/null | grep -q RUNNING lxc-info -n $lxc_name 2>/dev/null | grep -q RUNNING
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ $force -eq 1 ]; then if [ $force -eq 1 ]; then
lxc-stop -n $lxc_name lxc-stop -n $lxc_name
lxc-wait -n $lxc_name -s STOPPED lxc-wait -n $lxc_name -s STOPPED
else else
echo "$(basename $0): '$lxc_name' is running; aborted" >&2 echo "$(basename $0): '$lxc_name' is running; aborted" >&2
exit 1 exit 1
fi fi
fi fi
# Deduce the type of rootfs # Deduce the type of rootfs
...@@ -110,21 +111,21 @@ fi ...@@ -110,21 +111,21 @@ fi
# else, ignore it. We'll support deletion of others later. # 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/^[^/]*/\//'` rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
if [ -n "$rootdev" ]; then if [ -n "$rootdev" ]; then
if [ -b "$rootdev" -o -h "$rootdev" ]; then if [ -b "$rootdev" -o -h "$rootdev" ]; then
lvdisplay $rootdev > /dev/null 2>&1 lvdisplay $rootdev > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "removing backing store: $rootdev" echo "removing backing store: $rootdev"
lvremove -f $rootdev lvremove -f $rootdev
fi fi
elif [ -h "$rootdev" -o -d "$rootdev" ]; then elif [ -h "$rootdev" -o -d "$rootdev" ]; then
if which btrfs >/dev/null 2>&1 && if which btrfs >/dev/null 2>&1 &&
btrfs subvolume list "$rootdev" >/dev/null 2>&1; then btrfs subvolume list "$rootdev" >/dev/null 2>&1; then
btrfs subvolume delete "$rootdev" btrfs subvolume delete "$rootdev"
else else
# In case rootfs is not under $lxc_path/$lxc_name, remove it # In case rootfs is not under $lxc_path/$lxc_name, remove it
rm -rf --one-file-system --preserve-root $rootdev rm -rf --one-file-system --preserve-root $rootdev
fi fi
fi fi
fi fi
# recursively remove the container to remove old container configuration # recursively remove the container to remove old container configuration
......
...@@ -18,110 +18,110 @@ ...@@ -18,110 +18,110 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
usage() { usage() {
echo "usage: $(basename $0) -n|--name <name> -- [netstat_options]" >&2 echo "usage: $(basename $0) -n|--name <name> -- [netstat_options]" >&2
} }
help() { help() {
usage usage
echo >&2 echo >&2
echo "Execute 'netstat' for the specified container." >&2 echo "Execute 'netstat' for the specified container." >&2
echo >&2 echo >&2
echo " --name NAME specify the container name" >&2 echo " --name NAME specify the container name" >&2
echo " NETSTAT_OPTIONS netstat command options (see \`netstat --help')" >&2 echo " NETSTAT_OPTIONS netstat command options (see \`netstat --help')" >&2
} }
get_parent_cgroup() get_parent_cgroup()
{ {
local hierarchies hierarchy fields subsystems init_cgroup mountpoint local hierarchies hierarchy fields subsystems init_cgroup mountpoint
parent_cgroup="" parent_cgroup=""
# Obtain a list of hierarchies that contain one or more subsystems # Obtain a list of hierarchies that contain one or more subsystems
hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2) hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
# Iterate through the list until a suitable hierarchy is found # Iterate through the list until a suitable hierarchy is found
for hierarchy in $hierarchies; do for hierarchy in $hierarchies; do
# Obtain information about the init process in the hierarchy # Obtain information about the init process in the hierarchy
fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1) fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
if [ -z "$fields" ]; then continue; fi if [ -z "$fields" ]; then continue; fi
fields=${fields#*:} fields=${fields#*:}
# Get a comma-separated list of the hierarchy's subsystems # Get a comma-separated list of the hierarchy's subsystems
subsystems=${fields%:*} subsystems=${fields%:*}
# Get the cgroup of the init process in the hierarchy # Get the cgroup of the init process in the hierarchy
init_cgroup=${fields#*:} init_cgroup=${fields#*:}
# Get the filesystem mountpoint of the hierarchy # Get the filesystem mountpoint of the hierarchy
mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2) mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
if [ -z "$mountpoint" ]; then continue; fi if [ -z "$mountpoint" ]; then continue; fi
# Return the absolute path to the containers' parent cgroup # Return the absolute path to the containers' parent cgroup
# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem) # (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
if [[ ",$subsystems," == *,ns,* ]]; then if [[ ",$subsystems," == *,ns,* ]]; then
parent_cgroup="${mountpoint}${init_cgroup%/}" parent_cgroup="${mountpoint}${init_cgroup%/}"
else else
parent_cgroup="${mountpoint}${init_cgroup%/}/lxc" parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
fi fi
break break
done done
} }
exec="" exec=""
while true; do while true; do
case $1 in case $1 in
-h|--help) -h|--help)
help; exit 1;; help; exit 1;;
-n|--name) -n|--name)
name=$2; shift 2;; name=$2; shift 2;;
--exec) --exec)
exec="exec"; shift;; exec="exec"; shift;;
--) --)
shift; break;; shift; break;;
*) *)
break;; break;;
esac esac
done done
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then
echo "$(basename $0): must be run as root" >&2 echo "$(basename $0): must be run as root" >&2
exit 1 exit 1
fi fi
if [ -z "$name" ]; then if [ -z "$name" ]; then
usage usage
exit 1 exit 1
fi fi
if [ -z "$exec" ]; then 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 fi
lxc-info -n $name 2>&1 | grep -q 'STOPPED' lxc-info -n $name 2>&1 | grep -q 'STOPPED'
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "$(basename $0): container '$name' is not running" >&2 echo "$(basename $0): container '$name' is not running" >&2
exit 1 exit 1
fi fi
get_parent_cgroup get_parent_cgroup
if [ ! -d "$parent_cgroup" ]; then if [ ! -d "$parent_cgroup" ]; then
echo "$(basename $0): no cgroup mount point found" >&2 echo "$(basename $0): no cgroup mount point found" >&2
exit 1 exit 1
fi fi
pid=$(head -1 $parent_cgroup/$name/tasks) pid=$(head -1 $parent_cgroup/$name/tasks)
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
echo "$(basename $0): no process found for '$name'" >&2 echo "$(basename $0): no process found for '$name'" >&2
exit 1 exit 1
fi fi
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
if [ -z "$tmpdir" -o ! -d "$tmpdir" ]; then if [ -z "$tmpdir" -o ! -d "$tmpdir" ]; then
echo "$(basename $0): unable to create temporary directory" >&2 echo "$(basename $0): unable to create temporary directory" >&2
exit 1 exit 1
fi fi
# Bind mount /proc/$pid/net onto /proc/net before calling 'netstat'. # Bind mount /proc/$pid/net onto /proc/net before calling 'netstat'.
......
...@@ -19,125 +19,124 @@ ...@@ -19,125 +19,124 @@
usage() usage()
{ {
echo "usage: $(basename $0) [--lxc | --name NAME] [--] [PS_OPTIONS...]" >&2 echo "usage: $(basename $0) [--lxc | --name NAME] [--] [PS_OPTIONS...]" >&2
} }
help() { help() {
usage usage
echo >&2 echo >&2
echo "List current processes with container names." >&2 echo "List current processes with container names." >&2
echo >&2 echo >&2
echo " --lxc show processes in all containers" >&2 echo " --lxc show processes in all containers" >&2
echo " --name NAME show processes in the specified container" >&2 echo " --name NAME show processes in the specified container" >&2
echo " (multiple containers can be separated by commas)" >&2 echo " (multiple containers can be separated by commas)" >&2
echo " PS_OPTIONS ps command options (see \`ps --help')" >&2 echo " PS_OPTIONS ps command options (see \`ps --help')" >&2
} }
get_parent_cgroup() get_parent_cgroup()
{ {
local hierarchies hierarchy fields subsystems init_cgroup mountpoint local hierarchies hierarchy fields subsystems init_cgroup mountpoint
parent_cgroup="" parent_cgroup=""
# Obtain a list of hierarchies that contain one or more subsystems # Obtain a list of hierarchies that contain one or more subsystems
hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2) hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
# Iterate through the list until a suitable hierarchy is found # Iterate through the list until a suitable hierarchy is found
for hierarchy in $hierarchies; do for hierarchy in $hierarchies; do
# Obtain information about the init process in the hierarchy # Obtain information about the init process in the hierarchy
fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1) fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
if [ -z "$fields" ]; then continue; fi if [ -z "$fields" ]; then continue; fi
fields=${fields#*:} fields=${fields#*:}
# Get a comma-separated list of the hierarchy's subsystems # Get a comma-separated list of the hierarchy's subsystems
subsystems=${fields%:*} subsystems=${fields%:*}
# Get the cgroup of the init process in the hierarchy # Get the cgroup of the init process in the hierarchy
init_cgroup=${fields#*:} init_cgroup=${fields#*:}
# Get the filesystem mountpoint of the hierarchy # Get the filesystem mountpoint of the hierarchy
mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2) mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
if [ -z "$mountpoint" ]; then continue; fi if [ -z "$mountpoint" ]; then continue; fi
# Return the absolute path to the containers' parent cgroup # Return the absolute path to the containers' parent cgroup
# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem) # (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
if [[ ",$subsystems," == *,ns,* ]]; then if [[ ",$subsystems," == *,ns,* ]]; then
parent_cgroup="${mountpoint}${init_cgroup%/}" parent_cgroup="${mountpoint}${init_cgroup%/}"
else else
parent_cgroup="${mountpoint}${init_cgroup%/}/lxc" parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
fi fi
break break
done done
} }
containers="" containers=""
list_container_processes=0 list_container_processes=0
while true; do while true; do
case $1 in case $1 in
-h|--help) -h|--help)
help; exit 1;; help; exit 1;;
-n|--name) -n|--name)
containers=$2; list_container_processes=1; shift 2;; containers=$2; list_container_processes=1; shift 2;;
--lxc) --lxc)
list_container_processes=1; shift;; list_container_processes=1; shift;;
--) --)
shift; break;; shift; break;;
*) *)
break;; break;;
esac esac
done done
if [ "$list_container_processes" -eq "1" ]; then if [ "$list_container_processes" -eq "1" ]; then
set -- -e $@ set -- -e $@
fi fi
get_parent_cgroup get_parent_cgroup
if [ ! -d "$parent_cgroup" ]; then if [ ! -d "$parent_cgroup" ]; then
echo "$(basename $0): no cgroup mount point found" >&2 echo "$(basename $0): no cgroup mount point found" >&2
exit 1 exit 1
fi fi
declare -a container_of_pid declare -a container_of_pid
container_field_width=9 container_field_width=9
IFS="," IFS=","
if [ -z "$containers" ]; then 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 else
containers=( $containers ) containers=( $containers )
fi fi
declare -i pid declare -i pid
IFS=$'\n' IFS=$'\n'
for container in ${containers[@]}; do for container in ${containers[@]}; do
if [ "${#container}" -gt "$container_field_width" ]; then if [ "${#container}" -gt "$container_field_width" ]; then
container_field_width=${#container} container_field_width=${#container}
fi fi
if [ -f "$parent_cgroup/$container/tasks" ]; then if [ -f "$parent_cgroup/$container/tasks" ]; then
while read pid; do while read pid; do
container_of_pid[$pid]=$container container_of_pid[$pid]=$container
done < "$parent_cgroup/$container/tasks" done < "$parent_cgroup/$container/tasks"
fi fi
done done
declare -i line_pid_end_position declare -i line_pid_end_position
while read line; do while read line; do
if [ -z "$line_pid_end_position" ]; then if [ -z "$line_pid_end_position" ]; then
if [[ "$line" != *" PID"* ]]; then if [[ "$line" != *" PID"* ]]; then
echo "$(basename $0): no PID column found in \`ps' output" >&2 echo "$(basename $0): no PID column found in \`ps' output" >&2
exit 1 exit 1
fi fi
buffer=${line%" PID"*} buffer=${line%" PID"*}
let line_pid_end_position=${#buffer}+4 let line_pid_end_position=${#buffer}+4
printf "%-${container_field_width}s %s\n" "CONTAINER" "$line" printf "%-${container_field_width}s %s\n" "CONTAINER" "$line"
continue continue
fi fi
buffer=${line:0:$line_pid_end_position} buffer=${line:0:$line_pid_end_position}
pid=${buffer##* } pid=${buffer##* }
if [ "$list_container_processes" -eq "0" -o ! -z "${container_of_pid[pid]}" ]; then 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" printf "%-${container_field_width}s %s\n" "${container_of_pid[pid]}" "$line"
fi fi
done < <(ps "$@") done < <(ps "$@")
...@@ -97,16 +97,16 @@ while [ $# -gt 0 ]; do ...@@ -97,16 +97,16 @@ while [ $# -gt 0 ]; do
opt="$1" opt="$1"
shift shift
case "$opt" in case "$opt" in
-d) -d)
LXC_DROP_CAPS="yes" LXC_DROP_CAPS="yes"
;; ;;
-h|--help) -h|--help)
help help
exit 0 exit 0
;; ;;
--) --)
break break
;; ;;
-?) -?)
usage_err "unknown option '$opt'" usage_err "unknown option '$opt'"
;; ;;
...@@ -115,9 +115,9 @@ while [ $# -gt 0 ]; do ...@@ -115,9 +115,9 @@ while [ $# -gt 0 ]; do
set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@" set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
;; ;;
*) *)
usage usage
exit 1 exit 1
;; ;;
esac esac
done; done;
......
...@@ -41,9 +41,9 @@ help() { ...@@ -41,9 +41,9 @@ help() {
setuid() setuid()
{ {
if [ "$1" = "-r" ]; then if [ "$1" = "-r" ]; then
chmod -s $2 chmod -s $2
else else
chmod +s $1 chmod +s $1
fi fi
} }
...@@ -94,16 +94,16 @@ while [ $# -gt 0 ]; do ...@@ -94,16 +94,16 @@ while [ $# -gt 0 ]; do
opt="$1" opt="$1"
shift shift
case "$opt" in case "$opt" in
-d) -d)
LXC_DROP_CAPS="yes" LXC_DROP_CAPS="yes"
;; ;;
-h|--help) -h|--help)
help help
exit 0 exit 0
;; ;;
--) --)
break break
;; ;;
-?) -?)
usage_err "unknown option '$opt'" usage_err "unknown option '$opt'"
;; ;;
...@@ -112,9 +112,9 @@ while [ $# -gt 0 ]; do ...@@ -112,9 +112,9 @@ while [ $# -gt 0 ]; do
set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@" set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
;; ;;
*) *)
usage usage
exit 1 exit 1
;; ;;
esac esac
done; done;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# This library is distributed in the hope that it will be useful, # This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # 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. # Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
...@@ -151,8 +151,8 @@ download_altlinux() ...@@ -151,8 +151,8 @@ download_altlinux()
INSTALL_ROOT=$cache/partial INSTALL_ROOT=$cache/partial
mkdir -p $INSTALL_ROOT mkdir -p $INSTALL_ROOT
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to create '$INSTALL_ROOT' directory" echo "Failed to create '$INSTALL_ROOT' directory"
return 1 return 1
fi fi
# download a mini altlinux into a cache # download a mini altlinux into a cache
...@@ -166,8 +166,8 @@ download_altlinux() ...@@ -166,8 +166,8 @@ download_altlinux()
$APT_GET install $PKG_LIST $APT_GET install $PKG_LIST
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting."
return 1 return 1
fi fi
mv "$INSTALL_ROOT" "$cache/rootfs" mv "$INSTALL_ROOT" "$cache/rootfs"
...@@ -198,39 +198,37 @@ install_altlinux() ...@@ -198,39 +198,37 @@ install_altlinux()
{ {
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
fi fi
echo "Checking cache download in $cache/rootfs ... " echo "Checking cache download in $cache/rootfs ... "
if [ ! -e "$cache/rootfs" ]; then if [ ! -e "$cache/rootfs" ]; then
download_altlinux download_altlinux
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download 'altlinux base'" echo "Failed to download 'altlinux base'"
return 1 return 1
fi fi
else else
echo "Cache found. Updating..." echo "Cache found. Updating..."
update_altlinux update_altlinux
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to update 'altlinux base', continuing with last known good cache" echo "Failed to update 'altlinux base', continuing with last known good cache"
else else
echo "Update finished" echo "Update finished"
fi fi
fi fi
echo "Copy $cache/rootfs to $rootfs_path ... " echo "Copy $cache/rootfs to $rootfs_path ... "
copy_altlinux copy_altlinux
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to copy rootfs" echo "Failed to copy rootfs"
return 1 return 1
fi fi
return 0
return 0 ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $? return $?
} }
...@@ -302,8 +300,8 @@ sysfs $rootfs_path/sys sysfs defaults 0 0 ...@@ -302,8 +300,8 @@ sysfs $rootfs_path/sys sysfs defaults 0 0
EOF EOF
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to add configuration" echo "Failed to add configuration"
return 1 return 1
fi fi
return 0 return 0
...@@ -313,21 +311,20 @@ clean() ...@@ -313,21 +311,20 @@ clean()
{ {
if [ ! -e $cache ]; then if [ ! -e $cache ]; then
exit 0 exit 0
fi fi
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 200
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
fi fi
echo -n "Purging the download cache for ALTLinux-$release..." echo -n "Purging the download cache for ALTLinux-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
...@@ -370,17 +367,17 @@ eval set -- "$options" ...@@ -370,17 +367,17 @@ eval set -- "$options"
while true while true
do do
case "$1" in case "$1" in
-h|--help) usage $0 && exit 0;; -h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;; -p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
-P|--profile) profile=$2; shift 2;; -P|--profile) profile=$2; shift 2;;
-c|--clean) clean=$2; shift 2;; -c|--clean) clean=$2; shift 2;;
-R|--release) release=$2; shift 2;; -R|--release) release=$2; shift 2;;
-4|--ipv4) ipv4=$2; shift 2;; -4|--ipv4) ipv4=$2; shift 2;;
-6|--ipv6) ipv6=$2; shift 2;; -6|--ipv6) ipv6=$2; shift 2;;
-g|--gw) gw=$2; shift 2;; -g|--gw) gw=$2; shift 2;;
-d|--dns) dns=$2; shift 2;; -d|--dns) dns=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
done done
......
...@@ -108,36 +108,34 @@ EOF ...@@ -108,36 +108,34 @@ EOF
cat <<EOF >> $rootfs/usr/share/udhcpc/default.script cat <<EOF >> $rootfs/usr/share/udhcpc/default.script
#!/bin/sh #!/bin/sh
case "\$1" in case "\$1" in
deconfig) deconfig)
ip addr flush dev \$interface ip addr flush dev \$interface
;; ;;
renew|bound) renew|bound)
# flush all the routes
# flush all the routes if [ -n "\$router" ]; then
if [ -n "\$router" ]; then ip route del default 2> /dev/null
ip route del default 2> /dev/null fi
fi
# check broadcast
# check broadcast if [ -n "\$broadcast" ]; then
if [ -n "\$broadcast" ]; then broadcast="broadcast \$broadcast"
broadcast="broadcast \$broadcast" fi
fi
# add a new ip address
# add a new ip address ip addr add \$ip/\$mask \$broadcast dev \$interface
ip addr add \$ip/\$mask \$broadcast dev \$interface
if [ -n "\$router" ]; then
if [ -n "\$router" ]; then ip route add default via \$router dev \$interface
ip route add default via \$router dev \$interface fi
fi
[ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
[ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf for i in \$dns ; do
for i in \$dns ; do echo nameserver \$i >> /etc/resolv.conf
echo nameserver \$i >> /etc/resolv.conf done
done ;;
;;
esac esac
exit 0 exit 0
EOF EOF
...@@ -154,22 +152,22 @@ configure_busybox() ...@@ -154,22 +152,22 @@ configure_busybox()
type busybox >/dev/null type busybox >/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "busybox executable is not accessible" echo "busybox executable is not accessible"
return 1 return 1
fi fi
file $(which busybox) | grep -q "statically linked" file $(which busybox) | grep -q "statically linked"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "warning : busybox is not statically linked." echo "warning : busybox is not statically linked."
echo "warning : The template script may not correctly" echo "warning : The template script may not correctly"
echo "warning : setup the container environment." echo "warning : setup the container environment."
fi fi
# copy busybox in the rootfs # copy busybox in the rootfs
cp $(which busybox) $rootfs/bin cp $(which busybox) $rootfs/bin
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "failed to copy busybox in the rootfs" echo "failed to copy busybox in the rootfs"
return 1 return 1
fi fi
# symlink busybox for the commands it supports # symlink busybox for the commands it supports
...@@ -239,8 +237,8 @@ EOF ...@@ -239,8 +237,8 @@ EOF
options=$(getopt -o hp:n: -l help,path:,name: -- "$@") options=$(getopt -o hp:n: -l help,path:,name: -- "$@")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
usage $(basename $0) usage $(basename $0)
exit 1 exit 1
fi fi
eval set -- "$options" eval set -- "$options"
...@@ -249,7 +247,7 @@ do ...@@ -249,7 +247,7 @@ do
case "$1" in case "$1" in
-h|--help) usage $0 && exit 0;; -h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;; -p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# This library is distributed in the hope that it will be useful, # This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # 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. # Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
...@@ -31,9 +31,9 @@ configure_debian() ...@@ -31,9 +31,9 @@ configure_debian()
# squeeze only has /dev/tty and /dev/tty0 by default, # squeeze only has /dev/tty and /dev/tty0 by default,
# therefore creating missing device nodes for tty1-4. # therefore creating missing device nodes for tty1-4.
for tty in $(seq 1 4); do for tty in $(seq 1 4); do
if [ ! -e $rootfs/dev/tty$tty ]; then if [ ! -e $rootfs/dev/tty$tty ]; then
mknod $rootfs/dev/tty$tty c 4 $tty mknod $rootfs/dev/tty$tty c 4 $tty
fi fi
done done
# configure the inittab # configure the inittab
...@@ -78,11 +78,11 @@ EOF ...@@ -78,11 +78,11 @@ EOF
# reconfigure some services # reconfigure some services
if [ -z "$LANG" ]; then if [ -z "$LANG" ]; then
chroot $rootfs locale-gen en_US.UTF-8 UTF-8 chroot $rootfs locale-gen en_US.UTF-8 UTF-8
chroot $rootfs update-locale LANG=en_US.UTF-8 chroot $rootfs update-locale LANG=en_US.UTF-8
else else
chroot $rootfs locale-gen $LANG $(echo $LANG | cut -d. -f2) chroot $rootfs locale-gen $LANG $(echo $LANG | cut -d. -f2)
chroot $rootfs update-locale LANG=$LANG chroot $rootfs update-locale LANG=$LANG
fi fi
# remove pointless services in a container # remove pointless services in a container
...@@ -123,18 +123,18 @@ openssh-server ...@@ -123,18 +123,18 @@ openssh-server
# check the mini debian was not already downloaded # check the mini debian was not already downloaded
mkdir -p "$cache/partial-$SUITE-$arch" mkdir -p "$cache/partial-$SUITE-$arch"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to create '$cache/partial-$SUITE-$arch' directory" echo "Failed to create '$cache/partial-$SUITE-$arch' directory"
return 1 return 1
fi fi
# download a mini debian into a cache # download a mini debian into a cache
echo "Downloading debian minimal ..." echo "Downloading debian minimal ..."
debootstrap --verbose --variant=minbase --arch=$arch \ debootstrap --verbose --variant=minbase --arch=$arch \
--include=$packages \ --include=$packages \
"$SUITE" "$cache/partial-$SUITE-$arch" $MIRROR "$SUITE" "$cache/partial-$SUITE-$arch" $MIRROR
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting."
return 1 return 1
fi fi
mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch" mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch"
...@@ -166,32 +166,32 @@ install_debian() ...@@ -166,32 +166,32 @@ install_debian()
rootfs=$1 rootfs=$1
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
fi fi
arch=$(dpkg --print-architecture) arch=$(dpkg --print-architecture)
echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... " echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
download_debian $cache $arch download_debian $cache $arch
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download 'debian base'" echo "Failed to download 'debian base'"
return 1 return 1
fi fi
fi fi
copy_debian $cache $arch $rootfs copy_debian $cache $arch $rootfs
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to copy rootfs" echo "Failed to copy rootfs"
return 1 return 1
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $? return $?
} }
...@@ -234,8 +234,8 @@ lxc.mount.entry = sysfs sys sysfs defaults 0 0 ...@@ -234,8 +234,8 @@ lxc.mount.entry = sysfs sys sysfs defaults 0 0
EOF EOF
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to add configuration" echo "Failed to add configuration"
return 1 return 1
fi fi
return 0 return 0
...@@ -246,20 +246,20 @@ clean() ...@@ -246,20 +246,20 @@ clean()
cache="@LOCALSTATEDIR@/cache/lxc/debian" cache="@LOCALSTATEDIR@/cache/lxc/debian"
if [ ! -e $cache ]; then if [ ! -e $cache ]; then
exit 0 exit 0
fi fi
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 200
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
fi fi
echo -n "Purging the download cache..." echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
...@@ -275,7 +275,7 @@ EOF ...@@ -275,7 +275,7 @@ EOF
options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
usage $(basename $0) usage $(basename $0)
exit 1 exit 1
fi fi
eval set -- "$options" eval set -- "$options"
...@@ -284,8 +284,8 @@ do ...@@ -284,8 +284,8 @@ do
case "$1" in case "$1" in
-h|--help) usage $0 && exit 0;; -h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;; -p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
-c|--clean) clean=$2; shift 2;; -c|--clean) clean=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
......
...@@ -131,8 +131,8 @@ download_fedora() ...@@ -131,8 +131,8 @@ download_fedora()
INSTALL_ROOT=$cache/partial INSTALL_ROOT=$cache/partial
mkdir -p $INSTALL_ROOT mkdir -p $INSTALL_ROOT
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to create '$INSTALL_ROOT' directory" echo "Failed to create '$INSTALL_ROOT' directory"
return 1 return 1
fi fi
# download a mini fedora into a cache # download a mini fedora into a cache
...@@ -170,8 +170,8 @@ download_fedora() ...@@ -170,8 +170,8 @@ download_fedora()
$YUM install $PKG_LIST $YUM install $PKG_LIST
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting."
return 1 return 1
fi fi
mv "$INSTALL_ROOT" "$cache/rootfs" mv "$INSTALL_ROOT" "$cache/rootfs"
...@@ -202,39 +202,38 @@ install_fedora() ...@@ -202,39 +202,38 @@ install_fedora()
{ {
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
fi fi
echo "Checking cache download in $cache/rootfs ... " echo "Checking cache download in $cache/rootfs ... "
if [ ! -e "$cache/rootfs" ]; then if [ ! -e "$cache/rootfs" ]; then
download_fedora download_fedora
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download 'fedora base'" echo "Failed to download 'fedora base'"
return 1 return 1
fi fi
else else
echo "Cache found. Updating..." echo "Cache found. Updating..."
update_fedora update_fedora
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to update 'fedora base', continuing with last known good cache" echo "Failed to update 'fedora base', continuing with last known good cache"
else else
echo "Update finished" echo "Update finished"
fi fi
fi fi
echo "Copy $cache/rootfs to $rootfs_path ... "
copy_fedora
if [ $? -ne 0 ]; then
echo "Failed to copy rootfs"
return 1
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 $? return $?
} }
...@@ -277,8 +276,8 @@ proc proc proc nodev,noexec,nosuid 0 0 ...@@ -277,8 +276,8 @@ proc proc proc nodev,noexec,nosuid 0 0
sysfs sys sysfs defaults 0 0 sysfs sys sysfs defaults 0 0
EOF EOF
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to add configuration" echo "Failed to add configuration"
return 1 return 1
fi fi
return 0 return 0
...@@ -288,21 +287,20 @@ clean() ...@@ -288,21 +287,20 @@ clean()
{ {
if [ ! -e $cache ]; then if [ ! -e $cache ]; then
exit 0 exit 0
fi fi
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 200
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
fi fi
echo -n "Purging the download cache for Fedora-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
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 ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
...@@ -335,12 +333,12 @@ eval set -- "$options" ...@@ -335,12 +333,12 @@ eval set -- "$options"
while true while true
do do
case "$1" in case "$1" in
-h|--help) usage $0 && exit 0;; -h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;; -p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
-c|--clean) clean=$2; shift 2;; -c|--clean) clean=$2; shift 2;;
-R|--release) release=$2; shift 2;; -R|--release) release=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
done done
......
...@@ -67,11 +67,11 @@ EOF ...@@ -67,11 +67,11 @@ EOF
# reconfigure some services # reconfigure some services
if [ -z "$LANG" ]; then if [ -z "$LANG" ]; then
chroot $rootfs locale-gen en_US.UTF-8 chroot $rootfs locale-gen en_US.UTF-8
chroot $rootfs update-locale LANG=en_US.UTF-8 chroot $rootfs update-locale LANG=en_US.UTF-8
else else
chroot $rootfs locale-gen $LANG chroot $rootfs locale-gen $LANG
chroot $rootfs update-locale LANG=$LANG chroot $rootfs update-locale LANG=$LANG
fi fi
# remove pointless services in a container # remove pointless services in a container
...@@ -104,18 +104,19 @@ openssh-server ...@@ -104,18 +104,19 @@ openssh-server
# check the mini debian was not already downloaded # check the mini debian was not already downloaded
mkdir -p "$cache/partial-$SUITE-$arch" mkdir -p "$cache/partial-$SUITE-$arch"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to create '$cache/partial-$SUITE-$arch' directory" echo "Failed to create '$cache/partial-$SUITE-$arch' directory"
return 1 return 1
fi fi
# download a mini debian into a cache # download a mini debian into a cache
echo "Downloading debian minimal ..." echo "Downloading debian minimal ..."
debootstrap --verbose --variant=minbase --arch=$arch \ debootstrap --verbose --variant=minbase --arch=$arch \
--include $packages \ --include $packages \
"$SUITE" "$cache/partial-$SUITE-$arch" http://ftp.debian.org/debian "$SUITE" "$cache/partial-$SUITE-$arch" \
http://ftp.debian.org/debian
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting."
return 1 return 1
fi fi
mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch" mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch"
...@@ -142,32 +143,30 @@ install_debian() ...@@ -142,32 +143,30 @@ install_debian()
rootfs=$1 rootfs=$1
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
fi fi
arch=$(dpkg --print-architecture) arch=$(dpkg --print-architecture)
echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... " echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
download_debian $cache $arch download_debian $cache $arch
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download 'debian base'" echo "Failed to download 'debian base'"
return 1 return 1
fi fi
fi fi
copy_debian $cache $arch $rootfs copy_debian $cache $arch $rootfs
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to copy rootfs" echo "Failed to copy rootfs"
return 1 return 1
fi fi
return 0
return 0 ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $? return $?
} }
...@@ -209,8 +208,8 @@ lxc.mount.entry = sysfs sys sysfs defaults 0 0 ...@@ -209,8 +208,8 @@ lxc.mount.entry = sysfs sys sysfs defaults 0 0
EOF EOF
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to add configuration" echo "Failed to add configuration"
return 1 return 1
fi fi
return 0 return 0
...@@ -221,21 +220,20 @@ clean() ...@@ -221,21 +220,20 @@ clean()
cache="@LOCALSTATEDIR@/cache/lxc/$SUITE" cache="@LOCALSTATEDIR@/cache/lxc/$SUITE"
if [ ! -e $cache ]; then if [ ! -e $cache ]; then
exit 0 exit 0
fi fi
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 200
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
fi fi
echo -n "Purging the download cache..." echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
...@@ -249,8 +247,8 @@ EOF ...@@ -249,8 +247,8 @@ EOF
options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
usage $(basename $0) usage $(basename $0)
exit 1 exit 1
fi fi
eval set -- "$options" eval set -- "$options"
...@@ -259,8 +257,8 @@ do ...@@ -259,8 +257,8 @@ do
case "$1" in case "$1" in
-h|--help) usage $0 && exit 0;; -h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;; -p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
-c|--clean) clean=$2; shift 2;; -c|--clean) clean=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# This library is distributed in the hope that it will be useful, # This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # 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. # Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
...@@ -142,8 +142,8 @@ download_opensuse() ...@@ -142,8 +142,8 @@ download_opensuse()
mkdir -p "$cache/partial-$arch" mkdir -p "$cache/partial-$arch"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to create '$cache/partial-$arch' directory" echo "Failed to create '$cache/partial-$arch' directory"
return 1 return 1
fi fi
# download a mini opensuse into a cache # download a mini opensuse into a cache
...@@ -187,8 +187,8 @@ EOF ...@@ -187,8 +187,8 @@ EOF
rm -f $cache/partial-$arch/etc/mtab rm -f $cache/partial-$arch/etc/mtab
ln -sf /proc/self/mounts $cache/partial-$arch/etc/mtab ln -sf /proc/self/mounts $cache/partial-$arch/etc/mtab
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download the rootfs, aborting." echo "Failed to download the rootfs, aborting."
return 1 return 1
fi fi
rm -fr "$cache/partial-$arch-packages" rm -fr "$cache/partial-$arch-packages"
...@@ -217,33 +217,32 @@ install_opensuse() ...@@ -217,33 +217,32 @@ install_opensuse()
rootfs=$1 rootfs=$1
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
fi fi
arch=$(arch) arch=$(arch)
echo "Checking cache download in $cache/rootfs-$arch ... " echo "Checking cache download in $cache/rootfs-$arch ... "
if [ ! -e "$cache/rootfs-$arch" ]; then if [ ! -e "$cache/rootfs-$arch" ]; then
download_opensuse $cache $arch download_opensuse $cache $arch
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to download 'opensuse base'" echo "Failed to download 'opensuse base'"
return 1 return 1
fi fi
fi fi
echo "Copy $cache/rootfs-$arch to $rootfs ... " echo "Copy $cache/rootfs-$arch to $rootfs ... "
copy_opensuse $cache $arch $rootfs copy_opensuse $cache $arch $rootfs
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to copy rootfs" echo "Failed to copy rootfs"
return 1 return 1
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $? return $?
} }
...@@ -289,8 +288,8 @@ sysfs sys sysfs defaults 0 0 ...@@ -289,8 +288,8 @@ sysfs sys sysfs defaults 0 0
EOF EOF
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to add configuration" echo "Failed to add configuration"
return 1 return 1
fi fi
return 0 return 0
...@@ -301,21 +300,20 @@ clean() ...@@ -301,21 +300,20 @@ clean()
cache="@LOCALSTATEDIR@/cache/lxc/opensuse" cache="@LOCALSTATEDIR@/cache/lxc/opensuse"
if [ ! -e $cache ]; then if [ ! -e $cache ]; then
exit 0 exit 0
fi fi
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 200
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
fi fi
echo -n "Purging the download cache..." echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
...@@ -337,12 +335,12 @@ eval set -- "$options" ...@@ -337,12 +335,12 @@ eval set -- "$options"
while true while true
do do
case "$1" in case "$1" in
-h|--help) usage $0 && exit 0;; -h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;; -p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
-c|--clean) clean=$2; shift 2;; -c|--clean) clean=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
done done
......
...@@ -43,7 +43,7 @@ $rootfs/lib64" ...@@ -43,7 +43,7 @@ $rootfs/lib64"
mkdir -p $tree mkdir -p $tree
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
return 1 return 1
fi fi
return 0 return 0
...@@ -172,14 +172,14 @@ if [ $0 == "/sbin/init" ]; then ...@@ -172,14 +172,14 @@ if [ $0 == "/sbin/init" ]; then
type @LXCINITDIR@/lxc-init type @LXCINITDIR@/lxc-init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "'lxc-init is not accessible on the system" echo "'lxc-init is not accessible on the system"
exit 1 exit 1
fi fi
type sshd type sshd
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "'sshd' is not accessible on the system " echo "'sshd' is not accessible on the system "
exit 1 exit 1
fi fi
# run dhcp? # run dhcp?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment