Commands

Login to the server, then
$ cd ~/v10
$ ./HEEDSv10.sh UNIV YEAR TERM ACTION

where
  UNIV - CSU-Andrews CSU-Aparri CSU-Carig CSU-Gonzaga CSU-Lal-lo CSU-Lasam CSU-Piat CSU-Sanchez-Mira
  YEAR - chronological year when the School Year started (for example, 2012 for SY 2012-13)
  TERM - term of School Year (1=First, 2=Second, 3=Summer) for which students are being advised
  ACTION - one of the following:

Webserver ACTIONs
  Plan - run webserver to edit data for SY YEAR-(YEAR+1), advise/enlist students for YEAR TERM
  Amend - run webserver to edit enlistment and grades for SY YEAR-(YEAR+1), advising is disabled

CSV generation ACTIONs (non-webserver)
  Passwords - display passwords for ADMIN roles, generate CSV file of teacher and student passwords
  Masterlist - generate CSV file of student info
  Schedules - generate CSV file of class and block schedules
  Enlistment - generate CSV file of enlistment data
  Evaluations - generate CSV file of teacher evaluation summary
  CHED - generate CSV file of CHED forms

Utility ACTIONs (non-webserver)
  Test - check web configuration, existence of required directories
  Restore - restore data from backup file (UNIV-directory)/dat/(YEAR)/(UNIV)-BACKUP.XML
  Checklists - generate per-student checklists
  Payments - generate per-student record of payments from SIAS exports
  Assessments - generate per-student record of assessments from SIAS exports

HEEDSv10.sh

#!/bin/bash
#
# HEEDS run script, by Ricolindo.Carino@academicforecasts.com
#

# version (must match the version in Makefile)
VERSION=v10

# directory of executables (see Makefile)
BINPATH=/home/HEEDS/src/$VERSION

# the IP address that FastCGI will talk to (see nginx.conf)
IP=127.0.0.1

# (University + Action) port number must be the same as in nginx.conf
declare -a  University_Code=( CSU-Andrews CSU-Aparri CSU-Carig CSU-Gonzaga CSU-Lal-lo CSU-Lasam CSU-Piat CSU-Sanchez-Mira )
declare -a  University_Port=( 56000       58020      58030     58040       58050      58060     58070    58080            )
declare -a    SERVER_Action=( Plan Amend )
declare -a      SERVER_Port=( 100  200 )
declare -a     BATCH_Action=( Test Import Checklists Restore Special Passwords Payments Assessments Convert Masterlist Schedules Enlistment Evaluations CHED )

# There must be at least 4 arguments
if [ -z "$4" ]; then
    echo "USAGE: $0 UNIV YEAR TERM ACTION"
    echo "  where"
    echo "UNIV - ${University_Code[*]}"
    echo "YEAR - chronological year when the School Year started (for example, 2012 for SY 2012-13)"
    echo "TERM - term of School Year (1=First, 2=Second, 3=Summer) for which students are being advised"
    echo "ACTION - one of the following:"
    echo
    echo "Webserver ACTIONs"
    echo "  Plan - run webserver to edit data for SY YEAR-(YEAR+1), advise/enlist students for YEAR TERM"
    echo "  Amend - run webserver to edit enlistment and grades for SY YEAR-(YEAR+1), advising is disabled"
    echo
    echo "CSV generation ACTIONs (non-webserver)"
    echo "  Passwords - display passwords for ADMIN roles, generate CSV file of teacher and student passwords"
    echo "  Masterlist - generate CSV file of student info"
    echo "  Schedules - generate CSV file of class and block schedules"
    echo "  Enlistment - generate CSV file of enlistment data"
    echo "  Evaluations - generate CSV file of teacher evaluation summary"
    echo "  CHED - generate CSV file of CHED forms"
    echo
    echo "Utility ACTIONs (non-webserver)"
    echo "  Test - check web configuration, existence of required directories"
    echo "  Restore - restore data from backup file (UNIV-directory)/dat/(YEAR)/(UNIV)-BACKUP.XML"
    echo "  Checklists - generate per-student checklists"
    echo "  Payments - generate per-student record of payments from SIAS exports"
    echo "  Assessments - generate per-student record of assessments from SIAS exports"
    echo "  Import - initial conversion of SIAS exports into HEEDS native format"
    echo "  Convert - convert current version of HEEDS data into backup file for next version of HEEDS"
    exit 
fi

