1
0
mirror of synced 2026-01-26 11:42:00 +00:00

Create hooks/artful with new 40-setup-networking-deb-netplan

Since Ubuntu 17.10 Artful, Ubuntu has decided to use netplan instead
of ifupdown.

40-setup-networking-deb-netplan has been contributed by Arno and Peter.
(see https://github.com/xen-tools/xen-tools/issues/51#issuecomment-412019510)

Closes xen-tools/xen-tools#51.

Since we have to make a variant of hooks/karmic/ as hook/artful/,
rename hooks/karmic/80-install-kernel (which previously was unique to
hooks/karmic/) to hooks/common/80-install-kernel-ubuntu and add
symlinks to it from hooks/karmic/ and hook/artful/.
This commit is contained in:
Axel Beckert
2019-02-03 20:45:56 +01:00
parent cfd4406a93
commit 9ee1f63705
25 changed files with 159 additions and 6 deletions

View File

@@ -219,11 +219,12 @@ install-hooks:
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d xenial.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d yakkety.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d zesty.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d artful.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d bionic.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d cosmic.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d disco.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d devel.d
mkdir -p ${prefix}/usr/share/xen-tools/artful.d/
cp -R hooks/karmic/*-* ${prefix}/usr/share/xen-tools/artful.d/
-cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d bionic.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d cosmic.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d disco.d
-cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d devel.d
cp hooks/common.sh ${prefix}/usr/share/xen-tools
cp -r hooks/common ${prefix}/usr/share/xen-tools

View File

@@ -18,7 +18,7 @@ Distribution Releases Changes
* Support for
+ Ubuntu 17.10 Artful Aardvark
+ Ubuntu 18.04 Bionic Beaver (LTS)
+ Ubuntu 18.04 Bionic Beaver (LTS) (GH #51)
+ Ubuntu 18.10 Cosmic Cuttlefish
* Preliminary support for Ubuntu 19.04 Disco Dingo
* Knows about code name for Debian 12 (Bookworm).

4
debian/changelog vendored
View File

@@ -11,6 +11,10 @@ xen-tools (4.8-1) UNRELEASED; urgency=medium
[ Axel Beckert ]
+ Add preliminary support for future Debian 12 Bookworm release.
+ Add support for Ubuntu releases from 17.10 Artful to 19.04 Disco.
- Create hooks/artful with new 40-setup-networking-deb-netplan by
Arno Bakker and Peter. (Fixes xen-tools/xen-tools#51)
- Rename hooks/karmic/80-install-kernel to
hooks/common/80-install-kernel-ubu and add according symlinks.
[ Axel Beckert ]
* Fix wrong bug number for #849867 in previous changelog entry.

View File

@@ -0,0 +1 @@
../common/01-disable-daemons

View File

@@ -0,0 +1 @@
../common/05-shadowconfig-on

View File

@@ -0,0 +1 @@
../common/15-disable-hwclock

1
hooks/artful/20-setup-apt Symbolic link
View File

@@ -0,0 +1 @@
../common/20-setup-apt

View File

@@ -0,0 +1 @@
../common/25-generate-locale

View File

@@ -0,0 +1 @@
../common/30-disable-gettys

1
hooks/artful/35-setup-users Symbolic link
View File

@@ -0,0 +1 @@
../common/35-setup-users

View File

@@ -0,0 +1,128 @@
#!/bin/sh
#
# This script sets up the /etc/netplan/interface file for the new
# image.
#
# Steve
# --
# https://steve.fi/
prefix=$1
#
# Source our common functions
#
if [ -e /usr/share/xen-tools/common.sh ]; then
. /usr/share/xen-tools/common.sh
else
. ./hooks/common.sh
fi
# From: https://serverfault.com/questions/54981/linux-command-line-tool-to-work-with-netmasks-cidr-notation
mask2cdr ()
{
# Assumes there's no "255." after a non-255 byte in the mask
local x=${1##*255.}
set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
x=${1%%$3*}
echo $(( $2 + (${#x}/4) ))
}
#
# Log our start
#
logMessage Script $0 starting
#
# Make sure we have an /etc/netplan directory.
#
mkdir -p ${prefix}/etc/netplan
#
# A function to setup DHCP for our new image.
#
setupDynamicNetworking ()
{
#
# The host is using DHCP.
#
cat <<E_O_DHCP > ${prefix}/etc/netplan/01-netcfg.yaml
# Arno: Configure VM interface eth0 via DHCP
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
E_O_DHCP
}
#
# A function to setup static IP addresses for our new image.
#
setupStaticNetworking ()
{
# Arno
cidr='24';
if [ -n "${netmask}" ]; then
cidr="$(mask2cdr ${netmask})"
fi
#
# We have a static IP address
#
cat <<E_O_STATIC >${prefix}/etc/netplan/01-netcfg.yaml
# Arno: Set static IP for VM interface eth0
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses: [${ip1}/${cidr}]
gateway4: ${gateway}
nameservers:
addresses: [${nameserver}]
E_O_STATIC
# Arno: no support for multiple interfaces
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}
#
# Call the relevant function
#
if [ -z "${dhcp}" ]; then
logMessage "Setting up static networking"
setupStaticNetworking
else
logMessage "Setting up DHCP networking"
setupDynamicNetworking
fi
#
# Log our finish
#
logMessage Script $0 finished

View File

@@ -0,0 +1 @@
../common/50-setup-hostname-deb

View File

@@ -0,0 +1 @@
../common/60-copy-host-files

View File

@@ -0,0 +1 @@
../common/65-copy-user-files

1
hooks/artful/70-install-ssh Symbolic link
View File

@@ -0,0 +1 @@
../common/70-install-ssh-deb

View File

@@ -0,0 +1 @@
../common/75-fixup-securetty

View File

@@ -0,0 +1 @@
../common/80-install-kernel-ubuntu

View File

@@ -0,0 +1 @@
../common/80-install-modules-deb

View File

@@ -0,0 +1 @@
../common/81-install-modules-init-tools

View File

@@ -0,0 +1 @@
../common/82-install-grub-legacy

1
hooks/artful/90-make-fstab Symbolic link
View File

@@ -0,0 +1 @@
../common/90-make-fstab

1
hooks/artful/99-clean-image Symbolic link
View File

@@ -0,0 +1 @@
../common/99-clean-image-deb

View File

@@ -0,0 +1 @@
../common/99-enable-daemons

View File

@@ -0,0 +1 @@
../common/80-install-kernel-ubuntu