-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
71 lines (58 loc) · 2.05 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
IPADDR = "192.168.30.101"
NETMASK = "255.255.255.0"
GATEWAY = "192.168.30.1"
VMNAME = "hosting"
Vagrant.configure("2") do |config|
config.vm.define VMNAME do |d|
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
v.name = VMNAME
v.linked_clone = true
end
end
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network",
adapter: 2,
name: "vboxnet0",
ip: IPADDR,
netmask: NETMASK,
gateway: GATEWAY,
auto_config: false
config.vm.provision :shell, inline: <<-SCRIPT
sudo hostnamectl set-hostname #{VMNAME}
SCRIPT
config.vm.provision :shell do |shell|
shell.inline = <<-SCRIPT
sudo ifconfig eth1 #{IPADDR} netmask #{NETMASK} up
sudo ip route replace default via #{GATEWAY} dev eth1
SCRIPT
end
config.vm.provision :shell, inline: <<-SCRIPT
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.lo.disable_ipv6=1
SCRIPT
config.vm.provision :shell, inline: <<-SCRIPT
sudo sed -i 's|[#]*PasswordAuthentication yes|PasswordAuthentication no|g' /etc/ssh/sshd_config
sudo sed -i 's|UsePAM yes|UsePAM no|g' /etc/ssh/sshd_config
sudo sed -i 's|PermitRootLogin without-password|PermitRootLogin no|g' /etc/ssh/sshd_config
sudo service ssh restart
SCRIPT
config.vm.provision :shell, inline: <<-SCRIPT
sudo apt-get install -y git nginx shellinabox ipython python-ipdb
sudo rm /etc/nginx/sites-enabled/default
sudo rm /etc/default/shellinabox
sudo ln -s /vagrant/conf/hosting.conf /etc/nginx/sites-enabled/hosting.conf
sudo ln -s /vagrant/conf/shellinabox /etc/default/shellinabox
sudo ln -s /vagrant/bin/newuser.sh /usr/local/bin/u
sudo ln -s /vagrant/bin/hostingconf.py /usr/local/bin/hostingconf
sudo chmod a+x /usr/local/bin/u
sudo chmod a+x /usr/local/bin/hostingconf
sudo mkdir /etc/skel/www
rm /home/vagrant/www
ln -s /vagrant/www /home/vagrant/www
sudo service nginx restart
sudo service shellinabox restart
SCRIPT
end