-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathamazon-ec2-net-utils.spec
80 lines (66 loc) · 2.3 KB
/
amazon-ec2-net-utils.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Name: amazon-ec2-net-utils
%define base_version 2.5.1
%define source_version %{base_version}%{?_source_version_suffix}
Version: %{base_version}%{?_rpm_version_suffix}
Release: 1%{?dist}
Summary: utilities for managing network interfaces in Amazon EC2
License: Apache 2.0
URL: https://github.com/aws/amazon-ec2-net-utils/
Source0: amazon-ec2-net-utils-%{source_version}.tar.gz
BuildArch: noarch
BuildRequires: make
Requires: systemd-networkd, udev, curl, iproute
Requires: /usr/bin/md5sum
Requires: (systemd-resolved or systemd < 250)
%description
amazon-ec2-net-utils-ng provides udev integration and helper utilities
to manage network configuration in the Amazon EC2 cloud environment
%prep
%autosetup -n %{name}-%{source_version}
%install
make install DESTDIR=%{buildroot} PREFIX=/usr
%files
/usr/lib/systemd/network/80-ec2.network
/usr/lib/systemd/system/policy-routes@.service
/usr/lib/systemd/system/refresh-policy-routes@.service
/usr/lib/systemd/system/refresh-policy-routes@.timer
/usr/lib/udev/rules.d/99-vpc-policy-routes.rules
%{_bindir}/setup-policy-routes
%dir %{_datarootdir}/amazon-ec2-net-utils
%{_datarootdir}/amazon-ec2-net-utils/lib.sh
%post
setup_policy_routes() {
local iface node
for node in /sys/class/net/*; do
iface=$(basename $node)
unset ID_NET_DRIVER
eval $(udevadm info --export --query=property /sys/class/net/$iface)
case $ID_NET_DRIVER in
ena|ixgbevf|vif)
systemctl restart policy-routes@${iface}.service
systemctl start refresh-policy-routes@${iface}.timer
;;
esac
done
}
if [ $1 -eq 1 ]; then
# This is a new install
systemctl enable systemd-networkd.service
systemctl enable systemd-resolved.service
systemctl disable NetworkManager-wait-online.service
systemctl disable NetworkManager.service
[ -f /etc/resolv.conf ] && mv /etc/resolv.conf /etc/resolv.conf.old
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
if [ -d /run/systemd/system ]; then
systemctl stop NetworkManager.service
systemctl start systemd-networkd.service
setup_policy_routes
systemctl start systemd-resolved.service
fi
elif [ $1 -gt 1 ]; then
# This is an upgrade, there's less setup to do, but we do want to
# ensure we apply any configuration introduced by the new version
systemctl daemon-reload
setup_policy_routes
fi
%changelog