class backendHandler dir_root (frontend_lst: frontendHandler list) =
         let mk_rel_path = delete_prefix dir_root in object(this)
 
-  val file_regexp = ref (Str.regexp "[a-zA-Z][a-zA-Z0-9_-'.']*")
+  val file_regexp = ref (Str.regexp "[a-zA-Z][a-zA-Z0-9_'.']*")
 
   method new_dir fqp func =
     let s = Unix.stat fqp in
 
         flush Pervasives.stdout
 
 let add_watch dir events handler =
-  printf "Adding watch for %s\n" dir;
+  printf "Adding watch for %s\n" dir;flush Pervasives.stdout;
   let wd = Inotify.add_watch fd dir events in
       Hashtbl.add wdmap wd (dir,handler)
 
 
                   printf "Here: %d %s\n" !count curline;flush Pervasives.stdout;
                   fprintf fifo_outchan "%s\n" curline;flush fifo_outchan
               with 
-                | End_of_file|Sys_blocked_io|Unix_error(EPIPE,_,_) ->
+                | End_of_file|Sys_blocked_io|Unix_error(EPIPE,_,_)|Unix_error(EBADF,_,_) ->
                     begin
                       cont:=false
                     end
 
 let cont = ref true
 
 let _ =
-  printf "Vsys v0.3\n";flush stdout;
+  printf "Vsys v0.4\n";flush stdout;
   Arg.parse cmdspeclist (fun x->()) "Usage: vsys <list of mount points>";  
   if (!Globals.backend == "" || !input_file_list == []) then
       printf "Try vsys --help\n"
 
 #!/bin/bash
+# vsys initscript
+# Author: sapanb
+
+backend="/vsys"
 
 case "$1" in
-    start|restart|reload|update)
-       ;;
-    stop|status)
-       exit 0
-       ;;
+    start)
+        echo -n "Starting vsys:"
+        if [ ! -d $backend ]; then mkdir $backend; fi
+        find /vservers -maxdepth 1 -type d | perl -e 'while (<>) {if (/(\/vservers\/(.*_.*))/) {$dir=$1;if (not (-d "$dir/vsys")) {mkdir "$dir/vsys";}}}'
+        frontends=`find /vservers -maxdepth 1 -type d | perl -e 'while (<>) {if (/(\/vservers\/(.*_.*))/) {$dir=$1;$slice=$2;printf "-frontend $dir $slice "}}'`
+        vsys_command="/usr/bin/vsys -backend $backend $frontends"
+        echo $vsys_command
+        $vsys_command
+        ;;
+    stop)
+        echo -n "Stopping $prog:"
+        killall vsys
+        exit 0
+        ;;
     *)
-       echo $"Usage: $0 {start|stop|restart|status}"
-       exit 1
-       ;;
+        echo $"Usage: $0 {start|stop}"
+        exit 1
+        ;;
 esac
 
 # Source function library.