Mahdi Dibaiee d86daa863d fix(install): don't show output of install to user
feat(mysql): add mysql as a service, only installation works right now,
there's no configuration
feat(execute): internal function to execute commands
2017-02-19 16:17:37 +03:30

23 lines
798 B
Haskell

module System.Serverman.Actions.Env (OS(..), getOS) where
import System.Serverman.Utils
import System.Process
import Data.List
import System.IO.Error
import Data.Either
data OS = Debian | Arch | Mac | Unknown deriving (Show, Eq)
getOS = do
arch_release <- execute "/usr/bin/cat" ["/etc/os-release"] "" False
deb_release <- execute "/usr/bin/cat" ["/etc/lsb-release"] "" False
mac_release <- execute "/usr/bin/sw_vers" ["-productName"] "" False
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