From 3940f2cbde7a7ca220be932abb58f1c1a99c9b26 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 01:17:19 -0400 Subject: use fqdn --- HostName.hs | 10 ++++++---- HostProp.hs | 2 +- Utility/Network.hs | 21 --------------------- 3 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 Utility/Network.hs diff --git a/HostName.hs b/HostName.hs index dfe9efb4..2cc50ea9 100644 --- a/HostName.hs +++ b/HostName.hs @@ -1,10 +1,9 @@ module HostName where -import Data.Maybe import Control.Applicative import System.Environment -import qualified Utility.Network as Network +import Utility.Process type HostName = String @@ -12,5 +11,8 @@ getHostName :: IO HostName getHostName = go =<< getArgs where go (h:_) = return h - go [] = fromMaybe nohostname <$> Network.getHostname - nohostname = error "Cannot determine hostname! Pass it on the command line." + go [] = do + s <- takeWhile (/= '\n') <$> readProcess "hostname" ["-f"] + if null s + then error "Cannot determine hostname! Pass it on the command line." + else return s diff --git a/HostProp.hs b/HostProp.hs index 7a98c5a5..2b393cdd 100644 --- a/HostProp.hs +++ b/HostProp.hs @@ -15,7 +15,7 @@ main = ensureProperties . getProperties =<< getHostName - or one specified on the command line is converted into a list of - Properties for that system. -} getProperties :: HostName -> [Property] -getProperties "clam" = +getProperties "clam.kitenet.net" = -- Clean up the system as installed by cloudatcost.com [ User.nuked "user" , Apt.removed ["exim4"] `onChange` Apt.autoRemove diff --git a/Utility/Network.hs b/Utility/Network.hs deleted file mode 100644 index 62523c9e..00000000 --- a/Utility/Network.hs +++ /dev/null @@ -1,21 +0,0 @@ -{- network functions - - - - Copyright 2012 Joey Hess - - - - Licensed under the GNU GPL version 3 or higher. - -} - -module Utility.Network where - -import Utility.Process -import Utility.Exception - -import Control.Applicative - -{- Haskell lacks uname(2) bindings, except in the - - Bindings.Uname addon. Rather than depend on that, - - use uname -n when available. -} -getHostname :: IO (Maybe String) -getHostname = catchMaybeIO uname_node - where - uname_node = takeWhile (/= '\n') <$> readProcess "uname" ["-n"] -- cgit v1.2.3