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>
This commit is contained in:
Stéphane Graber 2012-12-05 16:47:19 -05:00
parent eba7df9ee0
commit 14d9c0f09d
17 changed files with 637 additions and 648 deletions

4
README
View File

@ -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

View File

@ -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
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

View File

@ -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
} }

View File

@ -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

View File

@ -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
# 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
# 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

View File

@ -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'.

View File

@ -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 "$@")

View File

@ -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
set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@" set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
;; ;;
*) *)
usage usage
exit 1 exit 1
;; ;;
esac esac
done; done;

View File

@ -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
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
set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@" set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
;; ;;
*) *)
usage usage
exit 1 exit 1
;; ;;
esac esac
done; done;

View File

@ -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()
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()
$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()
{ {
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
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()
{ {
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..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
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 ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
@ -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

View File

@ -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
if [ -n "\$router" ]; then
ip route del default 2> /dev/null
fi
# flush all the routes # check broadcast
if [ -n "\$router" ]; then if [ -n "\$broadcast" ]; then
ip route del default 2> /dev/null broadcast="broadcast \$broadcast"
fi fi
# check broadcast # add a new ip address
if [ -n "\$broadcast" ]; then ip addr add \$ip/\$mask \$broadcast dev \$interface
broadcast="broadcast \$broadcast"
fi
# add a new ip address if [ -n "\$router" ]; then
ip addr add \$ip/\$mask \$broadcast dev \$interface ip route add default via \$router dev \$interface
fi
if [ -n "\$router" ]; then [ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
ip route add default via \$router dev \$interface for i in \$dns ; do
fi echo nameserver \$i >> /etc/resolv.conf
done
[ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf ;;
for i in \$dns ; do
echo nameserver \$i >> /etc/resolv.conf
done
;;
esac esac
exit 0 exit 0
EOF EOF
@ -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
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
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

View File

@ -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()
# 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
# 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
# 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()
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
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()
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
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
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

View File

@ -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()
$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()
{ {
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 ... " echo "Copy $cache/rootfs to $rootfs_path ... "
copy_fedora copy_fedora
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 $?
} }
@ -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()
{ {
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"
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

View File

@ -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
# 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()
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
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()
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..."
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 ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
@ -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
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

View File

@ -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()
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
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()
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
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()
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..."
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 ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
} }
@ -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

View File

@ -41,7 +41,7 @@ is_btrfs_subvolume()
{ {
if which btrfs >/dev/null 2>&1 && \ if which btrfs >/dev/null 2>&1 && \
btrfs subvolume list "$1" >/dev/null 2>&1; then btrfs subvolume list "$1" >/dev/null 2>&1; then
return 0 return 0
fi fi
return 1 return 1
} }
@ -59,9 +59,9 @@ container_rootfs_configure()
mkdir -p $container_rootfs/selinux mkdir -p $container_rootfs/selinux
echo 0 > $container_rootfs/selinux/enforce echo 0 > $container_rootfs/selinux/enforce
if [ -e $container_rootfs/etc/selinux/config ]; then 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 else
echo "SELINUX=disabled" >$container_rootfs/etc/selinux/config echo "SELINUX=disabled" >$container_rootfs/etc/selinux/config
fi 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[ ]*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 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 # remove module stuff for iptables it just shows errors that are not
# relevant in a container # relevant in a container
if [ -f "$container_rootfs/etc/sysconfig/iptables-config" ]; then 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=".*|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_UNLOAD=".*|IPTABLES_MODULES_UNLOAD="no"|' $container_rootfs/etc/sysconfig/iptables-config
fi fi
# disable readahead in the container # disable readahead in the container
if [ $container_release_major = "6" -a -e $container_rootfs/etc/sysconfig/readahead ]; then 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-collector.conf
rm -f $container_rootfs/etc/init/readahead-disable-services.conf rm -f $container_rootfs/etc/init/readahead-disable-services.conf
sed -i 's|READAHEAD="yes"|READAHEAD="no"|' $container_rootfs/etc/sysconfig/readahead sed -i 's|READAHEAD="yes"|READAHEAD="no"|' $container_rootfs/etc/sysconfig/readahead
fi fi
# disable udev in the container # disable udev in the container
@ -125,13 +125,13 @@ EOF
# disable nash raidautorun in the container since no /dev/md* # disable nash raidautorun in the container since no /dev/md*
if [ $container_release_major = "5" ]; then 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.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.d/rc.sysinit
fi fi
# prevent rc.sysinit from attempting to loadkeys # prevent rc.sysinit from attempting to loadkeys
if [ $container_release_major = "5" -a -e $container_rootfs/etc/sysconfig/keyboard ]; then 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 fi
# dont try to sync the hwclock at shutdown # dont try to sync the hwclock at shutdown
@ -169,13 +169,13 @@ EOF
# start a getty on /dev/console, /dev/tty[1-4] # start a getty on /dev/console, /dev/tty[1-4]
if [ $container_release_major = "5" ]; then if [ $container_release_major = "5" ]; then
sed -i '/1:2345:respawn/i cns:2345:respawn:/sbin/mingetty console' $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 '/5:2345:respawn/d' $container_rootfs/etc/inittab
sed -i '/6:2345:respawn/d' $container_rootfs/etc/inittab sed -i '/6:2345:respawn/d' $container_rootfs/etc/inittab
fi fi
if [ $container_release_major = "6" ]; then if [ $container_release_major = "6" ]; then
cat <<EOF > $container_rootfs/etc/init/console.conf cat <<EOF > $container_rootfs/etc/init/console.conf
# console - getty # console - getty
# #
# This service maintains a getty on the console from the point the system is # 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 # 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 # some of these might not exist in the image, so we silence chkconfig complaining
# about the service file not being found # about the service file not being found
for service in \ for service in \
acpid auditd autofs cpuspeed dund gpm haldaemon hidd \ acpid auditd autofs cpuspeed dund gpm haldaemon hidd \
ip6tables irqbalance iscsi iscsid isdn kdump kudzu \ ip6tables irqbalance iscsi iscsid isdn kdump kudzu \
lm_sensors lvm2-monitor mdmonitor microcode_ctl \ lm_sensors lvm2-monitor mdmonitor microcode_ctl \
ntpd postfix sendmail udev-post ; ntpd postfix sendmail udev-post ;
do do
chroot $container_rootfs chkconfig 2>/dev/null $service off chroot $container_rootfs chkconfig 2>/dev/null $service off
done done
for service in rsyslog ; for service in rsyslog ;
do do
chroot $container_rootfs chkconfig 2>/dev/null $service on chroot $container_rootfs chkconfig 2>/dev/null $service on
done done
# create required devices. note that /dev/console will be created by lxc # 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 # take care to not nuke /dev in case $container_rootfs isn't set
dev_path="$container_rootfs/dev" dev_path="$container_rootfs/dev"
if [ $container_rootfs != "/" -a -d $dev_path ]; then if [ $container_rootfs != "/" -a -d $dev_path ]; then
rm -rf $dev_path rm -rf $dev_path
mkdir -p $dev_path mkdir -p $dev_path
fi fi
mknod -m 666 $dev_path/null c 1 3 mknod -m 666 $dev_path/null c 1 3
mknod -m 666 $dev_path/zero c 1 5 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 # 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 # 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 | \ 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 |\ head -1 |awk '{print $2}' | cut -c1-10 |\
sed 's/\(..\)/\1:/g; s/.$//'`" sed 's/\(..\)/\1:/g; s/.$//'`"
mkdir -p $cfg_dir || die "unable to create config dir $cfg_dir" mkdir -p $cfg_dir || die "unable to create config dir $cfg_dir"
cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config" cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
# Container configuration for Oracle Linux $release_major.$release_minor # Container configuration for Oracle Linux $release_major.$release_minor
@ -272,9 +272,9 @@ EOF
if [ -z "$lxc_network_type" -a \ if [ -z "$lxc_network_type" -a \
\( $host_distribution = "OracleServer" -o \ \( $host_distribution = "OracleServer" -o \
$host_distribution = "Fedora" \) ]; then $host_distribution = "Fedora" \) ]; then
echo "lxc.network.type = veth" >>$cfg_dir/config echo "lxc.network.type = veth" >>$cfg_dir/config
echo "lxc.network.flags = up" >>$cfg_dir/config echo "lxc.network.flags = up" >>$cfg_dir/config
echo "lxc.network.link = virbr0" >>$cfg_dir/config echo "lxc.network.link = virbr0" >>$cfg_dir/config
fi fi
cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config" cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
@ -304,13 +304,13 @@ EOF
container_rootfs_clone() container_rootfs_clone()
{ {
if is_btrfs_subvolume $template_rootfs; then if is_btrfs_subvolume $template_rootfs; then
# lxc-create already made $container_rootfs a btrfs subvolume, but # lxc-create already made $container_rootfs a btrfs subvolume, but
# in this case we want to snapshot the original subvolume so we we # in this case we want to snapshot the original subvolume so we we
# have to delete the one that lxc-create made # have to delete the one that lxc-create made
btrfs subvolume delete $container_rootfs btrfs subvolume delete $container_rootfs
btrfs subvolume snapshot $template_rootfs $container_rootfs || die "btrfs clone template" btrfs subvolume snapshot $template_rootfs $container_rootfs || die "btrfs clone template"
else else
cp -ax $template_rootfs $container_rootfs || die "copy template" cp -ax $template_rootfs $container_rootfs || die "copy template"
fi fi
} }
@ -318,121 +318,121 @@ container_rootfs_create()
{ {
cmds="rpm wget yum" cmds="rpm wget yum"
if [ $release_major = "5" ]; then if [ $release_major = "5" ]; then
if [ $host_distribution = "Ubuntu" ]; then if [ $host_distribution = "Ubuntu" ]; then
db_dump_cmd="db5.1_dump" db_dump_cmd="db5.1_dump"
db_load_cmd="db4.3_load" db_load_cmd="db4.3_load"
fi fi
if [ $host_distribution = "OracleServer" -o \ if [ $host_distribution = "OracleServer" -o \
$host_distribution = "Fedora" ]; then $host_distribution = "Fedora" ]; then
db_dump_cmd="db_dump" db_dump_cmd="db_dump"
db_load_cmd="db43_load" db_load_cmd="db43_load"
fi fi
cmds="$cmds $db_dump_cmd $db_load_cmd file" cmds="$cmds $db_dump_cmd $db_load_cmd file"
fi fi
for cmd in $cmds; do for cmd in $cmds; do
which $cmd >/dev/null 2>&1 which $cmd >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "The $cmd command is required, please install it" die "The $cmd command is required, please install it"
fi fi
done done
mkdir -p /var/lock/subsys/ mkdir -p /var/lock/subsys/
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "The template is busy." die "The template is busy."
fi fi
echo "Downloading release $release_major.$release_minor for $basearch" echo "Downloading release $release_major.$release_minor for $basearch"
# get yum repo file # get yum repo file
public_yum_url=http://public-yum.oracle.com public_yum_url=http://public-yum.oracle.com
if [ $release_major = "5" ]; then if [ $release_major = "5" ]; then
repofile=public-yum-el5.repo repofile=public-yum-el5.repo
elif [ $release_major = "6" ]; then elif [ $release_major = "6" ]; then
repofile=public-yum-ol6.repo repofile=public-yum-ol6.repo
else else
die "Unsupported release $release_major" die "Unsupported release $release_major"
fi fi
mkdir -p $container_rootfs/etc/yum.repos.d mkdir -p $container_rootfs/etc/yum.repos.d
wget -q $public_yum_url/$repofile -O $container_rootfs/etc/yum.repos.d/$repofile wget -q $public_yum_url/$repofile -O $container_rootfs/etc/yum.repos.d/$repofile
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "Failed to download repo file $public_yum_url/$repofile" die "Failed to download repo file $public_yum_url/$repofile"
fi fi
# yum will take $basearch from host, so force the arch we want # yum will take $basearch from host, so force the arch we want
sed -i "s|\$basearch|$basearch|" $container_rootfs/etc/yum.repos.d/$repofile sed -i "s|\$basearch|$basearch|" $container_rootfs/etc/yum.repos.d/$repofile
# replace url if they specified one # replace url if they specified one
if [ -n "$repourl" ]; then 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|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 sed -i "s|gpgkey=http://public-yum.oracle.com|gpgkey=$repourl|" $container_rootfs/etc/yum.repos.d/$repofile
fi fi
# disable all repos, then enable the repo for the version we are installing. # disable all repos, then enable the repo for the version we are installing.
if [ $release_minor = "latest" ]; then if [ $release_minor = "latest" ]; then
if [ $release_major = "5" ]; then if [ $release_major = "5" ]; then
repo="el"$release_major"_"$release_minor repo="el"$release_major"_"$release_minor
else else
repo="ol"$release_major"_"$release_minor repo="ol"$release_major"_"$release_minor
fi fi
elif [ $release_minor = "0" ]; then elif [ $release_minor = "0" ]; then
repo="ol"$release_major"_ga_base" repo="ol"$release_major"_ga_base"
else else
repo="ol"$release_major"_u"$release_minor"_base" repo="ol"$release_major"_u"$release_minor"_base"
fi fi
sed -i "s|enabled=1|enabled=0|" $container_rootfs/etc/yum.repos.d/$repofile 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 sed -i "/\[$repo\]/,/\[/ s/enabled=0/enabled=1/" $container_rootfs/etc/yum.repos.d/$repofile
# create rpm db, download and yum install minimal packages # create rpm db, download and yum install minimal packages
mkdir -p $container_rootfs/var/lib/rpm mkdir -p $container_rootfs/var/lib/rpm
rpm --root $container_rootfs --initdb rpm --root $container_rootfs --initdb
yum_cmd="yum --installroot $container_rootfs --disablerepo=* --enablerepo=$repo -y --nogpgcheck" 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" min_pkgs="yum initscripts passwd rsyslog vim-minimal openssh-server dhclient chkconfig rootfiles policycoreutils oraclelinux-release"
$yum_cmd install $min_pkgs $yum_cmd install $min_pkgs
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "Failed to download and install the rootfs, aborting." die "Failed to download and install the rootfs, aborting."
fi fi
# rsyslog and pam depend on coreutils for some common commands in # rsyslog and pam depend on coreutils for some common commands in
# their POSTIN scriptlets, but coreutils wasn't installed yet. now # their POSTIN scriptlets, but coreutils wasn't installed yet. now
# that coreutils is installed, reinstall the packages so their POSTIN # that coreutils is installed, reinstall the packages so their POSTIN
# runs right. similarly, libutempter depends on libselinux.so.1 when # runs right. similarly, libutempter depends on libselinux.so.1 when
# it runs /usr/sbin/groupadd, so reinstall it too # it runs /usr/sbin/groupadd, so reinstall it too
if [ $release_major = "5" ]; then if [ $release_major = "5" ]; then
rpm --root $container_rootfs --nodeps -e rsyslog pam libutempter rpm --root $container_rootfs --nodeps -e rsyslog pam libutempter
$yum_cmd install rsyslog pam libutempter $yum_cmd install rsyslog pam libutempter
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "Unable to reinstall packages" die "Unable to reinstall packages"
fi fi
fi fi
# these distributions put the rpm database in a place the guest is # these distributions put the rpm database in a place the guest is
# not expecting it, so move it # not expecting it, so move it
if [ $host_distribution = "Ubuntu" ]; then if [ $host_distribution = "Ubuntu" ]; then
mv $container_rootfs/root/.rpmdb/* $container_rootfs/var/lib/rpm mv $container_rootfs/root/.rpmdb/* $container_rootfs/var/lib/rpm
fi fi
# if the native rpm created the db with Hash version 9, we need to # 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 # downgrade it to Hash version 8 for use with OL5.x
db_version=`file $container_rootfs/var/lib/rpm/Packages | \ db_version=`file $container_rootfs/var/lib/rpm/Packages | \
grep -o 'version [0-9]*' |awk '{print $2}'` grep -o 'version [0-9]*' |awk '{print $2}'`
if [ $release_major = "5" -a $db_version != "8" ]; then if [ $release_major = "5" -a $db_version != "8" ]; then
echo "Fixing (downgrading) rpm database from version $db_version" echo "Fixing (downgrading) rpm database from version $db_version"
rm -f $container_rootfs/var/lib/rpm/__db* rm -f $container_rootfs/var/lib/rpm/__db*
for db in $container_rootfs/var/lib/rpm/* ; do for db in $container_rootfs/var/lib/rpm/* ; do
$db_dump_cmd $db |$db_load_cmd $db.new $db_dump_cmd $db |$db_load_cmd $db.new
mv $db.new $db mv $db.new $db
done done
fi fi
# the host rpm may not be the same as the guest, rebuild the db with # the host rpm may not be the same as the guest, rebuild the db with
# the guest rpm version # the guest rpm version
echo "Rebuilding rpm database" echo "Rebuilding rpm database"
rm -f $container_rootfs/var/lib/rpm/__db* rm -f $container_rootfs/var/lib/rpm/__db*
chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1 chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1
) 200>/var/lock/subsys/lxc-oracle-$name ) 200>/var/lock/subsys/lxc-oracle-$name
} }
@ -461,14 +461,14 @@ 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) cfg_dir=$2; shift 2;; -p|--path) cfg_dir=$2; shift 2;;
-n|--name) name=$2; shift 2;; -n|--name) name=$2; shift 2;;
-a|--arch) arch=$2; shift 2;; -a|--arch) arch=$2; shift 2;;
-R|--release) release_version=$2; shift 2;; -R|--release) release_version=$2; shift 2;;
-u|--url) repourl=$2; shift;; -u|--url) repourl=$2; shift;;
-t|--templatefs) template_rootfs=$2; shift 2;; -t|--templatefs) template_rootfs=$2; shift 2;;
--) shift 1; break ;; --) shift 1; break ;;
*) break ;; *) break ;;
esac esac
done done

View File

@ -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
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?