From 6053a89b299215c39f1e231dea598e88ca9e9745 Mon Sep 17 00:00:00 2001 From: "David M. Johnson" Date: Tue, 1 Dec 2015 21:17:41 -0700 Subject: [PATCH] Make systemd swap hack run on Ubuntu 15. So, the scripts are now in clientside/tmcc/linux since they're the same for any systemd-based Linux, and the centos7 and ubuntu15 makefiles install those files. Also had to improve fixup-fstab-swaps to handle the case where the / is something like /dev/disk/by-uuid/ which is a symlink to the real dev. So try readlink -f to handle that. --- clientside/tmcc/centos7/GNUmakefile.in | 4 ++-- .../{centos7 => linux}/emulab-fstab-fixup.service | 0 .../tmcc/{centos7 => linux}/emulab-systemd-swaps | 0 clientside/tmcc/linux/fixup-fstab-swaps | 14 +++++++++++++- clientside/tmcc/ubuntu15/GNUmakefile.in | 7 ++++++- 5 files changed, 21 insertions(+), 4 deletions(-) rename clientside/tmcc/{centos7 => linux}/emulab-fstab-fixup.service (100%) rename clientside/tmcc/{centos7 => linux}/emulab-systemd-swaps (100%) diff --git a/clientside/tmcc/centos7/GNUmakefile.in b/clientside/tmcc/centos7/GNUmakefile.in index 0d03fea5d..6bc017283 100644 --- a/clientside/tmcc/centos7/GNUmakefile.in +++ b/clientside/tmcc/centos7/GNUmakefile.in @@ -87,7 +87,7 @@ common-install: dir-install @echo "no centos-specific common files" bin-install: dir-install - $(INSTALL) -m 755 $(SRCDIR)/emulab-systemd-swaps $(BINDIR) + $(INSTALL) -m 755 $(SRCDIR)/../linux/emulab-systemd-swaps $(BINDIR) @echo "centos7 systemd swap.service" etc-install: dir-install sysetc-remove sysetc-install @@ -107,7 +107,7 @@ sysetc-install: ifcfgs dir-install $(INSTALL) -m 644 ifcfg-eth[0-9]* $(SYSETCDIR)/sysconfig/network-scripts $(INSTALL) -m 744 $(SRCDIR)/ifup-emulabcnet $(SYSETCDIR)/sysconfig/network-scripts $(INSTALL) -m 644 $(SRCDIR)/logrotate-syslog $(SYSETCDIR)/logrotate.d/syslog - $(INSTALL) -m 644 $(SRCDIR)/emulab-fstab-fixup.service $(SYSETCDIR)/systemd/system + $(INSTALL) -m 644 $(SRCDIR)/../linux/emulab-fstab-fixup.service $(SYSETCDIR)/systemd/system $(INSTALL) -m 644 $(SRCDIR)/ntpd.service $(SYSETCDIR)/systemd/system rm -f $(SYSETCDIR)/systemd/system/multi-user.target.wants/ntpd.service systemctl enable emulab-fstab-fixup.service diff --git a/clientside/tmcc/centos7/emulab-fstab-fixup.service b/clientside/tmcc/linux/emulab-fstab-fixup.service similarity index 100% rename from clientside/tmcc/centos7/emulab-fstab-fixup.service rename to clientside/tmcc/linux/emulab-fstab-fixup.service diff --git a/clientside/tmcc/centos7/emulab-systemd-swaps b/clientside/tmcc/linux/emulab-systemd-swaps similarity index 100% rename from clientside/tmcc/centos7/emulab-systemd-swaps rename to clientside/tmcc/linux/emulab-systemd-swaps diff --git a/clientside/tmcc/linux/fixup-fstab-swaps b/clientside/tmcc/linux/fixup-fstab-swaps index deab26bca..71eb228b2 100755 --- a/clientside/tmcc/linux/fixup-fstab-swaps +++ b/clientside/tmcc/linux/fixup-fstab-swaps @@ -128,7 +128,19 @@ sub findswaps() my $rootfs = `df / | grep /dev/`; if ($rootfs =~ /^(\/dev\/[a-z]+)\d+/) { $rdisk = $1; - } else { + } + elsif ($rootfs =~ /^(\/dev\/[^\s]+)\s/) { + $rootfs = `readlink -f $1`; + if ($rootfs =~ /^(\/dev\/[a-z]+)\d+/) { + $rdisk = $1; + } + else { + print STDERR "*** WARNING: could not identify root disk, ". + "no swap enabled\n"; + return; + } + } + else { print STDERR "*** WARNING: could not identify root disk, ". "no swap enabled\n"; return; diff --git a/clientside/tmcc/ubuntu15/GNUmakefile.in b/clientside/tmcc/ubuntu15/GNUmakefile.in index 7f9b28eb2..37ffe3c85 100644 --- a/clientside/tmcc/ubuntu15/GNUmakefile.in +++ b/clientside/tmcc/ubuntu15/GNUmakefile.in @@ -56,7 +56,7 @@ COMMON = $(SRCDIR)/../common DEFRUNLVLDIR ?= $(SYSETCDIR)/rc3.d install client-install: common-install etc-install \ - script-install bin-install sysetc-fixup + script-install bin-install sysetc-fixup systemd-fixup @echo "Remember to install the PEM files if necessary" simple-install: common-install script-install bin-install @@ -73,6 +73,8 @@ common-install: dir-install bin-install: dir-install (cd ../linux; $(MAKE) DESTDIR=$(DESTDIR) RCDIR=$(RCDIR) bin-install) $(INSTALL) -m 755 $(SRCDIR)/findcnet $(BINDIR)/findcnet + $(INSTALL) -m 755 $(SRCDIR)/../linux/emulab-systemd-swaps $(BINDIR) + @echo "Emulab systemd swap.service" etc-install: dir-install common-sysetc-install $(INSTALL) -m 644 $(SRCDIR)/group $(ETCDIR)/group @@ -106,6 +108,9 @@ systemd-fixup: rm -f /lib/systemd/system/network-online.target.wants/ifup-wait-all-auto.service ln -sf ../ifup-wait-emulab-cnet.service \ /lib/systemd/system/network-online.target.wants/ifup-wait-emulab-cnet.service + $(INSTALL) -m 644 $(SRCDIR)/../linux/emulab-fstab-fixup.service \ + /lib/systemd/system + systemctl enable emulab-fstab-fixup.service script-install: dir-install $(SCRIPTS) (cd ../linux; $(MAKE) DESTDIR=$(DESTDIR) RCDIR=$(RCDIR) script-install) -- GitLab