]> git.proxmox.com Git - ifupdown2.git/blame - debian/patches/pve/0009-postinst-rm-update-network-config-compatibility.patch
merge upstream and our changelog
[ifupdown2.git] / debian / patches / pve / 0009-postinst-rm-update-network-config-compatibility.patch
CommitLineData
234ce3a0 1From 2fe84449da923d01de8bbed84f4f8ce15548225f Mon Sep 17 00:00:00 2001
849ae55d
AD
2From: Alexandre Derumier <aderumier@odiso.com>
3Date: Fri, 21 Feb 2020 10:01:59 +0100
234ce3a0 4Subject: [PATCH 09/12] postinst/rm : update network config compatibility
849ae55d
AD
5
6Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
7---
8d5303c3
AD
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
849ae55d
AD
13
14diff --git a/debian/ifupdown2.postinst b/debian/ifupdown2.postinst
234ce3a0 15index 3689256..b7de485 100644
849ae55d
AD
16--- a/debian/ifupdown2.postinst
17+++ b/debian/ifupdown2.postinst
d32cfc02 18@@ -85,6 +85,25 @@ postinst_remove_diverts()
849ae55d
AD
19 _postinst_remove_diverts "/usr/share/man/man5/interfaces.5.gz"
20 }
21
22+proxmox_compatibility()
23+{
24+ perl -e '
d32cfc02
TL
25+ my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; };
26+ exit if !$haspve_common;
849ae55d
AD
27+ my $config = PVE::INotify::read_file('interfaces', 1);
28+ my $configdata = $config->{data};
29+
30+ PVE::INotify::write_file('interfaces', $configdata);
31+
4bb44e06 32+ $config = PVE::INotify::read_file('interfaces', 1);
849ae55d 33+
4bb44e06 34+ if (defined($config->{changes})) {
7298bb3f
TL
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";
849ae55d 37+ }
4bb44e06 38+ ' || true
849ae55d
AD
39+}
40+
41 case "$1" in
42 configure)
43 fix_dhclient_file_with_space
8d5303c3 44@@ -92,6 +111,10 @@ case "$1" in
849ae55d
AD
45 process_udev
46 chmod +x /usr/share/ifupdown2/__main__.py
47 postinst_remove_diverts
8d5303c3
AD
48+ if [ -f "/tmp/.ifupdown2-first-install" ]; then
49+ proxmox_compatibility
50+ rm /tmp/.ifupdown2-first-install
51+ fi
849ae55d
AD
52 ;;
53
54 abort-upgrade|abort-remove|abort-deconfigure)
55diff --git a/debian/ifupdown2.postrm b/debian/ifupdown2.postrm
8d5303c3 56index 5d90b21..fd62294 100644
849ae55d
AD
57--- a/debian/ifupdown2.postrm
58+++ b/debian/ifupdown2.postrm
d32cfc02 59@@ -25,10 +25,30 @@ process_udev()
849ae55d
AD
60 fi
61 }
62
63+proxmox_compatibility()
64+{
65+ perl -e '
d32cfc02
TL
66+ my $haspve_common; eval { require PVE::INotify; $haspve_common = 1; };
67+ exit if !$haspve_common;
849ae55d
AD
68+ my $config = PVE::INotify::read_file('interfaces', 1);
69+ my $configdata = $config->{data};
70+
71+ PVE::INotify::write_file('interfaces', $configdata);
72+
4bb44e06 73+ $config = PVE::INotify::read_file('interfaces', 1);
849ae55d 74+
4bb44e06 75+ if (defined($config->{changes})) {
7298bb3f
TL
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";
849ae55d 78+ }
4bb44e06 79+ ' || true
849ae55d
AD
80+}
81+
82 case "$1" in
83 purge|remove|abort-install|disappear)
84 process_state_file
85 process_udev
86+ proxmox_compatibility
87 ;;
88
89 upgrade|failed-upgrade|abort-upgrade|disappear)
8d5303c3
AD
90diff --git a/debian/ifupdown2.preinst b/debian/ifupdown2.preinst
91new file mode 100644
92index 0000000..aa8653e
93--- /dev/null
94+++ b/debian/ifupdown2.preinst
95@@ -0,0 +1,20 @@
96+#!/bin/sh
97+set -e
98+
99+case "$1" in
100+ install)
101+ touch /tmp/.ifupdown2-first-install
102+ ;;
103+
104+ upgrade|abort-upgrade)
105+ ;;
106+
107+ *)
108+ echo "postinst called with unknown argument \`$1'" >&2
109+ exit 0
110+ ;;
111+esac
112+
113+#DEBHELPER#
114+
115+exit 0
849ae55d 116--
234ce3a0 1172.30.2
849ae55d 118