Files
start-os/agent/src/Lib/SystemCtl.hs
Aiden McClelland 95d3845906 0.2.5 initial commit
Makefile incomplete
2020-11-23 13:44:28 -07:00

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"]