feat(mac): add mac to Install and Env
This commit is contained in:
parent
5e88bfa6cc
commit
cd44b525d1
@ -4,17 +4,18 @@ module System.Serverman.Actions.Env (OS(..), getOS) where
|
|||||||
import System.IO.Error
|
import System.IO.Error
|
||||||
import Data.Either
|
import Data.Either
|
||||||
|
|
||||||
data OS = Debian | Arch | Unknown deriving (Show, Eq)
|
data OS = Debian | Arch | Mac | Unknown deriving (Show, Eq)
|
||||||
|
|
||||||
getOS = do
|
getOS = do
|
||||||
arch_release <- tryIOError $ readProcessWithExitCode "/usr/bin/cat" ["/etc/os-release"] ""
|
arch_release <- tryIOError $ readProcessWithExitCode "/usr/bin/cat" ["/etc/os-release"] ""
|
||||||
deb_release <- tryIOError $ readProcessWithExitCode "/usr/bin/cat" ["/etc/lsb-release"] ""
|
deb_release <- tryIOError $ readProcessWithExitCode "/usr/bin/cat" ["/etc/lsb-release"] ""
|
||||||
-- mac_release <- tryIOError $ readProcessWithExitCode "/usr/bin/sw_vers" ["-productVersion"] ""
|
mac_release <- tryIOError $ readProcessWithExitCode "/usr/bin/sw_vers" ["-productName"] ""
|
||||||
|
|
||||||
let (_, release, _) = head $ rights [arch_release, deb_release, mac_release]
|
let (_, release, _) = head $ rights [arch_release, deb_release, mac_release]
|
||||||
distro
|
distro
|
||||||
| or $ map (`isInfixOf` release) ["ubuntu", "debian", "raspbian"] = Debian
|
| or $ map (`isInfixOf` release) ["ubuntu", "debian", "raspbian"] = Debian
|
||||||
| "arch" `isInfixOf` release = Arch
|
| "arch" `isInfixOf` release = Arch
|
||||||
|
| "Mac" `isInfixOf` release = Mac
|
||||||
| otherwise = Unknown
|
| otherwise = Unknown
|
||||||
|
|
||||||
return distro
|
return distro
|
||||||
|
@ -25,6 +25,7 @@ module System.Serverman.Actions.Install (installService) where
|
|||||||
let command = case os of
|
let command = case os of
|
||||||
Arch -> "pacman -S "
|
Arch -> "pacman -S "
|
||||||
Debian -> "apt-get install "
|
Debian -> "apt-get install "
|
||||||
|
Mac -> "brew install "
|
||||||
_ -> "echo 'Unknown operating system'"
|
_ -> "echo 'Unknown operating system'"
|
||||||
|
|
||||||
process <- async $ do
|
process <- async $ do
|
||||||
|
Loading…
Reference in New Issue
Block a user