addIptableRulesIfMissing :: [String] -> String -> IO ()
addIptableRulesIfMissing iptablesOut iptablesArgs = do
    unless (any (match iptablesArgs) iptablesOut) $ do
        (exitCode, _,err) <- do
                     debug $ "iptables " ++ iptablesArgs
                     readProcessWithExitCode_closeFds "iptables" (words iptablesArgs) []
        case exitCode of
             ExitSuccess -> return ()
             _ -> error $ printf "cannot add rule %s : %s" iptablesArgs err

    where match template rule  = rule =~ template :: Bool
addIptableRulesIfMissing :: [String] -> String -> IO ()
addIptableRulesIfMissing iptablesOut iptablesArgs = do
    unless (any (match iptablesArgs) iptablesOut) $ do
        (exitCode, _,err) <- do
                     debug $ "iptables " ++ iptablesArgs
                     readProcessWithExitCode_closeFds "iptables" (words iptablesArgs) []
        case exitCode of
             ExitSuccess -> return ()
             _ -> error $ printf "cannot add rule %s : %s" iptablesArgs err

    where match template rule  = rule =~ template :: Bool
addIptableRulesIfMissing iptablesOut iptablesArgs = do
    unless (any (match iptablesArgs) iptablesOut) $ do
        (exitCode, _,err) <- do
                     debug $ "iptables " ++ iptablesArgs
                     readProcessWithExitCode_closeFds "iptables" (words iptablesArgs) []
        case exitCode of
             ExitSuccess -> return ()
             _ -> error $ printf "cannot add rule %s : %s" iptablesArgs err

    where match template rule  = rule =~ template :: Bool