2013-10-01 21:20:51 +00:00
|
|
|
|
{- git-annex command
|
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
|
- Copyright 2013 Joey Hess <id@joeyh.name>
|
2013-10-01 21:20:51 +00:00
|
|
|
|
-
|
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
module Command.GCryptSetup where
|
|
|
|
|
|
|
|
|
|
import Command
|
|
|
|
|
import Annex.UUID
|
|
|
|
|
import qualified Remote.GCrypt
|
|
|
|
|
import qualified Git
|
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
|
cmd :: Command
|
|
|
|
|
cmd = dontCheck repoExists $ noCommit $
|
2015-07-08 19:08:02 +00:00
|
|
|
|
command "gcryptsetup" SectionPlumbing
|
|
|
|
|
"sets up gcrypt repository"
|
|
|
|
|
paramValue (withParams seek)
|
2013-10-01 21:20:51 +00:00
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
|
seek :: CmdParams -> CommandSeek
|
2018-10-01 18:12:06 +00:00
|
|
|
|
seek = withStrings (commandAction . start)
|
2013-10-01 21:20:51 +00:00
|
|
|
|
|
|
|
|
|
start :: String -> CommandStart
|
|
|
|
|
start gcryptid = next $ next $ do
|
|
|
|
|
u <- getUUID
|
2013-11-03 00:15:40 +00:00
|
|
|
|
when (u /= NoUUID) $
|
2016-11-16 01:29:54 +00:00
|
|
|
|
giveup "gcryptsetup refusing to run; this repository already has a git-annex uuid!"
|
2013-11-03 00:15:40 +00:00
|
|
|
|
|
|
|
|
|
g <- gitRepo
|
2013-10-01 21:20:51 +00:00
|
|
|
|
gu <- Remote.GCrypt.getGCryptUUID True g
|
2013-11-03 00:15:40 +00:00
|
|
|
|
let newgu = genUUIDInNameSpace gCryptNameSpace gcryptid
|
2014-10-09 19:35:19 +00:00
|
|
|
|
if isNothing gu || gu == Just newgu
|
2013-10-01 21:20:51 +00:00
|
|
|
|
then if Git.repoIsLocalBare g
|
|
|
|
|
then do
|
|
|
|
|
void $ Remote.GCrypt.setupRepo gcryptid g
|
|
|
|
|
return True
|
2016-11-16 01:29:54 +00:00
|
|
|
|
else giveup "cannot use gcrypt in a non-bare repository"
|
|
|
|
|
else giveup "gcryptsetup uuid mismatch"
|