Skip to content

Commit 3676d4d

Browse files
cliffeColdHeat
authored andcommitted
Vagrant uses mariadb database rather than sqlite - Fixes CTFd#648 (CTFd#649)
1 parent 36dadcf commit 3676d4d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Vagrantfile

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Install tmux and virtualenv to support development
55
$preProvision= <<SCRIPT
6-
sudo apt-get install tmux virtualenvwrapper -y
6+
sudo apt-get install tmux virtualenvwrapper mariadb-server -y
77
SCRIPT
88

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

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

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

3751
# Pre-provision
3852
config.vm.provision "shell", inline: $preProvision
39-
53+
4054
# Provisioning scripts
4155
config.vm.provision "shell", inline: $provision, privileged: false
4256

0 commit comments

Comments
 (0)