# Search for matching university
for univ in ${!University_Code[*]}
do
    if [ $1 = ${University_Code[$univ]} ]; then
        #printf "%4d: %s, %d\n" $univ ${University_Code[$univ]} ${University_Port[$univ]}

        # Search for matching BATCH_Action 
        for action in ${!BATCH_Action[*]}
        do
            if [ $4 = ${BATCH_Action[$action]} ]; then
		EXE=$BINPATH/HEEDS_STATIC-$VERSION
		if [ ! -x $EXE ]; then
		    echo Executable not found: $EXE
		    exit
		fi
		echo $EXE $*
		$EXE $*
		exit
	    fi
	done

        # Search for matching SERVER_Action 
        for action in ${!SERVER_Action[*]}
        do
            if [ $4 = ${SERVER_Action[$action]} ]; then
		EXE=$BINPATH/HEEDS_SERVER-$VERSION
		if [ ! -x $EXE ]; then
		    echo Executable not found: $EXE
		    exit
		fi
		echo spawn-fcgi -a $IP -p $((${University_Port[$univ]}+${SERVER_Port[$action]})) -f "$EXE $*"
		spawn-fcgi -a $IP -p $((${University_Port[$univ]}+${SERVER_Port[$action]})) -f "$EXE $*"
		exit
	    fi
	done

	# Wrong action
	echo "ACTION '$4' not recognized"
	exit

    fi

done
echo "UNIV '$1' not recognized"

Sample CAMPUS configuration file (/home/csuandrews/v9/CSU-Andrews.XML)

<CONFIGURATION>
    <comment>
        HEEDS setup for CAMPUS
          HEEDS_DIRECTORY - absolute path to parent directory of CAMPUS (Ex. /home/heeds, /data1, C:\HEEDS)
          SERVER_PROTOCOL - http:// or https://, depending on how the nginx server was set up
          SERVER_NAME - (Ex. some.domain.edu localhost, localhost:8080, 192.168.1.100, 192.168.1.100:8080)
          DOCUMENT_ROOT - 'root' for CAMPUS in the nginx configuration file (Ex. /home/heeds/CAMPUS/web, C:/HEEDS/web)
    </comment>
    <HEEDS_DIRECTORY>/data2/CSU-Andrews</HEEDS_DIRECTORY>
    <SERVER_PROTOCOL>http://</SERVER_PROTOCOL>
    <SERVER_NAME>heeds.csu.edu.ph</SERVER_NAME>
    <DOCUMENT_ROOT>/data1/www</DOCUMENT_ROOT>
</CONFIGURATION>

nginx configuration file (/etc/nginx/conf.d/default.conf)

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location  /CSU-Andrews-plan {
        fastcgi_pass   127.0.0.1:56100;
        include        fastcgi_params;
    }

    location  /CSU-Andrews-amend {
        fastcgi_pass   127.0.0.1:56200;
        include        fastcgi_params;
    }

    location  /CSU-Aparri-plan {
        fastcgi_pass   127.0.0.1:58120;
        include        fastcgi_params;
    }

    location  /CSU-Aparri-amend {
        fastcgi_pass   127.0.0.1:58220;
        include        fastcgi_params;
    }

    location  /CSU-Carig-plan {
        fastcgi_pass   127.0.0.1:58130;
        include        fastcgi_params;
    }

    location  /CSU-Carig-amend {
        fastcgi_pass   127.0.0.1:58230;
        include        fastcgi_params;
    }

    location  /CSU-Gonzaga-plan {
        fastcgi_pass   127.0.0.1:58140;
        include        fastcgi_params;
    }

    location  /CSU-Gonzaga-amend {
        fastcgi_pass   127.0.0.1:58240;
        include        fastcgi_params;
    }

    location  /CSU-Lal-lo-plan {
        fastcgi_pass   127.0.0.1:58150;
        include        fastcgi_params;
    }

    location  /CSU-Lal-lo-amend {
        fastcgi_pass   127.0.0.1:58250;
        include        fastcgi_params;
    }

    location  /CSU-Lasam-plan {
        fastcgi_pass   127.0.0.1:58160;
        include        fastcgi_params;
    }

    location  /CSU-Lasam-amend {
        fastcgi_pass   127.0.0.1:58260;
        include        fastcgi_params;
    }

    location  /CSU-Piat-plan {
        fastcgi_pass   127.0.0.1:58170;
        include        fastcgi_params;
    }

    location  /CSU-Piat-amend {
        fastcgi_pass   127.0.0.1:58270;
        include        fastcgi_params;
    }

    location  /CSU-Sanchez-Mira-plan {
        fastcgi_pass   127.0.0.1:58180;
        include        fastcgi_params;
    }

    location  /CSU-Sanchez-Mira-amend {
        fastcgi_pass   127.0.0.1:58280;
        include        fastcgi_params;
    }


    location / {
        #root   /usr/share/nginx/html;
        root   /data1/www;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        #root   /usr/share/nginx/html;
        root   /data1/www;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}