[pve-devel] [PATCH 2/2] add vps.postumount script

Alexandre Derumier aderumier at odiso.com
Tue May 6 05:59:14 CEST 2014


to cleanup bridges after openvz container umount

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 debian/rules          |    2 ++
 debian/vps.postumount |   28 ++++++++++++++++++++++++++++
 debian/vzctl.postinst |    6 ++++++
 3 files changed, 36 insertions(+)
 create mode 100755 debian/vps.postumount

diff --git a/debian/rules b/debian/rules
index c9805fd..0504db1 100644
--- a/debian/rules
+++ b/debian/rules
@@ -98,6 +98,8 @@ install: build
 	# install perl vznetaddbr version
 	install -m 644 $(CURDIR)/debian/vznetaddbr $(CURDIR)/debian/vzctl/usr/sbin/vznetaddbr
 
+	install -m 644 $(CURDIR)/debian/vps.postumount $(CURDIR)/debian/vzctl/etc/vz/vps.postumount
+
 
 
 # Build architecture-independent files here.
diff --git a/debian/vps.postumount b/debian/vps.postumount
new file mode 100755
index 0000000..d568d4f
--- /dev/null
+++ b/debian/vps.postumount
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use PVE::OpenVZ;
+use PVE::Tools qw(run_command);
+use PVE::Network;
+use PVE::ProcFSTools;
+use Data::Dumper;
+
+my $vmid = $ENV{VEID};
+die "missing vmid parameter" if !$vmid;
+
+my $conf = PVE::OpenVZ::load_config($vmid);
+
+my $ifaces = {};
+if (defined ($conf->{netif}) && $conf->{netif}->{value}) {
+	$ifaces = PVE::OpenVZ::parse_netif($conf->{netif}->{value}, $vmid);
+}
+
+foreach my $ifname (sort keys %$ifaces) {
+
+    my $iface = $ifaces->{$ifname}->{host_ifname};
+    PVE::Network::tap_unplug($iface);
+}
+
+exit 0;
+
+
diff --git a/debian/vzctl.postinst b/debian/vzctl.postinst
index 60f0e2c..d08e1aa 100644
--- a/debian/vzctl.postinst
+++ b/debian/vzctl.postinst
@@ -60,6 +60,12 @@ case "$1" in
 	    rm -f /etc/cron.d/vz
 	    rm -rf /etc/vz/cron
 	fi
+
+        if [ -r "/etc/vz/vps.postumount" ]; then
+            echo "move vps.postumount to config directory";
+            cp /etc/vz/vps.postumount /etc/pve/openvz/vps.postumount
+            #rm /etc/vz/vps.postumount
+        fi
     ;;
     abort-upgrade|abort-remove|abort-deconfigure)
     ;;
-- 
1.7.10.4




More information about the pve-devel mailing list