Skip to content

Commit

Permalink
Modified provisioning to use MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRantil committed Jun 12, 2014
1 parent 489dad0 commit 2a5f048
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/setup_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ packages=(
'libxslt-dev'
'nodejs'
'npm'
'postgresql-9.1'
'mysql-server'
'nginx'
'htop'
)
Expand Down
2 changes: 1 addition & 1 deletion conf/production.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DATABASE_URL=postgres://cabot:cabot@localhost:5432/index
DATABASE_URL=mysql://cabot:cabot@localhost/cabot
DJANGO_SETTINGS_MODULE=app.settings
HIPCHAT_URL=https://api.hipchat.com/v1/rooms/message
LOG_FILE=/dev/null
Expand Down
20 changes: 11 additions & 9 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
VENV_DIR = '%s/venv' % HOME_DIR
BACKUP_DIR = '/tmp/'

PG_DATABASE = 'index'
PG_USERNAME = 'cabot'
PG_PASSWORD = 'cabot' # You should probably change this
MY_DATABASE = 'cabot'
MY_USERNAME = 'cabot'
MY_PASSWORD = 'cabot' # You should probably change this


def _ensure_dirs():
Expand Down Expand Up @@ -150,18 +150,20 @@ def backup():
"""
backup_file = 'outfile.sql.gz'
with cd(BACKUP_DIR):
run('PGPASSWORD=cabot pg_dump -U cabot index | gzip > {}'.format(backup_file))
run('mysqldump -u root {0} | gzip > {1}'.format(MY_DATABASE, backup_file))
get(backup_file, 'backups/%(basename)s')


def create_database():
"""Creates role and database"""
with settings(warn_only=True):
sudo(
'psql -c "CREATE USER %s WITH NOCREATEDB NOCREATEUSER ENCRYPTED PASSWORD E\'%s\'"' %
(PG_USERNAME, PG_PASSWORD), user='postgres')
sudo('psql -c "CREATE DATABASE %s WITH OWNER %s"' %
(PG_DATABASE, PG_USERNAME), user='postgres')
run(
'mysql -u root -e "CREATE USER %s@localhost IDENTIFIED BY \'%s\'"' %
(MY_USERNAME, MY_PASSWORD))
run('mysql -u root -e "CREATE DATABASE %s;"' %
(MY_DATABASE,))
run('mysql -u root -e "GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@localhost"' %
(MY_DATABASE, MY_USERNAME))


@parallel
Expand Down

0 comments on commit 2a5f048

Please sign in to comment.