From 8c2a9de94b179c01fbb40324a5c06101f0713e9c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Jul 2014 02:58:34 -0400 Subject: [PATCH] propellor spin --- config-joey.hs | 24 +++++----------------- src/Propellor/Property/Grub.hs | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 src/Propellor/Property/Grub.hs diff --git a/config-joey.hs b/config-joey.hs index 1ef9a96..cce5005 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -21,6 +21,7 @@ import qualified Propellor.Property.Git as Git import qualified Propellor.Property.Apache as Apache import qualified Propellor.Property.Postfix as Postfix import qualified Propellor.Property.Service as Service +import qualified Propellor.Property.Grub as Grub import qualified Propellor.Property.HostingProvider.DigitalOcean as DigitalOcean import qualified Propellor.Property.HostingProvider.CloudAtCost as CloudAtCost import qualified Propellor.Property.SiteSpecific.GitHome as GitHome @@ -76,9 +77,11 @@ hosts = -- (o) ` & ipv4 "66.228.36.95" & ipv6 "2600:3c03::f03c:91ff:fe73:b0d2" + & Apt.installed ["linux-image-amd64"] + & Grub.chainPVGrub "hd0,0" "xen/xvda1" + & Grub.chainPVGrub "hd0" "xen/xvda" & Hostname.sane & Apt.unattendedUpgrades - & Apt.installed ["linux-image-amd64", "pv-grub-menu"] & Apt.installed ["systemd"] -- Important stuff that needs not too much memory or CPU. @@ -148,6 +151,7 @@ hosts = -- (o) ` in standardSystem "elephant.kitenet.net" Unstable "amd64" & ipv4 "193.234.225.114" + & Grub.chainPVGrub "hd0,0" "xen/xvda1" & Hostname.sane & Postfix.satellite & Apt.unattendedUpgrades @@ -156,24 +160,6 @@ hosts = -- (o) ` & Ssh.hostKey SshEcdsa ctx & Ssh.keyImported SshRsa "joey" ctx - -- PV-grub chaining - -- http://notes.pault.ag/linode-pv-grub-chainning/ - -- (Adapted to use xvda1/hd0,0 instead of xvda/hd0) - & "/boot/grub/menu.lst" `File.hasContent` - [ "default 1" - , "timeout 30" - , "" - , "title grub-xen shim" - , "root (hd0,0)" - , "kernel /boot/xen-shim" - , "boot" - ] - & "/boot/load.cf" `File.hasContent` - [ "configfile (xen/xvda1)/boot/grub/grub.cfg" ] - & Apt.installed ["grub-xen"] - & flagFile (scriptProperty ["update-grub; grub-mkimage --prefix '(xen/xvda1)/boot/grub' -c /boot/load.cf -O x86_64-xen /usr/lib/grub/x86_64-xen/*.mod > /boot/xen-shim"]) "/boot/xen-shim" - `describe` "/boot-xen-shim" - & alias "eubackup.kitenet.net" & Apt.installed ["obnam", "sshfs", "rsync"] & JoeySites.githubBackup diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs new file mode 100644 index 0000000..96b1e5b --- /dev/null +++ b/src/Propellor/Property/Grub.hs @@ -0,0 +1,37 @@ +module Propellor.Property.Grub where + +import Propellor +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt +import Utility.Applicative + +-- | Eg, hd0,0 or xen/xvda1 +type GrubDevice = String + +-- | Use PV-grub chaining to boot +-- +-- Useful when the VPS's pv-grub is too old to boot a modern kernel image. +-- +-- http://notes.pault.ag/linode-pv-grub-chainning/ +-- +-- The rootdev should be in the form "hd0", while the bootdev is in the form +-- "xen/xvda". +chainPVGrub :: GrubDevice -> GrubDevice -> Property +chainPVGrub rootdev bootdev = combineProperties desc + [ "/boot/grub/menu.lst" `File.hasContent` + [ "default 1" + , "timeout 30" + , "" + , "title grub-xen shim" + , "root (" ++ rootdev ++ ")" + , "kernel /boot/xen-shim" + , "boot" + ] + , "/boot/load.cf" `File.hasContent` + [ "configfile (" ++ bootdev ++ ")/boot/grub/grub.cfg" ] + , Apt.installed ["grub-xen"] + , flagFile (scriptProperty ["update-grub; grub-mkimage --prefix '(" ++ bootdev ++ ")/boot/grub' -c /boot/load.cf -O x86_64-xen /usr/lib/grub/x86_64-xen/*.mod > /boot/xen-shim"]) "/boot/xen-shim" + `describe` "/boot-xen-shim" + ] + where + desc = "chain PV-grub"