1 From 2fe84449da923d01de8bbed84f4f8ce15548225f Mon Sep 17 00:00:00 2001
2 From: Alexandre Derumier <aderumier@odiso.com>
3 Date: Fri, 21 Feb 2020 10:01:59 +0100
4 Subject: [PATCH 09/12] postinst/rm : update network config compatibility
6 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 debian/ifupdown2.postinst | 23 +++++++++++++++++++++++
9 debian/ifupdown2.postrm | 20 ++++++++++++++++++++
10 debian/ifupdown2.preinst | 20 ++++++++++++++++++++
11 3 files changed, 63 insertions(+)
12 create mode 100644 debian/ifupdown2.preinst
14 diff --git a/debian/ifupdown2.postinst b/debian/ifupdown2.postinst
15 index 3689256..b7de485 100644
16 --- a/debian/ifupdown2.postinst
17 +++ b/debian/ifupdown2.postinst
18 @@ -85,6 +85,25 @@ postinst_remove_diverts()
19 _postinst_remove_diverts "/usr/share/man/man5/interfaces.5.gz"
22 +proxmox_compatibility()
25 + my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; };
26 + exit if !$haspve_common;
27 + my $config = PVE::INotify::read_file('interfaces', 1);
28 + my $configdata = $config->{data};
30 + PVE::INotify::write_file('interfaces', $configdata);
32 + $config = PVE::INotify::read_file('interfaces', 1);
34 + if (defined($config->{changes})) {
35 + #print $config->{changes};
36 + print "\nnetwork config changes have been detected for ifupdown2 compatibility.\nSaved in /etc/network/interfaces.new for hot-apply or next reboot.\n\n";
43 fix_dhclient_file_with_space
44 @@ -92,6 +111,10 @@ case "$1" in
46 chmod +x /usr/share/ifupdown2/__main__.py
47 postinst_remove_diverts
48 + if [ -f "/tmp/.ifupdown2-first-install" ]; then
49 + proxmox_compatibility
50 + rm /tmp/.ifupdown2-first-install
54 abort-upgrade|abort-remove|abort-deconfigure)
55 diff --git a/debian/ifupdown2.postrm b/debian/ifupdown2.postrm
56 index 5d90b21..fd62294 100644
57 --- a/debian/ifupdown2.postrm
58 +++ b/debian/ifupdown2.postrm
59 @@ -25,10 +25,30 @@ process_udev()
63 +proxmox_compatibility()
66 + my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; };
67 + exit if !$haspve_common;
68 + my $config = PVE::INotify::read_file('interfaces', 1);
69 + my $configdata = $config->{data};
71 + PVE::INotify::write_file('interfaces', $configdata);
73 + $config = PVE::INotify::read_file('interfaces', 1);
75 + if (defined($config->{changes})) {
76 + #print $config->{changes};
77 + print "\nnetwork config changes have been detected for ifupdown2 to ifupdown1 switch compatibility.\nSaved in /etc/network/interfaces.new for next reboot\n\n";
83 purge|remove|abort-install|disappear)
86 + proxmox_compatibility
89 upgrade|failed-upgrade|abort-upgrade|disappear)
90 diff --git a/debian/ifupdown2.preinst b/debian/ifupdown2.preinst
92 index 0000000..aa8653e
94 +++ b/debian/ifupdown2.preinst
101 + touch /tmp/.ifupdown2-first-install
104 + upgrade|abort-upgrade)
108 + echo "postinst called with unknown argument \`$1'" >&2