--- /dev/null
+function config_glite_lb_check(){
+ requires MYSQL_PASSWORD
+}
+
+function config_glite_lb_setenv(){
+
+ yaimgridenv_set GLITE_LOCATION ${INSTALL_ROOT:-opt}/glite
+ yaimgridenv_set GLITE_LOCATION_VAR /var/glite
+ yaimgridenv_set GLITE_USER ${GLITE_USER:-glite}
+ yaimgridenv_set GLITE_WMS_QUERY_TIMEOUT 300
+ yaimgridenv_set GLITE_HOST_CERT ${GLITE_USER_HOME:-/home/glite}/.certs/hostcert.pem
+ yaimgridenv_set GLITE_HOST_KEY ${GLITE_USER_HOME:-/home/glite}/.certs/hostkey.pem
+ yaimgridenv_set X509_CERT_DIR /etc/grid-security/certificates
+ yaimgridenv_set X509_VOMS_DIR /etc/grid-security/vomsdir
+
+ yaimgridpath_append LD_LIBRARY_PATH ${INSTALL_ROOT:-opt}/glite/lib
+ yaimgridpath_append LD_LIBRARY_PATH ${INSTALL_ROOT:-opt}/globus/lib
+ yaimgridpath_append LD_LIBRARY_PATH ${INSTALL_ROOT:-opt}/c-ares/lib
+}
+
+function config_glite_lb() {
+
+ #############################################
+ # Logging and Bookkeeping configuration #
+ #############################################
+
+ HOSTNAME=`hostname -f`
+
+ chmod og+rx /var/lib/mysql/
+
+ # add option --max_allowed_packet=17M
+ if [ ! -f /etc/my.cnf ]; then
+ echo "[mysqld]" >> /etc/my.cnf
+ echo "max_allowed_packet=17M" >> /etc/my.cnf
+ else
+ grep "^[mysqld]" /etc/my.cnf > /dev/null
+ if [ ! $? = 0 ]; then
+ echo "[mysqld]" >> /etc/my.cnf
+ echo "max_allowed_packet=17M" >> /etc/my.cnf
+ fi
+ fi
+
+ /sbin/chkconfig mysql on
+ ps ax | grep -v grep |grep mysqld_safe > /dev/null 2>&1
+ if [ ! $? = 0 ] ; then
+ /etc/init.d/mysql start
+ sleep 1
+ fi
+
+ ls /tmp/mysql.sock > /dev/null 2>&1
+ if [ ! $? = 0 ]; then
+ ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
+ fi
+
+ # set mysql password
+ set_mysql_passwd || return 1 # the function uses $MYSQL_PASSWORD
+
+ # Check if database exist
+ mysqlshow --password="$MYSQL_PASSWORD" | grep "lbserver20" > /dev/null 2>&1
+
+ if [ ! $? = 0 ]; then
+ mysql -u root --password="$MYSQL_PASSWORD" -e "CREATE DATABASE lbserver20"
+ mysql --password="$MYSQL_PASSWORD" lbserver20 < ${INSTALL_ROOT}/glite/etc/glite-lb-dbsetup.sql
+ mysql -u root --password="$MYSQL_PASSWORD" -e "GRANT ALL PRIVILEGES on lbserver20.* to lbserver IDENTIFIED BY '' WITH GRANT OPTION;"
+ mysql -u root --password="$MYSQL_PASSWORD" -e "GRANT ALL PRIVILEGES on lbserver20.* to lbserver@'$HOSTNAME' IDENTIFIED BY '' WITH GRANT OPTION;"
+ mysql -u root --password="$MYSQL_PASSWORD" -e "GRANT ALL PRIVILEGES on lbserver20.* to lbserver@localhost IDENTIFIED BY '' WITH GRANT OPTION;"
+ mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE short_fields MAX_ROWS=1000000000;" lbserver20
+ mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE long_fields MAX_ROWS=55000000;" lbserver20
+ mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE states MAX_ROWS=9500000;" lbserver20
+ mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE events MAX_ROWS=175000000;" lbserver20
+ else
+ yaimlog "Database lbserver20 already exists"
+ fi
+
+ # do we need bkindex?
+
+ GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-/var/glite}
+ mkdir -p $GLITE_LOCATION_VAR # Needed to store PID of LB server
+
+ chown $GLITE_USER:$GLITE_USER $GLITE_LOCATION_VAR
+ chmod 0755 $GLITE_LOCATION_VAR
+
+ mkdir -p $GLITE_USER_HOME/.certs
+ chown $GLITE_USER:$GLITE_USER $GLITE_USER_HOME/.certs
+ chmod 0755 $GLITE_USER_HOME/.certs
+ cp -f /etc/grid-security/hostcert.pem /etc/grid-security/hostkey.pem $GLITE_USER_HOME/.certs/
+ if [ ! $? = 0 ] ; then
+ echo "Please copy host certificate and key into /etc/grid-security and"
+ echo " $GLITE_USER_HOME/.certs/, change the owner of the ones in"
+ echo " $GLITE_USER_HOME/.certs/ to $GLITE_USER"
+ fi
+ chown $GLITE_USER:$GLITE_USER $GLITE_USER_HOME/.certs/hostcert.pem $GLITE_USER_HOME/.certs/hostkey.pem
+ chmod 0644 $GLITE_USER_HOME/.certs/hostcert.pem
+ chmod 0400 $GLITE_USER_HOME/.certs/hostkey.pem
+
+ # Create cron for purging
+ mkdir -p /var/log/glite
+ logfile=/var/log/glite/glite-lb-purger.log
+ cat << EOF > /etc/cron.d/glite-lb-purge.cron
+HOME=/
+MAILTO=$SITE_EMAIL
+
+1 1 * * * $GLITE_USER . /opt/glite/etc/profile.d/grid-env.sh ; export GLITE_LB_EXPORT_BKSERVER=$HOSTNAME; export GLITE_LB_EXPORT_ENABLED=false; export GLITE_LB_EXPORT_PURGE_ARGS="--cleared 2d --aborted 15d --cancelled 15d --other 60d"; /opt/glite/sbin/glite-lb-export.sh >> $logfile 2>&1
+EOF
+
+ touch $logfile
+ chown $GLITE_USER:$GLITE_USER $logfile
+
+ cat > /etc/logrotate.d/lb-purger <<EOF
+$logfile {
+ weekly
+ compress
+ rotate 4
+ missingok
+}
+EOF
+
+
+ # Start services
+ if [ ! -f ${GLITE_LOCATION}/etc/gLiteservices ] ; then
+ touch ${GLITE_LOCATION}/etc/gLiteservices
+ fi
+
+ grep glite-lb-bkserverd ${GLITE_LOCATION}/etc/gLiteservices > /dev/null
+ if [ ! $? = 0 ] ; then
+ echo "${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd" >> ${GLITE_LOCATION}/etc/gLiteservices
+ fi
+
+ touch ${GLITE_LOCATION}/etc/LB-super-users
+
+ . /opt/glite/etc/profile.d/grid-env.sh
+ ${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd restart
+
+ if [ ! $? = 0 ] ; then
+ yaimlog ABORT "Service glite-lb-bkserverd failed to start!"
+ return 1
+ fi
+
+ return 0
+
+}