From cd44b525d1e97832ca76753b4bd9cfacf3d0ea98 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sun, 19 Feb 2017 14:12:18 +0330 Subject: [PATCH] feat(mac): add mac to Install and Env --- src/System/Serverman/Actions/Env.hs | 5 +++-- src/System/Serverman/Actions/Install.hs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/System/Serverman/Actions/Env.hs b/src/System/Serverman/Actions/Env.hs index cb912ff..67ed620 100644 --- a/src/System/Serverman/Actions/Env.hs +++ b/src/System/Serverman/Actions/Env.hs @@ -4,17 +4,18 @@ module System.Serverman.Actions.Env (OS(..), getOS) where import System.IO.Error import Data.Either - data OS = Debian | Arch | Unknown deriving (Show, Eq) + data OS = Debian | Arch | Mac | Unknown deriving (Show, Eq) getOS = do arch_release <- tryIOError $ readProcessWithExitCode "/usr/bin/cat" ["/etc/os-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] distro | or $ map (`isInfixOf` release) ["ubuntu", "debian", "raspbian"] = Debian | "arch" `isInfixOf` release = Arch + | "Mac" `isInfixOf` release = Mac | otherwise = Unknown return distro diff --git a/src/System/Serverman/Actions/Install.hs b/src/System/Serverman/Actions/Install.hs index 23b3eb9..c8133d3 100644 --- a/src/System/Serverman/Actions/Install.hs +++ b/src/System/Serverman/Actions/Install.hs @@ -25,6 +25,7 @@ module System.Serverman.Actions.Install (installService) where let command = case os of Arch -> "pacman -S " Debian -> "apt-get install " + Mac -> "brew install " _ -> "echo 'Unknown operating system'" process <- async $ do