Adding some library functions that'll facilitate the creation of vsys scripts.
[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
9 let input_file_list = ref []
10 let cur_dir = ref ""
11 let cur_slice = ref ""
12
13 let cmdspeclist =
14   [
15     ("-backend",Arg.Set_string(Globals.backend), "Backend directory");
16     ("-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");
17     ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment")
18   ]
19
20 let cont = ref true
21
22 let _ =
23   printf "Vsys v%s\n" Globals.vsys_version;flush stdout;
24   Arg.parse cmdspeclist (fun x->()) "Usage: vsys <list of mount points>";  
25   if (!Globals.backend == "" || !input_file_list == []) then
26       printf "Try vsys --help\n"
27   else
28     begin
29     Dirwatcher.initialize ();
30     Fifowatcher.initialize ();
31     let felst = List.map (fun lst->new frontendHandler lst) !input_file_list in
32         let _ = new backendHandler !Globals.backend felst in
33          Fdwatcher.start_watch ()
34     end