diff --git a/.gitignore b/.gitignore index ee794cfa..b24485eb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ notes.md .vagrant play +*.log +scripts/projects +code/* # editor backup files *~ diff --git a/Vagrantfile b/Vagrantfile index 6eaa6169..a5d3806b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,10 +2,10 @@ # vi: set ft=ruby : # Config Github Settings -github_username = "fideloper" -github_repo = "Vaprobash" -github_branch = "1.4.2" -github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}" +github_url = "https://raw.githubusercontent.com/rattfieldnz/Vaprobash/master" + +vm_synced_folder_host = "code" +vm_synced_folder_guest = "/var/www" # Because this:https://developer.github.com/changes/2014-12-08-removing-authorizations-token/ # https://github.com/settings/tokens @@ -13,7 +13,8 @@ github_pat = "" # Server Configuration -hostname = "vaprobash.dev" +hostname = "vaprobash.localhost" +network_bridge = "Intel(R) Dual Band Wireless-AC 3165" # Set a local private network IP address. # See http://en.wikipedia.org/wiki/Private_network for explanation @@ -22,33 +23,35 @@ 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_cpus = "1" # Cores -server_memory = "384" # MB -server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory +server_cpus = "4" # Cores +server_memory = "4096" # MB +server_swap = "8192" # Options: false | int (MB) - Guideline: Between one or two times the server_memory +disk_space = "100GB" # UTC for Universal Coordinated Time # EST for Eastern Standard Time # CET for Central European Time # US/Central for American Central # US/Eastern for American Eastern -server_timezone = "UTC" +server_timezone = "Pacific/Auckland" # Database Configuration mysql_root_password = "root" # We'll assume user "root" -mysql_version = "5.5" # Options: 5.5 | 5.6 +mysql_version = "5.7" # Options: 5.5 | 5.6 | 5.7 mysql_enable_remote = "false" # remote access enabled when true pgsql_root_password = "root" # We'll assume user "root" -mongo_version = "2.6" # Options: 2.6 | 3.0 +mongo_version = "3.2" # Options: 2.6 | 3.0 | 3.2 mongo_enable_remote = "false" # remote access enabled when true # Languages and Packages -php_timezone = "UTC" # http://php.net/manual/en/timezones.php -php_version = "5.6" # Options: 5.5 | 5.6 | 7.0 | 7.1 +php_timezone = "Pacific/Auckland" # http://php.net/manual/en/timezones.php +php_version = "7.4" # Options: 5.5 | 5.6 | 7.0 | 7.1 | 7.2 | 7.3 | 7.4 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", + "sass", + "compass", + "capistrano", + "capistrano-laravel" ] go_version = "latest" # Example: go1.4 (latest equals the latest stable version) @@ -58,29 +61,50 @@ 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.*", + "phpunit/phpunit:~8.4", + "codeception/codeception:~3.1", + "phpspec/phpspec:~6.0", + "squizlabs/php_codesniffer:^3.5", + "unitgen/unitgen:dev-master", + "phpunit/php-code-coverage:^7.0", + "mihaeu/test-generator:^1.3" ] # Default web server document root # Symfony's public directory is assumed "web" # Laravel's public directory is assumed "public" -public_folder = "/vagrant" +public_folder = "/home/vagrant/code" + +#laravel_server_name = "laravel-test.#{server_ip}.xip.io" +#laravel_alias = "laravel-test.localhost" +#laravel_root_folder = "/var/www/laravel-test" # Where to install Laravel. Will `composer install` if a composer.json file exists +#laravel_version = "master" # If you need a specific version of Laravel, set it here -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. +#symfony_server_name = "symfony-test.#{server_ip}.xip.io" +#symfony_alias = "symfony-test.localhost" +#symfony_root_folder = "/var/www/symfony-test" # 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", + "npm", + "grunt-cli", + "gulp", + "bower", + "yarn", + "yo", + "gulp-concat-css", + "gulp-minify-css", + "gulp-clean-css", + "gulp-rename", + "gulp-ruby-sass", + "gulp-sourcemaps", + "gulp-uglify", + "notify-send", + "sw-precache-webpack-plugin", + "cross-env", + "laravel-mix", + "laravel-elixir" ] - # RabbitMQ settings rabbitmq_user = "user" rabbitmq_password = "password" @@ -91,9 +115,9 @@ elasticsearch_version = "2.3.1" # 5.0.0-alpha1, 2.3.1, 2.2.2, 2.1.2, 1.7.5 Vagrant.configure("2") do |config| - # Set server to Ubuntu 14.04 - config.vm.box = "ubuntu/trusty64" - + # Set server to Ubuntu 16.04 + config.vm.box = "ubuntu/bionic64" + config.vm.boot_timeout = 600 config.vm.define "Vaprobash" do |vapro| end @@ -111,20 +135,19 @@ Vagrant.configure("2") do |config| # Create a static IP if Vagrant.has_plugin?("vagrant-auto_network") - config.vm.network :private_network, :ip => "0.0.0.0", :auto_network => true + config.vm.network :private_network, :ip => "0.0.0.0", :auto_network => true, bridge: network_bridge else - config.vm.network :private_network, ip: server_ip + config.vm.network :private_network, ip: server_ip, bridge: network_bridge config.vm.network :forwarded_port, guest: 80, host: 8000 + config.vm.network :forwarded_port, guest: 3000, host: 3000 + config.vm.network :forwarded_port, guest: 22, host: 2200, id: 'ssh' end # Enable agent forwarding over SSH connections config.ssh.forward_agent = true # Use NFS for the shared folder - config.vm.synced_folder ".", "/vagrant", - id: "core", - :nfs => true, - :mount_options => ['nolock,vers=3,udp,noatime,actimeo=2,fsc'] + config.vm.synced_folder vm_synced_folder_host, vm_synced_folder_guest # Replicate local .gitconfig file if it exists if File.file?(File.expand_path("~/.gitconfig")) @@ -146,77 +169,88 @@ Vagrant.configure("2") do |config| # 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] + + vb.customize ['setextradata', :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate//vagrant", '1'] # Prevent VMs running on Ubuntu to lose internet connection # vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] # vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + + # Set initial disk size + if Vagrant.has_plugin?("vagrant-disksize") + config.disksize.size = "#{disk_space}" + end 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 + #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 + #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 # Adding vagrant-digitalocean provider - https://github.com/smdahlen/vagrant-digitalocean # Needs to ensure that the vagrant plugin is installed - config.vm.provider :digital_ocean do |provider, override| - override.ssh.private_key_path = '~/.ssh/id_rsa' - override.ssh.username = 'vagrant' - override.vm.box = 'digital_ocean' - override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box" - - provider.token = 'YOUR TOKEN' - provider.image = 'ubuntu-14-04-x64' - provider.region = 'nyc2' - provider.size = '512mb' - end + #config.vm.provider :digital_ocean do |provider, override| + # override.ssh.private_key_path = '~/.ssh/id_rsa' + # override.ssh.username = 'ubuntu' + # override.vm.box = 'digital_ocean' + # override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box" + # + # provider.token = 'YOUR TOKEN' + # provider.image = 'ubuntu-14-04-x64' + # provider.region = 'nyc2' + # provider.size = '512mb' + #end #### # Base Items + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Provision Base Packages - config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap, server_timezone] + config.vm.provision "shell", path: "./scripts/base.sh", privileged: true, args: [github_url, server_swap, server_timezone] # optimize base box - config.vm.provision "shell", path: "#{github_url}/scripts/base_box_optimizations.sh", privileged: true + config.vm.provision "shell", path: "./scripts/base_box_optimizations.sh", privileged: true # Provision PHP - config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [php_timezone, hhvm, php_version] + config.vm.provision "shell", path: "./scripts/php.sh", args: [php_timezone, hhvm, php_version] # Enable MSSQL for PHP - # config.vm.provision "shell", path: "#{github_url}/scripts/mssql.sh" + # config.vm.provision "shell", path: "./scripts/mssql.sh" # Provision Vim - # config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url + config.vm.provision "shell", path: "./scripts/vim.sh", args: github_url # Provision Docker - # config.vm.provision "shell", path: "#{github_url}/scripts/docker.sh", args: "permissions" + # config.vm.provision "shell", path: "./scripts/docker.sh", args: "permissions" #### # Web Servers + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Provision Apache Base - # config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url] + config.vm.provision "shell", path: "./scripts/apache.sh", args: [server_ip, "/var/www/html", hostname, github_url] # Provision Nginx Base # config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url, php_version] @@ -224,16 +258,18 @@ Vagrant.configure("2") do |config| #### # Databases + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Provision MySQL - # config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote] + config.vm.provision "shell", path: "./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 + # config.vm.provision "shell", path: "./scripts/pgsql.sh", args: pgsql_root_password # Provision SQLite - # config.vm.provision "shell", path: "#{github_url}/scripts/sqlite.sh" + #config.vm.provision "shell", path: "./scripts/sqlite.sh" # Provision RethinkDB # config.vm.provision "shell", path: "#{github_url}/scripts/rethinkdb.sh", args: pgsql_root_password @@ -245,118 +281,131 @@ Vagrant.configure("2") do |config| # config.vm.provision "shell", path: "#{github_url}/scripts/couchdb.sh" # Provision MongoDB - # config.vm.provision "shell", path: "#{github_url}/scripts/mongodb.sh", args: [mongo_enable_remote, mongo_version] + #config.vm.provision "shell", path: "./scripts/mongodb.sh", args: [mongo_enable_remote, mongo_version] # Provision MariaDB - # config.vm.provision "shell", path: "#{github_url}/scripts/mariadb.sh", args: [mysql_root_password, mysql_enable_remote] + # config.vm.provision "shell", path: "./scripts/mariadb.sh", args: [mysql_root_password, mysql_enable_remote] # Provision Neo4J - # config.vm.provision "shell", path: "#{github_url}/scripts/neo4j.sh" + # config.vm.provision "shell", path: "./scripts/neo4j.sh" #### # Search Servers + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Install Elasticsearch - # config.vm.provision "shell", path: "#{github_url}/scripts/elasticsearch.sh", args: [elasticsearch_version] + # config.vm.provision "shell", path: "./scripts/elasticsearch.sh", args: [elasticsearch_version] # Install SphinxSearch - # config.vm.provision "shell", path: "#{github_url}/scripts/sphinxsearch.sh", args: [sphinxsearch_version] + # config.vm.provision "shell", path: "./scripts/sphinxsearch.sh", args: [sphinxsearch_version] #### # Search Server Administration (web-based) + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Install ElasticHQ # Admin for: Elasticsearch # Works on: Apache2, Nginx - # config.vm.provision "shell", path: "#{github_url}/scripts/elastichq.sh" + # config.vm.provision "shell", path: "./scripts/elastichq.sh" #### # In-Memory Stores + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Install Memcached - # config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh" + config.vm.provision "shell", path: "./scripts/memcached.sh" # Provision Redis (without journaling and persistence) - # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh" + config.vm.provision "shell", path: "./scripts/redis.sh" # Provision Redis (with journaling and persistence) - # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh", args: "persistent" + # config.vm.provision "shell", path: "./scripts/redis.sh", args: "persistent" # NOTE: It is safe to run this to add persistence even if originally provisioned without persistence #### # Utility (queue) + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Install Beanstalkd - # config.vm.provision "shell", path: "#{github_url}/scripts/beanstalkd.sh" + # config.vm.provision "shell", path: "./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" + # config.vm.provision "shell", path: "./scripts/supervisord.sh" # Install Kibana - # config.vm.provision "shell", path: "#{github_url}/scripts/kibana.sh" + # config.vm.provision "shell", path: "./scripts/kibana.sh" # Install ØMQ - # config.vm.provision "shell", path: "#{github_url}/scripts/zeromq.sh", args: [php_version] + # config.vm.provision "shell", path: "./scripts/zeromq.sh", args: [php_version] # Install RabbitMQ - # config.vm.provision "shell", path: "#{github_url}/scripts/rabbitmq.sh", args: [rabbitmq_user, rabbitmq_password] + # config.vm.provision "shell", path: "./scripts/rabbitmq.sh", args: [rabbitmq_user, rabbitmq_password] #### # Additional Languages + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Install Nodejs - # config.vm.provision "shell", path: "#{github_url}/scripts/nodejs.sh", privileged: false, args: nodejs_packages.unshift(nodejs_version, github_url) + config.vm.provision "shell", path: "./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) + config.vm.provision "shell", path: "./scripts/rvm.sh", privileged: false, args: ruby_gems.unshift(ruby_version) # Install Go Version Manager (GVM) - # config.vm.provision "shell", path: "#{github_url}/scripts/go.sh", privileged: false, args: [go_version] + # config.vm.provision "shell", path: "./scripts/go.sh", privileged: false, args: [go_version] #### # Frameworks and Tooling + # + # NOTE!: Comment out lines for scripts you don't want to run! ########## # Provision Composer # You may pass a github auth token as the first argument - # config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: [github_pat, composer_packages.join(" ")] + config.vm.provision "shell", path: "./scripts/composer.sh", privileged: false, args: [github_pat, 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] + #config.vm.provision "shell", path: "./scripts/laravel.sh", privileged: false, args: [laravel_root_folder, laravel_version, server_ip] # Provision Symfony - # config.vm.provision "shell", path: "#{github_url}/scripts/symfony.sh", privileged: false, args: [server_ip, symfony_root_folder, public_folder] + #config.vm.provision "shell", path: "./scripts/symfony.sh", privileged: false, args: [symfony_root_folder, server_ip] # Install Screen - # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh" + config.vm.provision "shell", path: "./scripts/screen.sh" # Install Mailcatcher - # config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh", args: [php_version] + config.vm.provision "shell", path: "./scripts/mailcatcher.sh", args: [php_version] # Install git-ftp - # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false + # config.vm.provision "shell", path: "./scripts/git-ftp.sh", privileged: false # Install Ansible - # config.vm.provision "shell", path: "#{github_url}/scripts/ansible.sh" + # config.vm.provision "shell", path: "./scripts/ansible.sh" # Install Android - # config.vm.provision "shell", path: "#{github_url}/scripts/android.sh" + # config.vm.provision "shell", path: "./scripts/android.sh" #### # 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: "./local-script.sh" + # config.vm.provision "shell", path: "./your_script_name.sh" + config.vm.provision "shell", path: "./scripts/install_phpmyadmin.sh" -end +end \ No newline at end of file diff --git a/code/.gitignore b/code/.gitignore new file mode 100644 index 00000000..4f085348 --- /dev/null +++ b/code/.gitignore @@ -0,0 +1,31 @@ +vendor/ +node_modules/ +storage/* + +# Laravel 4 specific +bootstrap/compiled.php +app/storage/ + +# Laravel 5 & Lumen specific +bootstrap/cache/ +.env.*.php +.env.php +.env + +# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer +.rocketeer/ + +_ide_helper.php +.phpstorm.meta.php +_ide_helper_models.php +/.idea + +# PHP CS Fixer +.php_cs.cache + +# Keep views from Laravel packages. +!/resources/views/vendor/ + +npm-debug.log +.yarnclean +*.log diff --git a/helpers/ngxcb.sh b/helpers/ngxcb.sh index 15f01e0d..2163cca8 100644 --- a/helpers/ngxcb.sh +++ b/helpers/ngxcb.sh @@ -44,7 +44,7 @@ function create_server_block { # Nginx Server Block config for PHP (without using SSL) read -d '' PHP_NO_SSL </dev/null; then - echo >&2 "!!! You need to install git" - exit 1 -fi +NVMSCRIPTURL="https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh" -if [ -d "$NVM_DIR" ]; then - echo ">>> NVM is already installed in $NVM_DIR, trying to update" - echo -ne "\r=> " - cd $NVM_DIR && git pull -else - # Cloning to $NVM_DIR - git clone https://github.com/creationix/nvm.git $NVM_DIR -fi +# The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc). +curl -sL $NVMSCRIPTURL -o install_nvm.sh +bash install_nvm.sh -PROFILE="/home/vagrant/.profile" -SOURCE_STR="\n# This loads NVM\n[[ -s /home/vagrant/.nvm/nvm.sh ]] && . /home/vagrant/.nvm/nvm.sh" +printf '\n\nexport NVM_DIR=~/.nvm +[ -s "~/.nvm/nvm.sh" ] && . "~/.nvm/nvm.sh"' >> $PROFILE -# Append NVM script to ~/.profile -if ! grep -qsc 'nvm.sh' $PROFILE; then - echo ">>> Appending source string to $PROFILE" - printf "$SOURCE_STR" >> "$PROFILE" -else - echo ">>> Source string already in $PROFILE" -fi \ No newline at end of file +printf '\n\nexport NVM_DIR=~/.nvm +[ -s "~/.nvm/nvm.sh" ] && . "~/.nvm/nvm.sh"' >> $BASHRC + +source $PROFILE +source $BASHRC diff --git a/helpers/vhost.sh b/helpers/vhost.sh index e07c4e97..105223ab 100644 --- a/helpers/vhost.sh +++ b/helpers/vhost.sh @@ -42,7 +42,7 @@ cat <<- _EOF_ ServerAdmin webmaster@localhost ServerName $ServerName - $ServerAlias + ServerAlias $ServerAlias DocumentRoot $DocumentRoot @@ -174,14 +174,14 @@ if [ -f "$DocumentRoot/$ServerName.conf" ]; then echo 'vHost already exists. Aborting' show_usage else - create_vhost > /etc/apache2/sites-available/${ServerName}.conf + sudo create_vhost > /etc/apache2/sites-available/${ServerName}.conf # Add :443 handling if [ "$CertPath" != "" ]; then - create_ssl_vhost >> /etc/apache2/sites-available/${ServerName}.conf + sudo create_ssl_vhost >> /etc/apache2/sites-available/${ServerName}.conf fi # Enable Site - cd /etc/apache2/sites-available/ && a2ensite ${ServerName}.conf - service apache2 reload -fi \ No newline at end of file + sudo a2ensite ${ServerName}.conf + sudo service apache2 reload +fi diff --git a/helpers/vimrc b/helpers/vimrc index 1aac4583..db61a151 100644 --- a/helpers/vimrc +++ b/helpers/vimrc @@ -1,33 +1,38 @@ set nocompatible filetype off set encoding=utf-8 +syntax enable set rtp+=~/.vim/bundle/vundle/ -call vundle#rc() +call vundle#begin() " let Vundle manage Vundle -Bundle 'gmarik/vundle' +Plugin 'VundleVim/Vundle.vim' " Bundles Here -Bundle 'altercation/vim-colors-solarized' -Bundle 'plasticboy/vim-markdown' -Bundle 'othree/html5.vim' -Bundle 'scrooloose/nerdtree' -Bundle 'kien/ctrlp.vim' -Bundle 'bling/vim-airline' -Bundle 'airblade/vim-gitgutter' -Bundle 'tpope/vim-fugitive' +Plugin 'altercation/vim-colors-solarized' +Plugin 'plasticboy/vim-markdown' +Plugin 'othree/html5.vim' +Plugin 'scrooloose/nerdtree' +Plugin 'kien/ctrlp.vim' +Plugin 'bling/vim-airline' +Plugin 'airblade/vim-gitgutter' +Plugin 'tpope/vim-fugitive' + +call vundle#end() + +colorscheme solarized filetype plugin indent on " "" Brief help -" :BundleList - list configured bundles -" " :BundleInstall(!) - install (update) bundles -" " :BundleSearch(!) foo - search (or refresh cache first) for foo -" " :BundleClean(!) - confirm (or auto-approve) removal of unused bundles -" " -" " see :h vundle for more details or wiki for FAQ -" " NOTE: comments after Bundle commands are not allowed. +" :PluginList - lists configured plugins +" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate +" :PluginSearch foo - searches for foo; append `!` to refresh local cache +" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal +" +" see :h vundle for more details or wiki for FAQ +" Put your non-Plugin stuff after this line " Settings diff --git a/projects/.gitignore b/projects/.gitignore new file mode 100644 index 00000000..8089c6d2 --- /dev/null +++ b/projects/.gitignore @@ -0,0 +1,6 @@ +* +*/ +*.sh +*.log +projects/*.sh +!.gitignore \ No newline at end of file diff --git a/readme.md b/readme.md index f3a065f6..d5321f24 100644 --- a/readme.md +++ b/readme.md @@ -2,15 +2,15 @@ **Va**​grant **Pro**​visioning **Bash** Scripts -[View the site and extended docs.](http://fideloper.github.io/Vaprobash/index.html) +[View the site and extended docs](http://fideloper.github.io/Vaprobash/index.html). -[![Build Status](https://travis-ci.org/fideloper/Vaprobash.png?branch=master)](https://travis-ci.org/fideloper/Vaprobash) +[![Build Status](https://travis-ci.org/rattfieldnz/Vaprobash.png?branch=master)](https://travis-ci.org/rattfieldnz/Vaprobash) ## Goal The goal of this project is to create easy to use bash scripts in order to provision a Vagrant server. -1. This targets Ubuntu LTS releases, currently 14.04.* +1. This targets Ubuntu LTS releases, currently 16.04.* 2. This project will give users various popular options such as LAMP, LEMP 3. This project will attempt some modularity. For example, users might choose to install a Vim setup, or not. @@ -24,6 +24,7 @@ Some further assumptions and self-imposed restrictions. If you find yourself nee * Vagrant `1.5.0`+ * Use `vagrant -v` to check your version * Vitualbox or VMWare Fusion +* Vagrant plugin `vagrant-disksize` ## Instructions @@ -31,10 +32,10 @@ Some further assumptions and self-imposed restrictions. If you find yourself nee ```bash # curl -$ curl -L http://bit.ly/vaprobash > Vagrantfile +$ curl -L http://bit.ly/rattfieldnz-vaprobash > Vagrantfile # wget -$ wget -O Vagrantfile http://bit.ly/vaprobash +$ wget -O Vagrantfile http://bit.ly/rattfieldnz-vaprobash ``` > The `bit.ly` link will always point to the master branch version of the Vagrantfile. diff --git a/scripts/android.sh b/scripts/android.sh index 913b1fa9..beb27d09 100644 --- a/scripts/android.sh +++ b/scripts/android.sh @@ -12,25 +12,27 @@ sudo apt-get install -y openjdk-7-jdk ant expect curl -O $ANDROID_SDK tar -xzvf $ANDROID_SDK_FILENAME -# Add permissions for vagrant user and removing .tgz file -sudo chown -R vagrant android-sdk-linux/ +# Add permissions for ubuntu user and removing .tgz file +sudo chown -R ubuntu android-sdk-linux/ sudo rm -rf $ANDROID_SDK_FILENAME # Add new values of variables environment in .bashrc -echo "" >> /home/vagrant/.bashrc -echo "JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java" >> /home/vagrant/.bashrc -echo "ANDROID_HOME=~/android-sdk-linux" >> /home/vagrant/.bashrc -echo "export PATH=\$PATH:~/android-sdk-linux/tools:~/android-sdk-linux/platform-tools" >> /home/vagrant/.bashrc +echo "" >> /home/ubuntu/.bashrc +echo "JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java" >> /home/ubuntu/.bashrc +echo "ANDROID_HOME=~/android-sdk-linux" >> /home/ubuntu/.bashrc +echo "export PATH=\$PATH:~/android-sdk-linux/tools:~/android-sdk-linux/platform-tools" >> /home/ubuntu/.bashrc expect -c ' set timeout -1 ; -spawn /home/vagrant/android-sdk-linux/tools/android update sdk -u --all --filter platform-tool,android-19,build-tools-19.1.0 +spawn /home/ubuntu/android-sdk-linux/tools/android update sdk -u --all --filter platform-tool,android-19,build-tools-19.1.0 expect { "Do you accept the license" { exp_send "y\r" ; exp_continue } eof } ' -sudo /home/vagrant/android-sdk-linux/platform-tools/adb kill-server -sudo /home/vagrant/android-sdk-linux/platform-tools/adb start-server -sudo /home/vagrant/android-sdk-linux/platform-tools/adb devices +sudo /home/ubuntu/android-sdk-linux/platform-tools/adb kill-server +sudo /home/ubuntu/android-sdk-linux/platform-tools/adb start-server +sudo /home/ubuntu/android-sdk-linux/platform-tools/adb devices + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/ansible.sh b/scripts/ansible.sh index e25996f2..97c7255c 100644 --- a/scripts/ansible.sh +++ b/scripts/ansible.sh @@ -11,3 +11,5 @@ sudo apt-get update # Intall ansible sudo apt-get install -y ansible + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/apache.sh b/scripts/apache.sh index f52c4450..daeb1503 100644 --- a/scripts/apache.sh +++ b/scripts/apache.sh @@ -3,6 +3,9 @@ # Test if PHP is installed php -v > /dev/null 2>&1 PHP_IS_INSTALLED=$? +PHP_INSTALLED_VERSION=$? + +[[ $PHP_IS_INSTALLED -eq 0 ]] && { PHP_INSTALLED_VERSION=$(php -r "echo PHP_VERSION;" | cut -c 1,2,3); } # Test if HHVM is installed hhvm --version > /dev/null 2>&1 @@ -16,17 +19,23 @@ echo ">>> Installing Apache Server" [[ -z $1 ]] && { echo "!!! IP address not set. Check the Vagrant file."; exit 1; } if [[ -z $2 ]]; then - public_folder="/vagrant" + public_folder="/home/vagrant/code" else public_folder="$2" fi if [[ -z $4 ]]; then - github_url="https://raw.githubusercontent.com/fideloper/Vaprobash/master" + github_url="https://raw.githubusercontent.com/rattfieldnz/Vaprobash/master" else github_url="$4" fi +if [[ -z $5 ]]; then + php_version="7.2" +else + php_version="$5" +fi + # Add repo for latest FULL stable Apache # (Required to remove conflicts with PHP PPA due to partial Apache upgrade within it) sudo add-apt-repository -y ppa:ondrej/apache2 @@ -42,14 +51,14 @@ sudo apt-get install -qq apache2 echo ">>> Configuring Apache" -# Add vagrant user to www-data group -sudo usermod -a -G www-data vagrant +# Add ubuntu user to www-data group +sudo usermod -a -G www-data ubuntu # Apache Config # On separate lines since some may cause an error # if not installed sudo a2dismod mpm_prefork mpm_worker -sudo a2dismod php5 +sudo a2dismod php${PHP_INSTALLED_VERSION} sudo a2enmod rewrite actions ssl curl --silent -L $github_url/helpers/vhost.sh > vhost sudo chmod guo+x vhost @@ -70,4 +79,7 @@ else sudo sed -i "s@ProxyPassMatch@#ProxyPassMatch@" /etc/apache2/sites-available/$1.xip.io.conf fi +sudo a2enmod php${PHP_INSTALLED_VERSION} +sudo a2enmod headers sudo service apache2 restart +sudo apt -f -y autoremove --purge diff --git a/scripts/base.sh b/scripts/base.sh index 803ac059..695c435d 100644 --- a/scripts/base.sh +++ b/scripts/base.sh @@ -1,27 +1,31 @@ #!/usr/bin/env bash -echo "Setting Timezone & Locale to $3 & en_US.UTF-8" +echo "Setting Timezone & Locale to $3 & en_NZ.UTF-8" + +# Update +sudo apt-get update && sudo apt-get -f -y upgrade && sudo apt-get -f -y dist-upgrade sudo ln -sf /usr/share/zoneinfo/$3 /etc/localtime sudo apt-get install -qq language-pack-en -sudo locale-gen en_US -sudo update-locale LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 +sudo locale-gen en_NZ +sudo update-locale LANG=en_NZ.UTF-8 LC_CTYPE=en_NZ.UTF-8 echo ">>> Installing Base Packages" -if [[ -z $1 ]]; then - github_url="https://raw.githubusercontent.com/fideloper/Vaprobash/master" -else - github_url="$1" -fi - -# Update -sudo apt-get update - # Install base packages # -qq implies -y --force-yes -sudo apt-get install -qq curl unzip git-core ack-grep software-properties-common build-essential cachefilesd +sudo apt-get install -qq vim build-essential python-software-properties git zip unzip tcl curl git-core ack-grep software-properties-common cachefilesd virtualbox-guest-dkms openssl pkg-config libssl-dev libsslcommon2-dev libpng-dev libjpeg-dev libwebp-dev imagemagick libmagickcore-dev libmagickwand-dev resolvconf network-manager + +echo ">>> Installing Git Secrets" +git clone https://github.com/awslabs/git-secrets.git +cd git-secrets +make test && sudo make install +echo ">>> Configure networking and nameserver properties" +sudo echo "nameserver 192.168.1.100 1.1.1.1" > /etc/resolvconf/resolv.conf.d/base +sudo service resolvconf restart +sudo service networkd-dispatcher restart +sudo service network-manager restart echo ">>> Installing *.xip.io self-signed SSL" @@ -31,12 +35,12 @@ PASSPHRASE="vaprobash" SUBJ=" C=US -ST=Connecticut +ST=California O=Vaprobash -localityName=New Haven +localityName=Los Angeles commonName=$DOMAIN -organizationalUnitName= -emailAddress= +organizationalUnitName=Vaprobash +emailAddress=vaprobash@test.com " sudo mkdir -p "$SSL_DIR" diff --git a/scripts/base_box_optimizations.sh b/scripts/base_box_optimizations.sh index 97641fbc..0e2e4f4c 100644 --- a/scripts/base_box_optimizations.sh +++ b/scripts/base_box_optimizations.sh @@ -14,4 +14,4 @@ fi perl -pi -e 's@^\s*(deb(\-src)?)\s+http://us.archive.*?\s+@\1 mirror://mirrors.ubuntu.com/mirrors.txt @g' /etc/apt/sources.list # update repositories -apt-get update +sudo apt-get update diff --git a/scripts/beanstalkd.sh b/scripts/beanstalkd.sh index 99ab98ad..9c1f643b 100644 --- a/scripts/beanstalkd.sh +++ b/scripts/beanstalkd.sh @@ -11,3 +11,5 @@ sudo sed -i "s/#START=yes/START=yes/" /etc/default/beanstalkd # Start Beanstalkd sudo service beanstalkd start + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/composer.sh b/scripts/composer.sh index 63638916..4c764db2 100644 --- a/scripts/composer.sh +++ b/scripts/composer.sh @@ -18,6 +18,9 @@ COMPOSER_IS_INSTALLED=$? GITHUB_OAUTH=$1 COMPOSER_PACKAGES=$2 +PROFILE=~/.profile +BASHRC=~/.bashrc + # True, if composer is not installed if [[ $COMPOSER_IS_INSTALLED -ne 0 ]]; then echo ">>> Installing Composer" @@ -28,15 +31,31 @@ if [[ $COMPOSER_IS_INSTALLED -ne 0 ]]; then sudo mv composer.phar /usr/local/bin/composer sudo rm installer - # Add an alias that will allow us to use composer without timeout's - printf "\n# Add an alias for sudo\n%s\n# Use HHVM when using Composer\n%s" \ - "alias sudo=\"sudo \"" \ - "alias composer=\"hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false /usr/local/bin/composer\"" \ - >> "/home/vagrant/.profile" - # Resource .profile # Doesn't seem to work do! The alias is only usefull from the moment you log in: vagrant ssh - . /home/vagrant/.profile + + # Re-source .profile if exists + if [[ -f $PROFILE ]]; then + + # Add an alias that will allow us to use composer without timeout's + printf "\n# Add an alias for sudo\n%s\n# Use HHVM when using Composer\n%s" \ + "alias sudo=\"sudo \"" \ + "alias composer=\"hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false /usr/local/bin/composer\"" \ + >> $PROFILE + + source $PROFILE + fi + + # Re-source .bashrc if exists + if [[ -f $BASHRC ]]; then + + # Add an alias that will allow us to use composer without timeout's + printf "\n# Add an alias for sudo\n%s\n# Use HHVM when using Composer\n%s" \ + "alias sudo=\"sudo \"" \ + "alias composer=\"hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false /usr/local/bin/composer\"" \ + >> $BASHRC + source $BASHRC + fi else # Install Composer curl -sS https://getcomposer.org/installer | php @@ -66,17 +85,17 @@ if [[ ! -z $COMPOSER_PACKAGES ]]; then echo " " ${COMPOSER_PACKAGES[@]} # Add Composer's Global Bin to ~/.profile path - if [[ -f "/home/vagrant/.profile" ]]; then - if ! grep -qsc 'COMPOSER_HOME=' /home/vagrant/.profile; then + if [[ -f $PROFILE ]]; then + if ! grep -qsc 'COMPOSER_HOME=' $PROFILE; then # Ensure COMPOSER_HOME variable is set. This isn't set by Composer automatically - printf "\n\nCOMPOSER_HOME=\"/home/vagrant/.composer\"" >> /home/vagrant/.profile + printf "\n\nCOMPOSER_HOME=\"/home/vagrant/.composer\"" >> $PROFILE # Add composer home vendor bin dir to PATH to run globally installed executables - printf "\n# Add Composer Global Bin to PATH\n%s" 'export PATH=$PATH:$COMPOSER_HOME/vendor/bin' >> /home/vagrant/.profile + printf "\n# Add Composer Global Bin to PATH\n%s" 'export PATH=$PATH:$COMPOSER_HOME/vagrant/bin' >> $PROFILE - # Source the .profile to pick up changes - . /home/vagrant/.profile - fi - fi + source $PROFILE + source $BASHRC + fi + fi if [[ $HHVM_IS_INSTALLED -eq 0 ]]; then hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false /usr/local/bin/composer global require ${COMPOSER_PACKAGES[@]} diff --git a/scripts/couchbase.sh b/scripts/couchbase.sh index 3ddd5a95..5bc13cde 100644 --- a/scripts/couchbase.sh +++ b/scripts/couchbase.sh @@ -4,7 +4,7 @@ echo ">>> Installing Couchbase Server" # Set some variables COUCHBASE_EDITION=community -COUCHBASE_VERSION=2.2.0 # Check http://http://www.couchbase.com/download/ for latest version +COUCHBASE_VERSION=6.0.3 # Check https://www.couchbase.com/downloads for latest version COUCHBASE_ARCH=x86_64 @@ -18,7 +18,7 @@ PHP_IS_INSTALLED=$? dpkg -s php-pear PEAR_IS_INSTALLED=$? -dpkg -s php5-dev +dpkg -s php7.1-dev PHPDEV_IS_INSTALLED=$? if [ ${PHP_IS_INSTALLED} -eq 0 ]; then @@ -28,20 +28,23 @@ if [ ${PHP_IS_INSTALLED} -eq 0 ]; then fi if [ ${PHPDEV_IS_INSTALLED} -eq 1 ]; then - sudo apt-get -qq install php5-dev + sudo apt-get -qq install php-dev fi sudo wget --quiet -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1204.list wget --quiet -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add - sudo apt-get update sudo apt-get -qq install libcouchbase2-libevent libcouchbase-dev - - sudo pecl install couchbase-1.2.2 - sudo cat > /etc/php5/mods-available/couchbase.ini << EOF + + sudo pecl channel-update pecl.php.net + sudo pecl install couchbase-${COUCHBASE_VERSION} + sudo cat > /etc/php/7.1/mods-available/couchbase.ini << EOF ; configuration for php couchbase module ; priority=30 extension=couchbase.so EOF - sudo php5enmod couchbase - sudo service php5-fpm restart -fi \ No newline at end of file + sudo php7.1enmod couchbase + sudo service php7.1-fpm restart +fi + +sudo apt -f -y autoremove --purge diff --git a/scripts/couchdb.sh b/scripts/couchdb.sh index fc0ed243..50483ab8 100755 --- a/scripts/couchdb.sh +++ b/scripts/couchdb.sh @@ -7,4 +7,6 @@ echo ">>> Installing CouchDB" sudo apt-get install -qq couchdb # Make Futon Available -sudo sed -i 's/;bind_address = 127.0.0.1/bind_address = 0.0.0.0/' /etc/couchdb/local.ini \ No newline at end of file +sudo sed -i 's/;bind_address = 127.0.0.1/bind_address = 0.0.0.0/' /etc/couchdb/local.ini + +sudo apt -f -y autoremove --purge diff --git a/scripts/docker.sh b/scripts/docker.sh index 2a51764b..0d9aa208 100644 --- a/scripts/docker.sh +++ b/scripts/docker.sh @@ -22,3 +22,5 @@ if [ ! -z "$1" ]; then fi # permissions fi # arg check + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/elastichq.sh b/scripts/elastichq.sh index 687e5b1a..4229bccc 100644 --- a/scripts/elastichq.sh +++ b/scripts/elastichq.sh @@ -47,7 +47,7 @@ sudo tee -a /etc/nginx/sites-available/vagrant > /dev/null <<'EOF' location ~ ^/elastichq/(.+\.php)$ { try_files $uri =404; root /usr/share/; - fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass unix:/var/run/php7.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; @@ -67,3 +67,5 @@ EOF # Reload Nginx to load in configuration sudo service nginx reload fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/elasticsearch.sh b/scripts/elasticsearch.sh index faf98e76..67ffff60 100644 --- a/scripts/elasticsearch.sh +++ b/scripts/elasticsearch.sh @@ -22,3 +22,5 @@ sudo service elasticsearch restart # Configure to start up Elasticsearch automatically sudo update-rc.d elasticsearch defaults 95 10 + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/go.sh b/scripts/go.sh index d8ab9dcb..9825d955 100755 --- a/scripts/go.sh +++ b/scripts/go.sh @@ -2,9 +2,9 @@ # check if a go version is set if [[ -z $1 ]]; then - GO_VERSION="latest" + GO_VERSION="latest" else - GO_VERSION=$1 + GO_VERSION=$1 fi # Check if gvm is installed @@ -29,3 +29,5 @@ else gvm install $GO_VERSION --prefer-binary gvm use $GO_VERSION --default fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/install_phpmyadmin.sh b/scripts/install_phpmyadmin.sh new file mode 100644 index 00000000..8685f1e6 --- /dev/null +++ b/scripts/install_phpmyadmin.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +echo "Lets update our packages list, and currently installed packages...\n"; +sudo apt-get update; +sudo apt-get -f -y upgrade; +sudo apt-get -f -y dist-upgrade; + +echo "Set-up MySQL and phpMyAdmin (for development purposes ONLY).\n" +DBHOST=localhost +DBUSER=root +DBPASSWD=root + +export DEBIAN_FRONTEND="noninteractive" + +sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password $DBPASSWD'; +sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password $DBPASSWD' +sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/dbconfig-install boolean true'; +sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/app-password-confirm password $DBPASSWD'; +sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/admin-pass password $DBPASSWD'; +sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/app-pass password $DBPASSWD'; +sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect none'; +sudo apt-get -f -y install phpmyadmin; + +echo "Set-up Apache Vhost file (assuming phpMyAdmin has been installed to /usr/share/phpmyadmin.\n" +if [ -d "/usr/share/phpmyadmin" ]; then +sudo echo " + ServerName phpmyadmin.localhost + ServerAlias phpmyadmin.localhost + DocumentRoot /usr/share/phpmyadmin + + Options FollowSymLinks + DirectoryIndex index.php + + + AddType application/x-httpd-php .php + + + SetHandler application/x-httpd-php + + php_flag magic_quotes_gpc Off + php_flag track_vars On + php_flag register_globals Off + php_admin_flag allow_url_fopen On + php_value include_path . + php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp + php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/ + + + + # Authorize for setup + + + + AuthType Basic + AuthName \"phpMyAdmin Setup\" + AuthUserFile /etc/phpmyadmin/htpasswd.setup + + Require valid-user + + + + # Disallow web access to directories that don't need it + + Require all denied + + + Require all denied + +" > /etc/apache2/sites-available/phpmyadmin.localhost.conf +sudo a2ensite phpmyadmin.localhost.conf +sudo service apache2 reload +fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/laravel.sh b/scripts/laravel.sh index 3298e805..6789fa2e 100644 --- a/scripts/laravel.sh +++ b/scripts/laravel.sh @@ -15,14 +15,14 @@ HHVM_IS_INSTALLED=$? # Test if Composer is installed composer -v > /dev/null 2>&1 || { printf "!!! Composer is not installed.\n Installing Laravel aborted!"; exit 0; } -# Test if Server IP is set in Vagrantfile -[[ -z "$1" ]] && { printf "!!! IP address not set. Check the Vagrantfile.\n Installing Laravel aborted!\n"; exit 0; } +# Test if Server Name is set in Vagrantfile +[[ -z "$1" ]] && { printf "!!! Server name address not set. Check the Vagrantfile.\n Installing Laravel aborted!\n"; exit 0; } # Check if Laravel root is set. If not set use default -if [[ -z $2 ]]; then - laravel_root_folder="/vagrant/laravel" +if [[ -z $laravel_root_folder ]]; then + laravel_root_folder="/var/www/laravel-test" else - laravel_root_folder="$2" + laravel_root_folder="$laravel_root_folder" fi laravel_public_folder="$laravel_root_folder/public" @@ -42,23 +42,23 @@ fi if [[ ! -f "$laravel_root_folder/composer.json" ]]; then if [[ $HHVM_IS_INSTALLED -eq 0 ]]; then # Create Laravel - if [[ "$4" == 'latest-stable' ]]; then + if [[ "$laravel_version" == 'latest-stable' || "$laravel_version" == '' ]]; then hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false /usr/local/bin/composer \ create-project --prefer-dist laravel/laravel $laravel_root_folder else hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false /usr/local/bin/composer \ - create-project laravel/laravel:$4 $laravel_root_folder + create-project laravel/laravel:$laravel_version $laravel_root_folder fi else # Create Laravel - if [[ "$4" == 'latest-stable' ]]; then + if [[ "$laravel_version" == 'latest-stable' || "$laravel_version" == '' ]]; then composer create-project --prefer-dist laravel/laravel $laravel_root_folder else - composer create-project laravel/laravel:$4 $laravel_root_folder + composer create-project laravel/laravel:$laravel_version $laravel_root_folder fi fi else - # Go to vagrant folder + # Go to Laravel folder cd $laravel_root_folder if [[ $HHVM_IS_INSTALLED -eq 0 ]]; then @@ -74,17 +74,18 @@ fi if [[ $NGINX_IS_INSTALLED -eq 0 ]]; then # Change default vhost created - sudo sed -i "s@root /vagrant@root $laravel_public_folder@" /etc/nginx/sites-available/vagrant + sudo sed -i "s@root /vagrant@root $laravel_public_folder@" /etc/nginx/sites-available/"laravel-test.$server_ip.xip.io" sudo service nginx reload fi if [[ $APACHE_IS_INSTALLED -eq 0 ]]; then - # Find and replace to find public_folder and replace with laravel_public_folder - # Change DocumentRoot - # Change ProxyPassMatch fcgi path - # Change path - sudo sed -i "s@$3@$laravel_public_folder@" /etc/apache2/sites-available/$1.xip.io.conf + # Make Laravel storage folder readable and writeable, + # and accessable by Apache. + chown -R www-data:www-data $laravel_root_folder/storage + chmod -R 755 $laravel_root_folder/storage + + sudo vhost -s "laravel-test.192.168.22.10.xip.io" -a "laravel-test.localhost" -d $laravel_public_folder - sudo service apache2 reload + sudo service apache2 restart fi diff --git a/scripts/mailcatcher.sh b/scripts/mailcatcher.sh index 90970e00..73e92e2e 100644 --- a/scripts/mailcatcher.sh +++ b/scripts/mailcatcher.sh @@ -14,18 +14,18 @@ APACHE_IS_INSTALLED=$? # Installing dependency # -qq implies -y --force-yes -sudo apt-get install -qq libsqlite3-dev ruby1.9.1-dev +sudo apt-get install -qq libsqlite3-dev ruby-dev if $(which rvm) -v > /dev/null 2>&1; then - echo ">>>>Installing with RVM" - $(which rvm) default@mailcatcher --create do gem install --no-rdoc --no-ri mailcatcher - $(which rvm) wrapper default@mailcatcher --no-prefix mailcatcher catchmail + echo ">>>>Installing with RVM" + $(which rvm) default@mailcatcher --create do gem install --no-rdoc --no-ri mailcatcher + $(which rvm) wrapper default@mailcatcher --no-prefix mailcatcher catchmail else - # Gem check - if ! gem -v > /dev/null 2>&1; then sudo aptitude install -y libgemplugin-ruby; fi + # Gem check + if ! gem -v > /dev/null 2>&1; then sudo aptitude install -y libgemplugin-ruby; fi - # Install - gem install --no-rdoc --no-ri mailcatcher + # Install + gem install --no-rdoc --no-ri mailcatcher fi # Make it start on boot @@ -44,12 +44,14 @@ EOL sudo service mailcatcher start if [[ $PHP_IS_INSTALLED -eq 0 ]]; then - # Make php use it to send mail + # Make php use it to send mail echo "sendmail_path = /usr/bin/env $(which catchmail)" | sudo tee /etc/php/${PHP_VERSION}/mods-available/mailcatcher.ini - sudo phpenmod mailcatcher - sudo service php${PHP_VERSION}-fpm restart + sudo phpenmod mailcatcher + sudo service php${PHP_VERSION}-fpm restart fi if [[ $APACHE_IS_INSTALLED -eq 0 ]]; then - sudo service apache2 restart + sudo service apache2 restart fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/mariadb.sh b/scripts/mariadb.sh index d89cacd3..05bd0beb 100644 --- a/scripts/mariadb.sh +++ b/scripts/mariadb.sh @@ -11,7 +11,7 @@ MARIADB_VERSION='10.1' sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db # Add repo for MariaDB -sudo add-apt-repository "deb [arch=amd64,i386] http://mirrors.accretive-networks.net/mariadb/repo/$MARIADB_VERSION/ubuntu trusty main" +sudo add-apt-repository "deb [arch=amd64,i386] http://mirrors.accretive-networks.net/mariadb/repo/$MARIADB_VERSION/ubuntu bionic main" # Update sudo apt-get update @@ -43,3 +43,5 @@ if [ $2 == "true" ]; then service mysql restart fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/memcached.sh b/scripts/memcached.sh index 07f2cacc..a269fe9c 100644 --- a/scripts/memcached.sh +++ b/scripts/memcached.sh @@ -3,3 +3,5 @@ # Install Memcached # -qq implies -y --force-yes sudo apt-get install -qq memcached + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/mongodb.sh b/scripts/mongodb.sh index d245ab7f..003faebc 100644 --- a/scripts/mongodb.sh +++ b/scripts/mongodb.sh @@ -3,14 +3,9 @@ echo ">>> Installing MongoDB" # Get key and add to sources -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 +sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 -# Make MongoDB connectable from outside world without SSH tunnel -if [ $2 == "3.0" ]; then - echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list -else - echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list -fi +echo "deb http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.1 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.1.list # Update @@ -20,30 +15,51 @@ sudo apt-get update # -qq implies -y --force-yes sudo apt-get install -qq mongodb-org +# Create a unit file to manage the MongoDB service +sudo touch /etc/systemd/system/mongodb.service +sudo echo '[Unit] +Description=High-performance, schema-free document-oriented database +After=network.target + +[Service] +User=mongodb +ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf + +[Install] +WantedBy=multi-user.target' > /etc/systemd/system/mongodb.service + +sudo systemctl start mongodb + # Make MongoDB connectable from outside world without SSH tunnel if [ $1 == "true" ]; then # enable remote access # setting the mongodb bind_ip to allow connections from everywhere - sed -i "s/bind_ip = .*/bind_ip = 0.0.0.0/" /etc/mongod.conf + sudo sed -i "s/bind_ip = .*/bind_ip = 0.0.0.0/" /etc/mongod.conf fi +sudo systemctl restart mongodb +sudo systemctl enable mongodb + # Test if PHP is installed php -v > /dev/null 2>&1 PHP_IS_INSTALLED=$? if [ $PHP_IS_INSTALLED -eq 0 ]; then + # get current PHP version + + PHP_INSTALLED_VERSION=$(php -r "echo PHP_VERSION;" | cut -c 1,2,3) + # install dependencies - sudo apt-get -y install php-pear php5-dev + sudo apt-get -y install php-pear php${PHP_INSTALLED_VERSION}-dev # install php extension - echo "no" > answers.txt - sudo pecl install mongo < answers.txt - rm answers.txt + sudo pecl channel-update pecl.php.net + sudo pecl install mongodb # add extension file and restart service - echo 'extension=mongo.so' | sudo tee /etc/php5/mods-available/mongo.ini + sudo echo 'extension=mongodb.so' | sudo tee /etc/php/${PHP_INSTALLED_VERSION}/mods-available/mongo.ini - ln -s /etc/php5/mods-available/mongo.ini /etc/php5/fpm/conf.d/mongo.ini - ln -s /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/mongo.ini - sudo service php5-fpm restart + sudo ln -s /etc/php/${PHP_INSTALLED_VERSION}/mods-available/mongo.ini /etc/php/${PHP_INSTALLED_VERSION}/fpm/conf.d/mongo.ini + sudo ln -s /etc/php/${PHP_INSTALLED_VERSION}/mods-available/mongo.ini /etc/php/${PHP_INSTALLED_VERSION}/cli/conf.d/mongo.ini + sudo service php${PHP_INSTALLED_VERSION}-fpm restart fi diff --git a/scripts/mssql.sh b/scripts/mssql.sh index 48c3986c..4d5f61ff 100644 --- a/scripts/mssql.sh +++ b/scripts/mssql.sh @@ -9,7 +9,7 @@ sudo apt-get update # Install PHP MSSQL # -qq implies -y --force-yes -sudo apt-get install -qq php5-mssql +sudo apt-get install -qq php7.1-mssql echo ">>> Installing freeTDS for MSSQL" @@ -21,5 +21,7 @@ echo ">>> Installing UnixODBC for MSSQL" # Install unixodbc sudo apt-get install -qq unixodbc unixodbc-dev -# Restart php5-fpm -sudo service php5-fpm restart \ No newline at end of file +# Restart php7.1-fpm +sudo service php-fpm restart + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/mysql.sh b/scripts/mysql.sh index 755e5191..a4106e50 100644 --- a/scripts/mysql.sh +++ b/scripts/mysql.sh @@ -7,14 +7,15 @@ echo ">>> Installing MySQL Server $2" mysql_package=mysql-server if [ $2 == "5.6" ]; then - # Add repo for MySQL 5.6 - sudo add-apt-repository -y ppa:ondrej/mysql-5.6 - # Update Again - sudo apt-get update + # Change package + mysql_package=mysql-server-5.6 +fi + +if [ $2 == "5.7" ]; then - # Change package - mysql_package=mysql-server-5.6 + # Change package + mysql_package=mysql-server-5.7 fi # Install MySQL without password prompt @@ -48,3 +49,5 @@ if [ $3 == "true" ]; then service mysql restart fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/neo4j.sh b/scripts/neo4j.sh index ab43ba8e..e2cf3d52 100644 --- a/scripts/neo4j.sh +++ b/scripts/neo4j.sh @@ -20,4 +20,6 @@ apt-get update apt-get install -qq neo4j # Start the server -service neo4j-service restart \ No newline at end of file +service neo4j-service restart + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/nginx.sh b/scripts/nginx.sh index dcc94668..7ce731de 100644 --- a/scripts/nginx.sh +++ b/scripts/nginx.sh @@ -16,7 +16,7 @@ echo ">>> Installing Nginx" [[ -z $1 ]] && { echo "!!! IP address not set. Check the Vagrant file."; exit 1; } if [[ -z $2 ]]; then - public_folder="/vagrant" + public_folder="/var/www/html" else public_folder="$2" fi @@ -29,7 +29,7 @@ else fi if [[ -z $4 ]]; then - github_url="https://raw.githubusercontent.com/fideloper/Vaprobash/master" + github_url="https://raw.githubusercontent.com/rattfieldnz/Vaprobash/master" else github_url="$4" fi @@ -54,8 +54,8 @@ sed -i 's/sendfile on;/sendfile off;/' /etc/nginx/nginx.conf sed -i "s/user www-data;/user vagrant;/" /etc/nginx/nginx.conf sed -i "s/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/" /etc/nginx/nginx.conf -# Add vagrant user to www-data group -usermod -a -G www-data vagrant +# Add ubuntu user to www-data group +usermod -a -G www-data ubuntu # Nginx enabling and disabling virtual hosts curl --silent -L $github_url/helpers/ngxen.sh > ngxen @@ -64,7 +64,7 @@ curl --silent -L $github_url/helpers/ngxcb.sh > ngxcb sudo chmod guo+x ngxen ngxdis ngxcb sudo mv ngxen ngxdis ngxcb /usr/local/bin -# Create Nginx Server Block named "vagrant" and enable it +# Create Nginx Server Block named "ubuntu" and enable it sudo ngxcb -d $public_folder -s "$1.xip.io$hostname" -e # Disable "default" @@ -78,3 +78,5 @@ if [[ $HHVM_IS_INSTALLED -ne 0 && $PHP_IS_INSTALLED -eq 0 ]]; then fi sudo service nginx restart + +sudo apt -f -y autoremove --purge diff --git a/scripts/nodejs.sh b/scripts/nodejs.sh index b801384c..5b8f6770 100644 --- a/scripts/nodejs.sh +++ b/scripts/nodejs.sh @@ -10,57 +10,53 @@ NODE_ARG=($@) # Number of arguments that are given NUMBER_OF_ARG=${#NODE_ARG[@]} -# Prepare the variables for installing specific Nodejs version and Global Node Packages -if [[ $NUMBER_OF_ARG -gt 2 ]]; then - # Nodejs version, github url and Global Node Packages are given - NODEJS_VERSION=${NODE_ARG[0]} - GITHUB_URL=${NODE_ARG[1]} - NODE_PACKAGES=${NODE_ARG[@]:2} -elif [[ $NUMBER_OF_ARG -eq 2 ]]; then - # Only Nodejs version and github url are given - NODEJS_VERSION=${NODE_ARG[0]} - GITHUB_URL=${NODE_ARG[1]} -else - # Default Nodejs version when nothing is given - NODEJS_VERSION=latest - GITHUB_URL="https://raw.githubusercontent.com/fideloper/Vaprobash/master" -fi +PROFILE=~/.profile +BASHRC=~/.bashrc # True, if Node is not installed if [[ $NODE_IS_INSTALLED -ne 0 ]]; then - echo ">>> Installing Node Version Manager" - + echo ">>> Installing latest stable Node LTS - 10.X" + + sudo apt-get -f -y upgrade; + sudo apt-get -f -y dist-upgrade; + sudo apt-get -y install python-software-properties + # Install NVM - curl --silent -L $GITHUB_URL/helpers/nvm_install.sh | sh - - # Re-source user profiles - # if they exist - if [[ -f "/home/vagrant/.profile" ]]; then - . /home/vagrant/.profile - fi - - echo ">>> Installing Node.js version $NODEJS_VERSION" - echo " This will also be set as the default node version" - - # If set to latest, get the current node version from the home page - if [[ $NODEJS_VERSION -eq "latest" ]]; then - NODEJS_VERSION="node" - fi + curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - + sudo apt-get update + sudo apt-get -y install nodejs node-gyp + + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash - # Install Node - nvm install $NODEJS_VERSION + # Install (optional) Global Node Packages - # Set a default node version and start using it - nvm alias default $NODEJS_VERSION + echo ">>> Start installing Global Node Packages" + sudo npm install -g npm --force; + sudo npm install -g grunt-cli --force; + sudo npm install -g gulp --force; + sudo npm install -g bower --force; + sudo npm install -g yarn --force; + sudo npm install -g gulp-concat-css --force; + sudo npm install -g gulp-minify-css --force; + sudo npm install -g gulp-clean-css --force; + sudo npm install -g gulp-rename --force; + sudo npm install -g gulp-ruby-sass --force; + sudo npm install -g gulp-sourcemaps --force; + sudo npm install -g gulp-uglify --force; + sudo npm install -g notify-send --force; + sudo npm install -g sw-precache-webpack-plugin --force; + sudo npm install -g cross-env --force; + sudo npm install -g laravel-mix --force; + sudo npm install -g laravel-elixir --force; - nvm use default + # Re-source user profiles + # if they exist + source $PROFILE + + # Re-source .bashrc if exists + source $BASHRC fi -# Install (optional) Global Node Packages -if [[ ! -z $NODE_PACKAGES ]]; then - echo ">>> Start installing Global Node Packages" - - npm install -g ${NODE_PACKAGES[@]} -fi +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/pgsql.sh b/scripts/pgsql.sh index 53834e16..9958884b 100644 --- a/scripts/pgsql.sh +++ b/scripts/pgsql.sh @@ -5,7 +5,7 @@ echo ">>> Installing PostgreSQL" [[ -z "$1" ]] && { echo "!!! PostgreSQL root password not set. Check the Vagrant file."; exit 1; } # Set some variables -POSTGRE_VERSION=9.4 +POSTGRE_VERSION=12 # Add PostgreSQL GPG public key # to get latest stable @@ -14,7 +14,7 @@ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt- # Add PostgreSQL Apt repository # to get latest stable sudo touch /etc/apt/sources.list.d/pgdg.list -sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list +sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list # Update Apt repos sudo apt-get update @@ -40,7 +40,9 @@ sudo -u postgres createuser -s vagrant # Create new user "root" w/ defined password # Not a superuser, just tied to new db "vagrant" -sudo -u postgres psql -c "CREATE ROLE root LOGIN UNENCRYPTED PASSWORD '$1' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;" +sudo -u postgres psql -c "CREATE ROLE root LOGIN PASSWORD '$1' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;" # Make sure changes are reflected by restarting sudo service postgresql restart + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/php.sh b/scripts/php.sh index 8a1cd814..6c9fd470 100644 --- a/scripts/php.sh +++ b/scripts/php.sh @@ -12,7 +12,7 @@ if [[ $HHVM == "true" ]]; then # Get key and add to sources wget --quiet -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add - - echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list + echo deb http://dl.hhvm.com/ubuntu xenial main | sudo tee /etc/apt/sources.list.d/hhvm.list # Update sudo apt-get update @@ -35,12 +35,23 @@ else sudo apt-key update sudo apt-get update + + git clone https://github.com/rapidwebltd/php-switch-scripts.git + cd php-switch-scripts/ + export DEBIAN_FRONTEND=noninteractive + ./setup.sh 2> /dev/null && ./switch-to-php-${PHP_VERSION}.sh # Install PHP # -qq implies -y --force-yes - sudo apt-get install -qq php${PHP_VERSION}-cli php${PHP_VERSION}-fpm php${PHP_VERSION}-mysql php${PHP_VERSION}-pgsql php${PHP_VERSION}-sqlite php${PHP_VERSION}-curl php${PHP_VERSION}-gd php${PHP_VERSION}-gmp php${PHP_VERSION}-mcrypt php${PHP_VERSION}-memcached php${PHP_VERSION}-imagick php${PHP_VERSION}-intl php${PHP_VERSION}-mbstring php${PHP_VERSION}-xml php-xdebug + # Install PHP module for Apache + + # sudo apt-get install -y libapache2-mod-php${PHP_VERSION} php${PHP_VERSION}-{cli,bcmath,bz2,intl,gd,mbstring,mysql,zip,redis,gd,fpm,curl,gmp,memcached,imagick,xml,dom,xdebug,common} + # sudo phpenmod zip cli fpm mysql pgsql sqlite curl gd gmp memcached imagick intl mbstring bcmath xml redis xdebug dom + + sudo a2enmod proxy_fcgi setenvif && a2enconf php${PHP_VERSION}-fpm + # Set PHP FPM to listen on TCP instead of Socket sudo sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf @@ -83,3 +94,5 @@ EOF sudo service php${PHP_VERSION}-fpm restart fi + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/rabbitmq.sh b/scripts/rabbitmq.sh index e6840f57..11145ad5 100644 --- a/scripts/rabbitmq.sh +++ b/scripts/rabbitmq.sh @@ -2,12 +2,14 @@ echo ">>> Installing RabbitMQ" -apt-get -y install erlang-nox +sudo apt-get -y install erlang-nox wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc apt-key add rabbitmq-signing-key-public.asc echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list -apt-get update -apt-get install -y rabbitmq-server +sudo apt-get update +sudo apt-get install -y rabbitmq-server rabbitmqctl add_user $1 $2 rabbitmqctl set_permissions -p / $1 ".*" ".*" ".*" + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/redis.sh b/scripts/redis.sh index 436e7cf4..6779b523 100644 --- a/scripts/redis.sh +++ b/scripts/redis.sh @@ -3,7 +3,7 @@ echo ">>> Installing Redis" # Add repository -sudo apt-add-repository ppa:rwky/redis -y +sudo apt-add-repository ppa:chris-lea/redis-server -y # Install Redis # -qq implies -y --force-yes @@ -20,20 +20,24 @@ EOF # Persistence if [ ! -z "$1" ]; then - if [ "$1" == "persistent" ]; then - echo ">>> Enabling Redis Persistence" - - # add the config to the redis config includes - if ! cat /etc/redis/redis.conf | grep -q "journaling.conf"; then - sudo echo "include /etc/redis/conf.d/journaling.conf" >> /etc/redis/redis.conf - fi - - # schedule background append rewriting - if ! crontab -l | grep -q "redis-cli bgrewriteaof"; then - line="*/5 * * * * /usr/bin/redis-cli bgrewriteaof > /dev/null 2>&1" - (sudo crontab -l; echo "$line" ) | sudo crontab - - fi - fi # persistent + if [ "$1" == "persistent" ]; then + echo ">>> Enabling Redis Persistence" + + # add the config to the redis config includes + if ! cat /etc/redis/redis.conf | grep -q "journaling.conf"; then + sudo chown vagrant:root /etc/redis/redis.conf + sudo echo "include /etc/redis/conf.d/journaling.conf" >> /etc/redis/redis.conf + sudo chown redis:redis /etc/redis/redis.conf + fi + + # schedule background append rewriting + if ! crontab -l | grep -q "redis-cli bgrewriteaof"; then + line="*/5 * * * * /usr/bin/redis-cli bgrewriteaof > /dev/null 2>&1" + (sudo crontab -l; echo "$line" ) | sudo crontab - + fi + fi # persistent fi # arg check -sudo service redis-server restart +sudo service redis-server start + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/rethinkdb.sh b/scripts/rethinkdb.sh index 23c8311e..b2616d23 100644 --- a/scripts/rethinkdb.sh +++ b/scripts/rethinkdb.sh @@ -11,3 +11,5 @@ sudo apt-get update # Install # -qq implies -y --force-yes sudo apt-get install -qq rethinkdb + +sudo apt -f -y autoremove --purge diff --git a/scripts/rvm.sh b/scripts/rvm.sh index 99707e77..1104b8d8 100644 --- a/scripts/rvm.sh +++ b/scripts/rvm.sh @@ -10,6 +10,9 @@ RUBY_ARG=($@) # Number of arguments that are given NUMBER_OF_ARG=${#RUBY_ARG[@]} +PROFILE=~/.profile +BASHRC=~/.bashrc + # Prepare the variables for installing specific Ruby version and Gems if [[ $NUMBER_OF_ARG -gt 1 ]]; then # Both Ruby version and Gems are given @@ -45,16 +48,17 @@ else fi # Re-source RVM - . /home/vagrant/.rvm/scripts/rvm + source ~/.rvm/scripts/rvm - # Re-source .profile if exists - if [[ -f "/home/vagrant/.profile" ]]; then - . /home/vagrant/.profile - fi + # Re-source .profile + source $PROFILE + + # Re-source .bashrc + source $BASHRC fi # Install (optional) Ruby Gems -if [[ ! -z $RUBY_GEMS ]]; then +if [ ! -z $RUBY_GEMS ]; then echo ">>> Start installing Ruby Gems" gem install ${RUBY_GEMS[@]} diff --git a/scripts/screen.sh b/scripts/screen.sh index 76fef791..63d71709 100644 --- a/scripts/screen.sh +++ b/scripts/screen.sh @@ -5,5 +5,10 @@ echo ">>> Installing Screen" # Screen # -qq implies -y --force-yes sudo apt-get install -qq screen -sudo touch /home/vagrant/.screenrc -sudo echo -e "startup_message off\ncaption always '%{= dg} %H %{G}%=%?%{d}%-w%?%{r}(%{d}%n %t%? {%u} %?%{r})%{d}%?%+w%?%=%{G} %{B}%M %d %c:%s '" >> /home/vagrant/.screenrc +touch ~/.screenrc + +SCREENINFO="startup_message off\ncaption always '%{= dg} %H %{G}%=%?%{d}%-w%?%{r}(%{d}%n %t%? {%u} %?%{r})%{d}%?%+w%?%=%{G} %{B}%M %d %c:%s '" + +echo -e $SCREENINFO >> ~/.screenrc + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/setup_projects.sh b/scripts/setup_projects.sh new file mode 100644 index 00000000..ffa348ed --- /dev/null +++ b/scripts/setup_projects.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +chmod -R u+x ./projects + +for file in ./projects/*.sh; do + [ -f "$file" ] && [ -x "$file" ] && "$file"; +done diff --git a/scripts/sphinxsearch.sh b/scripts/sphinxsearch.sh index 16c3f6f3..bedc6bcc 100644 --- a/scripts/sphinxsearch.sh +++ b/scripts/sphinxsearch.sh @@ -26,4 +26,6 @@ searchd --stop sudo sed -i 's/sphinxsearch\/searchd.pid/searchd.pid/' /etc/sphinxsearch/sphinx.conf # Start searchd -searchd \ No newline at end of file +searchd + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/sqlite.sh b/scripts/sqlite.sh index 28212942..f799be03 100644 --- a/scripts/sqlite.sh +++ b/scripts/sqlite.sh @@ -5,3 +5,5 @@ echo ">>> Installing SQLite Server" # Install SQLite Server # -qq implies -y --force-yes sudo apt-get install -qq sqlite + +sudo apt -f -y autoremove --purge diff --git a/scripts/supervisord.sh b/scripts/supervisord.sh index 3e3b7c94..3e12f4ed 100644 --- a/scripts/supervisord.sh +++ b/scripts/supervisord.sh @@ -5,3 +5,5 @@ echo ">>> Installing Supervisord" # Supervisord # -qq implies -y --force-yes sudo apt-get install -qq supervisor + +sudo apt -f -y autoremove --purge diff --git a/scripts/symfony.sh b/scripts/symfony.sh index e540c747..7eacb547 100755 --- a/scripts/symfony.sh +++ b/scripts/symfony.sh @@ -12,17 +12,14 @@ composer -v > /dev/null 2>&1 || { printf "!!! Composer is not installed.\n In [[ -z "$1" ]] && { printf "!!! IP address not set. Check the Vagrantfile.\n Installing Symfony aborted!\n"; exit 0; } # Check if Symfony root is set. If not set use default -if [ -z "$2" ]; then - symfony_root_folder="/vagrant/symfony" +if [ -z "$3" ]; then + symfony_root_folder="/var/www/symfony-test" else - symfony_root_folder="$2" + symfony_root_folder="$3" fi symfony_public_folder="$symfony_root_folder/web" -# The host ip is same as guest ip with last octet equal to 1 -host_ip=`echo $1 | sed 's/\.[0-9]*$/.1/'` - # Test if HHVM is installed hhvm --version > /dev/null 2>&1 HHVM_IS_INSTALLED=$? @@ -47,7 +44,7 @@ if [ ! -f "$symfony_root_folder/composer.json" ]; then composer create-project --prefer-dist symfony/framework-standard-edition $symfony_root_folder fi else - # Go to vagrant folder + # Go to Symfony folder cd $symfony_root_folder # Install Symfony @@ -65,8 +62,8 @@ sudo chmod -R 775 $symfony_root_folder/app/cache sudo chmod -R 775 $symfony_root_folder/app/logs sudo chmod -R 775 $symfony_root_folder/app/console -sed -i "s/('127.0.0.1', 'fe80::1'/('127.0.0.1', '$host_ip', 'fe80::1'/" $symfony_public_folder/app_dev.php -sed -i "s/'127.0.0.1',$/'127.0.0.1', '$host_ip',/" $symfony_public_folder/config.php +sed -i "s/('127.0.0.1', 'fe80::1'/('127.0.0.1', '192.168.22.10', 'fe80::1'/" $symfony_public_folder/app_dev.php +sed -i "s/'127.0.0.1',$/'127.0.0.1', '192.168.22.10',/" $symfony_public_folder/config.php if [ $NGINX_IS_INSTALLED -eq 0 ]; then # Change default vhost created @@ -75,11 +72,8 @@ if [ $NGINX_IS_INSTALLED -eq 0 ]; then fi if [ $APACHE_IS_INSTALLED -eq 0 ]; then - # Find and replace to find public_folder and replace with laravel_public_folder - # Change DocumentRoot - # Change ProxyPassMatch fcgi path - # Change path - sudo sed -i "s@$3@$symfony_public_folder@" /etc/apache2/sites-available/$1.xip.io.conf + + sudo vhost -s "symfony-test.192.168.22.10.xip.io" -a "symfony-test.localhost" -d $symfony_public_folder - sudo service apache2 reload + sudo service apache2 restart fi diff --git a/scripts/vim.sh b/scripts/vim.sh index ca349819..cab5ae42 100644 --- a/scripts/vim.sh +++ b/scripts/vim.sh @@ -3,7 +3,7 @@ echo ">>> Setting up Vim" if [[ -z $1 ]]; then - github_url="https://raw.githubusercontent.com/fideloper/Vaprobash/master" + github_url="https://raw.githubusercontent.com/rattfieldnz/Vaprobash/master" else github_url="$1" fi @@ -13,7 +13,7 @@ mkdir -p /home/vagrant/.vim/backup mkdir -p /home/vagrant/.vim/swap # Install Vundle and set owner of .vim files -git clone https://github.com/gmarik/vundle.git /home/vagrant/.vim/bundle/vundle +git clone https://github.com/VundleVim/Vundle.vim.git /home/vagrant/.vim/bundle/vundle sudo chown -R vagrant:vagrant /home/vagrant/.vim # Grab .vimrc and set owner @@ -22,3 +22,5 @@ sudo chown vagrant:vagrant /home/vagrant/.vimrc # Install Vundle Bundles sudo su - vagrant -c 'vim +BundleInstall +qall' + +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/scripts/zeromq.sh b/scripts/zeromq.sh index 21ea1cb8..695dd3ea 100644 --- a/scripts/zeromq.sh +++ b/scripts/zeromq.sh @@ -12,7 +12,7 @@ echo ">>> Installing ØMQ" sudo add-apt-repository -qq pp:chris-lea/zeromq sudo apt-get update -qq -sudo apt-get install -qq libtool autoconf automake uuid uuid-dev uuid-runtime build-essential php5-dev pkg-config libzmq3-dbg libzmq3-dev libzmq3 +sudo apt-get install -qq libtool autoconf automake uuid uuid-dev uuid-runtime build-essential php7.1-dev pkg-config libzmq3-dbg libzmq3-dev libzmq3 echo "" | sudo pecl install zmq-beta > /dev/null @@ -20,3 +20,4 @@ sudo echo "extension=zmq.so" >> /etc/php/${PHP_VERSION}/mods-available/zmq.ini sudo phpenmod zmq > /dev/null sudo service php${PHP_VERSION}-fpm restart > /dev/null +sudo apt -f -y autoremove --purge \ No newline at end of file diff --git a/start_vagrant b/start_vagrant new file mode 100644 index 00000000..45c1e86d --- /dev/null +++ b/start_vagrant @@ -0,0 +1 @@ +vagrant halt && vagrant box update && vagrant box prune && vagrant plugin update && vagrant up && vagrant ssh