mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
fixes apt-update issue 100 where Suites changed, kills update sound t… (#422)
* fixes apt-update issue 100 where Suites changed, kills update sound thread, sets updating to false if synchronization fails * cleans up code * appmgr changes * ui changes * updates required appmgr in agent * actually upgrade current version in appmgr
This commit is contained in:
committed by
GitHub
parent
18a069e6fd
commit
183f91859a
@@ -5,7 +5,7 @@ cabal-version: 1.12
|
||||
-- see: https://github.com/sol/hpack
|
||||
|
||||
name: ambassador-agent
|
||||
version: 0.2.14
|
||||
version: 0.2.16
|
||||
build-type: Simple
|
||||
extra-source-files:
|
||||
./migrations/0.1.0::0.1.0
|
||||
@@ -20,6 +20,8 @@ extra-source-files:
|
||||
./migrations/0.2.11::0.2.12
|
||||
./migrations/0.2.12::0.2.13
|
||||
./migrations/0.2.13::0.2.14
|
||||
./migrations/0.2.14::0.2.15
|
||||
./migrations/0.2.15::0.2.16
|
||||
./migrations/0.2.1::0.2.2
|
||||
./migrations/0.2.2::0.2.3
|
||||
./migrations/0.2.3::0.2.4
|
||||
|
||||
@@ -33,5 +33,5 @@ database:
|
||||
database: "start9_agent.sqlite3"
|
||||
poolsize: "_env:YESOD_SQLITE_POOLSIZE:10"
|
||||
|
||||
app-mgr-version-spec: "=0.2.15"
|
||||
app-mgr-version-spec: "=0.2.16"
|
||||
#analytics: UA-YOURCODE
|
||||
|
||||
1
agent/migrations/0.2.15::0.2.16
Normal file
1
agent/migrations/0.2.15::0.2.16
Normal file
@@ -0,0 +1 @@
|
||||
SELECT TRUE;
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ambassador-agent
|
||||
version: 0.2.15
|
||||
version: 0.2.16
|
||||
|
||||
default-extensions:
|
||||
- NoImplicitPrelude
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
module Lib.SelfUpdate where
|
||||
|
||||
import Startlude hiding ( runReader )
|
||||
import Startlude hiding ( handle
|
||||
, runReader
|
||||
)
|
||||
|
||||
import Control.Carrier.Error.Either
|
||||
import Control.Lens
|
||||
@@ -29,6 +31,7 @@ import Lib.SystemPaths
|
||||
import Lib.Types.Emver
|
||||
import Lib.WebServer
|
||||
import Settings
|
||||
import UnliftIO.Exception ( handle )
|
||||
|
||||
youngAgentPort :: Word16
|
||||
youngAgentPort = 5960
|
||||
@@ -191,18 +194,21 @@ runSyncOps syncOps = do
|
||||
pure res
|
||||
|
||||
synchronizeSystemState :: AgentCtx -> Version -> IO ()
|
||||
synchronizeSystemState ctx _version = handle @SomeException cleanup $ flip runReaderT ctx $ do
|
||||
synchronizeSystemState ctx _version = handle @_ @SomeException cleanup $ flip runReaderT ctx $ do
|
||||
(restartsAndRuns, mTid) <- case synchronizer of
|
||||
Synchronizer { synchronizerOperations } -> flip runStateT Nothing $ for synchronizerOperations $ \syncOp -> do
|
||||
shouldRun <- lift $ syncOpShouldRun syncOp
|
||||
putStrLn @Text [i|Sync Op "#{syncOpName syncOp}" should run: #{shouldRun}|]
|
||||
when shouldRun $ do
|
||||
whenM (isNothing <$> get) $ do
|
||||
tid <- liftIO . forkIO . forever $ playSong 300 updateInProgress *> threadDelay 20_000_000
|
||||
put (Just tid)
|
||||
tid <- get >>= \case
|
||||
Nothing -> do
|
||||
tid <- liftIO . forkIO . forever $ playSong 300 updateInProgress *> threadDelay 20_000_000
|
||||
put (Just tid)
|
||||
pure tid
|
||||
Just tid -> pure tid
|
||||
putStrLn @Text [i|Running Sync Op: #{syncOpName syncOp}|]
|
||||
setUpdate True
|
||||
lift $ syncOpRun syncOp
|
||||
lift $ handle @_ @SomeException (\e -> lift $ killThread tid *> cleanup e) $ syncOpRun syncOp
|
||||
pure $ (syncOpRequiresReboot syncOp, shouldRun)
|
||||
case mTid of
|
||||
Nothing -> pure ()
|
||||
@@ -222,5 +228,6 @@ synchronizeSystemState ctx _version = handle @SomeException cleanup $ flip runRe
|
||||
void $ try @SomeException Sound.stop
|
||||
void $ try @SomeException Sound.unexport
|
||||
let e' = InternalE $ show e
|
||||
setUpdate False
|
||||
flip runReaderT ctx $ cantFail $ failUpdate e'
|
||||
|
||||
|
||||
@@ -102,12 +102,12 @@ parseKernelVersion = do
|
||||
pure $ KernelVersion (Version (major', minor', patch', 0)) arch
|
||||
|
||||
synchronizer :: Synchronizer
|
||||
synchronizer = sync_0_2_15
|
||||
synchronizer = sync_0_2_16
|
||||
{-# INLINE synchronizer #-}
|
||||
|
||||
sync_0_2_15 :: Synchronizer
|
||||
sync_0_2_15 = Synchronizer
|
||||
"0.2.15"
|
||||
sync_0_2_16 :: Synchronizer
|
||||
sync_0_2_16 = Synchronizer
|
||||
"0.2.16"
|
||||
[ syncCreateAgentTmp
|
||||
, syncCreateSshDir
|
||||
, syncRemoveAvahiSystemdDependency
|
||||
@@ -180,7 +180,7 @@ syncFullUpgrade = SyncOp "Full Upgrade" check migrate True
|
||||
Just (Done _ (KernelVersion (Version av) _)) -> if av < (4, 19, 118, 0) then pure True else pure False
|
||||
_ -> pure False
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get full-upgrade -y"
|
||||
|
||||
sync32BitKernel :: SyncOp
|
||||
@@ -205,7 +205,7 @@ syncInstallNginx = SyncOp "Install Nginx" check migrate False
|
||||
where
|
||||
check = liftIO . run $ fmap isNothing (shell [i|which nginx || true|] $| conduit await)
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get install nginx -y"
|
||||
|
||||
syncInstallEject :: SyncOp
|
||||
@@ -213,7 +213,7 @@ syncInstallEject = SyncOp "Install Eject" check migrate False
|
||||
where
|
||||
check = liftIO . run $ fmap isNothing (shell [i|which eject || true|] $| conduit await)
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get install eject -y"
|
||||
|
||||
syncInstallDuplicity :: SyncOp
|
||||
@@ -221,7 +221,7 @@ syncInstallDuplicity = SyncOp "Install duplicity" check migrate False
|
||||
where
|
||||
check = liftIO . run $ fmap isNothing (shell [i|which duplicity || true|] $| conduit await)
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get install -y duplicity"
|
||||
|
||||
syncInstallExfatFuse :: SyncOp
|
||||
@@ -234,7 +234,7 @@ syncInstallExfatFuse = SyncOp "Install exfat-fuse" check migrate False
|
||||
ProcessException _ (ExitFailure 1) -> pure True
|
||||
_ -> throwIO e
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get install -y exfat-fuse"
|
||||
|
||||
syncInstallExfatUtils :: SyncOp
|
||||
@@ -247,7 +247,7 @@ syncInstallExfatUtils = SyncOp "Install exfat-utils" check migrate False
|
||||
ProcessException _ (ExitFailure 1) -> pure True
|
||||
_ -> throwIO e
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get install -y exfat-utils"
|
||||
|
||||
syncInstallLibAvahi :: SyncOp
|
||||
@@ -260,7 +260,7 @@ syncInstallLibAvahi = SyncOp "Install libavahi-client" check migrate False
|
||||
ProcessException _ (ExitFailure 1) -> pure True
|
||||
_ -> throwIO e
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
shell "apt-get install -y libavahi-client3"
|
||||
|
||||
syncWriteConf :: Text -> ByteString -> SystemPath -> SyncOp
|
||||
@@ -598,7 +598,7 @@ syncUpgradeTor = SyncOp "Install Latest Tor" check migrate False
|
||||
Just x -> x
|
||||
pure $ compareTorVersions torVersion "0.3.5.15-1" == LT
|
||||
migrate = liftIO . run $ do
|
||||
shell "apt-get update"
|
||||
shell "apt-get update --allow-releaseinfo-change"
|
||||
availVersions <-
|
||||
(shell "apt-cache madison tor" $| shell "cut -d '|' -f2" $| shell "xargs" $| conduit consume)
|
||||
latest <- case lastMay $ sortBy compareTorVersions availVersions of
|
||||
|
||||
Reference in New Issue
Block a user