mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
adds notification for successful OS update, as well as failure
This commit is contained in:
committed by
Aiden McClelland
parent
db13407294
commit
82df17d854
@@ -43,6 +43,8 @@ data AgentNotification =
|
|||||||
| RestartFailed S9Error
|
| RestartFailed S9Error
|
||||||
| DockerFuckening
|
| DockerFuckening
|
||||||
| CertRenewFailed ExitCode String String
|
| CertRenewFailed ExitCode String String
|
||||||
|
| OsUpdateSucceeded
|
||||||
|
| OsUpdateFailed Text
|
||||||
|
|
||||||
-- CODES
|
-- CODES
|
||||||
-- RULES:
|
-- RULES:
|
||||||
@@ -73,6 +75,7 @@ toCode :: AgentNotification -> Text
|
|||||||
toCode InstallSuccess = "100"
|
toCode InstallSuccess = "100"
|
||||||
toCode BackupSucceeded = "101"
|
toCode BackupSucceeded = "101"
|
||||||
toCode RestoreSucceeded = "102"
|
toCode RestoreSucceeded = "102"
|
||||||
|
toCode OsUpdateSucceeded = "103"
|
||||||
toCode InstallFailedGetApp = "300"
|
toCode InstallFailedGetApp = "300"
|
||||||
toCode (InstallFailedAppMgrExitCode _) = "301"
|
toCode (InstallFailedAppMgrExitCode _) = "301"
|
||||||
toCode DockerFuckening = "302"
|
toCode DockerFuckening = "302"
|
||||||
@@ -86,6 +89,7 @@ toTitle :: AgentNotification -> Text
|
|||||||
toTitle InstallSuccess = "Install succeeded"
|
toTitle InstallSuccess = "Install succeeded"
|
||||||
toTitle BackupSucceeded = "Backup succeeded"
|
toTitle BackupSucceeded = "Backup succeeded"
|
||||||
toTitle RestoreSucceeded = "Restore succeeded"
|
toTitle RestoreSucceeded = "Restore succeeded"
|
||||||
|
toTitle OsUpdateSucceeded = "EmbassyOS Update Succeeded"
|
||||||
toTitle InstallFailedGetApp = "Install failed"
|
toTitle InstallFailedGetApp = "Install failed"
|
||||||
toTitle (InstallFailedAppMgrExitCode _) = "Install failed"
|
toTitle (InstallFailedAppMgrExitCode _) = "Install failed"
|
||||||
toTitle (InstallFailedS9Error _) = "Install failed"
|
toTitle (InstallFailedS9Error _) = "Install failed"
|
||||||
@@ -118,3 +122,4 @@ Stdout:
|
|||||||
Stderr:
|
Stderr:
|
||||||
#{e}
|
#{e}
|
||||||
|]
|
|]
|
||||||
|
toMessage _ version OsUpdateSucceeded = [i|The update to EmbassyOS #{version} succeeded.|]
|
||||||
|
|||||||
@@ -20,14 +20,17 @@ import System.Posix.Files
|
|||||||
import System.Process
|
import System.Process
|
||||||
|
|
||||||
import Constants
|
import Constants
|
||||||
|
import Database.Persist.Sqlite ( runSqlPool )
|
||||||
import Foundation
|
import Foundation
|
||||||
import Handler.Types.V0.Base
|
import Handler.Types.V0.Base
|
||||||
import Lib.Algebra.State.RegistryUrl
|
import Lib.Algebra.State.RegistryUrl
|
||||||
import Lib.Error
|
import Lib.Error
|
||||||
import Lib.External.Registry
|
import Lib.External.Registry
|
||||||
|
import qualified Lib.Notifications as Notifications
|
||||||
import Lib.Sound as Sound
|
import Lib.Sound as Sound
|
||||||
import Lib.Synchronizers
|
import Lib.Synchronizers
|
||||||
import Lib.SystemPaths
|
import Lib.SystemPaths
|
||||||
|
import Lib.Types.Core
|
||||||
import Lib.Types.Emver
|
import Lib.Types.Emver
|
||||||
import Lib.WebServer
|
import Lib.WebServer
|
||||||
import Settings
|
import Settings
|
||||||
@@ -214,7 +217,10 @@ synchronizeSystemState ctx _version = handle @_ @SomeException cleanup $ flip ru
|
|||||||
Nothing -> pure ()
|
Nothing -> pure ()
|
||||||
Just tid -> liftIO $ killThread tid
|
Just tid -> liftIO $ killThread tid
|
||||||
setUpdate False
|
setUpdate False
|
||||||
when (any snd restartsAndRuns) $ liftIO $ playSong 400 marioPowerUp
|
when (any snd restartsAndRuns) $ liftIO $ do
|
||||||
|
_ <- flip runSqlPool (appConnPool ctx)
|
||||||
|
$ Notifications.emit (AppId "embassy-os") agentVersion Notifications.OsUpdateSucceeded
|
||||||
|
playSong 400 marioPowerUp
|
||||||
when (any (uncurry (&&)) restartsAndRuns) $ liftIO do
|
when (any (uncurry (&&)) restartsAndRuns) $ liftIO do
|
||||||
callCommand "/bin/sync"
|
callCommand "/bin/sync"
|
||||||
callCommand "/sbin/reboot"
|
callCommand "/sbin/reboot"
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import Data.ByteString.Char8 ( split )
|
|||||||
import qualified Data.ByteString.Char8 as C8
|
import qualified Data.ByteString.Char8 as C8
|
||||||
import Data.Conduit.List ( consume )
|
import Data.Conduit.List ( consume )
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import Database.Persist.Sqlite ( runSqlPool )
|
||||||
import Foundation
|
import Foundation
|
||||||
import Handler.Network
|
import Handler.Network
|
||||||
import qualified Lib.Algebra.Domain.AppMgr as AppMgr2
|
import qualified Lib.Algebra.Domain.AppMgr as AppMgr2
|
||||||
@@ -62,6 +63,7 @@ import Lib.ClientManifest
|
|||||||
import Lib.Error
|
import Lib.Error
|
||||||
import qualified Lib.External.AppMgr as AppMgr
|
import qualified Lib.External.AppMgr as AppMgr
|
||||||
import Lib.External.Registry
|
import Lib.External.Registry
|
||||||
|
import qualified Lib.Notifications as Notifications
|
||||||
import Lib.Sound
|
import Lib.Sound
|
||||||
import Lib.Ssl
|
import Lib.Ssl
|
||||||
import Lib.SystemCtl
|
import Lib.SystemCtl
|
||||||
@@ -651,8 +653,13 @@ syncRemoveDefaultNginxCfg = SyncOp "Remove Default Nginx Configuration" check mi
|
|||||||
|
|
||||||
failUpdate :: S9Error -> ExceptT Void (ReaderT AgentCtx IO) ()
|
failUpdate :: S9Error -> ExceptT Void (ReaderT AgentCtx IO) ()
|
||||||
failUpdate e = do
|
failUpdate e = do
|
||||||
ref <- asks appIsUpdateFailed
|
ref <- asks appIsUpdateFailed
|
||||||
putStrLn $ "UPDATE FAILED: " <> errorMessage (toError e)
|
pool <- asks appConnPool
|
||||||
|
let msg = errorMessage (toError e)
|
||||||
|
putStrLn $ "UPDATE FAILED: " <> msg
|
||||||
|
_ <- liftIO . flip runSqlPool pool $ Notifications.emit (AppId "embassy-os")
|
||||||
|
agentVersion
|
||||||
|
(Notifications.OsUpdateFailed msg)
|
||||||
liftIO $ playSong 216 beethoven
|
liftIO $ playSong 216 beethoven
|
||||||
liftIO $ writeIORef ref (Just e)
|
liftIO $ writeIORef ref (Just e)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user