agent: adds autoCheckUpdates to v0

This commit is contained in:
Aaron Greenspan
2021-01-19 17:40:16 -07:00
committed by Aiden McClelland
parent 7ed220dc51
commit 18f18e3b95
3 changed files with 9 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ data ServerRes = ServerRes
, serverAlternativeRegistryUrl :: Maybe Text , serverAlternativeRegistryUrl :: Maybe Text
, serverSpecs :: SpecsRes , serverSpecs :: SpecsRes
, serverWelcomeAck :: Bool , serverWelcomeAck :: Bool
, serverAutoCheckUpdates :: Bool
} deriving (Eq, Show) } deriving (Eq, Show)
type JsonEncoding a = Encoding type JsonEncoding a = Encoding
@@ -57,6 +58,7 @@ instance ToJSON ServerRes where
, "alternativeRegistryUrl" .= serverAlternativeRegistryUrl , "alternativeRegistryUrl" .= serverAlternativeRegistryUrl
, "specs" .= serverSpecs , "specs" .= serverSpecs
, "welcomeAck" .= serverWelcomeAck , "welcomeAck" .= serverWelcomeAck
, "autoCheckUpdates" .= serverAutoCheckUpdates
] ]
instance ToTypedContent ServerRes where instance ToTypedContent ServerRes where
toTypedContent = toTypedContent . toJSON toTypedContent = toTypedContent . toJSON

View File

@@ -58,6 +58,7 @@ getServerR = handleS9ErrT $ do
wifi <- WpaSupplicant.runWlan0 $ liftA2 WifiList WpaSupplicant.getCurrentNetwork WpaSupplicant.listNetworks wifi <- WpaSupplicant.runWlan0 $ liftA2 WifiList WpaSupplicant.getCurrentNetwork WpaSupplicant.listNetworks
specs <- getSpecs settings specs <- getSpecs settings
welcomeAck <- fmap isJust . lift . runDB . Persist.get $ WelcomeAckKey agentVersion welcomeAck <- fmap isJust . lift . runDB . Persist.get $ WelcomeAckKey agentVersion
autoCheckUpdates <- runM $ injectFilesystemBaseFromContext settings $ existsSystemPath autoCheckUpdatesPath
let sid = T.drop 7 $ specsNetworkId specs let sid = T.drop 7 $ specsNetworkId specs
@@ -72,6 +73,7 @@ getServerR = handleS9ErrT $ do
, serverAlternativeRegistryUrl = alternativeRegistryUrl , serverAlternativeRegistryUrl = alternativeRegistryUrl
, serverSpecs = specs , serverSpecs = specs
, serverWelcomeAck = welcomeAck , serverWelcomeAck = welcomeAck
, serverAutoCheckUpdates = autoCheckUpdates
} }
where where
parseSshKeys :: Text -> S9ErrT Handler [SshKeyFingerprint] parseSshKeys :: Text -> S9ErrT Handler [SshKeyFingerprint]

View File

@@ -80,6 +80,11 @@ readSystemPath path = do
$ (Just <$> readFile (toS loadPath)) $ (Just <$> readFile (toS loadPath))
`catch` (\(e :: IOException) -> if isDoesNotExistError e then pure Nothing else throwIO e) `catch` (\(e :: IOException) -> if isDoesNotExistError e then pure Nothing else throwIO e)
existsSystemPath :: (HasFilesystemBase sig m, MonadIO m) => SystemPath -> m Bool
existsSystemPath path = do
checkPath <- getAbsoluteLocationFor path
liftIO . doesPathExist $ toS checkPath
-- like the above, but throws IO error if file not found -- like the above, but throws IO error if file not found
readSystemPath' :: (HasFilesystemBase sig m, MonadIO m) => SystemPath -> m Text readSystemPath' :: (HasFilesystemBase sig m, MonadIO m) => SystemPath -> m Text
readSystemPath' path = do readSystemPath' path = do