[lxc-devel] [PATCH 1/4] support alternate container path in lxc-shutdown
Serge Hallyn
serge.hallyn at ubuntu.com
Fri May 3 12:16:57 UTC 2013
Quoting Harald Dunkel (harald.dunkel at aixigo.de):
> ---
> src/lxc/lxc-shutdown.in | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/src/lxc/lxc-shutdown.in b/src/lxc/lxc-shutdown.in
> index ee07f75..247e90b 100644
> --- a/src/lxc/lxc-shutdown.in
> +++ b/src/lxc/lxc-shutdown.in
> @@ -18,13 +18,17 @@
>
> set -e
>
> +lxcpath=/var/lib/lxc
> +test ! -f /etc/lxc/lxc.conf || . /etc/lxc/lxc.conf
Other scripts do this using:
. @DATADIR@/lxc/lxc.functions
Otherwise looks good, thanks. (Please let me know if you'd like to
resend or have me change it in-line)
> +
> usage() {
> - echo "usage: lxc-shutdown -n name [-w] [-r]"
> + echo "usage: lxc-shutdown -n name [-w] [-r] [-P lxcpath]"
> echo " Cleanly shut down a container."
> echo " -w: wait for shutdown to complete."
> echo " -r: reboot (ignore -w)."
> echo " -t timeout: wait at most timeout seconds (implies -w), then kill"
> echo " the container."
> + echo " -P lxcpath: path to the lxc container directories."
> }
>
> alarm() {
> @@ -38,7 +42,7 @@ alarm() {
> dolxcstop()
> {
> echo "Calling lxc-stop on $lxc_name"
> - lxc-stop -n $lxc_name
> + lxc-stop -n $lxc_name -P "$lxcpath"
> exit 0
> }
>
> @@ -82,6 +86,12 @@ while [ $# -gt 0 ]; do
> dowait=1
> shift
> ;;
> + -P|--lxcpath)
> + optarg_check $opt "$1"
> + lxcpath=$1
> + dowait=1
> + shift
> + ;;
> --)
> break;;
> -?)
> @@ -104,6 +114,11 @@ if [ -z "$lxc_name" ]; then
> exit 1
> fi
>
> +if [ ! -d "$lxcpath" ]; then
> + echo "$lxcpath: no such directory"
> + exit 1
> +fi
> +
> if [ "$(id -u)" != "0" ]; then
> echo "This command has to be run as root"
> exit 1
> @@ -112,7 +127,7 @@ fi
> which lxc-info > /dev/null 2>&1 || { echo "lxc-info not found."; exit 1; }
> which lxc-wait > /dev/null 2>&1 || { echo "lxc-wait not found."; exit 1; }
>
> -pid=`lxc-info -n $lxc_name -p 2>/dev/null | awk '{ print $2 }'`
> +pid=`lxc-info -n $lxc_name -P "$lxcpath" -p 2>/dev/null | awk '{ print $2 }'`
> if [ "$pid" = "-1" ]; then
> echo "$lxc_name is not running"
> exit 1
> @@ -135,7 +150,7 @@ if [ $timeout != "-1" ]; then
> alarmpid=$!
> fi
>
> -while ! lxc-info -n $lxc_name --state-is STOPPED; do
> +while ! lxc-info -n $lxc_name -P "$lxcpath" --state-is STOPPED; do
> sleep 1
> done
>
> --
> 1.8.1.3
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
More information about the lxc-devel
mailing list