diff --git a/.gitignore b/.gitignore
index f416f39a8..035b8b8d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,8 +60,6 @@ src/lxc/lxc-info
src/lxc/lxc-init
src/lxc/lxc-monitor
src/lxc/lxc-monitord
-src/lxc/lxc-netstat
-src/lxc/lxc-ps
src/lxc/lxc-shutdown
src/lxc/lxc-snapshot
src/lxc/lxc-start
@@ -70,7 +68,6 @@ src/lxc/lxc-stop
src/lxc/lxc-unfreeze
src/lxc/lxc-unshare
src/lxc/lxc-usernsexec
-src/lxc/lxc-version
src/lxc/lxc-wait
src/lxc/legacy/lxc-ls
src/lxc/lxc-user-nic
diff --git a/configure.ac b/configure.ac
index fd3803816..73facf355 100644
--- a/configure.ac
+++ b/configure.ac
@@ -596,8 +596,6 @@ AC_CONFIG_FILES([
doc/lxc-info.sgml
doc/lxc-ls.sgml
doc/lxc-monitor.sgml
- doc/lxc-netstat.sgml
- doc/lxc-ps.sgml
doc/lxc-snapshot.sgml
doc/lxc-start-ephemeral.sgml
doc/lxc-start.sgml
@@ -607,7 +605,6 @@ AC_CONFIG_FILES([
doc/lxc-unshare.sgml
doc/lxc-user-nic.sgml
doc/lxc-usernsexec.sgml
- doc/lxc-version.sgml
doc/lxc-wait.sgml
doc/lxc.conf.sgml
@@ -643,8 +640,6 @@ AC_CONFIG_FILES([
doc/ja/lxc-info.sgml
doc/ja/lxc-ls.sgml
doc/ja/lxc-monitor.sgml
- doc/ja/lxc-netstat.sgml
- doc/ja/lxc-ps.sgml
doc/ja/lxc-snapshot.sgml
doc/ja/lxc-start-ephemeral.sgml
doc/ja/lxc-start.sgml
@@ -654,7 +649,6 @@ AC_CONFIG_FILES([
doc/ja/lxc-unshare.sgml
doc/ja/lxc-user-nic.sgml
doc/ja/lxc-usernsexec.sgml
- doc/ja/lxc-version.sgml
doc/ja/lxc-wait.sgml
doc/ja/lxc.conf.sgml
@@ -686,10 +680,7 @@ AC_CONFIG_FILES([
src/Makefile
src/lxc/Makefile
- src/lxc/lxc-ps
- src/lxc/lxc-netstat
src/lxc/lxc-checkconfig
- src/lxc/lxc-version
src/lxc/lxc-start-ephemeral
src/lxc/legacy/lxc-ls
src/lxc/lxc.functions
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ba3a234bb..e84871722 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -27,8 +27,6 @@ man_MANS = \
lxc-freeze.1 \
lxc-info.1 \
lxc-monitor.1 \
- lxc-netstat.1 \
- lxc-ps.1 \
lxc-snapshot.1 \
lxc-start.1 \
lxc-stop.1 \
@@ -36,7 +34,6 @@ man_MANS = \
lxc-unshare.1 \
lxc-user-nic.1 \
lxc-usernsexec.1 \
- lxc-version.1 \
lxc-wait.1 \
\
lxc.conf.5 \
diff --git a/doc/ja/Makefile.am b/doc/ja/Makefile.am
index fccc66b91..45b3aa29e 100644
--- a/doc/ja/Makefile.am
+++ b/doc/ja/Makefile.am
@@ -20,8 +20,6 @@ man_MANS = \
lxc-freeze.1 \
lxc-info.1 \
lxc-monitor.1 \
- lxc-netstat.1 \
- lxc-ps.1 \
lxc-snapshot.1 \
lxc-start.1 \
lxc-stop.1 \
@@ -29,7 +27,6 @@ man_MANS = \
lxc-unshare.1 \
lxc-user-nic.1 \
lxc-usernsexec.1 \
- lxc-version.1 \
lxc-wait.1 \
\
lxc.conf.5 \
diff --git a/doc/ja/lxc-netstat.sgml.in b/doc/ja/lxc-netstat.sgml.in
deleted file mode 100644
index 790d38465..000000000
--- a/doc/ja/lxc-netstat.sgml.in
+++ /dev/null
@@ -1,161 +0,0 @@
-
-
-
-]>
-
-
-
- @LXC_GENERATE_DATE@
-
-
- lxc-netstat
- 1
-
-
-
- lxc-netstat
-
-
-
- 指定したコンテナに対する netstat の実行
-
-
-
-
-
- lxc-netstat
- --name name
- -- netstat option
-
-
-
-
- 説明
-
-
- lxc-netstat は netstat コマンドのラッパーです.
-
-
-
-
- オプション
-
-
-
-
-
-
-
-
-
- コンテナ名
-
-
-
-
-
-
-
-
-
-
-
- netstat オプションは lxc-netstat のオプションと で分けなければなりません.
-
-
-
-
-
-
-
-
-
- 例
-
-
- lxc-netstat --name foo -- -lnp
-
-
-
- コンテナ foo に対して netstat -lnp を呼び出します.
-
-
-
-
-
-
-
- See Also
-
-
-
- netstat
- 1
- ,
-
-
-
-
- &seealso;
-
-
- 作者
- Stéphane Graber stgraber@ubuntu.com
-
-
-
-
-
diff --git a/doc/ja/lxc-ps.sgml.in b/doc/ja/lxc-ps.sgml.in
deleted file mode 100644
index 2666fc4f2..000000000
--- a/doc/ja/lxc-ps.sgml.in
+++ /dev/null
@@ -1,217 +0,0 @@
-
-
-
-]>
-
-
-
- @LXC_GENERATE_DATE@
-
-
- lxc-ps
- 1
-
-
-
- lxc-ps
-
-
-
- 指定したコンテナに属するプロセスのリスト表示
-
-
-
-
-
- lxc-ps
- --name name
- --lxc
- --host
- -- ps options
-
-
-
-
- 説明
-
-
- lxc-ps は,プロセスが属する lxc コンテナ名を報告する ps コマンドのラッパーです.
-
-
-
- lxc-ps がコンテナに関連するプロセスを見つけるためには,コンテナが作成される前に cgroup FS がマウントされている必要があります.
-
-
-
- lxc-ps がコンテナに関連したプロセスを見つけるためには,追加で指定された ps options が,標準の ps コマンドのヘッダや pid 情報を削除してはいけません.
-
-
-
-
- オプション
-
-
-
-
-
-
-
-
-
- name で指定したコンテナに属するプロセスのみ出力します.
-
-
-
-
-
-
-
-
-
-
-
- 全ての lxc コンテナに属するプロセスを出力します.
-
-
-
-
-
-
-
-
-
-
-
- ホスト (訳注: コンテナ以外) に属するプロセスのみを出力します.
-
-
-
-
-
-
-
-
-
-
-
- ps のオプションと,lxc-ps のオプションとは, で区切って指定します.
-
-
-
-
-
-
-
-
-
- 例
-
-
- lxc-ps --name foo -- --forest
-
-
-
- foo という名前のコンテナに属する全てのプロセスをリスト表示し,依存関係を示します.
-
-
-
-
-
-
-
- See Also
-
-
-
- ps
- 1
- ,
-
-
-
-
- &seealso;
-
-
- 作者
- Daniel Lezcano daniel.lezcano@free.fr
-
-
-
-
-
diff --git a/doc/ja/lxc-version.sgml.in b/doc/ja/lxc-version.sgml.in
deleted file mode 100644
index 4d6d7104a..000000000
--- a/doc/ja/lxc-version.sgml.in
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-]>
-
-
-
- @LXC_GENERATE_DATE@
-
-
- lxc-version
- 1
-
-
-
- lxc-version
-
-
-
- 現在インストールされている lxc のバージョンの表示
-
-
-
-
-
- lxc-version
-
-
-
-
- 説明
-
-
- lxc-version は,現在インストールされている lxc のバージョンを表示します.
-
-
-
-
- 例
-
-
- lxc-version
-
-
-
- 現在インストールされている lxc のバージョンを表示します.
-
-
-
-
-
-
- &seealso;
-
-
- 作者
- Stéphane Graber stgraber@ubuntu.com
-
-
-
-
diff --git a/doc/ja/lxc.sgml.in b/doc/ja/lxc.sgml.in
index 6077b991b..0258bfa19 100644
--- a/doc/ja/lxc.sgml.in
+++ b/doc/ja/lxc.sgml.in
@@ -682,7 +682,6 @@ rootfs
following commands may be useful:
lxc-ls
- lxc-ps --name foo
lxc-info -n foo
-->
@@ -690,7 +689,6 @@ rootfs
このような時には,以下のようなコマンドが役に立つかもしれません.
lxc-ls
- lxc-ps --name foo
lxc-info -n foo
@@ -702,29 +700,6 @@ rootfs
lxc-ls は,システムのコンテナを一覧します.
-
-
- lxc-ps は特定のコンテナに対する pid を表示します.
- lxc-ps は ps コマンドをうまく利用して作られており,同じオプションを利用可能です.
- 例えば,
- lxc-ps --name foo --forest
- は 'foo' という名前のコンテナに属するプロセスを階層構造で表示します.
-
- lxc-ps --lxc
- は全てのコンテナとそのコンテナに属するプロセスを表示します.
-
-
ここで,以上のコマンドを組み合わせて,どのようにしたら全てのコンテナのリストと,それぞれの状態が得られるかの例を示します.
@@ -757,39 +724,6 @@ rootfs
lxc-info -n $i
done
-
- そして,全てのコンテナの全ての pid を表示させる例です.
-
-
- for i in $(lxc-ls -1); do
- lxc-ps --name $i --forest
- done
-
-
-
-
-
- lxc-netstat は,指定したコンテナのネットワークの情報を表示します.
- このコマンドは netstat をうまく利用して作られており,netstat のオプションを受け付けます.
-
-
-
-
- 以下のコマンドは,'foo' という名前のコンテナのソケット情報を表示します.
-
- lxc-netstat -n foo -tano
-
diff --git a/doc/ja/see_also.sgml.in b/doc/ja/see_also.sgml.in
index 4c579f4b7..44d5cb8f5 100644
--- a/doc/ja/see_also.sgml.in
+++ b/doc/ja/see_also.sgml.in
@@ -85,11 +85,6 @@ by KATOH Yasufumi
1
,
-
- lxc-ps
- 1
- ,
-
lxc-info
1
diff --git a/doc/lxc-netstat.sgml.in b/doc/lxc-netstat.sgml.in
deleted file mode 100644
index b4539d277..000000000
--- a/doc/lxc-netstat.sgml.in
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-
-]>
-
-
-
- @LXC_GENERATE_DATE@
-
-
- lxc-netstat
- 1
-
-
-
- lxc-netstat
-
-
- run netstat for the specified container
-
-
-
-
-
- lxc-netstat
- --name name
- -- netstat option
-
-
-
-
- Description
-
- lxc-netstat is a wrapper to the netstat command.
-
-
-
-
- Options
-
-
-
-
-
-
-
-
- The container name.
-
-
-
-
-
-
-
-
-
-
- The netstat options must be separated
- from lxc-netstat options by
- the parameter.
-
-
-
-
-
-
-
-
-
- Example
-
-
- lxc-netstat --name foo -- -lnp
-
-
- Call netstat -lnp for container foo.
-
-
-
-
-
-
-
- See Also
-
-
-
- netstat
- 1
- ,
-
-
-
-
- &seealso;
-
-
- Author
- Stéphane Graber stgraber@ubuntu.com
-
-
-
-
-
diff --git a/doc/lxc-ps.sgml.in b/doc/lxc-ps.sgml.in
deleted file mode 100644
index 16902a44f..000000000
--- a/doc/lxc-ps.sgml.in
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-]>
-
-
-
- @LXC_GENERATE_DATE@
-
-
- lxc-ps
- 1
-
-
-
- lxc-ps
-
-
- list the processes belonging to a specific container.
-
-
-
-
-
- lxc-ps
- --name name
- --lxc
- --host
- -- ps options
-
-
-
-
- Description
-
- lxc-ps is a wrapper to the ps command
- to report the name of lxc container associated
- to reported processes.
-
-
- The cgroup fs must be mounted before container creation,
- to be able to have lxc-ps to find
- the container associated to processes.
-
-
- The additional specified ps options must not
- remove the default ps header and the pid information,
- to be able to have the lxc-ps to find
- the container associated to processes.
-
-
-
-
- Options
-
-
-
-
-
-
-
-
- specify the container name
- to limit the output to the processes belonging
- to this container name.
-
-
-
-
-
-
-
-
-
-
- limit the output to the processes belonging
- to all lxc containers.
-
-
-
-
-
-
-
-
-
-
- limit the output to the processes belonging
- to the host.
-
-
-
-
-
-
-
-
-
-
- The ps options must be separated
- from lxc-ps options by
- the parameter.
-
-
-
-
-
-
-
-
-
- Example
-
-
- lxc-ps --name foo -- --forest
-
-
- list all the processes belonging to container 'foo' and show
- dependencies.
-
-
-
-
-
-
-
- See Also
-
-
-
- ps
- 1
- ,
-
-
-
-
- &seealso;
-
-
- Author
- Daniel Lezcano daniel.lezcano@free.fr
-
-
-
-
-
diff --git a/doc/lxc-version.sgml.in b/doc/lxc-version.sgml.in
deleted file mode 100644
index f3a7b6377..000000000
--- a/doc/lxc-version.sgml.in
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-]>
-
-
-
- @LXC_GENERATE_DATE@
-
-
- lxc-version
- 1
-
-
-
- lxc-version
-
-
- print the currently installed lxc version
-
-
-
-
-
- lxc-version
-
-
-
-
- Description
-
- lxc-version print the currently installed lxc version
-
-
-
-
- Examples
-
-
- lxc-version
-
-
- print the currently installed lxc version.
-
-
-
-
-
-
- &seealso;
-
-
- Author
- Stéphane Graber stgraber@ubuntu.com
-
-
-
-
diff --git a/doc/lxc.sgml.in b/doc/lxc.sgml.in
index 5822fb87b..85816aeac 100644
--- a/doc/lxc.sgml.in
+++ b/doc/lxc.sgml.in
@@ -457,7 +457,6 @@ rootfs
following commands may be useful:
lxc-ls
- lxc-ps --name foo
lxc-info -n foo
@@ -466,19 +465,6 @@ rootfs
system.
-
- lxc-ps will display the pids for a specific
- container. lxc-ps
- is built on top of ps and accepts the same
- options, eg:
- lxc-ps --name foo --forest
- will display the processes hierarchy for the processes
- belonging the 'foo' container.
-
- lxc-ps --lxc
- will display all the containers and their processes.
-
-
lxc-info gives information for a specific
container.
@@ -493,29 +479,6 @@ rootfs
done
- And displaying all the pids of all the containers:
-
-
- for i in $(lxc-ls -1); do
- lxc-ps --name $i --forest
- done
-
-
-
-
-
- lxc-netstat display network information for
- a specific container. This command is built on top of
- the netstat command and will accept its
- options
-
-
-
- The following command will display the socket information for
- the container 'foo'.
-
- lxc-netstat -n foo -tano
-
diff --git a/doc/see_also.sgml.in b/doc/see_also.sgml.in
index 16530f389..4954e8e15 100644
--- a/doc/see_also.sgml.in
+++ b/doc/see_also.sgml.in
@@ -82,11 +82,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1
,
-
- lxc-ps
- 1
- ,
-
lxc-info
1
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 25cdf6d86..83c05856c 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -156,11 +156,7 @@ liblxc_so_LDADD += $(CGMANAGER_LIBS) $(DBUS_LIBS) $(NIH_LIBS) $(NIH_DBUS_LIBS)
liblxc_so_CFLAGS += $(CGMANAGER_CFLAGS) $(DBUS_CFLAGS) $(NIH_CFLAGS) $(NIH_DBUS_CFLAGS)
#endif
-bin_SCRIPTS = \
- lxc-ps \
- lxc-netstat \
- lxc-checkconfig \
- lxc-version
+bin_SCRIPTS = lxc-checkconfig
EXTRA_DIST = \
lxc-device \
diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c
index aaf96341e..e02114376 100644
--- a/src/lxc/arguments.c
+++ b/src/lxc/arguments.c
@@ -33,6 +33,7 @@
#include "arguments.h"
#include "utils.h"
+#include "version.h"
/*---------------------------------------------------------------------------*/
static int build_shortopts(const struct option *a_options,
@@ -128,6 +129,11 @@ static void print_usage(const struct option longopts[],
exit(0);
}
+static void print_version() {
+ printf("%s\n", LXC_VERSION);
+ exit(0);
+}
+
static void print_help(const struct lxc_arguments *args, int code)
{
fprintf(stderr, "\
@@ -140,6 +146,7 @@ Common options :\n\
-P, --lxcpath=PATH Use specified container path\n\
-?, --help Give this help list\n\
--usage Give a short usage message\n\
+ --version Print the version number\n\
\n\
Mandatory or optional arguments to long options are also mandatory or optional\n\
for any corresponding short options.\n\
@@ -203,6 +210,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
return ret;
break;
case OPT_USAGE: print_usage(args->options, args);
+ case OPT_VERSION: print_version();
case '?': print_help(args, 1);
case 'h': print_help(args, 0);
default:
diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h
index d99f79b46..767bfcfc7 100644
--- a/src/lxc/arguments.h
+++ b/src/lxc/arguments.h
@@ -105,6 +105,7 @@ struct lxc_arguments {
{"name", required_argument, 0, 'n'}, \
{"help", no_argument, 0, 'h'}, \
{"usage", no_argument, 0, OPT_USAGE}, \
+ {"version", no_argument, 0, OPT_VERSION}, \
{"quiet", no_argument, 0, 'q'}, \
{"logfile", required_argument, 0, 'o'}, \
{"logpriority", required_argument, 0, 'l'}, \
@@ -113,6 +114,7 @@ struct lxc_arguments {
/* option keys for long only options */
#define OPT_USAGE 0x1000
+#define OPT_VERSION OPT_USAGE-1
extern int lxc_arguments_parse(struct lxc_arguments *args,
int argc, char *const argv[]);
diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in
deleted file mode 100644
index 0aecb0c0f..000000000
--- a/src/lxc/lxc-netstat.in
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/bin/sh
-
-#
-# lxc: linux Container library
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-. @DATADIR@/lxc/lxc.functions
-
-usage() {
- echo "usage: $(basename $0) -n|--name [-P|--lxcpath ] -- [netstat_options]" >&2
-}
-
-help() {
- usage
- echo >&2
- echo "Execute 'netstat' for the specified container." >&2
- echo >&2
- echo " --name NAME specify the container name" >&2
- echo " --lxcpath LXC_PATH use an alternate container path" >&2
- echo " NETSTAT_OPTIONS netstat command options (see \`netstat --help')" >&2
-}
-
-get_parent_cgroup()
-{
- parent_cgroup=""
-
- # Obtain a list of hierarchies that contain one or more subsystems
- hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
-
- # Iterate through the list until a suitable hierarchy is found
- for hierarchy in $hierarchies; do
- # Obtain information about the init process in the hierarchy
- fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
- if [ -z "$fields" ]; then continue; fi
- fields=${fields#*:}
-
- # Get a comma-separated list of the hierarchy's subsystems
- subsystems=${fields%:*}
-
- # Get the cgroup of the init process in the hierarchy
- init_cgroup=${fields#*:}
-
- # Get the filesystem mountpoint of the hierarchy
- mountpoint=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
- '$3 == "cgroup" && $4 ~ subsysregex {print $2}' /proc/self/mounts)
- if [ -z "$mountpoint" ]; then continue; fi
-
- # Return the absolute path to the containers' parent cgroup
- # (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
- case ",$subsystems," in
- *,ns,*) parent_cgroup="${mountpoint}${init_cgroup%/}";;
- *) parent_cgroup="${mountpoint}${init_cgroup%/}/lxc";;
- esac
- break
- done
-}
-
-exec=""
-
-while true; do
- case $1 in
- -h|--help)
- help; exit 1;;
- -n)
- # If we already have a value for $name, treat -n as being an
- # argument for netstat
- if [ -n "$name" ]
- then
- break
- else
- name="$2"; shift 2;
- fi
- ;;
- --name)
- name=$2; shift 2;;
- -P|--lxcpath)
- lxc_path="$2"; shift 2;;
- --exec)
- exec="exec"; shift;;
- --)
- shift; break;;
- *)
- break;;
- esac
-done
-
-if [ "$(id -u)" != "0" ]; then
- echo "$(basename $0): must be run as root" >&2
- exit 1
-fi
-
-if [ -z "$name" ]; then
- usage
- exit 1
-fi
-
-if [ -z "$lxc_path" ]; then
- echo "$(basename $0): no configuration path defined" >&2
- usage
- exit 1
-fi
-
-if [ -z "$exec" ]; then
- exec @BINDIR@/lxc-unshare -s MOUNT -- $0 -n $name -P "$lxc_path" --exec -- "$@"
-fi
-
-if lxc-wait -n $name -P "$lxc_path" -s 'STOPPED' -t 0; then
- echo "$(basename $0): container '$name' is not running" >&2
- exit 1
-fi
-
-get_parent_cgroup
-if [ ! -d "$parent_cgroup" ]; then
- echo "$(basename $0): no cgroup mount point found" >&2
- exit 1
-fi
-
-pid=$(head -1 $parent_cgroup/$name/tasks)
-
-if [ -z "$pid" ]; then
- echo "$(basename $0): no process found for '$name'" >&2
- exit 1
-fi
-
-tmpdir=$(mktemp -d)
-
-if [ -z "$tmpdir" -o ! -d "$tmpdir" ]; then
- echo "$(basename $0): unable to create temporary directory" >&2
- exit 1
-fi
-
-# Bind mount /proc/$pid/net onto /proc/net before calling 'netstat'.
-# However, we can not simply bind mount on top of procfs, so we have
-# to move procfs out of the way first.
-mount -n --move /proc "$tmpdir" && \
- mount -n -t tmpfs tmpfs /proc && \
- mkdir /proc/root /proc/net && \
- mount -n --move "$tmpdir" /proc/root && \
- rmdir "$tmpdir" && \
- mount -n --bind /proc/root/$pid/net /proc/net && \
- exec netstat "$@"
diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in
deleted file mode 100644
index 5c6c17568..000000000
--- a/src/lxc/lxc-ps.in
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/sh
-
-#
-# lxc: linux Container library
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-. @DATADIR@/lxc/lxc.functions
-
-usage()
-{
- echo "usage: $(basename $0) [-P PATH] [--lxc | --host | --name NAME] [[--] [PS_OPTIONS...]" >&2
-}
-
-help() {
- usage
- echo >&2
- echo "List current processes with container names." >&2
- echo >&2
- echo " --lxc show processes in all containers" >&2
- echo " --host show processes not related to any container, i.e. to the host" >&2
- echo " --name NAME show processes in the specified container" >&2
- echo " (multiple containers can be separated by commas)" >&2
- echo " -P PATH show container in lxcpath PATH" >&2
- echo " PS_OPTIONS ps command options (see \`ps --help')" >&2
-}
-
-get_parent_cgroup()
-{
- local hierarchies hierarchy fields init_cgroup mountpoint
-
- parent_cgroup=""
- subsystems=""
-
- # Obtain a list of hierarchies that contain one or more subsystems
- hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
-
- # Iterate through the list until a suitable hierarchy is found
- for hierarchy in $hierarchies; do
- # Obtain information about the init process in the hierarchy
- fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
- if [ -z "$fields" ]; then continue; fi
- fields=${fields#*:}
-
- # Get a comma-separated list of the hierarchy's subsystems
- subsystems=${fields%:*}
-
- # Get the cgroup of the init process in the hierarchy
- init_cgroup=${fields#*:}
-
- # Get the filesystem mountpoint of the hierarchy
- mountpoint=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
- '$3 == "cgroup" && $4 ~ subsysregex {print $2}' /proc/self/mounts)
- if [ -z "$mountpoint" ]; then continue; fi
-
- # Return the absolute path to the containers' parent cgroup
- parent_cgroup="${mountpoint}${init_cgroup%/}";
- break
- done
-}
-
-containers=""
-list_container_processes=0
-while true; do
- case $1 in
- -h|--help)
- help; exit 1;;
- -n|--name)
- containers=$2; list_container_processes=1; shift 2;;
- --lxc)
- list_container_processes=1; shift;;
- --host)
- list_container_processes=-1; shift;;
- -P|--lxcpath)
- lxc_path=$2; shift 2;;
- --)
- shift; break;;
- *)
- break;;
- esac
-done
-
-if [ "$list_container_processes" -eq "1" ]; then
- set -- -e $@
-fi
-
-get_parent_cgroup
-if [ ! -d "$parent_cgroup" ]; then
- echo "$(basename $0): no cgroup mount point found" >&2
- exit 1
-fi
-
-if [ -z "$containers" ]; then
- case ",$subsystems," in
- *,ns,*) containers="$(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')";;
- *) containers="$(find $parent_cgroup/lxc -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')";;
- esac
-fi
-
-container_field_width=9
-tasks_files=
-for container in ${containers}; do
- if [ "${#container}" -gt "$container_field_width" ]; then
- container_field_width=${#container}
- fi
-
- if ! lxc-wait -P $lxc_path -s STOPPED -n $container -t 0; then
- initpid=`lxc-info -P $lxc_path -p -n $container | awk -F: '{ print $2 }' | awk '{ print $1 }'`
- cgroup=`grep cpuset /proc/$initpid/cgroup | awk -F: '{ print $3}'`
- if [ -f "$parent_cgroup/$cgroup/tasks" ]; then
- tasks_files="$tasks_files $parent_cgroup$cgroup/tasks"
- fi
- fi
-done
-
-# first file is stdin, the rest are the container tasks
-ps "$@" | awk -v container_field_width="$container_field_width" \
- -v list_container_processes="$list_container_processes" '
-# first line is PS header
-NR == 1 {
- header = $0
- # find pid field index
- for (i = 1; i<=NF; i++)
- if ($i == "PID") {
- pididx = i
- break
- }
- if (pididx == "") {
- print("No PID field found") > "/dev/stderr"
- header = "" # to signal error condition to the END rule
- exit 1
- }
- next
-}
-
-# store lines from ps with pid as index
-NR == FNR {
- ps_line[NR] = $0
- pid_of_line[NR] = $pididx
- next
-}
-
-# find container name from filename on first line
-FNR == 1 {
- container = FILENAME
- sub(/\/tasks/, "", container)
- sub(/.*\//, "", container)
-}
-
-# container tasks
-{
- container_of_pid[$0] = container
-}
-
-END {
- if (!header) exit 1 # quit due to internal error
- printf("%-" container_field_width "s %s\n", "CONTAINER", header)
- for (i in ps_line) {
- container = container_of_pid[pid_of_line[i]]
- if (list_container_processes == 0 || (container != "") == (list_container_processes > 0) )
- printf("%-" container_field_width "s %s\n", container, ps_line[i])
- }
-}
-
-' - $tasks_files
diff --git a/src/lxc/lxc-version.in b/src/lxc/lxc-version.in
deleted file mode 100644
index b6875da26..000000000
--- a/src/lxc/lxc-version.in
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo "lxc version: @PACKAGE_VERSION@"