[pve-devel] [PATCH container 8/8] setup/suse: fix #1464: support SLES 12 container

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Aug 1 11:28:59 CEST 2017


SLES 12 shares its base with opensuse leap, so we shouldn't get into
much trouble here.
I copied the os-release file from a SLES installation.
I didn't found official SLES CT/rootfs images, people with access to
the repos should be able to create them.

Fixes: #1464
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup.pm                               |  1 +
 src/PVE/LXC/Setup/SUSE.pm                          |  3 +++
 src/test/test-opensuse-005/config                  |  3 +++
 src/test/test-opensuse-005/etc/os-release          |  7 +++++++
 src/test/test-opensuse-005/etc/securetty           |  7 +++++++
 src/test/test-opensuse-005/etc/securetty.exp       | 12 +++++++++++
 .../etc/sysconfig/network/ifcfg-eth0.exp           |  4 ++++
 .../etc/sysconfig/network/ifcfg-eth1.exp           |  2 ++
 .../etc/sysconfig/network/ifroute-eth0.exp         |  5 +++++
 .../root/.ssh/authorized_keys.exp                  |  3 +++
 .../lib/systemd/system/container-getty at .service    | 24 ++++++++++++++++++++++
 11 files changed, 71 insertions(+)
 create mode 100644 src/test/test-opensuse-005/config
 create mode 100644 src/test/test-opensuse-005/etc/os-release
 create mode 100644 src/test/test-opensuse-005/etc/securetty
 create mode 100644 src/test/test-opensuse-005/etc/securetty.exp
 create mode 100644 src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth0.exp
 create mode 100644 src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth1.exp
 create mode 100644 src/test/test-opensuse-005/etc/sysconfig/network/ifroute-eth0.exp
 create mode 100644 src/test/test-opensuse-005/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-opensuse-005/usr/lib/systemd/system/container-getty at .service

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index aa8bc45..1d3063b 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -20,6 +20,7 @@ my $plugins = {
     centos    => 'PVE::LXC::Setup::CentOS',
     fedora    => 'PVE::LXC::Setup::Fedora',
     opensuse  => 'PVE::LXC::Setup::SUSE',
+    sles      => 'PVE::LXC::Setup::SUSE',
     archlinux => 'PVE::LXC::Setup::ArchLinux',
     arch      => 'PVE::LXC::Setup::ArchLinux',
     alpine    => 'PVE::LXC::Setup::Alpine',
diff --git a/src/PVE/LXC/Setup/SUSE.pm b/src/PVE/LXC/Setup/SUSE.pm
index 3a526cf..6e83c36 100644
--- a/src/PVE/LXC/Setup/SUSE.pm
+++ b/src/PVE/LXC/Setup/SUSE.pm
@@ -22,6 +22,9 @@ sub new {
 	} elsif ($major == 13 && $minor <= 2) {
 	    # OK
 	    $setup_ct_getty_service = 1 if $minor >= 2;
+	} elsif ($ostype eq 'sles' && $major == 12) {
+	    # OK - shares base with LEAP (42)
+	    $setup_ct_getty_service = 1;
 	} else {
 	    die "unsupported suse release '$version'\n";
 	}
diff --git a/src/test/test-opensuse-005/config b/src/test/test-opensuse-005/config
new file mode 100644
index 0000000..ac3e532
--- /dev/null
+++ b/src/test/test-opensuse-005/config
@@ -0,0 +1,3 @@
+hostname: pvesuse1
+net0: bridge=vmbr0,name=eth0,ip=1.2.3.4/24,gw=4.3.2.1,ip6=2001:1::/64,gw6=2001:1::ffff
+net1: bridge=vmbr0,name=eth1,ip=dhcp
diff --git a/src/test/test-opensuse-005/etc/os-release b/src/test/test-opensuse-005/etc/os-release
new file mode 100644
index 0000000..795d501
--- /dev/null
+++ b/src/test/test-opensuse-005/etc/os-release
@@ -0,0 +1,7 @@
+NAME="SLES"
+VERSION="12-SP2"
+VERSION_ID="12.2"
+PRETTY_NAME="SUSE Linux Enterprise Server 12 SP2"
+ID="sles"
+ANSI_COLOR="0;32"
+CPE_NAME="cpe:/o:suse:sles:12:sp2"
diff --git a/src/test/test-opensuse-005/etc/securetty b/src/test/test-opensuse-005/etc/securetty
new file mode 100644
index 0000000..e0bd229
--- /dev/null
+++ b/src/test/test-opensuse-005/etc/securetty
@@ -0,0 +1,7 @@
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+console
diff --git a/src/test/test-opensuse-005/etc/securetty.exp b/src/test/test-opensuse-005/etc/securetty.exp
new file mode 100644
index 0000000..a0f3062
--- /dev/null
+++ b/src/test/test-opensuse-005/etc/securetty.exp
@@ -0,0 +1,12 @@
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+console
+lxc/console
+lxc/tty1
+lxc/tty2
+lxc/tty3
+lxc/tty4
diff --git a/src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth0.exp b/src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth0.exp
new file mode 100644
index 0000000..d5255e2
--- /dev/null
+++ b/src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth0.exp
@@ -0,0 +1,4 @@
+STARTMODE=onboot
+BOOTPROTO=static
+IPADDR_1=1.2.3.4/24
+IPADDR_2=2001:1::/64
diff --git a/src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth1.exp b/src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth1.exp
new file mode 100644
index 0000000..9afa8b7
--- /dev/null
+++ b/src/test/test-opensuse-005/etc/sysconfig/network/ifcfg-eth1.exp
@@ -0,0 +1,2 @@
+STARTMODE=onboot
+BOOTPROTO=dhcp4
diff --git a/src/test/test-opensuse-005/etc/sysconfig/network/ifroute-eth0.exp b/src/test/test-opensuse-005/etc/sysconfig/network/ifroute-eth0.exp
new file mode 100644
index 0000000..31e51de
--- /dev/null
+++ b/src/test/test-opensuse-005/etc/sysconfig/network/ifroute-eth0.exp
@@ -0,0 +1,5 @@
+# --- BEGIN PVE ---
+4.3.2.1 0.0.0.0 255.255.255.255 eth0
+default 4.3.2.1 0.0.0.0 eth0
+default 2001:1::ffff - eth0
+# --- END PVE ---
diff --git a/src/test/test-opensuse-005/root/.ssh/authorized_keys.exp b/src/test/test-opensuse-005/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-opensuse-005/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-opensuse-005/usr/lib/systemd/system/container-getty at .service b/src/test/test-opensuse-005/usr/lib/systemd/system/container-getty at .service
new file mode 100644
index 0000000..5a34773
--- /dev/null
+++ b/src/test/test-opensuse-005/usr/lib/systemd/system/container-getty at .service
@@ -0,0 +1,24 @@
+[Unit]
+Description=Container Getty on /dev/pts/%I
+Documentation=man:agetty(8) man:machinectl(1)
+After=systemd-user-sessions.service plymouth-quit-wait.service
+After=rc-local.service
+Before=getty.target
+IgnoreOnIsolate=yes
+ConditionPathExists=/dev/pts/%I
+
+[Service]
+# The '-o' option value tells agetty to replace 'login' arguments with an
+# option to preserve environment (-p), followed by '--' for safety, and then
+# the entered username.
+ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear --keep-baud pts/%I 115200,38400,9600 $TERM
+Type=idle
+Restart=always
+RestartSec=0
+UtmpIdentifier=pts/%I
+TTYPath=/dev/pts/%I
+TTYReset=yes
+TTYVHangup=yes
+KillMode=process
+IgnoreSIGPIPE=no
+SendSIGHUP=yes
-- 
2.11.0





More information about the pve-devel mailing list