Compare commits
8 commits
contrib/49
...
master
Author | SHA1 | Date | |
---|---|---|---|
a47660a1e5 | |||
3575d65ffb | |||
|
938a29ed96 | ||
|
ff58ecd5f2 | ||
|
df6b78c4ed | ||
|
4d53acb9fb | ||
|
b88d50fb68 | ||
4e3306ed74 |
2 changed files with 8 additions and 14 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
🟢 We plan to support and maintain vagrant-lxc, as well as clean it up.<br/>
|
||||||
|
🟢 Please feel free to contribute Issues and pull requests.<br/>
|
||||||
|
🟢 P.S: Thanks [Fabio Rehm](https://fabiorehm.com) for the amazing initial project.
|
||||||
|
|
||||||
# vagrant-lxc
|
# vagrant-lxc
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) [![Gitter chat](https://badges.gitter.im/fgrehm/vagrant-lxc.png)](https://gitter.im/fgrehm/vagrant-lxc)
|
[![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) [![Gitter chat](https://badges.gitter.im/fgrehm/vagrant-lxc.png)](https://gitter.im/fgrehm/vagrant-lxc)
|
||||||
|
@ -9,10 +13,6 @@ as an alternative to the built in VirtualBox provider for Linux hosts. Check out
|
||||||
[this blog post](http://fabiorehm.com/blog/2013/04/28/lxc-provider-for-vagrant/)
|
[this blog post](http://fabiorehm.com/blog/2013/04/28/lxc-provider-for-vagrant/)
|
||||||
to see it in action.
|
to see it in action.
|
||||||
|
|
||||||
## Help Needed!
|
|
||||||
|
|
||||||
This project is looking for maintainers, please see [GH-375](https://github.com/fgrehm/vagrant-lxc/issues/375) for more.
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Provides the same workflow as the Vagrant VirtualBox provider
|
* Provides the same workflow as the Vagrant VirtualBox provider
|
||||||
|
|
|
@ -144,12 +144,9 @@ CONTAINER_IFNAME=${CONTAINER_IFNAME:-eth1}
|
||||||
|
|
||||||
# Second step: find the guest (for now, we only support LXC containers)
|
# Second step: find the guest (for now, we only support LXC containers)
|
||||||
while read _ mnt fstype options _; do
|
while read _ mnt fstype options _; do
|
||||||
[ "$fstype" != "cgroup2" ] && [ "$fstype" != "cgroup" ] && continue
|
[ "$fstype" != "cgroup" ] && continue
|
||||||
if [ "$fstype" = "cgroup" ]; then
|
echo "$options" | grep -qw devices || continue
|
||||||
echo "$options" | grep -qw devices || continue
|
|
||||||
fi
|
|
||||||
CGROUPMNT=$mnt
|
CGROUPMNT=$mnt
|
||||||
CGROUPTYPE=$fstype
|
|
||||||
done < /proc/mounts
|
done < /proc/mounts
|
||||||
|
|
||||||
[ "$CGROUPMNT" ] || {
|
[ "$CGROUPMNT" ] || {
|
||||||
|
@ -157,9 +154,7 @@ done < /proc/mounts
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to find a cgroup matching exactly the provided name.
|
# Try to find a cgroup matching exactly the provided name.
|
||||||
[ "$CGROUPTYPE" = "cgroup" ] && N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
|
N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
|
||||||
[ "$CGROUPTYPE" = "cgroup2" ] && N=$(find "$CGROUPMNT" -name "lxc.payload.$GUESTNAME" | wc -l)
|
|
||||||
|
|
||||||
case "$N" in
|
case "$N" in
|
||||||
0)
|
0)
|
||||||
# If we didn't find anything, try to lookup the container with Docker.
|
# If we didn't find anything, try to lookup the container with Docker.
|
||||||
|
@ -240,8 +235,7 @@ fi
|
||||||
if [ "$DOCKERPID" ]; then
|
if [ "$DOCKERPID" ]; then
|
||||||
NSPID=$DOCKERPID
|
NSPID=$DOCKERPID
|
||||||
else
|
else
|
||||||
NSPATH=$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)
|
NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
|
||||||
[ -f "$NSPATH/tasks" ] && NSPID=$(head -n 1 "$NSPATH/tasks")
|
|
||||||
[ "$NSPID" ] || {
|
[ "$NSPID" ] || {
|
||||||
# it is an alternative way to get the pid
|
# it is an alternative way to get the pid
|
||||||
NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+')
|
NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+')
|
||||||
|
|
Loading…
Reference in a new issue