diff options
| author | Félix Sipma <felix.sipma@no-log.org> | 2016-04-03 20:13:55 +0200 |
|---|---|---|
| committer | Félix Sipma <felix.sipma@no-log.org> | 2016-04-22 16:01:14 +0200 |
| commit | 2676a68ce19cf6c05a55790c4b8e2b377ae63dd8 (patch) | |
| tree | a6a2101ed0e096a95ab961d7563f886ed92262e7 /src | |
| parent | ee96e62cfc07dfa4016d0f9bcb970ad17e8e9a41 (diff) | |
Attic: add init, restored, and propellor 3.0 support
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Attic.hs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/Propellor/Property/Attic.hs b/src/Propellor/Property/Attic.hs index b5410579..961b681a 100644 --- a/src/Propellor/Property/Attic.hs +++ b/src/Propellor/Property/Attic.hs @@ -7,23 +7,39 @@ import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Cron as Cron import Data.List (intercalate) -installed :: Property NoInfo +installed :: Property DebianLike installed = Apt.installed ["attic"] repoExists :: FilePath -> IO Bool repoExists repo = boolSystem "attic" [Param "list", File repo] -backup :: [FilePath] -> FilePath -> Cron.Times -> [String] -> Property NoInfo -backup dirs backupdir crontimes extraargs = propertyList (backupdir ++ " attic backup") - [ installed - , check (not <$> repoExists backupdir) $ cmdProperty "attic" initargs - , Cron.niceJob ("attic_backup" ++ backupdir) crontimes (User "root") "/" backupcmd - ] +init :: FilePath -> Property DebianLike +init backupdir = check (not <$> repoExists backupdir) (cmdProperty "attic" initargs) + `requires` installed where initargs = [ "init" , backupdir ] + +restored :: [FilePath] -> FilePath -> Property DebianLike +restored dirs backupdir = cmdProperty "attic" restoreargs + `assume` MadeChange + `describe` ("attic restore from " ++ backupdir) + `requires` installed + where + restoreargs = + [ "extract" + , backupdir + ] + ++ dirs + +backup :: [FilePath] -> FilePath -> Cron.Times -> [String] -> Property DebianLike +backup dirs backupdir crontimes extraargs = propertyList (backupdir ++ " attic backup") $ props + & check (not <$> repoExists backupdir) (restored dirs backupdir) + & Cron.niceJob ("attic_backup" ++ backupdir) crontimes (User "root") "/" backupcmd + `requires` installed + where backupcmd = intercalate ";" [ createCommand , pruneCommand |
