From rPath Wiki
#! /bin/bash
#
# sugar-reset sets up default configuration for sugarcrm
#
# chkconfig: 2345 90 60
# description: this will config the db for sugar to the default state, start services, and set config files
#
# Source function library.
. /etc/init.d/functions
#
RETVAL=0
#
# See how we were called.
#
prog="sugar-reset"
#
start() {
#check to see if the appliance has already been installed here
if [ ! -f /srv/mysql/sugarcrm ]
#if not, then create then create the database and copy the sugar config files
then
#
#turn on the services for running sugar
chkconfig --level 35 ntpd on
service ntpd start
chkconfig --level 35 sendmail on
service sendmail start
chkconfig --level 35 httpd on
service httpd start
chkconfig --level 35 mysqld on
service mysqld start
chkconfig --level 35 raa on
service raa start
chkconfig --level 35 raa-lighttpd on
service raa-lighttpd start
#
#set the unique key for sugar so SugarCRM can track updates
UUID=$(dd if=/dev/random bs=16 count=1 2>/dev/null | od -x | head -1 |
sed 's/[^ ]* //
s/ *//g')
sed -i "s/'unique_key' => 'rPath_no_UUID',/'unique_key' => 'rPath_${UUID}',/" /root/config.php
#
#copy config files over and create db
echo -n $"Setting up sugarcrm config and database"
cp /root/config.php /usr/share/sugarcrm/
mysql </root/db_setup.sql
mysql sugarcrm < /root/sugarcrm.sql
#set sugar to not be available for conary update because sugarcrm db migration is broken
conary erase sugarcrm --just-db
fi
#
#remove this init script so it only runs once.
chkconfig --del sugar-reset.init
mv /etc/init.d/sugar-reset.init /root/
conary remove /etc/init.d/sugar-reset.init
RETVAL=$?
echo
[ $RETVAL -eq 0 ]
return $RETVAL
}
#
case "$1" in
start)
start
;;
*)
echo $"Usage: $0 {start}"
exit 1
esac
#
exit $?