|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +# Allow user to pass in a different web port forward value. |
| 5 | +# Use when you are running multiple vms on one system |
| 6 | +PORTNUM = ENV["PORTNUM"] || "10000" |
| 7 | + |
| 8 | +Vagrant.configure("2") do |config| |
| 9 | + config.vm.box = "ubuntu/jammy64" |
| 10 | + |
| 11 | + # Assign this VM to a bridged network, allowing you to connect directly to a |
| 12 | + # network using the host's network device. This makes the VM appear as another |
| 13 | + # physical device on your network. |
| 14 | + # Uncomment the following if you want this VM to have its own IP |
| 15 | + #config.vm.network :bridged |
| 16 | + |
| 17 | + # Create a forwarded port mapping which allows access to a specific port |
| 18 | + # within the machine from a port on the host machine. In the example below, |
| 19 | + # accessing "localhost:10000" will access port 80 on the guest machine. |
| 20 | + # NOTE: This will enable public access to the opened port |
| 21 | + config.vm.network "forwarded_port", guest: 80, host: PORTNUM , auto_correct: false |
| 22 | + |
| 23 | + # Set up our repo as a synced folder |
| 24 | + config.vm.synced_folder ".", "/opt/ona" |
| 25 | + |
| 26 | + # The basic install script |
| 27 | + $script = <<-SCRIPT |
| 28 | +#------- Start provision -------- |
| 29 | +PORTNUM=$1 |
| 30 | +
|
| 31 | +# Tell apt to quit its whining |
| 32 | +export DEBIAN_FRONTEND=noninteractive |
| 33 | +
|
| 34 | +apt-get update |
| 35 | +apt-get install -y \ |
| 36 | + curl \ |
| 37 | + apache2 \ |
| 38 | + mariadb-server \ |
| 39 | + php \ |
| 40 | + php-mysql \ |
| 41 | + php-mbstring \ |
| 42 | + php-gmp \ |
| 43 | + php-pear \ |
| 44 | + libapache2-mod-php \ |
| 45 | + libyaml-dev \ |
| 46 | + libio-socket-ssl-perl |
| 47 | +
|
| 48 | +# Link in our ona code |
| 49 | +[ ! -d /var/www/html/ona ] && ln -fs /opt/ona/www /var/www/html/ona |
| 50 | +
|
| 51 | +# Allow others to see apache logs (and probably other stuff) |
| 52 | +#usermod -a -G adm www-data |
| 53 | +#usermod -a -G adm vagrant |
| 54 | +
|
| 55 | +# Set up application log file |
| 56 | +if [ ! -f /var/log/ona.log ] |
| 57 | +then |
| 58 | + touch /var/log/ona.log |
| 59 | + chmod 666 /var/log/ona.log |
| 60 | +fi |
| 61 | +
|
| 62 | +# restart apache so it picks up changes |
| 63 | +systemctl restart apache2.service |
| 64 | +
|
| 65 | +# Clean out any old configs |
| 66 | +# Re-running the provisioner will wipe out any previous configs |
| 67 | +rm -f /opt/ona/www/local/config/database_settings.inc.php |
| 68 | +
|
| 69 | +# Run the CLI installer with all default options |
| 70 | +echo "\n\n\n"|php /opt/ona/install/installcli.php |
| 71 | +
|
| 72 | +echo " |
| 73 | +
|
| 74 | +
|
| 75 | +Please point your browser to: http://localhost:${PORTNUM}/ona |
| 76 | +
|
| 77 | +" |
| 78 | +#------- End provision -------- |
| 79 | + SCRIPT |
| 80 | + |
| 81 | + # Run our shell provisioner |
| 82 | + config.vm.provision "shell", inline: $script, :args => [ PORTNUM ] |
| 83 | + |
| 84 | +end |
0 commit comments