~serge-hallyn/ubuntu/quantal/lxc/lxc-fixapi

« back to all changes in this revision

Viewing changes to .pc/07-lxc-netstat.patch/src/lxc/lxc-netstat.in

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2012-04-26 15:18:35 UTC
  • mfrom: (3.1.41 sid)
  • Revision ID: package-import@ubuntu.com-20120426151835-3vz6kb4m90gb26js
Tags: 0.8.0~rc1-4ubuntu1
* Merge from unstable.  Remaining changes:
  - control:
    - update maintainer
    - Build-Depends: add dh-apparmor and libapparmor-dev
    - lxc Depends: add bridge-utils, dnsmasq-base, iptables, rsync
    - lxc Recommends: add cgroup-lite | cgroup-bin, openssl
    - lxc Suggests: add btrfs-tools, lvm2, qemu-user-static
    - lxc Conflicts: remove (cgroup-bin)
  - Add lxc-start-ephemeral and lxc-wait to debian/local
  - apparmor:
    - add lxc.apparmor, lxc-containers.apparmor,
      lxc-default.apparmor, and new lxc.apparmor.in
  - add debian/lxc.conf (default container creation config file)
  - debian/lxc.install.in:
    * add lxc-start-ephemeral
    * add debian/lxc.conf
    * skip lxc-debconf*
    * skip lxc-ls (Use upstream's)
  - debian/lxc*.install.in: use '*', not @DEB_HOST_MULTIARCH@
  - Use our own completely different lxc.postinst and lxc.postrm
  - remove lxc.templates
  - debian/rules:
    * add DEB_DH_INSTALLINIT_ARGS = --upstart-only
    * don't do debconf stuff
    * add debian/*.apparmor.in to files processed under
      override_dh_auto_clean
    * don't comment out ubuntu or busybox templates
    * do apparmor stuff and install our own lxc-wait under override_dh_install
    * install our upstart scripts in override_dh_installinit
  - add lxc.default, lxc.lxc-net.upstart, lxc.upstart under
    debian/

* patches kept:
  - 0013-lxc-create-use-default-config.patch (needed manual rebase)
  - 0030-ubuntu-template-fail.patch
  - 0031-ubuntu-template-resolvconf.patch
  - 0044-lxc-destroy-rm-autos
  - debian/patches/0045-fix-other-templates
  - debian/patches/0046-lxc-clone-change-hwaddr
  - debian/patches/0047-bindhome-check-shell
  - debian/patches/0049-ubuntu-template-sudo-and-cleanup
  - debian/patches/0050-clone-lvm-sizes
  - debian/patches/0052-ubuntu-bind-user-conflict
  - debian/patches/0053-lxc-start-pin-rootfs
  - debian/patches/0054-ubuntu-debug
  - debian/patches/0055-ubuntu-handle-badgrp
  - debian/patches/0056-dont-watch-utmp
  - debian/patches/0057-update-manpages
  - debian/patches/0058-fixup-ubuntu-cloud
  - debian/patches/0059-reenable-daily-cloudimg
  - debian/patches/0060-lxc-shutdown
  - debian/patches/0061-lxc-start-apparmor
  - debian/patches/0062-templates-relative-paths
  - debian/patches/0063-check-apparmor-enabled
  - debian/patches/0064-apparmor-mount-proc
  - debian/patches/0065-fix-bindhome-relpath
  - debian/patches/0066-confile-typo
  - debian/patches/0067-templates-lxc-profile
  - debian/patches/0068-fix-lxc-config-layout 
  - debian/patches/0069-ubuntu-cloud-fix
  - debian/patches/0070-templates-rmdir-dev-shm
  - debian/patches/0071-ubuntu-cloud-fix-image-extraction
  - debian/patches/0072-lxc-shutdown-help
  - debian/patches/0073-lxc-destroy-waits-before-destroy
  - mark all patches which have been forwarded as such, refresh all
* 0074-lxc-execute-find-init: lxc-init had moved.  Introduce a function in
  lxc-execute to go find it.  Otherwise lxc-execute for any older releases
  will fail.
* 0075-lxc-ls-bash: lxc-ls needs bash, not sh
* add debian/lxc.apparmor.in so DEB_HOST_MULTIARCH can be expanded
* 0076-fix-sprintfs:  - check return values for all sprintfs and snprintfs
  which could overflow (LP: #988918)
* 0077-execute-without-rootfs: let lxc-execute succeed with no rootfs
  (LP: #981955)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# set -ex
 
3
 
 
4
usage() {
 
5
        echo "usage: $(basename $0) --name <name> [netstat options]"
 
6
}
 
7
 
 
8
help() {
 
9
        usage
 
10
        echo
 
11
        echo "execute netstat for the specified container"
 
12
        echo "with the added netstat options"
 
13
        echo
 
14
        echo "Options:"
 
15
        echo "name  : name of the container"
 
16
        echo "help  : this current help."
 
17
        echo
 
18
        echo "to be executed as root."
 
19
}
 
20
 
 
21
exec=""
 
22
 
 
23
if [ $# -eq  0 ]; then
 
24
        usage
 
25
        exit 1
 
26
fi
 
27
 
 
28
for i in "$@"; do
 
29
        case $i in
 
30
                -h|--help)
 
31
                        help; exit 1;;
 
32
                -n|--name)
 
33
                        name=$2; shift 2;;
 
34
                --exec)
 
35
                        exec="exec"; shift;;
 
36
        esac
 
37
done
 
38
 
 
39
if [ -z "$exec" ]; then
 
40
    exec @BINDIR@/lxc-unshare -s MOUNT -- $0 -n $name --exec "$@"
 
41
fi
 
42
 
 
43
if [ -z "$name" ]; then
 
44
        usage
 
45
        exit 1
 
46
fi
 
47
 
 
48
lxc-info -n $name 2>&1 | grep -q 'STOPPED'
 
49
if [ $? -eq 0 ]; then
 
50
        echo "Container $name is not running"
 
51
        exit 1
 
52
fi
 
53
 
 
54
cgroups=$(mount -l -t cgroup)
 
55
cgroup_path=""
 
56
 
 
57
for i in "$cgroups"; do
 
58
 
 
59
    cgroup_name=$(echo $i | awk ' { print $1 } ')
 
60
    cgroup_path=$(echo $i | awk ' { print $3 } ')
 
61
 
 
62
    if [ "$cgroup_name" = "lxc" ]; then
 
63
        break;
 
64
    fi
 
65
 
 
66
done
 
67
 
 
68
if [ -z "$cgroup_path" ]; then
 
69
        cgroups=`grep -m1 -E '^[^ \t]+[ \t]+[^ \t]+[ \t]+cgroup' /proc/self/mounts`
 
70
        for i in "$cgroups"; do
 
71
            cgroup_path=$(echo $i | awk ' { print $2 } ')
 
72
            if [ -n $cgroup_path ]; then
 
73
                break;
 
74
            fi
 
75
        done
 
76
fi
 
77
 
 
78
if [ -z "$cgroup_path" ]; then
 
79
    echo "no cgroup mount point found"
 
80
    exit 1
 
81
fi
 
82
 
 
83
# the container will be in:
 
84
# ${cgroup_path}.${init_cgroup_path}."lxc".$name
 
85
init_cgroup=`cat /proc/1/cgroup | awk -F: '{ print $3 }' | head -1`
 
86
final_cgroup_path=$cgroup_path/$init_cgroup/lxc
 
87
pid=$(head -1 $final_cgroup_path/$name/tasks)
 
88
 
 
89
if [ -z "$pid" ]; then
 
90
    echo "no process found for '$name'"
 
91
    exit 1
 
92
fi
 
93
 
 
94
mount -n --bind /proc/$pid/net /proc/$$/net && \
 
95
    exec netstat "$@"