Author: <geox@localhost>
Description: Adaptation of config.tcl and daemontools/run to debian install.
--- a/etc/config.tcl
+++ b/etc/config.tcl
@@ -9,8 +9,10 @@
 ###################################################################### 
 
 #---------------------------------------------------------------------
-# change to 80 and 443 for production use
-set httpport                  8000
+# Defined in /etc/aolserver4/conf.d/openacs.sh
+set httpport                  [exec grep "^AOL_PORT" /etc/aolserver4/conf.d/dotlrn.sh | sed s/AOL_PORT=//] 
+set address                   [exec grep "^AOL_ADDRESS" /etc/aolserver4/conf.d/dotlrn.sh | sed s/AOL_ADDRESS=//]
+
 set httpsport                 8443 
 # If setting port below 1024 with AOLServer 4, read comments in file:
 #  /var/lib/aolserver/service0/packages/etc/daemontools/run
@@ -18,16 +20,16 @@
 # The hostname and address should be set to actual values.
 # setting the address to 0.0.0.0 means aolserver listens on all interfaces
 set hostname                  localhost
-set address                   127.0.0.1
 
 # Note: If port is privileged (usually < 1024), OpenACS must be
 # started by root, and, in AOLserver 4, the run script have a 
 # '-b address' flag which matches the address according to settings (above)
 
-set server                    "service0" 
-set servername                "New OpenACS Installation - Development"
+set server                    "dotlrn" 
+set servername                "dotLRN"
 
-set serverroot                "/var/www/${server}"
+set serverroot                "/usr/share/${server}"
+set pidfile                    /var/run/aolserver4/${server}.pid
 
 #---------------------------------------------------------------------
 # which database do you want? postgres or oracle
@@ -38,9 +40,11 @@
 if { $database eq "oracle" } {
     set db_password           "mysitepassword"
 } else {
-    set db_host               localhost
-    set db_port               ""
-    set db_user               $server
+# Defined in /etc/dotlrn/config.local
+    set db_host               [exec grep "^db_host" /etc/dotlrn/config.local | sed s/^db_host=//]
+    set db_password           [exec grep "^db_password" /etc/dotlrn/config.local | sed s/^db_password=//]
+    set db_port               [exec grep "^db_port" /etc/dotlrn/config.local | sed s/^db_port=//]
+    set db_user               [exec grep "^db_user" /etc/dotlrn/config.local | sed s/^db_user=//]
 }
 
 #---------------------------------------------------------------------
@@ -85,6 +89,7 @@
     ns_param   maxbackup          5
     ns_param   debug              $debug
 #    ns_param   mailhost           localhost 
+    ns_param   pidfile           ${pidfile}
 
     # setting to Unicode by default
     # see http://dqd.com/~mayoff/encoding-doc.html
@@ -100,7 +105,7 @@
 ns_section ns/threads 
     ns_param   mutexmeter         true      ;# measure lock contention 
     # The per-thread stack size must be a multiple of 8k for AOLServer to run under MacOS X
-    ns_param   stacksize          [expr {128 * 8192}]
+    ns_param   stacksize          [expr {512 * 8192}]
 
 # 
 # MIME types. 
@@ -569,7 +574,7 @@
         ns_param   driver             postgres 
         ns_param   datasource         ${db_host}:${db_port}:${db_name}
         ns_param   user               $db_user
-        ns_param   password           ""
+        ns_param   password           $db_password
     } 
 
 ns_section ns/db/pool/pool2
@@ -588,7 +593,7 @@
         ns_param   driver             postgres 
         ns_param   datasource         ${db_host}:${db_port}:${db_name}
         ns_param   user               $db_user
-        ns_param   password           ""
+        ns_param   password           $db_password 
     } 
 
 ns_section ns/db/pool/pool3
@@ -607,7 +612,7 @@
         ns_param   driver             postgres 
         ns_param   datasource         ${db_host}:${db_port}:${db_name}
         ns_param   user               $db_user
-        ns_param   password           ""
+        ns_param   password           $db_password
     } 
 
 ns_section ns/server/${server}/db
@@ -621,12 +626,14 @@
 ns_section ns/server/${server}/modules 
     ns_param   nssock             ${bindir}/nssock.so 
     ns_param   nslog              ${bindir}/nslog.so 
-    ns_param   nssha1             ${bindir}/nssha1.so 
+    ns_param   nssha1             ${bindir}/nssha1.so
+ 
     # since aolserver version 4.5.1 built-in ns_cache, so we dont
     # need to load the nscache module. 
     if {[ns_info version] < 4.5 || [ns_info patchlevel] eq "4.5.0"} {
           ns_param   nscache            ${bindir}/nscache.so 
     }
+
     # openacs versions earlier than 5.x requires nsxml
 #    ns_param nsxml              ${bindir}/nsxml.so
 
@@ -662,7 +669,7 @@
     }
 
     # nsthread library which should become standard in 5.3
-    ns_param libthread  [lindex [glob ${homedir}/lib/thread*/libthread*[info sharedlibextension]] 0]
+    ns_param libthread  [lindex [glob /usr/lib/tcltk/thread*/libthread*-aolserver[info sharedlibextension]] 0]
 
     if {[ns_info version] >= 4.5} {
         ns_limits set default -maxupload [ns_config ns/server/${server}/module/nssock maxinput]
@@ -673,3 +680,4 @@
 if {[ns_info version] >= 4.5} {
     ns_limits set default -maxupload [ns_config ns/server/${server}/module/nssock maxinput]
 }
+
--- a/etc/daemontools/run
+++ b/etc/daemontools/run
@@ -9,7 +9,12 @@
 # see http://openacs.org/forums/message-view?message_id=176100
 sleep 4
 
-exec /usr/lib/aolserver4/bin/nsd -it /var/www/service0/etc/config.tcl -u service0 -g web
+. /etc/aolserver4/conf.d/dotlrn.sh
+
+DAEMON="/usr/lib/aolserver4/bin/nsd"
+CONF="/etc/dotlrn/config.tcl"
+
+exec $DAEMON -it $CONF -u $AOL_USER -g $AOL_GROUP -b $AOL_ADDRESS:$AOL_PORT
 
 # For AOLserver 4 using privileged ports (usually < 1024), add the flag
 # -b youraddress:yourport to the nsd command
