Compare commits
1 commit
master
...
contrib/ad
Author | SHA1 | Date | |
---|---|---|---|
a9b0d34bb2 |
2 changed files with 15 additions and 9 deletions
|
@ -1,7 +1,3 @@
|
||||||
🟢 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)
|
||||||
|
@ -13,6 +9,10 @@ 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,9 +144,12 @@ 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" != "cgroup" ] && continue
|
[ "$fstype" != "cgroup2" ] && [ "$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" ] || {
|
||||||
|
@ -154,7 +157,9 @@ done < /proc/mounts
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to find a cgroup matching exactly the provided name.
|
# Try to find a cgroup matching exactly the provided name.
|
||||||
N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
|
[ "$CGROUPTYPE" = "cgroup" ] && 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.
|
||||||
|
@ -235,7 +240,8 @@ fi
|
||||||
if [ "$DOCKERPID" ]; then
|
if [ "$DOCKERPID" ]; then
|
||||||
NSPID=$DOCKERPID
|
NSPID=$DOCKERPID
|
||||||
else
|
else
|
||||||
NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
|
NSPATH=$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)
|
||||||
|
[ -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]+')
|
||||||
|
@ -390,7 +396,7 @@ else
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
if installed ipcalc; then
|
if installed ipcalc; then
|
||||||
eval "$(ipcalc -b $IPADDR)"
|
eval $(ipcalc -b $IPADDR)
|
||||||
ip netns exec "$NSPID" ip addr add "$IPADDR" brd "$BROADCAST" dev "$CONTAINER_IFNAME"
|
ip netns exec "$NSPID" ip addr add "$IPADDR" brd "$BROADCAST" dev "$CONTAINER_IFNAME"
|
||||||
else
|
else
|
||||||
ip netns exec "$NSPID" ip addr add "$IPADDR" dev "$CONTAINER_IFNAME"
|
ip netns exec "$NSPID" ip addr add "$IPADDR" dev "$CONTAINER_IFNAME"
|
||||||
|
|
Loading…
Reference in a new issue