From 916600c77b25817162e8e0fbf5e4c8829c56095e Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Wed, 17 May 2017 10:16:10 -0700 Subject: [PATCH] Add something that kinda works, but not really Need to finish getting disk resizing to work --- Vagrantfile | 81 +++++++++++++++++++++++++++++++++++++++++++++ cloudron_logs.sh | 3 ++ restart_cloudron.sh | 3 ++ 3 files changed, 87 insertions(+) create mode 100644 Vagrantfile create mode 100755 cloudron_logs.sh create mode 100755 restart_cloudron.sh diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..9cf51e0 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,81 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby sw=2 ts=2 : + +# Set this to custom url if using a fork +cloudron_setup_url = 'https://git.cloudron.io/cloudron/box/raw/master/scripts/cloudron-setup' + +Vagrant.configure(2) do |config| + # Minimum requirement for Cloudron is 16.04 + config.vm.box = "ubuntu/xenial64" + + # Mosh is super nice, why not? + enable_mosh = false + if enable_mosh + (60000..61000).each do |p| + config.vm.network "forwarded_port", guest: p, host: p, protocol: 'udp' + end + end + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + # config.vm.network "forwarded_port", guest: 443, host: 8081 + + config.vm.network "private_network", ip: "192.168.100.100" + + # Set hostname for the box + config.vm.hostname = "cloudron.cloud" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "~/.ssh", "~/.ssh/vagrant_data" + + config.vm.provider "virtualbox" do |vb| + # Display the VirtualBox GUI when booting the machine + vb.gui = false + + # Customize the amount of memory on the VM: + vb.memory = "2048" + end + + # disk_filepath "~/VirtualBox\ VMs/#{:name}/disk1.vdi" + disk_filepath = 'disk1.vdi' + if ARGV[0] == "up" && ! File.exists?(disk_filepath) + # Create vdi + config.vm.provider :virtualbox do |vb| + vb.customize [ + 'createhd', + '--filename', disk_filepath, + '--format', 'VDI', + # 20GB + '--size', 20 * 1024 + ] + + vb.customize [ + 'storageattach', :id, + '--storagectl', 'IDE', + '--port', 1, '--device', 0, + '--type', 'hdd', '--medium', + disk_filepath + ] + end + + # Run script to map new disk + config.vm.provision "shell", inline: <<-SHELL + pvcreate /dev/sdb + vgextend VolGroup /dev/sdb + lvextend /dev/VolGroup/lv_root /dev/sdb + resize2fs /dev/VolGroup/lv_root + SHELL + end + + # Set up Cloudron on provision. If using a fork, change this URL + config.vm.provision "shell", inline: <<-SHELL + wget #{cloudron_setup_url} + chmod +x cloudron-setup + ./cloudron-setup --domain cloudron.cloud --provider generic --tls-provider fallback --dns-provider noop + SHELL +end diff --git a/cloudron_logs.sh b/cloudron_logs.sh new file mode 100755 index 0000000..18a516c --- /dev/null +++ b/cloudron_logs.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +vagrant ssh -c 'journalctl -u box -af' diff --git a/restart_cloudron.sh b/restart_cloudron.sh new file mode 100755 index 0000000..e8d2305 --- /dev/null +++ b/restart_cloudron.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +vagrant ssh -c 'systemctl restart box'