From c23de3a64ecc0b87dd2bf3e4987b867749fbf5e7 Mon Sep 17 00:00:00 2001 From: Hauke Altmann Date: Fri, 20 Jun 2014 16:05:44 +0200 Subject: [PATCH 1/3] added vagrant configuration for running a friendica development instance --- .gitignore | 3 + Vagrantfile | 269 ++++++++++++++++++++++++++++++++++++++ util/vagrant_provision.sh | 20 +++ 3 files changed, 292 insertions(+) create mode 100644 Vagrantfile create mode 100644 util/vagrant_provision.sh diff --git a/.gitignore b/.gitignore index 7152833590..38d5e6fd2c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ report/ /privacy_image_cache/ /photo/ nbproject + +#ignore vagrant dir +.vagrant/ diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..015ceb83d9 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,269 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Config Github Settings +github_username = "fideloper" +github_repo = "Vaprobash" +github_branch = "1.0.0" +github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}" + +# Server Configuration + +hostname = "vaprobash.dev" + +# Set a local private network IP address. +# See http://en.wikipedia.org/wiki/Private_network for explanation +# You can use the following IP ranges: +# 10.0.0.1 - 10.255.255.254 +# 172.16.0.1 - 172.31.255.254 +# 192.168.0.1 - 192.168.255.254 +server_ip = "192.168.22.10" +server_memory = "384" # MB +server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory +server_timezone = "UTC" + +# Database Configuration +mysql_root_password = "root" # We'll assume user "root" +mysql_version = "5.5" # Options: 5.5 | 5.6 +mysql_enable_remote = "false" # remote access enabled when true +pgsql_root_password = "root" # We'll assume user "root" + +# Languages and Packages +ruby_version = "latest" # Choose what ruby version should be installed (will also be the default version) +ruby_gems = [ # List any Ruby Gems that you want to install + #"jekyll", + #"sass", + #"compass", +] + +# To install HHVM instead of PHP, set this to "true" +hhvm = "false" + +# PHP Options +composer_packages = [ # List any global Composer packages that you want to install + #"phpunit/phpunit:4.0.*", + #"codeception/codeception=*", + #"phpspec/phpspec:2.0.*@dev", + #"squizlabs/php_codesniffer:1.5.*", +] + +# Default web server document root +# Symfony's public directory is assumed "web" +# Laravel's public directory is assumed "public" +public_folder = "/vagrant" + +laravel_root_folder = "/vagrant/laravel" # Where to install Laravel. Will `composer install` if a composer.json file exists +laravel_version = "latest-stable" # If you need a specific version of Laravel, set it here +symfony_root_folder = "/vagrant/symfony" # Where to install Symfony. + +nodejs_version = "latest" # By default "latest" will equal the latest stable version +nodejs_packages = [ # List any global NodeJS packages that you want to install + #"grunt-cli", + #"gulp", + #"bower", + #"yo", +] + +Vagrant.configure("2") do |config| + + # Set server to Ubuntu 14.04 + config.vm.box = "ubuntu/trusty64" + + # 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 = hostname + + # Create a static IP + config.vm.network :private_network, ip: server_ip + + # Use NFS for the shared folder + config.vm.synced_folder ".", "/vagrant", + id: "core", + :nfs => true, + :mount_options => ['nolock,vers=3,udp,noatime'] + + # If using VirtualBox + config.vm.provider :virtualbox do |vb| + + # Set server memory + vb.customize ["modifyvm", :id, "--memory", server_memory] + + # Set the timesync threshold to 10 seconds, instead of the default 20 minutes. + # If the clock gets more than 15 minutes out of sync (due to your laptop going + # to sleep for instance, then some 3rd party services will reject requests. + vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000] + + # Prevent VMs running on Ubuntu to lose internet connection + # vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + # vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + + end + + # If using VMWare Fusion + config.vm.provider "vmware_fusion" do |vb, override| + override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box" + + # Set server memory + vb.vmx["memsize"] = server_memory + + end + + # If using Vagrant-Cachier + # http://fgrehm.viewdocs.io/vagrant-cachier + if Vagrant.has_plugin?("vagrant-cachier") + # Configure cached packages to be shared between instances of the same base box. + # Usage docs: http://fgrehm.viewdocs.io/vagrant-cachier/usage + config.cache.scope = :box + + config.cache.synced_folder_opts = { + type: :nfs, + mount_options: ['rw', 'vers=3', 'tcp', 'nolock'] + } + end + + #### + # Base Items + ########## + + # Provision Base Packages + config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap] + + # Provision PHP + config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [server_timezone, hhvm] + + # Enable MSSQL for PHP + # config.vm.provision "shell", path: "#{github_url}/scripts/mssql.sh" + + # Provision Vim + # config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url + + + #### + # Web Servers + ########## + + # Provision Apache Base + config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url] + + # Provision Nginx Base + # config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url] + + + #### + # Databases + ########## + + # Provision MySQL + config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote] + + # Provision PostgreSQL + # config.vm.provision "shell", path: "#{github_url}/scripts/pgsql.sh", args: pgsql_root_password + + # Provision SQLite + # config.vm.provision "shell", path: "#{github_url}/scripts/sqlite.sh" + + # Provision RethinkDB + # config.vm.provision "shell", path: "#{github_url}/scripts/rethinkdb.sh", args: pgsql_root_password + + # Provision Couchbase + # config.vm.provision "shell", path: "#{github_url}/scripts/couchbase.sh" + + # Provision CouchDB + # config.vm.provision "shell", path: "#{github_url}/scripts/couchdb.sh" + + # Provision MongoDB + # config.vm.provision "shell", path: "#{github_url}/scripts/mongodb.sh" + + # Provision MariaDB + # config.vm.provision "shell", path: "#{github_url}/scripts/mariadb.sh", args: [mysql_root_password, mysql_enable_remote] + + #### + # Search Servers + ########## + + # Install Elasticsearch + # config.vm.provision "shell", path: "#{github_url}/scripts/elasticsearch.sh" + + # Install SphinxSearch + # config.vm.provision "shell", path: "#{github_url}/scripts/sphinxsearch.sh" + + #### + # Search Server Administration (web-based) + ########## + + # Install ElasticHQ + # Admin for: Elasticsearch + # Works on: Apache2, Nginx + # config.vm.provision "shell", path: "#{github_url}/scripts/elastichq.sh" + + + #### + # In-Memory Stores + ########## + + # Install Memcached + # config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh" + + # Provision Redis (without journaling and persistence) + # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh" + + # Provision Redis (with journaling and persistence) + # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh", args: "persistent" + # NOTE: It is safe to run this to add persistence even if originally provisioned without persistence + + + #### + # Utility (queue) + ########## + + # Install Beanstalkd + # config.vm.provision "shell", path: "#{github_url}/scripts/beanstalkd.sh" + + # Install Heroku Toolbelt + # config.vm.provision "shell", path: "https://toolbelt.heroku.com/install-ubuntu.sh" + + # Install Supervisord + # config.vm.provision "shell", path: "#{github_url}/scripts/supervisord.sh" + + #### + # Additional Languages + ########## + + # Install Nodejs + # config.vm.provision "shell", path: "#{github_url}/scripts/nodejs.sh", privileged: false, args: nodejs_packages.unshift(nodejs_version, github_url) + + # Install Ruby Version Manager (RVM) + # config.vm.provision "shell", path: "#{github_url}/scripts/rvm.sh", privileged: false, args: ruby_gems.unshift(ruby_version) + + #### + # Frameworks and Tooling + ########## + + # Provision Composer + # config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: composer_packages.join(" ") + + # Provision Laravel + # config.vm.provision "shell", path: "#{github_url}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version] + + # Provision Symfony + # config.vm.provision "shell", path: "#{github_url}/scripts/symfony.sh", privileged: false, args: [server_ip, symfony_root_folder, public_folder] + + # Install Screen + # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh" + + # Install Mailcatcher + config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" + + # Install git-ftp + # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false + + #### + # Local Scripts + # Any local scripts you may want to run post-provisioning. + # Add these to the same directory as the Vagrantfile. + ########## + config.vm.provision "shell", path: "./util/vagrant_provision.sh" + config.vm.synced_folder "./", "/vagrant/", :owner=> 'www-data', :group=>'vagrant', :mount_options => ['dmode=775', 'fmode=775'] + +end diff --git a/util/vagrant_provision.sh b/util/vagrant_provision.sh new file mode 100644 index 0000000000..7507b0715a --- /dev/null +++ b/util/vagrant_provision.sh @@ -0,0 +1,20 @@ +#!/bin/bash +#Script to setup the vagrant instance for running friendica +# +#DO NOT RUN on your physical machine as this won't be of any use +#and f.e. deletes your /var/www/ folder! + +#make the vagrant directory the docroot +rm -rf /var/www/ +ln -fs /vagrant /var/www + +#create the friendica database +echo "create database friendica" | mysql -u root -proot + +#create cronjob +echo "*/10 * * * * cd /vagrant; /usr/bin/php include/poller.php" >> friendicacron +crontab friendicacron +rm friendicacron + +#Optional: checkout addon repository +#git clone https://github.com/friendica/friendica-addons.git /vagrant/addon \ No newline at end of file From e89e8d2914bd24b60aab26dd641128902d5f0612 Mon Sep 17 00:00:00 2001 From: Hauke Altmann Date: Fri, 20 Jun 2014 18:32:40 +0200 Subject: [PATCH 2/3] adjusted configuration due to problems with mailcatcher --- Vagrantfile | 8 ++++---- util/vagrant_provision.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 015ceb83d9..147f248810 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,8 +18,8 @@ hostname = "vaprobash.dev" # 172.16.0.1 - 172.31.255.254 # 192.168.0.1 - 192.168.255.254 server_ip = "192.168.22.10" -server_memory = "384" # MB -server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory +server_memory = "400" # MB +server_swap = "800" # Options: false | int (MB) - Guideline: Between one or two times the server_memory server_timezone = "UTC" # Database Configuration @@ -252,8 +252,8 @@ Vagrant.configure("2") do |config| # Install Screen # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh" - # Install Mailcatcher - config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" + # Install config Mailcatcher + # ls -config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" # Install git-ftp # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false diff --git a/util/vagrant_provision.sh b/util/vagrant_provision.sh index 7507b0715a..476a1cd1c2 100644 --- a/util/vagrant_provision.sh +++ b/util/vagrant_provision.sh @@ -8,6 +8,13 @@ rm -rf /var/www/ ln -fs /vagrant /var/www +#delete .htconfig.php file if it exists to have a fresh friendica +#installation +if [ -f /vagrant/.htconfig.php ] + then + rm /vagrant/.htconfig.php +fi + #create the friendica database echo "create database friendica" | mysql -u root -proot @@ -16,5 +23,5 @@ echo "*/10 * * * * cd /vagrant; /usr/bin/php include/poller.php" >> friendicacro crontab friendicacron rm friendicacron -#Optional: checkout addon repository +#Optional: checkout addon repositroy #git clone https://github.com/friendica/friendica-addons.git /vagrant/addon \ No newline at end of file From b8b9675f598a2db360ad08b75826a6d703725433 Mon Sep 17 00:00:00 2001 From: hauke Date: Sat, 21 Jun 2014 20:26:11 +0200 Subject: [PATCH 3/3] remove NFS option for vagrant folder as this doesn't work on windows machines --- Vagrantfile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 147f248810..033cb230c8 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,8 +18,8 @@ hostname = "vaprobash.dev" # 172.16.0.1 - 172.31.255.254 # 192.168.0.1 - 192.168.255.254 server_ip = "192.168.22.10" -server_memory = "400" # MB -server_swap = "800" # Options: false | int (MB) - Guideline: Between one or two times the server_memory +server_memory = "384" # MB +server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory server_timezone = "UTC" # Database Configuration @@ -28,7 +28,7 @@ mysql_version = "5.5" # Options: 5.5 | 5.6 mysql_enable_remote = "false" # remote access enabled when true pgsql_root_password = "root" # We'll assume user "root" -# Languages and Packages +# Languages and Packages6 ruby_version = "latest" # Choose what ruby version should be installed (will also be the default version) ruby_gems = [ # List any Ruby Gems that you want to install #"jekyll", @@ -77,12 +77,6 @@ Vagrant.configure("2") do |config| # Create a static IP config.vm.network :private_network, ip: server_ip - # Use NFS for the shared folder - config.vm.synced_folder ".", "/vagrant", - id: "core", - :nfs => true, - :mount_options => ['nolock,vers=3,udp,noatime'] - # If using VirtualBox config.vm.provider :virtualbox do |vb| @@ -253,7 +247,7 @@ Vagrant.configure("2") do |config| # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh" # Install config Mailcatcher - # ls -config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" + # config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" # Install git-ftp # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false