From 5024b7426cb81135920b0e30fecb973fa893413d Mon Sep 17 00:00:00 2001 From: Silke Meyer Date: Sat, 19 Nov 2016 16:08:08 +0100 Subject: [PATCH] Vagrant: Allow to choose between Ubuntu 14.04 und 16.04 --- Vagrantfile | 54 ++++++++++++++++++++++++++++----------- util/vagrant_provision.sh | 27 +++++++++++++++----- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 0c16fa6b8..129c90fb4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,30 +1,54 @@ -server_ip = "192.168.22.10" +server_ip_trusty = "192.168.22.10" +server_ip_xenial = "192.168.22.11" server_memory = "1024" # MB server_timezone = "UTC" public_folder = "/vagrant" Vagrant.configure(2) do |config| - # Set server to Ubuntu 14.04 - config.vm.box = "ubuntu/trusty64" + config.vm.define "trusty" do |trusty| + trusty.vm.box = "ubuntu/trusty64" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false - # Create a hostname, don't forget to put it to the `hosts` file - # This will point to the server's default virtual host - # TO DO: Make this work with virtualhost along-side xip.io URL - config.vm.hostname = "friendica.dev" + # Create a hostname, don't forget to put it to the `hosts` file + # This will point to the server's default virtual host + # TO DO: Make this work with virtualhost along-side xip.io URL + trusty.vm.hostname = "friendica-trusty.dev" - # Create a static IP - config.vm.network :private_network, ip: server_ip + # Create a static IP + trusty.vm.network :private_network, ip: server_ip_trusty + + # Share a folder between host and guest + trusty.vm.synced_folder "./", "/vagrant/", owner: "www-data", group: "vagrant" + end + + # Set server to Ubuntu 16.04 + config.vm.define "xenial" do |xenial| + xenial.vm.box = "ubuntu/xenial64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a hostname, don't forget to put it to the `hosts` file + # This will point to the server's default virtual host + # TO DO: Make this work with virtualhost along-side xip.io URL + xenial.vm.hostname = "friendica-xenial.dev" + + # Create a static IP + xenial.vm.network :private_network, ip: server_ip_xenial + + # Share a folder between host and guest + xenial.vm.synced_folder "./", "/vagrant/", owner: "www-data", group: "vagrant" + end - # Share a folder between host and guest - config.vm.synced_folder "./", "/vagrant/", owner: "www-data", group: "vagrant" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. diff --git a/util/vagrant_provision.sh b/util/vagrant_provision.sh index 12e792c04..f01f0f66a 100644 --- a/util/vagrant_provision.sh +++ b/util/vagrant_provision.sh @@ -37,11 +37,19 @@ sudo a2dissite 000-default sudo service apache2 restart #Install php -echo ">>> Installing PHP5" -sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd -sudo apt-get install -y imagemagick -sudo apt-get install -y php5-imagick -sudo service apache2 restart +if [ $( lsb_release -c | cut -f 2 ) == "trusty" ]; then + echo ">>> Installing PHP5" + sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd + sudo apt-get install -y imagemagick + sudo apt-get install -y php5-imagick + sudo service apache2 restart +elif [ $( lsb_release -c | cut -f 2 ) == "xenial" ]; then + echo ">>> Installing PHP7" + sudo apt-get install -y php libapache2-mod-php php-cli php-mysql php-curl php-gd + sudo apt-get install -y imagemagick + sudo apt-get install -y php-imagick + sudo systemctl restart apache2 +fi #Install mysql @@ -59,7 +67,12 @@ Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" Q2="FLUSH PRIVILEGES;" SQL="${Q1}${Q2}" $MYSQL -uroot -proot -e "$SQL" -service mysql restart +if [ $( lsb_release -c | cut -f 2 ) == "trusty" ]; then + service mysql restart +elif [ $( lsb_release -c | cut -f 2 ) == "xenial" ]; then + systemctl restart mysql +fi + #configure rudimentary mail server (local delivery only) @@ -87,4 +100,4 @@ sudo crontab friendicacron sudo rm friendicacron #Optional: checkout addon repositroy -#sudo git clone https://github.com/friendica/friendica-addons.git /vagrant/addon +sudo git clone https://github.com/friendica/friendica-addons.git /vagrant/addon