This repository has been archived by the owner on Nov 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
111 lines (92 loc) · 2.97 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION=2
MEMORY=2048
CPU_COUNT = 4
IOAPIC = "on"
PROJECT_NAME = "toolbox"
IP_ADDRESS = "192.168.33.100"
ADMIN_USERNAME="toolbox"
ADMIN_EMAIL="toolbox@localhost"
ADMIN_PASSWORD="FooBarBaz1"
$provision = <<SCRIPT
echo "Europe/Amsterdam" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
export DEBIAN_FRONTEND="noninteractive"
echo "mysql-apt-config mysql-apt-config/select-server select mysql-5.6" | debconf-set-selections
echo "mysql-apt-config mysql-apt-config/repo-distro string debian" | debconf-set-selections
echo "mysql-apt-config mysql-apt-config/repo-codename string jessie" | debconf-set-selections
wget --quiet http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
dpkg -i mysql-apt-config_0.6.0-1_all.deb
#echo 'deb http://repo.mysql.com/apt/debian/ jessie mysql-5.6' >> /etc/apt/sources.list.d/mysql.list
rm -f mysql-apt-config_0.6.0-1_all.deb
apt-get update
apt-get install -y \
mysql-community-server \
libmysqlclient-dev \
python \
python-dev \
python-pip \
libjpeg-dev \
libpng-dev \
ufw
mysql -u root -e 'create database `toolbox-dev`'
mysqladmin password "root"
ufw allow 22
ufw allow 3306
ufw allow 80
ufw --force enable
pip install --quiet virtualenv
virtualenv /toolboxenv
source /toolboxenv/bin/activate
cd /toolbox/
pip install --quiet -r requirements.txt
logdir=/toolbox/toolbox/logs
if [ ! -d "$logdir" ]; then
mkdir $logdir
fi
python manage.py migrate --noinput
python manage.py collectstatic --noinput
echo "from django.contrib.auth.models import User; \
User.objects.create_superuser('$1', '$2', '$3')" | python manage.py shell
cat > /lib/systemd/system/toolbox.service <<EOF
[Unit]
Description=Toolbox DEV server
After=network.target
Requires=mysql.service
[Service]
Type=simple
KillMode=process
RemainAfterExit=no
Restart=always
RestartSec=20
ExecStart=/toolboxenv/bin/python2 /toolbox/manage.py runserver 0.0.0.0:80 --insecure
[Install]
WantedBy=multi-user.target
EOF
systemctl enable toolbox.service
systemctl start toolbox.service
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "debian/jessie64"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", MEMORY]
vb.customize ["modifyvm", :id, "--cpus", CPU_COUNT]
vb.customize ["modifyvm", :id, "--ioapic", IOAPIC]
end
config.vm.box_check_update = true
#config.hostmanager.enabled = true
#config.hostmanager.manage_host = true
config.vm.define PROJECT_NAME do |node|
node.vm.hostname = PROJECT_NAME + ".local"
node.vm.network :private_network, ip: IP_ADDRESS
end
config.vbguest.auto_update = true
config.vbguest.no_remote = false
config.vm.synced_folder ".", "/vagrant/", disabled: true
config.vm.synced_folder ".", "/toolbox/", type: "virtualbox"
config.vm.provision "shell" do |s|
s.inline = $provision
s.args = [ADMIN_USERNAME, ADMIN_EMAIL, ADMIN_PASSWORD]
end
end