Added vsys.conf processing that Faiyaz requested.
[vsys.git] / main.ml
1 (** main () *)
2 open Globals
3 open Printf
4 open Inotify
5 open Backend
6 open Frontend
7 open Fifowatcher
8 open Conffile
9
10 let input_file_list = ref []
11 let cur_dir = ref ""
12 let cur_slice = ref ""
13
14 let cmdspeclist =
15   [
16     ("-conffile",Arg.Set_string(Globals.conffile), "Config file");
17     ("-backend",Arg.Set_string(Globals.backend), "Backend directory");
18     ("-frontend",Arg.Tuple[Arg.String(fun s->cur_dir:=s);Arg.String(fun s->cur_slice:=s;input_file_list:=(!cur_dir,!cur_slice)::!input_file_list)], "frontendN,slicenameN");
19     ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment")
20   ]
21
22 let cont = ref true
23
24 let _ =
25   printf "Vsys v%s\n" Globals.vsys_version;flush stdout;
26   Arg.parse cmdspeclist (fun x->()) "Usage: vsys <list of mount points>";  
27   if (!Globals.backend == "") then
28       printf "Try vsys --help\n"
29   else
30     begin
31     Dirwatcher.initialize ();
32     Fifowatcher.initialize ();
33     if (!Globals.conffile != "") then
34       let frontends = Conffile.read_frontends !Globals.conffile in
35         input_file_list:=List.concat [!input_file_list;frontends];
36
37     let felst = List.map (fun lst->let (x,y)=lst in printf "Slice %s (%s)\n" x y;flush Pervasives.stdout;new frontendHandler lst) !input_file_list in
38         let _ = new backendHandler !Globals.backend felst in
39          Fdwatcher.start_watch ()
40     end