summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/OS.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property/OS.hs')
-rw-r--r--src/Propellor/Property/OS.hs54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index 144b17f6..30f8c4bb 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -2,18 +2,16 @@ module Propellor.Property.OS (
cleanInstallOnce,
Confirmation(..),
preserveNetworkInterfaces,
+ preserveResolvConf,
preserveRootSshAuthorized,
- grubBoots,
- GrubDev,
rebootForced,
- kernelInstalled,
oldOSRemoved,
) where
import Propellor
import qualified Propellor.Property.Debootstrap as Debootstrap
import qualified Propellor.Property.Ssh as Ssh
-import qualified Propellor.Property.User as User
+import qualified Propellor.Property.File as File
import Propellor.Property.Mount
import Propellor.Property.Chroot.Util (stdPATH)
import Utility.SafeCommand
@@ -47,12 +45,17 @@ import Control.Exception (throw)
-- > & os (System (Debian Unstable) "amd64")
-- > & cleanInstallOnce (Confirmed "foo.example.com")
-- > `onChange` propertyList "fixing up after clean install"
--- > [ preserveNetworkInterfaces
+-- > [ User.shadowConfig True
+-- > , preserveNetworkInterfaces
+-- > , preserveResolvConf
-- > , preserverRootSshAuthorized
--- > -- , kernelInstalled
--- > -- , grubBoots "hd0"
+-- > , Apt.update
+-- > -- , Grub.boots "/dev/sda"
+-- > -- `requires` Grub.installed Grub.PC
-- > -- , oldOsRemoved (Confirmed "foo.example.com")
-- > ]
+-- > & Hostname.sane
+-- > & Apt.installed ["linux-image-amd64"]
-- > & Apt.installed ["ssh"]
-- > & User.hasSomePassword "root"
-- > & User.accountFor "joey"
@@ -67,8 +70,6 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
`requires`
propellorbootstrapped
`requires`
- User.shadowConfig True
- `requires`
flipped
`requires`
osbootstrapped
@@ -96,8 +97,10 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
massRename (renamesout ++ renamesin)
removeDirectoryRecursive newOSDir
- -- Prepare environment for running additional properties.
+ -- Prepare environment for running additional properties,
+ -- overriding old OS's environment.
void $ setEnv "PATH" stdPATH True
+ void $ unsetEnv "LANG"
-- Remount /dev, so that block devices etc are
-- available for other properties to use.
@@ -105,6 +108,14 @@ cleanInstallOnce confirmation = check (not <$> doesFileExist flagfile) $
warningMessage $ "failed mounting /dev using " ++ devfstype ++ "; falling back to MAKEDEV generic"
void $ boolSystem "sh" [Param "-c", Param "cd /dev && /sbin/MAKEDEV generic"]
+ -- Mount /sys too, needed by eg, grub-mkconfig.
+ unlessM (mount "sysfs" "sysfs" "/sys") $
+ warningMessage "failed mounting /sys"
+
+ -- And /dev/pts, used by apt.
+ unlessM (mount "devpts" "devpts" "/dev/pts") $
+ warningMessage "failed mounting /dev/pts"
+
liftIO $ writeFile flagfile ""
return MadeChange
@@ -164,6 +175,16 @@ confirmed desc (Confirmed c) = property desc $ do
preserveNetworkInterfaces :: Property
preserveNetworkInterfaces = undefined
+-- | /etc/resolv.conf is copied the from the old OS
+preserveResolvConf :: Property
+preserveResolvConf = check (fileExist oldloc) $
+ property (newloc ++ " copied from old OS") $ do
+ ls <- liftIO $ lines <$> readFile oldloc
+ ensureProperty $ newloc `File.hasContent` ls
+ where
+ newloc = "/etc/resolv.conf"
+ oldloc = oldOSDir ++ newloc
+
-- | Root's .ssh/authorized_keys has added to it any ssh keys that
-- were authorized in the old OS. Any other contents of the file are
-- retained.
@@ -176,19 +197,6 @@ preserveRootSshAuthorized = check (fileExist oldloc) $
newloc = "/root/.ssh/authorized_keys"
oldloc = oldOSDir ++ newloc
--- | Installs an appropriate kernel from the OS distribution.
-kernelInstalled :: Property
-kernelInstalled = undefined
-
--- | Installs grub onto a device to boot the system.
---
--- You may want to install grub to multiple devices; eg for a system
--- that uses software RAID.
-grubBoots :: GrubDev -> Property
-grubBoots = undefined
-
-type GrubDev = String
-
-- | Forces an immediate reboot, without contacting the init system.
--
-- Can be used after cleanInstallOnce.