]> git.proxmox.com Git - ifupdown2.git/blob - debian/patches/pve/0010-postinst-rm-update-network-config-compatibility.patch
update patch10: only rewrite config on first ifupdown2
[ifupdown2.git] / debian / patches / pve / 0010-postinst-rm-update-network-config-compatibility.patch
1 From 723bfd8e3ed7a6140a411260a4881ed886efc829 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] postinst/rm : update network config compatibility
5
6 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
7 ---
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
13
14 diff --git a/debian/ifupdown2.postinst b/debian/ifupdown2.postinst
15 index 3689256..5162109 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"
20 }
21
22 +proxmox_compatibility()
23 +{
24 + perl -e '
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};
29 +
30 + PVE::INotify::write_file('interfaces', $configdata);
31 +
32 + $config = PVE::INotify::read_file('interfaces', 1);
33 +
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";
37 + }
38 + ' || true
39 +}
40 +
41 case "$1" in
42 configure)
43 fix_dhclient_file_with_space
44 @@ -92,6 +111,10 @@ case "$1" in
45 process_udev
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
51 + fi
52 ;;
53
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()
60 fi
61 }
62
63 +proxmox_compatibility()
64 +{
65 + perl -e '
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};
70 +
71 + PVE::INotify::write_file('interfaces', $configdata);
72 +
73 + $config = PVE::INotify::read_file('interfaces', 1);
74 +
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";
78 + }
79 + ' || true
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)
90 diff --git a/debian/ifupdown2.preinst b/debian/ifupdown2.preinst
91 new file mode 100644
92 index 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
116 --
117 2.20.1
118