mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +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
|
||||
|
||||
2
appmgr/Cargo.lock
generated
2
appmgr/Cargo.lock
generated
@@ -43,7 +43,7 @@ checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
|
||||
|
||||
[[package]]
|
||||
name = "appmgr"
|
||||
version = "0.2.15"
|
||||
version = "0.2.16"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"avahi-sys",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
authors = ["Aiden McClelland <me@drbonez.dev>"]
|
||||
edition = "2018"
|
||||
name = "appmgr"
|
||||
version = "0.2.15"
|
||||
version = "0.2.16"
|
||||
|
||||
[lib]
|
||||
name = "appmgrlib"
|
||||
|
||||
@@ -32,8 +32,9 @@ mod v0_2_12;
|
||||
mod v0_2_13;
|
||||
mod v0_2_14;
|
||||
mod v0_2_15;
|
||||
mod v0_2_16;
|
||||
|
||||
pub use v0_2_15::Version as Current;
|
||||
pub use v0_2_16::Version as Current;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[serde(untagged)]
|
||||
@@ -61,6 +62,7 @@ enum Version {
|
||||
V0_2_13(Wrapper<v0_2_13::Version>),
|
||||
V0_2_14(Wrapper<v0_2_14::Version>),
|
||||
V0_2_15(Wrapper<v0_2_15::Version>),
|
||||
V0_2_16(Wrapper<v0_2_16::Version>),
|
||||
Other(emver::Version),
|
||||
}
|
||||
|
||||
@@ -178,6 +180,7 @@ pub async fn init() -> Result<(), failure::Error> {
|
||||
Version::V0_2_13(v) => v.0.migrate_to(&Current::new()).await?,
|
||||
Version::V0_2_14(v) => v.0.migrate_to(&Current::new()).await?,
|
||||
Version::V0_2_15(v) => v.0.migrate_to(&Current::new()).await?,
|
||||
Version::V0_2_16(v) => v.0.migrate_to(&Current::new()).await?,
|
||||
Version::Other(_) => (),
|
||||
// TODO find some way to automate this?
|
||||
}
|
||||
@@ -274,6 +277,7 @@ pub async fn self_update(requirement: emver::VersionRange) -> Result<(), Error>
|
||||
Version::V0_2_13(v) => Current::new().migrate_to(&v.0).await?,
|
||||
Version::V0_2_14(v) => Current::new().migrate_to(&v.0).await?,
|
||||
Version::V0_2_15(v) => Current::new().migrate_to(&v.0).await?,
|
||||
Version::V0_2_16(v) => Current::new().migrate_to(&v.0).await?,
|
||||
Version::Other(_) => (),
|
||||
// TODO find some way to automate this?
|
||||
};
|
||||
|
||||
21
appmgr/src/version/v0_2_16.rs
Normal file
21
appmgr/src/version/v0_2_16.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use super::*;
|
||||
|
||||
const V0_2_16: emver::Version = emver::Version::new(0, 2, 16, 0);
|
||||
|
||||
pub struct Version;
|
||||
#[async_trait]
|
||||
impl VersionT for Version {
|
||||
type Previous = v0_2_15::Version;
|
||||
fn new() -> Self {
|
||||
Version
|
||||
}
|
||||
fn semver(&self) -> &'static emver::Version {
|
||||
&V0_2_16
|
||||
}
|
||||
async fn up(&self) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
async fn down(&self) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
manifest-version: 0
|
||||
app-id: start9-ambassador
|
||||
app-version: 0.2.15
|
||||
app-version: 0.2.16
|
||||
uri-rewrites:
|
||||
- =/api -> http://{{start9-ambassador}}:5959/authenticate
|
||||
- /api/ -> http://{{start9-ambassador}}:5959/
|
||||
|
||||
2
ui/package-lock.json
generated
2
ui/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "embassy-ui",
|
||||
"version": "0.2.14",
|
||||
"version": "0.2.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "embassy-ui",
|
||||
"version": "0.2.15",
|
||||
"version": "0.2.16",
|
||||
"description": "GUI for EmbassyOS",
|
||||
"author": "Start9 Labs",
|
||||
"homepage": "https://github.com/Start9Labs/embassy-ui",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title >
|
||||
<ion-label style="font-size: 20px;" class="ion-text-wrap">Welcome to 0.2.15!</ion-label>
|
||||
<ion-label style="font-size: 20px;" class="ion-text-wrap">Welcome to 0.2.16!</ion-label>
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
@@ -499,8 +499,8 @@ const mockApiNotifications: ReqRes.GetNotificationsRes = [
|
||||
const mockApiServer: () => ReqRes.GetServerRes = () => ({
|
||||
serverId: 'start9-mockxyzab',
|
||||
name: 'Embassy:12345678',
|
||||
versionInstalled: '0.2.15',
|
||||
versionLatest: '0.2.15',
|
||||
versionInstalled: '0.2.16',
|
||||
versionLatest: '0.2.16',
|
||||
status: ServerStatus.RUNNING,
|
||||
alternativeRegistryUrl: 'beta-registry.start9labs.com',
|
||||
welcomeAck: true,
|
||||
|
||||
Reference in New Issue
Block a user