- # MySQL:
- # install mysql non-interactively and set root password
- DEBIAN_FRONTEND=noninteractive apt-get install mysql-server -y
- # hang out while sql starts
- echo "sleeping for 5 seconds to let MySQL start"
- sleep 5
- # move in our my.cnf file
- ln -sf /opt/loggly/web/config/my.cnf /etc/mysql/my.cnf
- # reset the password
- mysqladmin -u root password $DB_MYSQL_ROOT_PWD
- # build the SQL for the create and priv statements
- cat <<EOF>> /tmp/create_django.sql
- create database django;
- grant all privileges on django.* to django@'$LOCAL_FQDN' identified by '$DB_DJANGO_PWD';
- grant all privileges on test_django.* to django@'$LOCAL_FQDN' identified by '$DB_DJANGO_PWD';
- grant all privileges on django.* to django@'%' identified by '$DB_DJANGO_PWD';
- grant all privileges on test_django.* to django@'%' identified by '$DB_DJANGO_PWD';
- grant all privileges on django.* to django@'localhost' identified by '$DB_DJANGO_PWD';
- grant all privileges on test_django.* to django@'localhost' identified by '$DB_DJANGO_PWD';
- use mysql;
- update user set password=password('$DB_DJANGO_PWD') where user="django";
- flush privileges;
- EOF
- # run the SQL
- mysql -u root -p$DB_MYSQL_ROOT_PWD < /tmp/create_django.sql
- # remove the tmp file
- #rm -rf /tmp/create_django.sql
- # stop apache (because django won't work anyway without the syncdb crap, which has to be run manually)
- /etc/init.d/apache2 stop
- # restart mysql
- /etc/init.d/mysql restart
- # populate our fixture for servers
- internalip=`ifconfig -a|grep Bcast:|cut -d\: -f2|awk '{print $1}'`
- externalip=$EXTERNAL_IP
- launchtime=`date +%Y-%m-%d\ %H:%M:%S`
- cat <<EOF> /opt/loggly/web/app/server/fixtures/initial_data.json
- [{"pk": 1, "model": "server.server", "fields": {"fqdn": "dev-web.$DOMAIN", "internal_ip": "$internalip", "external_ip": "$externalip", "role": "web", "launched": "$launchtime", "status": "up"}},{"pk": 2, "model": "server.server", "fields": {"fqdn": "dev-db.$DOMAIN", "internal_ip": "$internalip", "external_ip": "$externalip", "role": "database", "launched": "$launchtime", "status": "up"}},{"pk": 3, "model": "server.server", "fields": {"fqdn": "dev-solr.$DOMAIN", "internal_ip": "$internalip", "external_ip": "$externalip", "role": "indexer", "launched": "$launchtime", "status": "up"}},{"pk": 4, "model": "server.server", "fields": {"fqdn": "dev-proxy.$DOMAIN", "internal_ip": "$internalip", "external_ip": "$externalip", "role": "proxy", "launched": "$launchtime", "status": "up"}}]
- EOF
- # populate our fixture for sites
- cat <<EOF> /opt/loggly/web/app/sites/fixtures/initial_data.json
- [{"pk": 1, "model": "sites.site", "fields": {"domain": "http://www.$DOMAIN", "name": "$DOMAIN"}}]
- EOF