Index: openacs-4/etc/install/checkout.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/checkout.sh,v diff -u -N -r1.9 -r1.10 --- openacs-4/etc/install/checkout.sh 3 Nov 2003 16:19:43 -0000 1.9 +++ openacs-4/etc/install/checkout.sh 4 Nov 2003 14:39:04 -0000 1.10 @@ -13,6 +13,9 @@ # # @author Peter Marklund (peter@collaboraid.biz) +set -e +set -x + export CVS_RSH=ssh script_path=$(dirname $(which $0)) @@ -21,11 +24,12 @@ # Sometimes script path will be the dot so I need this workaround script_path=$PWD -source functions.sh +source ./functions.sh # Fetch config parameters serverroot=`get_config_param serverroot` aolserver_user=`get_config_param aolserver_user` +aolserver_group=`get_config_param aolserver_group` echo "$0: Starting checkout for server path $serverroot with config_file $config_file and dotlrn=$dotlrn" @@ -48,7 +52,7 @@ mkdir -p ${serverroot}-tmp cd ${serverroot}-tmp oacs_branch=`get_config_param oacs_branch` -if [ "$oacs_branch" == "HEAD"]; then +if [ "$oacs_branch" == "HEAD" ]; then oacs_branch_switch="" else oacs_branch_switch="-r $oacs_branch" @@ -81,6 +85,6 @@ echo $(date) > ${serverroot}/www/SYSTEM/checkout-date # Set proper privileges -# TODO - get service name and group from config file -chown -R ${aolsever_user}.web ${serverroot} +# Change owner and permissions on checked out files +chown -R ${aolsever_user}.${aolserver_group} ${serverroot} chmod -R go+rwX ${serverroot} Index: openacs-4/etc/install/config-replace.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/config-replace.sh,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/etc/install/config-replace.sh 4 Nov 2003 14:39:04 -0000 1.1 @@ -0,0 +1,79 @@ +#!/bin/sh +# +# There is some degree of duplication of parameters in the etc/install/install.tcl file +# and the etc/config.tcl file. This script will take +# +# +# The next line restarts using tclsh. Do not remove this backslash: \ +exec tclsh "$0" "$@" + +set install_file_path [lindex $argv 0] + +source $install_file_path + +#---------------------------------------------------------------------- +# Replace variables in config.tcl +#---------------------------------------------------------------------- + +# Left side = install.tcl, right side = config.tcl +array set __replace_with { + server server + serverroot serverroot + httpport server_port + hostname server_host + address server_ip + servername system_name + homedir aolserver_home + database database + db_name db_name + db_password oracle_password + db_host pg_host + db_port pg_port + db_user pg_db_user +} + +set __config_file_path "${serverroot}/etc/config.tcl" +set __fd [open $__config_file_path] +set __config_text [read $__fd] +close $__fd + +set __output {} +foreach __line [split $__config_text \n] { + if { [regexp {^(\s*)set\s+([^\s]+)\s+} $__line match __whitespace __varname] } { + if { [info exists __replace_with($__varname)] } { + append __output $__whitespace [list set $__varname [set $__replace_with($__varname)]] \n + continue + } + } + append __output $__line \n +} + +set __new_config_file_path "${__config_file_path}.new" +set __fd [open $__new_config_file_path w] +puts $__fd $__output +close $__fd + +# Rename +file delete "${__config_file_path}.bak" +file rename $__config_file_path "${__config_file_path}.bak" +file rename $__new_config_file_path $__config_file_path + + +#---------------------------------------------------------------------- +# Create daemontools run file +#---------------------------------------------------------------------- + +set __run_file_path "${serverroot}/etc/daemontools/run" +set __new_run_file_path "${serverroot}/etc/daemontools/run.new" + +set __fd [open $__new_run_file_path w] +puts $__fd "#!/bin/sh" +puts $__fd "" +puts $__fd "exec ${aolserver_home}/bin/nsd-${database} -it ${serverroot}/etc/config.tcl -u ${aolserver_user} -g ${aolserver_group}" +close $__fd + +# Rename +file delete "${__run_file_path}.bak" +file rename $__run_file_path "${__run_file_path}.bak" +file rename $__new_run_file_path $__run_file_path + Index: openacs-4/etc/install/functions.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/functions.sh,v diff -u -N -r1.3 -r1.4 --- openacs-4/etc/install/functions.sh 10 Sep 2003 09:57:12 -0000 1.3 +++ openacs-4/etc/install/functions.sh 4 Nov 2003 14:39:04 -0000 1.4 @@ -45,3 +45,8 @@ ;; esac } + +# peter_marklund/lars: ps|grep for pid of process using full path of executable +grep_for_pid(){ + echo `ps auwx | grep $1 | grep -v grep | awk '{print $2}'` +} Index: openacs-4/etc/install/install-and-alert.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/install-and-alert.sh,v diff -u -N -r1.5 -r1.6 --- openacs-4/etc/install/install-and-alert.sh 4 Nov 2003 11:10:29 -0000 1.5 +++ openacs-4/etc/install/install-and-alert.sh 4 Nov 2003 14:39:04 -0000 1.6 @@ -12,7 +12,7 @@ script_path=$(dirname $(which $0)) cd $script_path -source functions.sh +source ./functions.sh # Get a proper environment set up if [ -f ~/.bashrc ]; then Index: openacs-4/etc/install/install.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/install.sh,v diff -u -N -r1.22 -r1.23 --- openacs-4/etc/install/install.sh 4 Nov 2003 11:10:29 -0000 1.22 +++ openacs-4/etc/install/install.sh 4 Nov 2003 14:39:04 -0000 1.23 @@ -13,14 +13,17 @@ # @author Lars Pind (lars@collaboraid.biz) # @author Joel Aufrecht (joel@aufrecht.org) -# DEBUG: If any command fails - exit +# If any command fails - exit set -e +# Uncomment following line for debug mode +#set -x # Set the script directory to the current dir for convenience script_path=$(dirname $(which $0)) cd $script_path -source functions.sh +# If you don't say ./, it'll search for functions.sh in your path +source ./functions.sh # TODO: create user if necessary # we should check for the existence of the specified user @@ -42,7 +45,7 @@ # before we load the config file config_val_next=0 server_next=0 -export config_file="install.tcl" +export config_file="$script_path/install.tcl" server_overridden="no" for arg in "$@" do @@ -195,7 +198,7 @@ echo "$0: Taking down $serverroot at $(date)" if parameter_true $use_daemontools; then - $svc_bindir/svc -kd ${svscanroot} + $svc_bindir/svc -d ${svscanroot} else # non-daemontools stop $stop_server_command @@ -206,17 +209,25 @@ echo "$0: Waiting $shutdown_seconds seconds for server to shut down at $(date)" sleep $shutdown_seconds +# Check that it's been shut down +pid=`grep_for_pid "nsd.*$serverroot"` +if ! [ "$pid" == "" ]; then + echo "The server is still running. You must shut down the server first." + echo "Process IDs of running servers: $pid" + exit +fi + # Recreate the database user echo "$0: Recreating database user at $(date)" if [ $database == "postgres" ]; then # Postgres pg_bindir=`get_config_param pg_bindir` pg_port=`get_config_param pg_port` - pg_db_name=`get_config_param pg_db_name` - su `get_config_param pg_db_user` -c "export LD_LIBRARY_PATH=${pg_bindir}/../lib; ${pg_bindir}/dropdb -p $pg_port $pg_db_name; ${pg_bindir}/createdb -p $pg_port $pg_db_name;"; + db_name=`get_config_param db_name` + su `get_config_param pg_db_user` -c "export LD_LIBRARY_PATH=${pg_bindir}/../lib; ${pg_bindir}/dropdb -p $pg_port $db_name; ${pg_bindir}/createdb -p $pg_port $db_name;"; # createlang was part of this command but is not necessary (and causes an error) for # newer installs - # ${pg_bindir}/createlang -p $pg_port plpgsql $pg_db_name"; + # ${pg_bindir}/createlang -p $pg_port plpgsql $db_name"; else #Oracle # Need to su to login shell for sqlplus to be in path. Should maybe make ORA_HOME @@ -225,7 +236,7 @@ fi # Check out new files -if [ $do_checkout == "yes" ]; then +if parameter_true $do_checkout; then # The pre_checkout script can move away any files or changes # to the source tree that we want to keep (for example an @@ -243,9 +254,19 @@ exit -1 fi rm ${svscanroot} - fi - $svc_bindir/svc -xd $svscan_sourcedir + fi + if [ -r "$svscan_sourcedir" ]; then + $svc_bindir/svc -dx $svscan_sourcedir + fi fi + + pid=`grep_for_pid "nsd.*$serverroot"` + + if ! [ "$pid" == "" ]; then + echo "The server is still running. You must shut down the server first." + echo "Process IDs of running servers: $pid" + exit + fi echo "$0: Checking out OpenACS at $(date)" chmod +x checkout.sh @@ -256,6 +277,7 @@ # We need to update it with settings in install.tcl since certain parameters # (such as serverroot) are duplicated between the two files. ./config-replace.sh $config_file + chmod +x $serverroot/etc/daemontools/run fi # The post_checkout script can copy back any files (AOLServer config files, @@ -365,7 +387,7 @@ if [ $database == "postgres" ]; then # Run vacuum analyze echo "$0: Beginning 'vacuum analyze' at $(date)" - su `get_config_param pg_db_user` -c "export LD_LIBRARY_PATH=${pg_bindir}/../lib; ${pg_bindir}/vacuumdb -p $pg_port -z `get_config_param pg_db_name`" + su `get_config_param pg_db_user` -c "export LD_LIBRARY_PATH=${pg_bindir}/../lib; ${pg_bindir}/vacuumdb -p $pg_port -z `get_config_param db_name`" fi # Report the time at which we were done Index: openacs-4/etc/install/install.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/install.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/etc/install/install.tcl 4 Nov 2003 13:16:49 -0000 1.3 +++ openacs-4/etc/install/install.tcl 4 Nov 2003 14:39:04 -0000 1.4 @@ -6,38 +6,38 @@ # This is the name of your server (website). # It will be used as the name of directories, the name of database users and/or tablespaces, etc. -set server "service0" +set server "test" # Server root directory. This is where all of the files for your server will live. # Some people like this to be at /web/${server}, but we recommend the below standard setting. -set serverroot "/var/lib/aolserver/${server}" +set serverroot "/web/${server}" # The host name (DNS) the server will be listening on -set server_host localhost +set server_host {} # The IP address the server will be listening on -set server_ip 127.0.0.1 +set server_ip {} # The port number the server will be listening on -set server_port 8000 +set server_port 8028 # The URL where your server will be accessible. This is used by the installation scripts to complete the installation. # Don't forget to include the port number above set server_url "http://${server_host}:${server_port}" # OS user and group that AOLserver runs as. We recommend that you create a new user for your server. # If you do not want to do that, change the user name below -set aolserver_user "${server}" +set aolserver_user "nsadmin" set aolserver_group "web" # OpenACS configuration -set admin_email "postmaster@localhost" +set admin_email "admin@collaboraid.net" set admin_username "admin" -set admin_first_names "Your" -set admin_last_name "Name" -set admin_password "openacsrocks" -set system_name "OpenACS" -set publisher_name "Yourname" +set admin_first_names "Admin" +set admin_last_name "Collaboraid" +set admin_password "password" +set system_name "Test Server" +set publisher_name "Collaboraid" # Should we automatically grab the OpenACS code from CVS? # If not, you must have already unpacked a tar-ball in the server root directory specified above @@ -47,7 +47,7 @@ # For example, say "HEAD" to get the latest code, oacs-5-0-0 to get the 5.0.0 release. set oacs_branch "HEAD" -# Choose which database you will use - Oracle or PostgreSQL +# Choose which database you will use - Say 'oracle' or 'postgres' set database "postgres" #---------------------------------------------------------------------- @@ -67,7 +67,7 @@ set pg_port 5432 # The home directory of your PostgreSQL server. Type 'which psql' to find this. -set pg_bindir "/usr/local/pgsql/bin" +set pg_bindir "/usr/local/pgsql-7.3/bin" Index: openacs-4/etc/install/warn-if-installation-errors.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/warn-if-installation-errors.sh,v diff -u -N -r1.1 -r1.2 --- openacs-4/etc/install/warn-if-installation-errors.sh 4 Sep 2003 16:51:26 -0000 1.1 +++ openacs-4/etc/install/warn-if-installation-errors.sh 4 Nov 2003 14:39:04 -0000 1.2 @@ -9,7 +9,7 @@ file_name=$1 -source functions.sh +source ./functions.sh alert_keyword=`get_config_param alert_keyword` Index: openacs-4/etc/install/tcl/twt-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/twt-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/etc/install/tcl/twt-procs.tcl 29 Oct 2003 14:38:09 -0000 1.9 +++ openacs-4/etc/install/tcl/twt-procs.tcl 4 Nov 2003 14:39:05 -0000 1.10 @@ -56,18 +56,20 @@ set error_p 0 while { [catch {::tclwebtest::do_request $page_url} errmsg] } { set error_p 1 - global errorInfo - if { [regexp {host is unreachable} $errmsg] } { - # Socket problem - retry $retry_max times - if { $retry_count < $retry_max } { - ::twt::log "Failed to connect to server with error \"$errmsg\" - retrying" - incr retry_count - exec "sleep" "5" - continue - } else { - ::twt::log "Failed to connect to server with error \"$errmsg\" - giving up" - break + if { $retry_count < $retry_max } { + switch -regexp -- $errmsg { + {unreachable} - {refused} { + ::twt::log "Failed to connect to server with error \"$errmsg\" - retrying" + incr retry_count + exec "sleep" "5" + set error_p 0 + continue + } + default { + ::twt::log "Failed to connect to server with error \"$errmsg\" - giving up" + break + } } } else { break @@ -77,7 +79,8 @@ if { $error_p } { # Either some non-socket error, or a socket problem occuring with more than # $retry_max times. Propagate the error while retaining the stack trace - error "::tclwebtest::do_request threw error $errmsg with errorInfo $errorInfo" + global errorInfo + error $errmsg $errorInfo } ::twt::acs_lang::check_no_keys