#!/bin/bash function check_ver { if ( ls ${MY_SERVERCONFIGDIR} | grep -q apache2 ); then echo apache2; else echo apache1; fi } if [ $1 = "start" -o $1 = "install" ]; then cd ${VHOST_ROOT} || die # reconfigure the installation APACHE_VER=`check_ver` MY_VHOST=`basename ${VHOST_ROOT}` MY_VHOST_ROOT=`echo ${VHOST_ROOT} | sed "s.\/.\\\\\/.g"` MY_INST=`echo ${MY_INSTALLDIR} | sed "s.\/.\\\\\/.g"` sed -e "s/VIRTUAL/${MY_VHOST_ROOT}/ s/PATH/${MY_VHOST}/ s/VHOST/${MY_VHOST}/ s/SERVER/${MY_VHOST}/" -i ${MY_SERVERCONFIGDIR}/${APACHE_VER}-bugzilla.conf FILE="bugzilla.cron.daily bugzilla.cron.tab cronset.sh firstcheck.sh" for file in ${FILE}; do sed -e "s/\/var\/www\/bugzilla/${MY_VHOST_ROOT}/" -i ${D}/${VHOST_ROOT}/${FILE} done if ( test -a localconfig ) ; then echo "The following does not work on previous installations, please run checksetup.pl in ${VHOST_ROOT}" exit 1 fi echo "Finalizing the installation of bugzilla in ${VHOST_ROOT}" # config setting echo -n "mysql bugs db name [bugs]: "; read mybugsdb if (test -z ${mybugsdb}) ; then mybugsdb="bugs" ; fi echo -n "mysql bugs db host [localhost]: "; read mybugshost if (test -z ${mybugshost}) ; then mybugshost="localhost" ; fi echo -n "mysql bugs dbuser name [bugs]: "; read mybugsuser if (test -z ${mybugsuser}) ; then mybugsuser="bugs" ; fi echo -n "mysql bugs dbuser password: "; read mybugspwd if (test -z ${mybugspwd}) ; then echo "Error: no dbuser password" ; exit 1; fi cat bz.cfg.templ | sed -e "s/tmpdbname/${mybugsdb}/ s/tmphost/${mybugshost}/ s/tmpdbuser/${mybugsuser}/ s/tmpdbpass/${mybugspwd}/" > bz.cfg.pl if [ ! -f bz.cfg.pl ] ; then echo "Error: no template for db vars" ; exit 1 ; fi # privileges echo "Setting correct privileges for bugzilla mysql connection" echo -n "Please enter login info for user who has grant privileges on ${mybugshost} [$USER]: "; read adminuser if (test -z ${adminuser}) ; then adminuser="$USER" ; fi if [ "${mybugshost}" != "localhost" ]; then echo -n "Client address for bugzilla (at db side) [$(hostname -f)]: "; read clientaddr if (test -z ${clientaddr}) ; then clientaddr="$(hostname -f)" ; fi fi # this will be default for localhost if (test -z ${clientaddr}) ; then clientaddr="${mybugshost}" ; fi # if $bugshost == localhost, don't specify -h argument, so local socket can be used. host=${mybugshost/localhost} mysql -u ${adminuser} ${host:+-h ${host}} -p mysql --exec="GRANT SELECT,INSERT,UPDATE,DELETE,INDEX, ALTER,CREATE,DROP,REFERENCES ON ${mybugsdb}.* TO ${mybugsuser}@${clientaddr} IDENTIFIED BY '${mybugspwd}'; FLUSH PRIVILEGES;" || { echo "Error running query!" echo echo "Please run it manually on ${host}." echo echo " \$ mysql -u ${adminuser} -p mysql --exec=\"GRANT SELECT,INSERT,UPDATE,DELETE,INDEX, ALTER,CREATE,DROP,REFERENCES ON ${mybugsdb}.* TO ${mybugsuser}@${clientaddr} IDENTIFIED BY '${mybugspwd}'; FLUSH PRIVILEGES;\"" echo } echo "Setting the template for localconfig variables" ./checksetup.pl bz.cfg.pl || exit 1 echo "Final step: setting all html templates and db tables" chmod 750 ${VHOST_ROOT}/firstcheck.sh ./firstcheck.sh || die echo -n "Do you want to set a crontab [y/N]" ; read cronyes if (test -z ${cronyes}) ; then cronyes="n" ; fi if [ ${cronyes} = "y" ] ; then crontab -u apache ${VHOST_ROOT}/bugzilla.cron.tab ; fi else echo $1 fi