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,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