agent 0.2.14

This commit is contained in:
Keagan McClelland
2021-07-13 12:16:27 -06:00
parent 57e9a97d44
commit 39f85c7199
3 changed files with 31 additions and 16 deletions

View File

@@ -0,0 +1 @@
SELECT TRUE;

View File

@@ -1,5 +1,5 @@
name: ambassador-agent name: ambassador-agent
version: 0.2.13 version: 0.2.14
default-extensions: default-extensions:
- NoImplicitPrelude - NoImplicitPrelude
@@ -182,4 +182,4 @@ executables:
condition: flag(library-only) condition: flag(library-only)
- condition: false - condition: false
other-modules: Paths_ambassador_agent other-modules: Paths_ambassador_agent
extra-source-files: ./migrations/* extra-source-files: ./migrations/*

View File

@@ -24,6 +24,7 @@ import qualified Data.Conduit.Combinators as Conduit
import Data.Conduit.Shell hiding ( arch import Data.Conduit.Shell hiding ( arch
, hostname , hostname
, patch , patch
, split
, stream , stream
) )
import qualified Data.Conduit.Tar as Conduit import qualified Data.Conduit.Tar as Conduit
@@ -50,6 +51,8 @@ import Constants
import Control.Effect.Error hiding ( run ) import Control.Effect.Error hiding ( run )
import Control.Effect.Labelled ( runLabelled ) import Control.Effect.Labelled ( runLabelled )
import Daemon.ZeroConf ( getStart9AgentHostname ) import Daemon.ZeroConf ( getStart9AgentHostname )
import Data.ByteString.Char8 ( split )
import Data.Conduit.List ( consume )
import qualified Data.Text as T import qualified Data.Text as T
import Foundation import Foundation
import Handler.Network import Handler.Network
@@ -98,12 +101,12 @@ parseKernelVersion = do
pure $ KernelVersion (Version (major', minor', patch', 0)) arch pure $ KernelVersion (Version (major', minor', patch', 0)) arch
synchronizer :: Synchronizer synchronizer :: Synchronizer
synchronizer = sync_0_2_13 synchronizer = sync_0_2_14
{-# INLINE synchronizer #-} {-# INLINE synchronizer #-}
sync_0_2_13 :: Synchronizer sync_0_2_14 :: Synchronizer
sync_0_2_13 = Synchronizer sync_0_2_14 = Synchronizer
"0.2.13" "0.2.14"
[ syncCreateAgentTmp [ syncCreateAgentTmp
, syncCreateSshDir , syncCreateSshDir
, syncRemoveAvahiSystemdDependency , syncRemoveAvahiSystemdDependency
@@ -585,19 +588,30 @@ syncRestarterService = SyncOp "Install Restarter Service" check migrate True
liftIO $ callCommand "systemctl enable restarter.timer" liftIO $ callCommand "systemctl enable restarter.timer"
syncUpgradeTor :: SyncOp syncUpgradeTor :: SyncOp
syncUpgradeTor = SyncOp "Install Tor 0.3.5.14-1" check migrate False syncUpgradeTor = SyncOp "Install Latest Tor" check migrate False
where where
check = check = run $ do
liftIO shell "apt-get update"
$ ( run (shell [i|dpkg -l|] $| shell [i|grep tor|] $| shell [i|grep 0.3.5.14-1|] $| conduit await) mTorVersion <- (shell "dpkg -s tor" $| shell "grep '^Version'" $| shell "cut -d ' ' -f2" $| conduit await)
$> False echo ("CURRENT TOR VERSION:" :: Text) (show mTorVersion :: Text)
) let torVersion = case mTorVersion of
`catch` \(e :: ProcessException) -> case e of Nothing -> panic "invalid output from dpkg, can't read tor version"
ProcessException _ (ExitFailure 1) -> pure True Just x -> x
_ -> throwIO e availVersions <-
(shell "apt-cache madison tor" $| shell "cut -d '|' -f2" $| shell "xargs" $| conduit consume)
echo ("AVAILABLE TOR VERSIONS:" :: Text) (show availVersions :: Text)
pure . not $ isJust (find ((== EQ) . compareTorVersions torVersion) availVersions)
migrate = liftIO . run $ do migrate = liftIO . run $ do
shell "apt-get update" shell "apt-get update"
shell "apt-get install -y tor=0.3.5.14-1" shell "apt-get install -y tor"
compareTorVersions :: ByteString -> ByteString -> Ordering
compareTorVersions a b =
let a' = (traverse (readMaybe @Int . decodeUtf8) . (split '.' <=< split '-') $ a)
b' = (traverse (readMaybe @Int . decodeUtf8) . (split '.' <=< split '-') $ b)
in case liftA2 compare a' b' of
Nothing -> panic "invalid tor version string"
Just x -> x
syncDropCertificateUniqueness :: SyncOp syncDropCertificateUniqueness :: SyncOp
syncDropCertificateUniqueness = SyncOp "Eliminate OpenSSL unique_subject=yes" check migrate False syncDropCertificateUniqueness = SyncOp "Eliminate OpenSSL unique_subject=yes" check migrate False