Skip to content

Commit

Permalink
Vagrant uses mariadb database rather than sqlite - Fixes CTFd#648 (CT…
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffe authored and ColdHeat committed Jul 29, 2018
1 parent 36dadcf commit 3676d4d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Install tmux and virtualenv to support development
$preProvision= <<SCRIPT
sudo apt-get install tmux virtualenvwrapper -y
sudo apt-get install tmux virtualenvwrapper mariadb-server -y
SCRIPT

# Wrap provisioning script with a virutalenv for pip packages
Expand All @@ -14,12 +14,26 @@ workon ctfd
cd /vagrant
./prepare.sh
pip install -r development.txt
echo "Initialising database"
commands="CREATE DATABASE ctfd;
CREATE USER 'ctfduser'@'localhost' IDENTIFIED BY 'ctfd';
GRANT USAGE ON *.* TO 'ctfduser'@'localhost' IDENTIFIED BY 'ctfd';
GRANT ALL privileges ON ctfd.* TO 'ctfduser'@'localhost';FLUSH PRIVILEGES;"
echo "${commands}" | sudo /usr/bin/mysql -u root -pctfd
SCRIPT

# Start development server in a tmux session
$startServer= <<SCRIPT
source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
workon ctfd
export DATABASE_URL="mysql+pymysql://ctfduser:ctfd@localhost/ctfd"
cd /vagrant
python manage.py db upgrade
echo "Starting CTFd"
tmux new-session -d -n "ctfd" -c "/vagrant" -s "ctfd" "gunicorn --bind 0.0.0.0:8000 -w 4 'CTFd:create_app()'"
SCRIPT

Expand All @@ -36,7 +50,7 @@ Vagrant.configure("2") do |config|

# Pre-provision
config.vm.provision "shell", inline: $preProvision

# Provisioning scripts
config.vm.provision "shell", inline: $provision, privileged: false

Expand Down

0 comments on commit 3676d4d

Please sign in to comment.