; reads package description in the right order
; in the end, the server can be started via (server)

(batch 'on)
(define *ASSUMED-SUNET-HOME*
  (in 'scsh '(run (match:substring 
		   (regexp-search (rx (submatch (* any) "sunet")) (cwd))
		   1))))
(define *SUNET-PACKAGE* 
  (in 'scsh `(run (string-append 
		   (or (getenv "SUNETHOME")
		       ,*ASSUMED-SUNET-HOME*)
		   "/packages.scm"))))
(define *SSAX-PACKAGE* 
  (in 'scsh `(run (string-append
		   (or (getenv "SSAXPATH")
		       (string-append ,*ASSUMED-SUNET-HOME* "/SSAX"))
		   "/lib/packages.scm"))))
(define *SURFLET-PACKAGE* 
  (in 'scsh `(run (string-append 
		   (or (getenv "SUNETHOME")
		       ,*ASSUMED-SUNET-HOME*)
		   "/httpd/surflets/packages.scm"))))
(define *SURFLET-SERVER*
  (in 'scsh `(run (string-append 
		   (or (getenv "SUNETHOME")
		       ,*ASSUMED-SUNET-HOME*)
		   "/httpd/surflets/start-surflet-server"))))
(config `(load ,*SUNET-PACKAGE*))
(config `(load ,*SSAX-PACKAGE*))
(config `(load ,*SURFLET-PACKAGE*))
(config `(load ,*SURFLET-SERVER*))
(user)
(open 'surflet-server)
(batch 'off)
(in 'scsh '(run (display "type (server) to start the server\n")))