agent: .autoCheckUpdates

This commit is contained in:
Aiden McClelland
2021-01-16 17:01:18 -07:00
committed by Aiden McClelland
parent d5d0ea3ade
commit fcb807eb42
3 changed files with 19 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
/v0 ServerR GET PATCH
/v0/name NameR PATCH
/v0/autoCheckUpdates AutoCheckUpdatesR PATCH
/v0/welcome/#Version WelcomeR POST
/v0/specs SpecsR GET

View File

@@ -109,9 +109,24 @@ newtype NullablePatchReq = NullablePatchReq { mpatchValue :: Maybe Text } derivi
instance FromJSON NullablePatchReq where
parseJSON = withObject "Nullable Patch Request" $ \o -> NullablePatchReq <$> o .:? "value"
newtype BoolPatchReq = BoolPatchReq { bpatchValue :: Bool } deriving (Eq, Show)
instance FromJSON BoolPatchReq where
parseJSON = withObject "Patch Request" $ \o -> BoolPatchReq <$> o .: "value"
patchNameR :: Handler ()
patchNameR = patchFile serverNamePath
patchAutoCheckUpdatesR :: Handler ()
patchAutoCheckUpdatesR = do
settings <- getsYesod appSettings
BoolPatchReq val <- requireCheckJsonBody
runM $
injectFilesystemBaseFromContext settings $
if val
then writeSystemPath autoCheckUpdatesPath ""
else deleteSystemPath autoCheckUpdatesPath
patchFile :: SystemPath -> Handler ()
patchFile path = do
settings <- getsYesod appSettings

View File

@@ -188,6 +188,9 @@ agentTorHiddenServicePrivateKeyPath = agentTorHiddenServiceDirectory <> "/hs_ed2
serverNamePath :: SystemPath
serverNamePath = "/root/agent/name.txt"
autoCheckUpdatesPath :: SystemPath
autoCheckUpdatesPath = "/root/agent/.autoCheckUpdates"
altRegistryUrlPath :: SystemPath
altRegistryUrlPath = "/root/agent/alt_registry_url.txt"