mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 04:53:40 +00:00
24 lines
676 B
Haskell
24 lines
676 B
Haskell
module Lib.SystemCtl where
|
|
|
|
import Startlude hiding ( words )
|
|
import Protolude.Unsafe ( unsafeHead )
|
|
|
|
import Data.String
|
|
import System.Process
|
|
import Text.Casing
|
|
|
|
data ServiceAction =
|
|
StartService
|
|
| StopService
|
|
| RestartService
|
|
deriving (Eq, Show)
|
|
|
|
toAction :: ServiceAction -> String
|
|
toAction = fmap toLower . unsafeHead . words . wordify . show
|
|
|
|
systemCtl :: ServiceAction -> Text -> IO ExitCode
|
|
systemCtl action service = rawSystem "systemctl" [toAction action, toS service]
|
|
|
|
systemCtlDaemonReload :: IO ExitCode
|
|
systemCtlDaemonReload = rawSystem "systemctl" ["daemon-reload"]
|