#!/bin/sh # Copyrights : CNRS # Author : Oleg Lodygensky # Acknowledgment : XtremWeb-HEP is based on XtremWeb 1.8.0 by inria : http://www.xtremweb.net/ # Web : http://www.xtremweb-hep.org # # This file is part of XtremWeb-HEP. # # XtremWeb-HEP is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # XtremWeb-HEP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XtremWeb-HEP. If not, see . # # # # File : xtremweb.database # # Purpose : This installs/removes the xtremweb database # # Params : $1 [install | remove | config] # -u # -d # # install to install database # remove to uninstall database # config to install config files from database # # return : 0 on success # 1 on error # # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # ** DO NOT EDIT ** # ** This file is generated by install script ** # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # ################################################### # Help ################################################### Help() { head -17 $0 exit 1 } ################################################### # Install config file # Parameters : # $1 config file # $2 login # $3 password ################################################### config() { CONF=$1 LOGIN=$2 PASSWORD=$3 [ ! -f $CONF ] && touch $CONF grep "login=" $CONF > /dev/null 2>&1 INSERT=$? if [ $INSERT -eq 1 ] ; then echo "login=$LOGIN" >> $CONF else TEMP=`date | sed "s/[[:space:]][[:space:]]*/_/g"` sed "s/login=.*/login=$LOGIN/g" $CONF > $TEMP mv $TEMP $CONF fi grep "password=" $CONF > /dev/null 2>&1 INSERT=$? if [ $INSERT -eq 1 ]; then echo "password=$PASSWORD" >> $CONF else TEMP=`date | sed "s/[[:space:]][[:space:]]*/_/g"` sed "s/password=.*/password=$PASSWORD/g" $CONF > $TEMP mv $TEMP $CONF fi echo "$CONF installed" } ################################################### # Main ################################################### CONFDIR="`dirname $0`/../conf" if [ ! -d $CONFDIR ]; then echo "Can't find config directory" exit 1 fi ROOTDIR=@INSTALLDIR@ BINDIR=$ROOTDIR/bin DBUSER="root" SQLFILE="" ACTION="" DB="xtremweb" # # Parse command line parameters # while [ $# -gt 0 ]; do case "$1" in install) SQLFILE="$BINDIR/db-maintenance/xwhep-core-tables-create-tables.sql" ACTION=$1 ;; remove) SQLFILE="$BINDIR/db-maintenance/xwhep-core-tables-drop-triggers-and-tables.sql" ACTION=$1 ;; config) ACTION=$1 ;; -u) shift DBUSER=$1 ;; -d) shift DB=$1 ;; *) Help esac shift done if [ "X$SQLFILE" = "X" -a "X$ACTION" != "Xconfig" ]; then Help fi mysql -u $DBUSER $DB -e "show databases" > /dev/null 2>&1 NEEDPASSWORD=$? if [ "X$ACTION" != "Xconfig" ]; then DBPASS="" if [ $NEEDPASSWORD -ne 0 ] ; then read -s -p "Enter database password (return if no password) : " PASSWORD [ "X$PASSWORD" != "X" ] && DBPASS="-p$PASSWORD" echo "" fi mysql -u $DBUSER $DBPASS $DB < $SQLFILE RETVAL=$? echo -n "`date` [`uname -n`] INFO : $ACTION database " case "$RETVAL" in 0) echo "[OK]" ;; *) echo "[FAILED]" ;; esac [ $RETVAL -ne 0 ] && exit $RETVAL [ "X$ACTION" = "Xremove" ] && exit $RETVAL fi # # install administrator config file # LP=`mysql -B -u $DBUSER $DBPASS -e 'select login,password from xtremweb.users where login="xtremweb"' | tail -1 | sed "s/[[:space:]][[:space:]]*/ /g"` LOGIN=`echo $LP | cut -d ' ' -f 1` PASSWORD=`echo $LP | cut -d ' ' -f 2` CONF="$CONFDIR/xtremweb.client.conf" config $CONF $LOGIN $PASSWORD # # install worker config file # LP=`mysql -B -u $DBUSER $DBPASS -e 'select login,password from xtremweb.users where login="xwworker"' | tail -1 | sed "s/[[:space:]][[:space:]]*/ /g"` LOGIN=`echo $LP | cut -d ' ' -f 1` PASSWORD=`echo $LP | cut -d ' ' -f 2` CONF="$CONFDIR/xtremweb.worker.conf" config $CONF $LOGIN $PASSWORD exit 0 # # End Of File #