summaryrefslogtreecommitdiff
path: root/custom/tinc/generate_hostfile.hs
diff options
context:
space:
mode:
Diffstat (limited to 'custom/tinc/generate_hostfile.hs')
-rwxr-xr-xcustom/tinc/generate_hostfile.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/custom/tinc/generate_hostfile.hs b/custom/tinc/generate_hostfile.hs
new file mode 100755
index 00000000..a8420780
--- /dev/null
+++ b/custom/tinc/generate_hostfile.hs
@@ -0,0 +1,19 @@
1#!/usr/bin/env runhaskell
2
3import System.Directory.Tree
4import Data.List
5
6main :: IO ()
7main = readDirectory "." >>= putStrLn . genHostFile
8
9genHostFile :: AnchoredDirTree String -> String
10genHostFile (_ :/ (Dir _ contents)) = "{\n" ++ entries ++ "\n}\n"
11 where
12 entries = concat [ genEntry name content | (File name content) <- contents, name `notElem` hidden ]
13 genEntry fileName fileContent = unlines . indent $ [ "\"" ++ fileName ++ "\" = ''" ] ++ indent (lines fileContent) ++ [ "'';" ]
14 hidden = [ "to_nix.sh"
15 , "signup.sh"
16 ]
17
18indent :: [String] -> [String]
19indent = map (" " ++)