diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1869933 --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# ▒ Mac OS X +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# ▒ Windows +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# OS generated files +ehthumbs.db +Thumbs.db + +# ▒ WebStorm/PHPStorm +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +.idea + +# ▒ SublimeText +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Cache files for sublime text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# User-specific workspace files +*.sublime-workspace + +# Project files +*.sublime-project + +# sftp configuration file +sftp-config.json + +node_modules +prepScripts/escapeHTMLinJSON.sh +logs \ No newline at end of file diff --git a/DebianBackports7Wheezy/Vagrantfile b/DebianBackports7Wheezy/Vagrantfile new file mode 100644 index 0000000..437f6db --- /dev/null +++ b/DebianBackports7Wheezy/Vagrantfile @@ -0,0 +1,124 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" +# docker-1.1.1 on backports Debian 7.5 +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "danielsreichenbach/wheezy64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 80 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/DebianBackports7Wheezy/bootstrap.sh b/DebianBackports7Wheezy/bootstrap.sh new file mode 100644 index 0000000..ba6c234 --- /dev/null +++ b/DebianBackports7Wheezy/bootstrap.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +sudo -s +# +# Backported Debian 7 Wheezy version +# docker-1.1.1 on backports Debian 7.5 +: ' +Reference Links: +https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 +https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts +https://www.digitalocean.com/community/tutorials/how-to-use-vagrant-on-your-own-vps-running-ubuntu +http://wiki.nginx.org/Install +http://nginx.org/en/docs/http/server_names.html +community boxes: + http://www.vagrantbox.es/ +' + +# use nginx=development for latest development version +#nginx=stable + +#Start with downloading and installing PGP keys +wget -O key http://nginx.org/keys/nginx_signing.key && sudo apt-key add key && sudo rm -f key + + +echo "Nginx: Key installed" + +# alt: wheezy-backports +echo "deb http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list +echo "deb-src http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list + +echo "Nginx: Updated >> /etc/apt/sources.list" + +# Update apt lists +apt-get update + +echo "Updated apt lists" + +# Installpdate apt lists +apt-get install -y nginx + +echo "Nginx: Installed" + +nginx -v + +# Remove bs down the line +rm -rf /var/www + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/pt80 + +# Own it all +chown -R $USER:$USER /var/www +chmod -R 755 /var/www + +# Synced home folder +ln -fs /vagrant/www /var/www/pt80 +#ln -l /vagrant/www/ /var/www/pt80/ + +# Remove active defafault (custom install: directory does not exist) +#rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.bak + +# Nginx: mv default to my default page +mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/pt80.conf + +# Nginx: symlink all new vhosts (custom install: directory does not exist) +#sudo ln -s /etc/nginx/sites-available/pt80 /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:/usr/share/nginx/html:/var/www/pt80:" /etc/nginx/conf.d/pt80.conf + +# Nginx: Allow long domain names +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" /etc/nginx/nginx.conf + +# Nginx: Restart +service nginx restart + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/pt80/index.html diff --git a/DebianBackports7Wheezy/bootstrap_test.sh b/DebianBackports7Wheezy/bootstrap_test.sh new file mode 100644 index 0000000..52d0b59 --- /dev/null +++ b/DebianBackports7Wheezy/bootstrap_test.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# bootstrap_test.sh +# +# +# Created by vtool on 9/5/14. +# +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + diff --git a/DebianBackports7Wheezy/www/index.html b/DebianBackports7Wheezy/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/DebianBackports7Wheezy/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful
diff --git a/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/action_provision b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/action_provision new file mode 100644 index 0000000..7387460 --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:9c137eb6-5db4-4743-a41c-c2c090949033 \ No newline at end of file diff --git a/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/action_set_name b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/action_set_name new file mode 100644 index 0000000..3900d22 --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/action_set_name @@ -0,0 +1 @@ +1450480646 \ No newline at end of file diff --git a/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/id b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/id new file mode 100644 index 0000000..a0226c3 --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/id @@ -0,0 +1 @@ +9c137eb6-5db4-4743-a41c-c2c090949033 \ No newline at end of file diff --git a/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/index_uuid b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/index_uuid new file mode 100644 index 0000000..7d86352 --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/index_uuid @@ -0,0 +1 @@ +b08bdecacbb0455d89e16b5ad5da9af3 \ No newline at end of file diff --git a/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/synced_folders b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/synced_folders new file mode 100644 index 0000000..e1a27f8 --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/.vagrant/machines/default/virtualbox/synced_folders @@ -0,0 +1 @@ +{"rsync":{"/vagrant":{"type":"rsync","guestpath":"/vagrant","hostpath":"/Volumes/stereo_2/VVT_VirtualEnvironments/DebianJessie64_RPi_NginxPHPPy","disabled":false,"owner":"vagrant","group":"vagrant"}}} \ No newline at end of file diff --git a/DebianJessie64_RPi_NginxPHPPy/Vagrantfile b/DebianJessie64_RPi_NginxPHPPy/Vagrantfile new file mode 100644 index 0000000..64a959e --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/Vagrantfile @@ -0,0 +1,126 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" +# docker-1.1.1 on backports Debian 7.5 +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "debian/jessie64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 80 + config.vm.network :forwarded_port, host: 4445, guest: 8080 + config.vm.network :forwarded_port, host: 4446, guest: 8081 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/DebianJessie64_RPi_NginxPHPPy/bootstrap.sh b/DebianJessie64_RPi_NginxPHPPy/bootstrap.sh new file mode 100644 index 0000000..d2c15dc --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/bootstrap.sh @@ -0,0 +1,755 @@ +#!/bin/bash +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ Run commands as the root user \x1B[0m" +sudo -s +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Shell initialization > System-wide configuration files +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Shell initialization > System-wide configuration files \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# > Creates a file if it doesn't exist. If it exits, overwrites. +# >> Appends to file if it exists else creates file. + +# Fix Debian server and add dynamic motd.d just like in Ubuntu +# create directory +mkdir /etc/update-motd.d/ +# change to new directory +cd /etc/update-motd.d/ +# Create dynamic files +touch 00-header 01-personal-messages +# make files executable +chmod +x /etc/update-motd.d/* +# remove MOTD file +rm /etc/motd +# symlink dynamic MOTD file +ln -s /var/run/motd /etc/motd + +# Add personal messages +echo "#!/bin/sh" >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒ If you have any issues, contact vincent@toolofna.com"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages + +# non-Ubuntu /etc/bashrc +# Ubuntu /etc/bash.bashrc + +echo -e "\x1B[01;90m ▒ /etc/bash.bashrc and /etc/environment > backup original \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +cp /etc/bash.bashrc /etc/bash.bashrc.bak +cp /etc/environment /etc/environment.bak + +echo -e "\x1B[01;90m ▒ Set ENV vars - First set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "VHOST1='vhost1'" >> /etc/environment +echo "VHOST2='vhost2'" >> /etc/environment +echo "VHOST3='vhost3'" >> /etc/environment +echo "PROJ1='projectA'" >> /etc/environment +echo "PROJ2='projectB'" >> /etc/environment +echo "PROJ3='projectC'" >> /etc/environment +. /etc/environment + +echo -e "\x1B[01;90m ▒ Set ENV vars - Second set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "NGINX_CONF=/etc/nginx/nginx.conf" >> /etc/environment +echo "VHOST1_CONF=/etc/nginx/sites-available/${VHOST1}_${PROJ1}.conf" >> /etc/environment +echo "VHOST2_CONF=/etc/nginx/sites-available/${VHOST2}_${PROJ2}.conf" >> /etc/environment +echo "VHOST3_CONF=/etc/nginx/sites-available/${VHOST3}_${PROJ3}.conf" >> /etc/environment +echo "PHP_INI=/etc/php5/fpm/php.ini" >> /etc/environment +# Edit: Removing /etc/bash.bashrc and switching to /etc/environment, great post http://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables +. /etc/environment + +echo -e "\x1B[01;90m ▒ Check vars\x1B[0m" +echo -e "\x1B[01;90m ▒ Are there values below? \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +echo $NGINX_CONF +echo $VHOST1_CONF +echo $VHOST2_CONF +echo $VHOST3_CONF + +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;90m ▒ END \x1B[0m" +#cat /etc/environment +#cat /etc/bash.bashrc + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Shell initialization > System-wide configuration files \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Install build and main packages +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED: Disabled !!!!!!!!!!!!!!!!!] Install build and main packages \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# https://help.ubuntu.com/community/AptGet/Howto + +# build-essential is available on Main repository for 14.04. So first enable repository. Didint use for RVM ruby +# sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" + +# Run this command periodically to make sure your source list is up-to-date +echo -e "\x1B[01;90m =========== Update source list =========== \x1B[0m" +#sudo apt-get update + +#aptitude update +#aptitude -y upgrade + +#sudo apt-get install -y git-core curl zlib1g-dev build-essential checkinstall python-software-properties +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Install build and main packages \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ User setup +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] User control \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +USER1="dev1" +USER2="dev2" +GROUP1="teamwww" + +# Add group +echo -e "\x1B[01;90m =========== Add groups =========== \x1B[0m" +addgroup $GROUP1 + +# Add users +echo -e "\x1B[01;90m =========== Add users =========== \x1B[0m" + +# Create user [pass: london5] quietly add a user without password +adduser $USER1 --quiet --disabled-password --shell /bin/bash --home /home/$USER1 --gecos "Developer One" +adduser $USER2 --quiet --disabled-password --shell /bin/bash --home /home/$USER2 --gecos "Developer Two" + +# Set passwords +echo -e "\x1B[01;90m =========== Set passwords =========== \x1B[0m" +# Additonal usermod option -G SECONDARYGROUP1,SECONDARYGROUP2 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london5") $USER1 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london55") $USER2 +#echo "dev1:london5" | chpasswd + +# Providing SSH creds +echo -e "\x1B[01;90m =========== Providing SSH creds =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER1@localhost =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER2@localhost =========== \x1B[0m" + +# Create www group and add dev1 to it [to undo: sudo deluser user group] +#usermod -a -G teamwww dev1 + +# Give team privages to user www-data, then check +echo -e "\x1B[01;90m =========== Add user www-data to teamwww, then check =========== \x1B[0m" +gpasswd -a www-data teamwww +groups www-data + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] User control \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Setup webspaces in preparation of server +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Setup webspaces in preparation of server \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# Remove bs down the line +echo -e "\x1B[01;90m =========== Remove bs down the line /var/www =========== \x1B[0m" +rm -rf /var/www + +# Setup vhost directories +echo -e "\x1B[01;90m =========== Setup vhost directories =========== \x1B[0m" + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/{$VHOST1,$VHOST2,$VHOST3} +mkdir -p /var/www/$VHOST1/$PROJ1/www +mkdir -p /var/www/$VHOST2/$PROJ2/www +mkdir -p /var/www/$VHOST3/$PROJ3/www + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www/$VHOST1 +chown -R dev1:teamwww /var/www/$VHOST2 +chown -R dev2:teamwww /var/www/$VHOST3 + +#chmod -R 755 /var/www +# 2 = all files and directories newly created within it inherit the group from that directory +chmod -R 2775 /var/www/$VHOST1 +chmod -R 2775 /var/www/$VHOST2 +chmod -R 2775 /var/www/$VHOST3 + +# Set user or group ID on execution +chmod -R g+s /var/www/$VHOST1 +chmod -R g+s /var/www/$VHOST2 +chmod -R g+s /var/www/$VHOST3 + +# List directories +echo -e "\x1B[01;90m =========== List directories =========== \x1B[0m" +# '-print' arg is optional - it's default. also if a specific listing format is required it can be fed into xargs to run ls with any desired options, e.g. find /path/ -type d -print0 | xargs -0 -r ls -ld. Note the -print0 for NULL terminated output, and the matching -0 xargs arg +find /var/www/ -type d -print0 | xargs -0 -r ls -ld + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Check octal permissions on vhosts =========== \x1B[0m" +stat -c "%a %n" /var/www/$VHOST1 +stat -c "%a %n" /var/www/$VHOST2 +stat -c "%a %n" /var/www/$VHOST3 + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Setup webspaces in preparation of server \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Sync Vagrant home directory with /var/www +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Sync Vagrant home directory with /var/www \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +ln -fs /vagrant/www /var/www +#ln -l /vagrant/www/ /var/www/pt80/ + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Nginx install and setup \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +#Start with downloading and installing PGP keys +wget -O key http://nginx.org/keys/nginx_signing.key && sudo apt-key add key && sudo rm -f key +echo "Nginx: Key installed" + +echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list +echo "deb-src http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list +echo "Nginx: Updated >> /etc/apt/sources.list" + + +apt-get update +echo "Updated apt lists" + +#https://packages.debian.org/sid/nginx-extras +#apt-get install -y nginx +apt-get install -y nginx-extras + +echo -e "\x1B[01;90m =========== Nginx: Installed version No =========== \x1B[0m" +nginx -v + +echo -e "\x1B[01;90m =========== Nginx: Remove active default =========== \x1B[0m" +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +echo -e "\x1B[01;90m =========== Nginx: Backup default config =========== \x1B[0m" +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +echo -e "\x1B[01;90m =========== Nginx: Make their default = my default page =========== \x1B[0m" +mv /etc/nginx/sites-available/default ${VHOST1_CONF} +cp ${VHOST1_CONF} ${VHOST2_CONF} +cp ${VHOST1_CONF} ${VHOST3_CONF} + + +# Nginx: Replace default vhost root: /usr/share/nginx/html +echo -e "\x1B[01;90m =========== Nginx: Replace default vhost root =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] on OSX use extra blank sting in after -i +#sed -i "s:/usr/share/nginx/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} ${VHOST2_CONF} ${VHOST3_CONF} +sed -i "s:/var/www/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} +sed -i "s:/var/www/html:/var/www/$VHOST2/$PROJ2/www:" ${VHOST2_CONF} +sed -i "s:/var/www/html:/var/www/$VHOST3/$PROJ3/www:" ${VHOST3_CONF} + +# Nginx: Change ports 8080 +echo -e "\x1B[01;90m =========== Nginx: Change ports - 1 =========== \x1B[0m" +sed -i "s:listen 80:listen 8080:" ${VHOST2_CONF} +sed -i "s:listen 80:listen 8081:" ${VHOST3_CONF} + +# Delete line containing pattern = listen [::]:80 +echo -e "\x1B[01;90m =========== Nginx: Delete line containing pattern = listen [::]:80 =========== \x1B[0m" +sed -i '/:80/d' ${VHOST1_CONF} ${VHOST2_CONF} ${VHOST3_CONF} + +# Nginx: Delete Default Server +echo -e "\x1B[01;90m =========== Nginx: Change ports - 1 =========== \x1B[0m" +sed -i "s: default_server::g" ${VHOST1_CONF} ${VHOST2_CONF} ${VHOST3_CONF} + +echo -e "\x1B[01;90m =========== Nginx: Change ports - 2 =========== \x1B[0m" +#sed -i 's_:80_:3000_' /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Remove unnecessary example file towards bottom of conf =========== \x1B[0m" +# Delete lines starting from a pattern till the last line +sed -i '/# Virtual Host configuration for/,$d' ${VHOST1_CONF} ${VHOST2_CONF} ${VHOST3_CONF} +#sed -i '/# You should look at the following UR/,$d' ${VHOST1_CONF} ${VHOST2_CONF} ${VHOST3_CONF} + +# Delete lines starting from a pattern till the last line +sed -i '/# pass the PHP scripts/,$d' ${VHOST2_CONF} ${VHOST3_CONF} + +# Delete lines starting from a pattern till the last line +sed -i '/location \/ {/,$d' ${VHOST3_CONF} + +STRING_WITH_SPACES="index.php index.html" +sed -i "s:index.html:$STRING_WITH_SPACES:" ${VHOST1_CONF} ${VHOST2_CONF} ${VHOST3_CONF} + +echo -e "\x1B[01;90m =========== Nginx: symlink all new vhosts =========== \x1B[0m" +# Nginx: symbolic link symlink all new vhosts +sudo ln -s "$VHOST1_CONF" /etc/nginx/sites-enabled/ +sudo ln -s "$VHOST2_CONF" /etc/nginx/sites-enabled/ +sudo ln -s "$VHOST3_CONF" /etc/nginx/sites-enabled/ + +echo -e "\x1B[01;90m =========== Nginx: new server names =========== \x1B[0m" +SERVER_NAME1="server_name dev.vincent.com www.dev.vincent.com" +SERVER_NAME2="server_name stage.vincent.com www.stage.vincent.com" +SERVER_NAME3="server_name py.vincent.com www.py.vincent.com" +sed -i "s:server_name _:$SERVER_NAME1:" ${VHOST1_CONF} +sed -i "s:server_name _:$SERVER_NAME2:" ${VHOST2_CONF} +sed -i "s:server_name _:$SERVER_NAME3:" ${VHOST3_CONF} + + + +# Nginx: Allow long domain names +echo -e "\x1B[01;90m =========== Nginx: Allow long domain names =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" ${NGINX_CONF} + +# Do not advertise server version and real server type +sed -i "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" ${NGINX_CONF} +#sed -i '' "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" testSed.txt +#cat testSed.txt |tr 'VVV' '\012' +#tr '⋱' '\012' < testSed.txt |tee testSed.txt +#tr '⋱' '\012' < /etc/nginx/nginx.conf |tee /etc/nginx/nginx.conf +sed -i 's/⋱/\n/g' ${NGINX_CONF} + + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +); + +# Add PHP support to vhost2 +export EASY_PHP=$(cat < +END +); + +export NGINX_PHP_BLOCK=$(cat <<'END_HEREDOC' + location ~ .php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + expires off; + + fastcgi_intercept_errors on; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + + fastcgi_buffering on; + + fastcgi_buffer_size 32k; + fastcgi_buffers 512 32k; + fastcgi_busy_buffers_size 32k; + fastcgi_read_timeout 120s; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} +END_HEREDOC +); + + + +#sed -i '/# pass the PHP scripts/,$d' ${VHOST2_CONF} +echo "$NGINX_PHP_BLOCK" >> ${VHOST2_CONF} + +# Nginx: Restart +sudo nginx -t && service nginx restart +# /etc/init.d/nginx configtest && sudo /etc/init.d/nginx reload + + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/$VHOST1/$PROJ1/www/index.html +echo $EASY_PHP >> /var/www/$VHOST2/$PROJ2/www/index.php + +# Remove Nginx default vhost +echo -e "\x1B[01;90m =========== Remove Nginx default vhost =========== \x1B[0m" +rm -rf /var/www/{html,www} + +export FORWARDED_PORTS=$(cat <<'END_HEREDOC' +config.vm.network :forwarded_port, host: 4444, guest: 80 +config.vm.network :forwarded_port, host: 4445, guest: 8080 +config.vm.network :forwarded_port, host: 4446, guest: 8081 +END_HEREDOC +); +echo -e "\x1B[01;95m =========== http://localhost:80/ =========== \x1B[0m" +echo -e "\x1B[01;95m =========== http://localhost:4445/ =========== \x1B[0m" +echo -e "\x1B[01;95m =========== http://localhost:4446/ =========== \x1B[0m" +echo "$FORWARDED_PORTS" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Nginx \x1B[0m" + + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ PHP +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] PHP \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +apt-get install php5-fpm php5-cli php5-cgi php5-curl -y + +TIME_ZONE="date.timezone = America/Los_Angeles" +EXPOSE_PHP="expose_php = Off" + +echo -e "\x1B[01;90m =========== PHP: Set filepath for CGI scrits =========== \x1B[0m" +sed -i "s:;cgi.fix_pathinfo:cgi.fix_pathinfo:" ${PHP_INI} + +echo -e "\x1B[01;90m =========== PHP: Set timezone =========== \x1B[0m" +sed -i "s:;date.timezone =:$TIME_ZONE:" ${PHP_INI} + +echo -e "\x1B[01;90m =========== PHP: Do not advertise PHP is on the server through header =========== \x1B[0m" +sed -i "s:expose_php = On:$EXPOSE_PHP:" ${PHP_INI} + +echo -e "\x1B[01;90m =========== PHP: Conf adjustments =========== \x1B[0m" +PHP_FPM_CONF="/etc/php5/fpm/php-fpm.conf" + +emergency_restart_threshold="emergency_restart_threshold = 10" +emergency_restart_interval="emergency_restart_interval = 1" +process_control_timeout="process_control_timeout = 10" +sed -i "s:;emergency_restart_threshold = 0:$emergency_restart_threshold:" ${PHP_FPM_CONF} +sed -i "s:;emergency_restart_interval = 0:$emergency_restart_interval:" ${PHP_FPM_CONF} +sed -i "s:;process_control_timeout = 0:$process_control_timeout:" ${PHP_FPM_CONF} + + +#restart PHP-FPM and add it on system's start-up using +service php5-fpm restart +update-rc.d -f php5-fpm enable + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] PHP \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Vim +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Vim \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +#Remove shitty vim for good one +apt-get remove vim-tiny -y && apt-get install vim -y + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Vim \x1B[0m" + + + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Python +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# PIP on osx http://www.leeladharan.com/installing-nginx-flask-uwsgi-on-mac-osx-yosemite +# PIP Linux instuctions also work after pip is installed on os x with easy_install pip; pip install virtualenv; +# https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04 +echo -e "\x1B[01;95m ▒ [STARTED] Python \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# Establish Python-related environment variables +echo -e "\x1B[01;90m =========== Python: Establish Python-related environment variables =========== \x1B[0m" +PYTHON_WSGI_APP_NAME=wsgiApp001 +PYTHON_VIRTUALENV=myappenv +uWSGI_Config_INI=/var/www/${PYTHON_WSGI_APP_NAME}/${PYTHON_WSGI_APP_NAME}.ini +WSGI_Application=/var/www/${PYTHON_WSGI_APP_NAME}/wsgi.py + +# Add user to sudoers file +echo -e "\x1B[01;90m =========== Python: Add $USER1 to sudoers file =========== \x1B[0m" +echo "$USER1 ALL=(ALL:ALL) ALL" | (EDITOR="tee -a" visudo) + +#Install +apt-get install python-dev python-pip -y + +# Create App Directory +echo -e "\x1B[01;90m =========== Python: Create App Directory =========== \x1B[0m" +mkdir -p /var/www/$PYTHON_WSGI_APP_NAME +chown -R dev1:teamwww /var/www/$PYTHON_WSGI_APP_NAME +cd /var/www/$PYTHON_WSGI_APP_NAME + +# pip Python package manager. We can use this to install the virtualenv package, which we will use to isolate our application's Python environment from any others that may exist on the system: +echo -e "\x1B[01;90m =========== Python: Install the virtualenv package =========== \x1B[0m" +pip install virtualenv + +# Install the uwsgi server +echo -e "\x1B[01;90m =========== Python: Install the uwsgi server =========== \x1B[0m" +pip install uwsgi + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Python: Check octal permissions on App Directory =========== \x1B[0m" +stat -c "%a %n" /var/www/$PYTHON_WSGI_APP_NAME + +# Adjust default group of files that get created in a certain directory using ACLs or Access Control Lists +# -R Apply operations to all files and directories recursively. -m odifying the -d efault ACLs – those that will be applied to newly created items +echo -e "\x1B[01;90m =========== Python: ACL creation =========== \x1B[0m" +setfacl -Rdm g:teamwww:rwx /var/www/$PYTHON_WSGI_APP_NAME + +# Enforce ACL +echo -e "\x1B[01;90m =========== Python: Enforce ACL =========== \x1B[0m" +chmod g+rwxs /var/www/$PYTHON_WSGI_APP_NAME + +# Switch to dev1 +echo -e "\x1B[01;90m =========== Python: [NIS] Switch to dev1 =========== \x1B[0m" +#su dev1 + +# Create a self-contained Virtual (Python) Environment +echo -e "\x1B[01;90m =========== Python: Create a self-contained Virtual (Python) Environment: $PYTHON_VIRTUALENV =========== \x1B[0m" +virtualenv $PYTHON_VIRTUALENV + +export wsgiApp=$(cat <<'END_HEREDOC' +def application(environ, start_response): + start_response('200 OK', [('Content-Type', 'text/html')]) + return ["

Hello There!

"] +END_HEREDOC +); + +echo "$wsgiApp" >> ${WSGI_Application} + + +echo -e "\x1B[01;90m =========== Python: Create INI file by heredoc for that the uWSGI server can read =========== \x1B[0m" + + +# create a directory under /run to place the socket file so that both uWSGI and Nginx can access it + + +export uWSGIConfigINI=$(cat <> ${uWSGI_Config_INI} + + +echo -e "\x1B[01;90m =========== Python: Update vhost3 =========== \x1B[0m" +export VHOST3_LOCATION=$(cat <> ${VHOST3_CONF} + +echo -e "\x1B[01;90m =========== Python: Restart Nginx and test configs, should pass now =========== \x1B[0m" +sudo nginx -t && service nginx restart + + +# Run WSGI Application as dev1 +#runuser + + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Python \x1B[0m" + +export TestHere=$(cat <> ~/aaaaaa_TestHere.txt + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Service Management Daemons > Init systems +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Version No \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# auto-start, add to runlevel. +# systemd + + +# place this in the /etc/systemd/system directory which is the best place for user-created unit files +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Runlevels +# ▒ In linux system telinit utility is used to change system runlevel among 6 possible values: +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +#0 System Halt +#1 Single user +#2 Full multi-user mode (Default) +#3 Full multi-user mode +#4 Full multi-user mode +#5 Full multi-user mode +#6 System Reboot +#/var/www/$PYTHON_WSGI_APP_NAME/$PYTHON_WSGI_APP_NAME.sock +#ExecStartPre=-/bin/bash -c 'mkdir -p /run/uwsgi; chown www-data /run/uwsgi' + +echo -e "\x1B[01;90m =========== Python: UNIT FILE > Use this to start the uWSGI server, used by init/Upstart/**** systemctl ****/systemd script =========== \x1B[0m" +# +export PYTHON_WSGI_UNIT=$(cat <> /etc/systemd/system/uwsgi.service + +systemctl start uwsgi +systemctl enable uwsgi +systemctl status uwsgi +ls -la /etc/systemd/system/multi-user.target.wants/ + +# If there are no troubles for the status check on tht unit file, enable the service so that it starts at boot +# https://wiki.archlinux.org/index.php/Systemd +#sudo systemctl enable uwsgi +#sudo systemctl stop uwsgi + +# http://unix.stackexchange.com/questions/106656/how-do-services-in-debian-work-and-how-can-i-manage-them +# https://wiki.ubuntu.com/SystemdForUpstartUsers +# Create an Upstart File to Manage the App +echo -e "\x1B[01;90m =========== Python: [NIS] Create an Upstart File to Manage the App =========== \x1B[0m" +export Upstart_File=$(cat <<'END_HEREDOC' +description "uWSGI instance to serve myapp" + +start on runlevel [2345] +stop on runlevel [!2345] + +setuid dev1 +setgid www-data + +script +cd /var/www/wsgiApp001 +. myappenv/bin/activate +uwsgi --ini wsgiApp001.ini +end script +END_HEREDOC +); + +echo "$Upstart_File" >> /etc/init/${PYTHON_WSGI_APP_NAME}.conf + +exit 0 + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Python \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Version +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Version No \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# Python: Version No +python --version + +# Nginx: Version No +nginx -v + +# jenkins: Version No +echo -n "$JENKINS_V" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Version No\x1B[0m" +printf "\n\n" + +# Ruby one-liner to print first 10 lines of file +echo -e "\x1B[01;90m =========== Nginx: First ten lines of $VHOST1.conf =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-available/$VHOST1_CONF +printf "\n\n" + +echo -e "\x1B[01;90m =========== Jenkins: First ten lines of log =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/default/jenkins +printf "\n\n" + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] EXITING BOOTSTRAP SCRIPT\x1B[0m" + +exit 0 +# DB restore from dump: mongorestore --drop -d db3--host mongodb1.example.net --port 27017 --username user --password pass /opt/backup/mongodump-2011-10-24 diff --git a/DebianJessie64_RPi_NginxPHPPy/www/index.html b/DebianJessie64_RPi_NginxPHPPy/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/DebianJessie64_RPi_NginxPHPPy/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..10d1eaf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Vincent V. Toscano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 90acc64..0703f05 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # VVT_VirtualEnvironments Explore virtual environment loadouts in preparation of projects or for exploratory purposes. + +# License +This project is licensed under the terms of the MIT license. Please see the full license in the file named LICENSE.md. \ No newline at end of file diff --git a/UbuntuTrusty64_1404/Vagrantfile b/UbuntuTrusty64_1404/Vagrantfile new file mode 100644 index 0000000..86ec5c6 --- /dev/null +++ b/UbuntuTrusty64_1404/Vagrantfile @@ -0,0 +1,124 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 80 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/UbuntuTrusty64_1404/bootstrap.sh b/UbuntuTrusty64_1404/bootstrap.sh new file mode 100644 index 0000000..6a56c61 --- /dev/null +++ b/UbuntuTrusty64_1404/bootstrap.sh @@ -0,0 +1,264 @@ +#!/usr/bin/env bash + +sudo -s + +: ' +#Reference Links: +https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 +https://www.digitalocean.com/community/tutorials/how-to-use-vagrant-on-your-own-vps-running-ubuntu +http://wiki.nginx.org/Install +http://nginx.org/en/docs/http/server_names.html + +#Nginx server block: +https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts +https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 + +#community boxes: + http://www.vagrantbox.es/ + +#Node.js: +https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions + +# Ruby: +https://gorails.com/deploy/ubuntu/14.04 +http://www.centurylinklabs.com/tutorials/ubuntu/installing-ruby-2-1-2-on-rails-4-1-2-on-ubuntu-trusty-14-04/ +https://www.digitalocean.com/community/tutorials/how-to-install-ruby-2-1-0-and-sinatra-on-ubuntu-13-with-rvm +http://leonid.shevtsov.me/en/making-rvm-play-nicely-with-system-scripts +http://rvm.io/rvm/install + +# Ruby oneliners +http://reference.jumpingmonkey.org/programming_languages/ruby/ruby-one-liners.html + +#vsftpd +https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-on-ubuntu-12-04 +https://www.digitalocean.com/community/questions/var-www-to-home-user-public_html + +#Server setup +https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04 +https://www.digitalocean.com/community/tutorials/how-to-launch-your-site-on-a-new-ubuntu-12-04-server-with-lamp-sftp-and-dns +https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-12-04 + +# User control +https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-an-ubuntu-14-04-vps +https://www.linode.com/docs/tools-reference/linux-users-and-groups + + +# Limit an FTP or SFTP linux +http://www.faqs.org/docs/securing/chap29sec295.html +http://ubuntuforums.org/showthread.php?t=1980933 +http://stackoverflow.com/questions/24575033/restricting-sftp-user-to-home-directory +## best +https://survivalguides.wordpress.com/2011/05/20/chroot-sftp-connection/ + +vi /etc/ssh/sshd_config +Go to bottom +#Subsystem sftp /usr/lib/openssh/sftp-server +Subsystem sftp internal-sftp +Match group teamwww +ChrootDirectory /var/www +X11Forwarding no +AllowTcpForwarding no +ForceCommand internal-sftp + + +sudo service ssh restart + +# Unix Permissions Calculator and check octal permissions +http://permissions-calculator.org/ +http://askubuntu.com/questions/152001/how-can-i-get-octal-file-permissions-from-command-line + +# IP +http://www.cyberciti.biz/faq/how-to-find-out-the-ip-address-assigned-to-eth0-and-display-ip-only/ +' + + + +aptitude update +aptitude -y upgrade + + + +# User control +# Create user [pass: london5] +adduser dev1 + +# Add group +addgroup teamwww + +# Create www group and add dev1 to it [to undo: sudo deluser user group] +usermod -a -G teamwww dev1 + +# Give team privages to user www-data, then check +gpasswd -a www-data teamwww +groups www-data + + + +# use nginx=development for latest development version +nginx=stable +add-apt-repository ppa:nginx/$nginx +apt-get update +apt-get install -y nginx +nginx -v + +# Remove bs down the line +rm -rf /var/www + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/pt80 + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www +#chmod -R 755 /var/www +chmod -R 2774 /var/www + +# Set user or group ID on execution +chmod -R g+s /var/www + +# Check octal permissions +stat -c "%a %n" /var/www/pt80/ + +# Synced home folder +ln -fs /vagrant/www /var/www/pt80 +#ln -l /vagrant/www/ /var/www/pt80/ + +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +mv /etc/nginx/sites-available/default /etc/nginx/sites-available/pt80 + +# Nginx: symlink all new vhosts +sudo ln -s /etc/nginx/sites-available/pt80 /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:/usr/share/nginx/html:/var/www/pt80:" /etc/nginx/sites-available/pt80 +sed -i "s:/var/www/html:/var/www/pt80:" /etc/nginx/sites-available/pt80 + +# Nginx: Allow long domain names +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" /etc/nginx/nginx.conf + +# Nginx: Restart +service nginx restart + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/pt80/index.html + +# Installing Node.js via package manager + +# Node.js: Download and pipe to bash +curl -sL https://deb.nodesource.com/setup | sudo bash - + +# Node.js: install with Ubuntu: +sudo apt-get install -y nodejs + + +# Delete lock file for the following error: +# E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) + +# Update Ruby version to 2.1.2 +# Ruby: install some dependencies for Ruby. +echo -e "\x1B[01;95m =========== Main Repo Added [STARTED]=========== \x1B[0m" + +# build-essential is available on Main repository for 14.04. So first enable repository. Didint use for RVM ruby +# sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" + +sudo apt-get update +echo -e "\x1B[01;95m =========== Main Repo Added [MID]=========== \x1B[0m" +sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties +echo -e "\x1B[01;95m =========== Main Repo Added [COMPLETE]=========== \x1B[0m" + +command curl -sSL https://rvm.io/mpapis.asc | sudo gpg --import - +# OR: gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 +# Ruby: use rbenv as it one of the most popular install systems +curl -L get.rvm.io | bash -s stable + +# Ruby: create a system environment using RVM shell script +source /etc/profile.d/rvm.sh + + +# Ruby: Install +echo -e "\x1B[01;90m =========== Ruby: Install 2.1.2 =========== \x1B[0m" +rvm reload +rvm install 2.1.2 + + +: ' +cd +git clone git://github.com/sstephenson/rbenv.git .rbenv +echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc +echo 'eval "$(rbenv init -)"' >> ~/.bashrc +exec $SHELL + +git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc +exec $SHELL + +rbenv install 2.1.2 +rbenv global 2.1.2 +ruby -v +#The last step is to tell Rubygems not to install the documentation for each package locally +echo "gem: --no-ri --no-rdoc" > ~/.gemrc +' + +echo -e "\x1B[01;95m \n\n\n\n======================================== \x1B[0m" +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;90m =========== Version No [STARTED]=========== \x1B[0m" +echo -e "\x1B[01;90m ======================================== \x1B[0m" +# Nginx: Version No +nginx -v + +# Node.js: Version No +node --version + +# Python: Version No +python --version + +# Ruby: Version No +ruby --version + +echo -e "\x1B[01;90m =========== Version No [COMPLETE]=========== \x1B[0m" +echo "\n\n\n\n" + +# Ruby one-liner to print first 10 lines of file +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-enabled/pt80 + + +# htpasswd +sudo apt-get install apache2-utils +sudo htpasswd -c /etc/nginx/.htpasswd tool +vi /etc/nginx/sites-enabled/pt80 +sudo /etc/init.d/nginx reload +# Nginx: To ensure that nginx will be up after reboots, it’s best to add it to the startup. +sudo apt-get purge apache2-utils + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /etc/nginx/sites-protected +cd /etc/nginx/sites-protected + +# Password file +touch .pt80WebrootPasswd + +# Manual operations +perl -le 'print crypt("car21train", "salt-hash")' +# vi .pt80WebrootPasswd + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" diff --git a/UbuntuTrusty64_1404/bootstrap_test.sh b/UbuntuTrusty64_1404/bootstrap_test.sh new file mode 100644 index 0000000..52d0b59 --- /dev/null +++ b/UbuntuTrusty64_1404/bootstrap_test.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# bootstrap_test.sh +# +# +# Created by vtool on 9/5/14. +# +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + diff --git a/UbuntuTrusty64_1404/www/index.html b/UbuntuTrusty64_1404/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/UbuntuTrusty64_1404/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful
diff --git a/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/action_provision b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/action_provision new file mode 100644 index 0000000..2bd793d --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:1f5e9d78-0550-4898-ab67-728a7e0fddd5 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/action_set_name b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/action_set_name new file mode 100644 index 0000000..77a4ca1 --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/action_set_name @@ -0,0 +1 @@ +1441327474 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/id b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/id new file mode 100644 index 0000000..7d41c92 --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/id @@ -0,0 +1 @@ +1f5e9d78-0550-4898-ab67-728a7e0fddd5 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/index_uuid b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/index_uuid new file mode 100644 index 0000000..6dccd52 --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/index_uuid @@ -0,0 +1 @@ +c5aa2bbe42aa4483a4419b993f35f1d8 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/synced_folders b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/synced_folders new file mode 100644 index 0000000..2f64d76 --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/.vagrant/machines/default/virtualbox/synced_folders @@ -0,0 +1 @@ +{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Volumes/stereo_2/virtualSims/ubuntuTrusty64_1404_Ajenti","disabled":false}}} \ No newline at end of file diff --git a/UbuntuTrusty64_1404_Ajenti/Vagrantfile b/UbuntuTrusty64_1404_Ajenti/Vagrantfile new file mode 100644 index 0000000..db6d911 --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/Vagrantfile @@ -0,0 +1,128 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 80 + config.vm.network :forwarded_port, host: 4445, guest: 8080 +# Ajenti + config.vm.network :forwarded_port, host: 4446, guest: 8000 + #config.vm.network :forwarded_port, host: 4447, guest: 27017 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/UbuntuTrusty64_1404_Ajenti/bootstrap.sh b/UbuntuTrusty64_1404_Ajenti/bootstrap.sh new file mode 100644 index 0000000..27a7ffb --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/bootstrap.sh @@ -0,0 +1,432 @@ +#!/bin/bash +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ Run commands as the root user \x1B[0m" +sudo -s +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Shell initialization > System-wide configuration files +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Shell initialization > System-wide configuration files \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# > Creates a file if it doesn't exist. If it exits, overwrites. +# >> Appends to file if it exists else creates file. + + +# Add personal messages +echo "#!/bin/sh" >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒ If you have any issues, contact vincent@toolofna.com"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages + +# non-Ubuntu /etc/bashrc +# Ubuntu /etc/bash.bashrc + +echo -e "\x1B[01;90m ▒ /etc/bash.bashrc and /etc/environment > backup original \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +cp /etc/bash.bashrc /etc/bash.bashrc.bak +cp /etc/environment /etc/environment.bak + +echo -e "\x1B[01;90m ▒ Set ENV vars - First set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "VHOST1='vhost1'" >> /etc/environment +echo "VHOST2='vhost2'" >> /etc/environment +echo "VHOST3='vhost3'" >> /etc/environment +echo "PROJ1='jenkins80'" >> /etc/environment +echo "PROJ2='jenkins443'" >> /etc/environment +echo "PROJ3='projectNameOrRepo'" >> /etc/environment +. /etc/environment + +echo -e "\x1B[01;90m ▒ Set ENV vars - Second set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "NGINX_CONF=/etc/nginx/nginx.conf" >> /etc/environment +echo "VHOST1_CONF=/etc/nginx/sites-available/${VHOST1}_${PROJ1}.conf" >> /etc/environment +echo "VHOST2_CONF=/etc/nginx/sites-available/${VHOST2}_${PROJ2}.conf" >> /etc/environment +echo "VHOST3_CONF=/etc/nginx/sites-available/${VHOST3}_${PROJ3}.conf" >> /etc/environment +echo "JENKINS_CONF=etc/default/jenkins" >> /etc/environment +# Edit: Removing /etc/bash.bashrc and switching to /etc/environment, great post http://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables +. /etc/environment + +echo -e "\x1B[01;90m ▒ Check vars\x1B[0m" +echo -e "\x1B[01;90m ▒ Are there values below? \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +echo $NGINX_CONF +echo $VHOST1_CONF +echo $VHOST2_CONF +echo $VHOST3_CONF + +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;90m ▒ END \x1B[0m" +#cat /etc/environment +#cat /etc/bash.bashrc + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Shell initialization > System-wide configuration files \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Install build and main packages +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED: Disabled !!!!!!!!!!!!!!!!!] Install build and main packages \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# https://help.ubuntu.com/community/AptGet/Howto + +# build-essential is available on Main repository for 14.04. So first enable repository. Didint use for RVM ruby +# sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" + +# Run this command periodically to make sure your source list is up-to-date +echo -e "\x1B[01;90m =========== Update source list =========== \x1B[0m" +#sudo apt-get update + +#aptitude update +#aptitude -y upgrade + +#sudo apt-get install -y git-core curl zlib1g-dev build-essential checkinstall python-software-properties +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Install build and main packages \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ User setup +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] User control \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +USER1="dev1" +USER2="dev2" +GROUP1="teamwww" + +# Add group +echo -e "\x1B[01;90m =========== Add groups =========== \x1B[0m" +addgroup $GROUP1 + +# Add users +echo -e "\x1B[01;90m =========== Add users =========== \x1B[0m" + +# Create user [pass: london5] quietly add a user without password +adduser $USER1 --quiet --disabled-password --shell /bin/bash --home /home/$USER1 --gecos "Developer One" +adduser $USER2 --quiet --disabled-password --shell /bin/bash --home /home/$USER2 --gecos "Developer Two" + + +# Set passwords +echo -e "\x1B[01;90m =========== Set passwords =========== \x1B[0m" +# Additonal usermod option -G SECONDARYGROUP1,SECONDARYGROUP2 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london5") $USER1 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london55") $USER2 +#echo "dev1:london5" | chpasswd + +# Providing SSH creds +echo -e "\x1B[01;90m =========== Providing SSH creds =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER1@localhost =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER2@localhost =========== \x1B[0m" + +# Create www group and add dev1 to it [to undo: sudo deluser user group] +#usermod -a -G teamwww dev1 + +# Give team privages to user www-data, then check +echo -e "\x1B[01;90m =========== Add user www-data to teamwww, then check =========== \x1B[0m" +gpasswd -a www-data teamwww +groups www-data + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] User control \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Setup webspaces in preparation of server +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Setup webspaces in preparation of server \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# Remove bs down the line +echo -e "\x1B[01;90m =========== Remove bs down the line /var/www =========== \x1B[0m" +rm -rf /var/www + +# Setup vhost directories +echo -e "\x1B[01;90m =========== Setup vhost directories =========== \x1B[0m" + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/{$VHOST1,$VHOST2,$VHOST3} +mkdir -p /var/www/$VHOST1/$PROJ1/www +mkdir -p /var/www/$VHOST2/$PROJ2/www +mkdir -p /var/www/$VHOST3/$PROJ3/www + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www/$VHOST1 +chown -R dev1:teamwww /var/www/$VHOST2 +chown -R dev2:teamwww /var/www/$VHOST3 + +#chmod -R 755 /var/www +# 2 = all files and directories newly created within it inherit the group from that directory +chmod -R 2775 /var/www/$VHOST1 +chmod -R 2775 /var/www/$VHOST2 +chmod -R 2775 /var/www/$VHOST3 + +# Set user or group ID on execution +chmod -R g+s /var/www/$VHOST1 +chmod -R g+s /var/www/$VHOST2 +chmod -R g+s /var/www/$VHOST3 + +# List directories +echo -e "\x1B[01;90m =========== List directories =========== \x1B[0m" +# '-print' arg is optional - it's default. also if a specific listing format is required it can be fed into xargs to run ls with any desired options, e.g. find /path/ -type d -print0 | xargs -0 -r ls -ld. Note the -print0 for NULL terminated output, and the matching -0 xargs arg +find /var/www/ -type d -print0 | xargs -0 -r ls -ld + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Check octal permissions on vhosts =========== \x1B[0m" +stat -c "%a %n" /var/www/$VHOST1 +stat -c "%a %n" /var/www/$VHOST2 +stat -c "%a %n" /var/www/$VHOST3 + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Setup webspaces in preparation of server \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Sync Vagrant home directory with /var/www +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Sync Vagrant home directory with /var/www \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +ln -fs /vagrant/www /var/www +#ln -l /vagrant/www/ /var/www/pt80/ + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Sync Vagrant home directory with /var/www \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Ajenti +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Ajenti install and setup \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +#Insall Ajenti +wget http://repo.ajenti.org/debian/key -O- | apt-key add - +echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list +apt-get update && sudo apt-get install -y ajenti +service ajenti restart + +# Uninstall Apache2 +#sudo apt-get autoremove && sudo apt-get remove apache2* + +# Install Ajenti-v +apt-get install -y ajenti-v ajenti-v-nginx ajenti-v-mysql ajenti-v-php-fpm php5-mysql +service ajenti restart + +#sudo apt-get clean +#sudo apt-get autoclean +#sudo apt-get remove --purge mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 +#sudo apt-get install mysql-server + +# If you <3 Ruby +#apt-get install -y ajenti-v-ruby-unicorn ajenti-v-ruby-puma + +# If you need Python +#apt-get install -y ajenti-v-python-gunicorn + +# If you need nodeJS +#apt-get install -y ajenti-v-nodejs + +# If you want FTP +#apt-get -y install ajenti-v-ftp-pureftpd + +# If you want mail +#apt-get -y install ajenti-v-mail + +# If you want POP support (for gmail etc.) +#apt-get -y install courier-pop + +# Restart All Services +#service ajenti restart + + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Ajenti Done \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + + + +exit 0 + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Nginx install and setup \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# use nginx=development for latest development version +nginx=stable +add-apt-repository ppa:nginx/$nginx +apt-get update + +#https://packages.debian.org/sid/nginx-extras +#apt-get install -y nginx +apt-get install -y nginx-extras + +echo -e "\x1B[01;90m =========== Nginx: Installed version No =========== \x1B[0m" +nginx -v + +echo -e "\x1B[01;90m =========== Nginx: Remove active default =========== \x1B[0m" +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +echo -e "\x1B[01;90m =========== Nginx: Backup default config =========== \x1B[0m" +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +echo -e "\x1B[01;90m =========== Nginx: Make their default = my default page =========== \x1B[0m" +mv /etc/nginx/sites-available/default ${VHOST1_CONF} + +echo -e "\x1B[01;90m =========== Nginx: symlink all new vhosts =========== \x1B[0m" +# Nginx: symbolic link symlink all new vhosts +sudo ln -s "$VHOST1_CONF" /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +echo -e "\x1B[01;90m =========== Nginx: Replace default vhost root =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] on OSX use extra blank sting in after -i +sed -i "s:/usr/share/nginx/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} +sed -i "s:/var/www/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} + + +# Nginx: Change ports 8080 +echo -e "\x1B[01;90m =========== Nginx: Change ports - 1 =========== \x1B[0m" +#sed -i "s:listen 80:listen 8080:" /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Change ports - 2 =========== \x1B[0m" +#sed -i 's_:80_:3000_' /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Remove unnecessary example file towards bottom of conf =========== \x1B[0m" +# Delete lines starting from a pattern till the last line +sed -i '/# Virtual Host configuration for/,$d' ${VHOST1_CONF} + +# Nginx: Allow long domain names +echo -e "\x1B[01;90m =========== Nginx: Allow long domain names =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" ${NGINX_CONF} + + + +# Do not advertise server version and real server type +sed -i "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" ${NGINX_CONF} +#sed -i '' "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" testSed.txt +#cat testSed.txt |tr 'VVV' '\012' +#tr '⋱' '\012' < testSed.txt |tee testSed.txt +#tr '⋱' '\012' < /etc/nginx/nginx.conf |tee /etc/nginx/nginx.conf +sed -i 's/⋱/\n/g' ${NGINX_CONF} + +# Nginx: Restart +sudo nginx -t && service nginx restart +# /etc/init.d/nginx configtest && sudo /etc/init.d/nginx reload + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/$VHOST1/$PROJ1/www/index.html + +echo -e "\x1B[01;95m =========== http://127.0.0.1:4444/ =========== \x1B[0m" +echo -e "\x1B[01;95m =========== http://127.0.0.1:4445/ =========== \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Nginx \x1B[0m" + + + + + + +exit 0 + + + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Version No \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# Python: Version No +python --version + +# Nginx: Version No +nginx -v + +# jenkins: Version No +echo -n "$JENKINS_V" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Version No\x1B[0m" +printf "\n\n" + +# Ruby one-liner to print first 10 lines of file +echo -e "\x1B[01;90m =========== Nginx: First ten lines of $VHOST1.conf =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-available/$VHOST1_CONF +printf "\n\n" + +echo -e "\x1B[01;90m =========== Jenkins: First ten lines of log =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/default/jenkins +printf "\n\n" + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] EXITING BOOTSTRAP SCRIPT\x1B[0m" + +exit 0 +# DB restore from dump: mongorestore --drop -d db3--host mongodb1.example.net --port 27017 --username user --password pass /opt/backup/mongodump-2011-10-24 diff --git a/UbuntuTrusty64_1404_Ajenti/www/index.html b/UbuntuTrusty64_1404_Ajenti/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/UbuntuTrusty64_1404_Ajenti/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful
diff --git a/UbuntuTrusty64_1404_Nginx.sh b/UbuntuTrusty64_1404_Nginx.sh new file mode 100644 index 0000000..b494ff9 --- /dev/null +++ b/UbuntuTrusty64_1404_Nginx.sh @@ -0,0 +1,287 @@ +#!/bin/sh + +# UbuntuTrusty64_1404_Nginx.sh +# +# +# Created by Vincent V. Toscano on 5/22/15. +# +#!/bin/bash +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ Run commands as the root user \x1B[0m" +sudo -s +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Shell initialization > System-wide configuration files +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Shell initialization > System-wide configuration files \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + + +# Add personal messages +echo "#!/bin/sh" >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒ If you have any issues, contact Vincent V. Toscano"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages + +echo -e "\x1B[01;90m ▒ /etc/bash.bashrc and /etc/environment > backup original \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +cp /etc/bash.bashrc /etc/bash.bashrc.bak +cp /etc/environment /etc/environment.bak + +echo -e "\x1B[01;90m ▒ Set ENV vars - First set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "VHOST1='vhost1'" >> /etc/environment +echo "VHOST2='vhost2'" >> /etc/environment +echo "VHOST3='vhost3'" >> /etc/environment +echo "PROJ1='project1'" >> /etc/environment +echo "PROJ2='project2'" >> /etc/environment +echo "PROJ3='project3'" >> /etc/environment +. /etc/environment + +echo -e "\x1B[01;90m ▒ Set ENV vars - Second set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "NGINX_CONF=/etc/nginx/nginx.conf" >> /etc/environment +echo "VHOST1_CONF=/etc/nginx/sites-available/${VHOST1}_${PROJ1}.conf" >> /etc/environment +echo "VHOST2_CONF=/etc/nginx/sites-available/${VHOST2}_${PROJ2}.conf" >> /etc/environment +echo "VHOST3_CONF=/etc/nginx/sites-available/${VHOST3}_${PROJ3}.conf" >> /etc/environment +echo "JENKINS_CONF=etc/default/jenkins" >> /etc/environment +. /etc/environment + +echo -e "\x1B[01;90m ▒ Check vars\x1B[0m" +echo -e "\x1B[01;90m ▒ Are there values below? \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +echo $NGINX_CONF +echo $VHOST1_CONF +echo $VHOST2_CONF +echo $VHOST3_CONF + +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;90m ▒ END \x1B[0m" +#cat /etc/environment +#cat /etc/bash.bashrc + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Shell initialization > System-wide configuration files \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Install build and main packages +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED: Disabled !!!!!!!!!!!!!!!!!] Install build and main packages \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# Run this command periodically to make sure your source list is up-to-date +echo -e "\x1B[01;90m =========== Update source list =========== \x1B[0m" +sudo apt-get update + +#aptitude update +#aptitude -y upgrade + +sudo apt-get install -y git-core curl zlib1g-dev build-essential checkinstall python-software-properties +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Install build and main packages \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ User setup +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ + +#removed + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Setup webspaces in preparation of server +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Setup webspaces in preparation of server \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# Remove bs down the line +echo -e "\x1B[01;90m =========== Remove bs down the line /var/www =========== \x1B[0m" +rm -rf /var/www + +# Setup vhost directories +echo -e "\x1B[01;90m =========== Setup vhost directories =========== \x1B[0m" + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/{$VHOST1,$VHOST2,$VHOST3} +mkdir -p /var/www/$VHOST1/$PROJ1/www +mkdir -p /var/www/$VHOST2/$PROJ2/www +mkdir -p /var/www/$VHOST3/$PROJ3/www + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www/$VHOST1 +chown -R dev1:teamwww /var/www/$VHOST2 +chown -R dev2:teamwww /var/www/$VHOST3 + +#chmod -R 755 /var/www +# 2 = all files and directories newly created within it inherit the group from that directory +chmod -R 2774 /var/www/$VHOST1 +chmod -R 2774 /var/www/$VHOST2 +chmod -R 2774 /var/www/$VHOST3 + +# Set user or group ID on execution +chmod -R g+s /var/www/$VHOST1 +chmod -R g+s /var/www/$VHOST2 +chmod -R g+s /var/www/$VHOST3 + +# List directories +echo -e "\x1B[01;90m =========== List directories =========== \x1B[0m" +find /var/www/ -type d -print0 | xargs -0 -r ls -ld + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Check octal permissions on vhosts =========== \x1B[0m" +stat -c "%a %n" /var/www/$VHOST1 +stat -c "%a %n" /var/www/$VHOST2 +stat -c "%a %n" /var/www/$VHOST3 + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Setup webspaces in preparation of server \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Nginx install and setup \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# use nginx=development for latest development version +nginx=stable +add-apt-repository ppa:nginx/$nginx +apt-get update + +#https://packages.debian.org/sid/nginx-extras +#apt-get install -y nginx +apt-get install -y nginx-extras + +echo -e "\x1B[01;90m =========== Nginx: Installed version No =========== \x1B[0m" +nginx -v + +echo -e "\x1B[01;90m =========== Nginx: Remove active default =========== \x1B[0m" +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +echo -e "\x1B[01;90m =========== Nginx: Backup default config =========== \x1B[0m" +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +echo -e "\x1B[01;90m =========== Nginx: Make their default = my default page =========== \x1B[0m" +mv /etc/nginx/sites-available/default ${VHOST1_CONF} + +echo -e "\x1B[01;90m =========== Nginx: symlink all new vhosts =========== \x1B[0m" +# Nginx: symbolic link symlink all new vhosts +sudo ln -s "$VHOST1_CONF" /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +echo -e "\x1B[01;90m =========== Nginx: Replace default vhost root =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] on OSX use extra blank sting in after -i +sed -i "s:/usr/share/nginx/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} +sed -i "s:/var/www/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} + + +# Nginx: Change ports 8080 +echo -e "\x1B[01;90m =========== Nginx: Change ports - 1 =========== \x1B[0m" +#sed -i "s:listen 80:listen 8080:" /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Change ports - 2 =========== \x1B[0m" +#sed -i 's_:80_:3000_' /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Remove unnecessary example file towards bottom of conf =========== \x1B[0m" +# Delete lines starting from a pattern till the last line +sed -i '/# Virtual Host configuration for/,$d' ${VHOST1_CONF} + +# Nginx: Allow long domain names +echo -e "\x1B[01;90m =========== Nginx: Allow long domain names =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" ${NGINX_CONF} + + + +# Do not advertise server version and real server type +sed -i "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" ${NGINX_CONF} +sed -i 's/⋱/\n/g' ${NGINX_CONF} + +# Nginx: Restart +sudo nginx -t && service nginx restart +# /etc/init.d/nginx configtest && sudo /etc/init.d/nginx reload + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/$VHOST1/$PROJ1/www/index.html + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Nginx \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Version No \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# Python: Version No +python --version + +# Nginx: Version No +nginx -v + + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Version No\x1B[0m" +printf "\n\n" + +# Ruby one-liner to print first 10 lines of file +echo -e "\x1B[01;90m =========== Nginx: First ten lines of $VHOST1.conf =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-available/$VHOST1_CONF +printf "\n\n" + + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] EXITING BOOTSTRAP SCRIPT\x1B[0m" + +exit 0 + diff --git a/UbuntuTrusty64_1404_NginxJenkins/Vagrantfile b/UbuntuTrusty64_1404_NginxJenkins/Vagrantfile new file mode 100644 index 0000000..2834488 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxJenkins/Vagrantfile @@ -0,0 +1,127 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 80 + config.vm.network :forwarded_port, host: 4445, guest: 8080 + #config.vm.network :forwarded_port, host: 4446, guest: 3002 + #config.vm.network :forwarded_port, host: 4447, guest: 27017 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/UbuntuTrusty64_1404_NginxJenkins/bootstrap.sh b/UbuntuTrusty64_1404_NginxJenkins/bootstrap.sh new file mode 100644 index 0000000..5cd087b --- /dev/null +++ b/UbuntuTrusty64_1404_NginxJenkins/bootstrap.sh @@ -0,0 +1,443 @@ +#!/bin/bash +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ Run commands as the root user \x1B[0m" +sudo -s +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Shell initialization > System-wide configuration files +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Shell initialization > System-wide configuration files \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# > Creates a file if it doesn't exist. If it exits, overwrites. +# >> Appends to file if it exists else creates file. + + +# Add personal messages +echo "#!/bin/sh" >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒ If you have any issues, contact vincent@toolofna.com"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages +echo 'echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m"' >> /etc/update-motd.d/01-personal-messages + +# non-Ubuntu /etc/bashrc +# Ubuntu /etc/bash.bashrc + +echo -e "\x1B[01;90m ▒ /etc/bash.bashrc and /etc/environment > backup original \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +cp /etc/bash.bashrc /etc/bash.bashrc.bak +cp /etc/environment /etc/environment.bak + +echo -e "\x1B[01;90m ▒ Set ENV vars - First set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "VHOST1='vhost1'" >> /etc/environment +echo "VHOST2='vhost2'" >> /etc/environment +echo "VHOST3='vhost3'" >> /etc/environment +echo "PROJ1='jenkins80'" >> /etc/environment +echo "PROJ2='jenkins443'" >> /etc/environment +echo "PROJ3='projectNameOrRepo'" >> /etc/environment +. /etc/environment + +echo -e "\x1B[01;90m ▒ Set ENV vars - Second set \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo "# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" >> /etc/environment +echo "NGINX_CONF=/etc/nginx/nginx.conf" >> /etc/environment +echo "VHOST1_CONF=/etc/nginx/sites-available/${VHOST1}_${PROJ1}.conf" >> /etc/environment +echo "VHOST2_CONF=/etc/nginx/sites-available/${VHOST2}_${PROJ2}.conf" >> /etc/environment +echo "VHOST3_CONF=/etc/nginx/sites-available/${VHOST3}_${PROJ3}.conf" >> /etc/environment +echo "JENKINS_CONF=etc/default/jenkins" >> /etc/environment +# Edit: Removing /etc/bash.bashrc and switching to /etc/environment, great post http://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables +. /etc/environment + +echo -e "\x1B[01;90m ▒ Check vars\x1B[0m" +echo -e "\x1B[01;90m ▒ Are there values below? \x1B[0m" +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +echo $NGINX_CONF +echo $VHOST1_CONF +echo $VHOST2_CONF +echo $VHOST3_CONF + +echo -e "\x1B[01;90m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;90m ▒ END \x1B[0m" +#cat /etc/environment +#cat /etc/bash.bashrc + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Shell initialization > System-wide configuration files \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Install build and main packages +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED: Disabled !!!!!!!!!!!!!!!!!] Install build and main packages \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# https://help.ubuntu.com/community/AptGet/Howto + +# build-essential is available on Main repository for 14.04. So first enable repository. Didint use for RVM ruby +# sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" + +# Run this command periodically to make sure your source list is up-to-date +echo -e "\x1B[01;90m =========== Update source list =========== \x1B[0m" +#sudo apt-get update + +#aptitude update +#aptitude -y upgrade + +#sudo apt-get install -y git-core curl zlib1g-dev build-essential checkinstall python-software-properties +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Install build and main packages \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ User setup +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] User control \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +USER1="dev1" +USER2="dev2" +GROUP1="teamwww" + +# Add group +echo -e "\x1B[01;90m =========== Add groups =========== \x1B[0m" +addgroup $GROUP1 + +# Add users +echo -e "\x1B[01;90m =========== Add users =========== \x1B[0m" + +# Create user [pass: london5] quietly add a user without password +adduser $USER1 --quiet --disabled-password --shell /bin/bash --home /home/$USER1 --gecos "Developer One" +adduser $USER2 --quiet --disabled-password --shell /bin/bash --home /home/$USER2 --gecos "Developer Two" + + +# Set passwords +echo -e "\x1B[01;90m =========== Set passwords =========== \x1B[0m" +# Additonal usermod option -G SECONDARYGROUP1,SECONDARYGROUP2 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london5") $USER1 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london55") $USER2 +#echo "dev1:london5" | chpasswd + +# Providing SSH creds +echo -e "\x1B[01;90m =========== Providing SSH creds =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER1@localhost =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER2@localhost =========== \x1B[0m" + +# Create www group and add dev1 to it [to undo: sudo deluser user group] +#usermod -a -G teamwww dev1 + +# Give team privages to user www-data, then check +echo -e "\x1B[01;90m =========== Add user www-data to teamwww, then check =========== \x1B[0m" +gpasswd -a www-data teamwww +groups www-data + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] User control \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Setup webspaces in preparation of server +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Setup webspaces in preparation of server \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# Remove bs down the line +echo -e "\x1B[01;90m =========== Remove bs down the line /var/www =========== \x1B[0m" +rm -rf /var/www + +# Setup vhost directories +echo -e "\x1B[01;90m =========== Setup vhost directories =========== \x1B[0m" + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/{$VHOST1,$VHOST2,$VHOST3} +mkdir -p /var/www/$VHOST1/$PROJ1/www +mkdir -p /var/www/$VHOST2/$PROJ2/www +mkdir -p /var/www/$VHOST3/$PROJ3/www + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www/$VHOST1 +chown -R dev1:teamwww /var/www/$VHOST2 +chown -R dev2:teamwww /var/www/$VHOST3 + +#chmod -R 755 /var/www +# 2 = all files and directories newly created within it inherit the group from that directory +chmod -R 2774 /var/www/$VHOST1 +chmod -R 2774 /var/www/$VHOST2 +chmod -R 2774 /var/www/$VHOST3 + +# Set user or group ID on execution +chmod -R g+s /var/www/$VHOST1 +chmod -R g+s /var/www/$VHOST2 +chmod -R g+s /var/www/$VHOST3 + +# List directories +echo -e "\x1B[01;90m =========== List directories =========== \x1B[0m" +# '-print' arg is optional - it's default. also if a specific listing format is required it can be fed into xargs to run ls with any desired options, e.g. find /path/ -type d -print0 | xargs -0 -r ls -ld. Note the -print0 for NULL terminated output, and the matching -0 xargs arg +find /var/www/ -type d -print0 | xargs -0 -r ls -ld + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Check octal permissions on vhosts =========== \x1B[0m" +stat -c "%a %n" /var/www/$VHOST1 +stat -c "%a %n" /var/www/$VHOST2 +stat -c "%a %n" /var/www/$VHOST3 + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Setup webspaces in preparation of server \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Sync Vagrant home directory with /var/www +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Sync Vagrant home directory with /var/www \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +ln -fs /vagrant/www /var/www +#ln -l /vagrant/www/ /var/www/pt80/ + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Sync Vagrant home directory with /var/www \x1B[0m" + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Nginx install and setup \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" + +# use nginx=development for latest development version +nginx=stable +add-apt-repository ppa:nginx/$nginx +apt-get update + +#https://packages.debian.org/sid/nginx-extras +#apt-get install -y nginx +apt-get install -y nginx-extras + +echo -e "\x1B[01;90m =========== Nginx: Installed version No =========== \x1B[0m" +nginx -v + +echo -e "\x1B[01;90m =========== Nginx: Remove active default =========== \x1B[0m" +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +echo -e "\x1B[01;90m =========== Nginx: Backup default config =========== \x1B[0m" +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +echo -e "\x1B[01;90m =========== Nginx: Make their default = my default page =========== \x1B[0m" +mv /etc/nginx/sites-available/default ${VHOST1_CONF} + +echo -e "\x1B[01;90m =========== Nginx: symlink all new vhosts =========== \x1B[0m" +# Nginx: symbolic link symlink all new vhosts +sudo ln -s "$VHOST1_CONF" /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +echo -e "\x1B[01;90m =========== Nginx: Replace default vhost root =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] on OSX use extra blank sting in after -i +sed -i "s:/usr/share/nginx/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} +sed -i "s:/var/www/html:/var/www/$VHOST1/$PROJ1/www:" ${VHOST1_CONF} + + +# Nginx: Change ports 8080 +echo -e "\x1B[01;90m =========== Nginx: Change ports - 1 =========== \x1B[0m" +#sed -i "s:listen 80:listen 8080:" /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Change ports - 2 =========== \x1B[0m" +#sed -i 's_:80_:3000_' /etc/nginx/sites-available/$VHOST1_CONF + +echo -e "\x1B[01;90m =========== Nginx: Remove unnecessary example file towards bottom of conf =========== \x1B[0m" +# Delete lines starting from a pattern till the last line +sed -i '/# Virtual Host configuration for/,$d' ${VHOST1_CONF} + +# Nginx: Allow long domain names +echo -e "\x1B[01;90m =========== Nginx: Allow long domain names =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" ${NGINX_CONF} + + + +# Do not advertise server version and real server type +sed -i "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" ${NGINX_CONF} +#sed -i '' "s[# server_tokens off;[server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1;[" testSed.txt +#cat testSed.txt |tr 'VVV' '\012' +#tr '⋱' '\012' < testSed.txt |tee testSed.txt +#tr '⋱' '\012' < /etc/nginx/nginx.conf |tee /etc/nginx/nginx.conf +sed -i 's/⋱/\n/g' ${NGINX_CONF} + +# Nginx: Restart +sudo nginx -t && service nginx restart +# /etc/init.d/nginx configtest && sudo /etc/init.d/nginx reload + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/$VHOST1/$PROJ1/www/index.html + +echo -e "\x1B[01;95m =========== http://127.0.0.1:4444/ =========== \x1B[0m" +echo -e "\x1B[01;95m =========== http://127.0.0.1:4445/ =========== \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Nginx \x1B[0m" + +exit 0 + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Jenkins +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# +# https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-with-ssl-as-a-reverse-proxy-for-jenkins +# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-jenkins-on-ubuntu-12-04 +# http://pkg.jenkins-ci.org/debian/ +# https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu +# https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins +# https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu +echo -e "\x1B[01;95m ▒[STARTED] Jenkins install and setup =========== \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;90m =========== Jenkins: Set conf var: /etc/default/jenkins =========== \x1B[0m" + +# Jenkins: Install key +wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add - + +# Jenkins: Generate a file with the Jenkins repository url +echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list + + +# Jenkins: Update local repos +sudo apt-get update + +# Jenkins: Install +apt-get install -y jenkins + +# Jenkins: Check it +ps -ef | grep jenkins + +echo -e "\x1B[01;90m =========== Jenkins: Backup default config =========== \x1B[0m" +cp /etc/default/jenkins /etc/default/jenkins.bak + +echo -e "\x1B[01;90m =========== Jenkins: Change home =========== \x1B[0m" +sed -i "s:JENKINS_HOME=/var/lib/jenkins:JENKINS_HOME=/home/jenkins:" $JENKINS_CONF + +mkdir -p /home/jenkins +chown -R jenkins:jenkins /home/jenkins + +# /etc/default/jenkins +echo -e "\x1B[01;90m =========== Jenkins: Change port [disabled] =========== \x1B[0m" +#sed -i "s:#port = 27017:port = 27017:" /etc/mongod.conf + +echo -e "\x1B[01;90m =========== Jenkins: Listen on all interfaces 0.0.0.0 [disabled] =========== \x1B[0m" +#sed -i "s:bind_ip:#bind_ip:" /etc/mongod.conf + +#sudo service mongod restart +# /etc/default/jenkins + +# Jenkins: Remove old JENKINS_ARGS +# JENKINS_ARGS="--webroot=/var/cache/jenkins/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT --prefix=/jenkins" +# JENKINS_ARGS="--webroot=/var/cache/jenkins/war --httpListenAddress=127.0.0.1 --httpPort=$HTTP_PORT -ajp13Port=$AJP_PORT" +sed -i "/JENKINS_ARGS=/d" $JENKINS_CONF +echo 'JENKINS_ARGS="--webroot=/var/cache/jenkins/war --httpListenAddress=127.0.0.1 --httpPort=$HTTP_PORT -ajp13Port=$AJP_PORT"' >> $JENKINS_CONF + +# jenkins: Version No +JENKINS_V=$(apt-cache policy jenkins) +#JENKINS_CMD=/usr/bin/java -- -jar /home/jenkins/jenkins.war + + +echo -e "\x1B[01;90m =========== Jenkins: startup: /etc/init.d/jenkins =========== \x1B[0m" +/etc/init.d/jenkins start +sudo service jenkins restart +sudo service nginx restart +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒[COMPLETE] Jenkins $JENKINS_V \x1B[0m" + +# Delete lock file for the following error: +# E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) + +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# ▒ Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒ [STARTED] Version No \x1B[0m" +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +# Python: Version No +python --version + +# Nginx: Version No +nginx -v + +# jenkins: Version No +echo -n "$JENKINS_V" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] Version No\x1B[0m" +printf "\n\n" + +# Ruby one-liner to print first 10 lines of file +echo -e "\x1B[01;90m =========== Nginx: First ten lines of $VHOST1.conf =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-available/$VHOST1_CONF +printf "\n\n" + +echo -e "\x1B[01;90m =========== Jenkins: First ten lines of log =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/default/jenkins +printf "\n\n" + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \x1B[0m" +echo -e "\x1B[01;95m ▒ [COMPLETE] EXITING BOOTSTRAP SCRIPT\x1B[0m" + +exit 0 +# DB restore from dump: mongorestore --drop -d db3--host mongodb1.example.net --port 27017 --username user --password pass /opt/backup/mongodump-2011-10-24 diff --git a/UbuntuTrusty64_1404_NginxJenkins/estSed.txt b/UbuntuTrusty64_1404_NginxJenkins/estSed.txt new file mode 100644 index 0000000..575d5cc --- /dev/null +++ b/UbuntuTrusty64_1404_NginxJenkins/estSed.txt @@ -0,0 +1,21 @@ +aeDSdf +asdfasdf +asdf +server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1; +dfsdf +sdfaefasdfasdf +asdf +asd +asdf +asd + +server_tokens off;⋱more_set_headers 'Server: Mine';⋱add_header X-VVT-Built BK-1; + +f +asd +fasdf +asdf +asdf + + +asdf diff --git a/UbuntuTrusty64_1404_NginxJenkins/readableString.txt b/UbuntuTrusty64_1404_NginxJenkins/readableString.txt new file mode 100644 index 0000000..1770f57 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxJenkins/readableString.txt @@ -0,0 +1,3 @@ +server_tokens off; +more_set_headers 'Server: Mine'; +add_header X-VVT-Built BK-1; diff --git a/UbuntuTrusty64_1404_NginxJenkins/testSed.txt b/UbuntuTrusty64_1404_NginxJenkins/testSed.txt new file mode 100644 index 0000000..0ba986b --- /dev/null +++ b/UbuntuTrusty64_1404_NginxJenkins/testSed.txt @@ -0,0 +1,25 @@ +aeDSdf +asdfasdf +asdf +server_tokens off; +more_set_headers 'Server: Mine'; +add_header X-VVT-Built BK-1; +dfsdf +sdfaefasdfasdf +asdf +asd +asdf +asd + +server_tokens off; +more_set_headers 'Server: Mine'; +add_header X-VVT-Built BK-1; + +f +asd +fasdf +asdf +asdf + + +asdf diff --git a/UbuntuTrusty64_1404_NginxJenkins/www/index.html b/UbuntuTrusty64_1404_NginxJenkins/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxJenkins/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful
diff --git a/UbuntuTrusty64_1404_NginxLuaLangRouting/Vagrantfile b/UbuntuTrusty64_1404_NginxLuaLangRouting/Vagrantfile new file mode 100644 index 0000000..e5d3aa9 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxLuaLangRouting/Vagrantfile @@ -0,0 +1,126 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 3000 + config.vm.network :forwarded_port, host: 4445, guest: 3001 + config.vm.network :forwarded_port, host: 4446, guest: 3002 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/UbuntuTrusty64_1404_NginxLuaLangRouting/bootstrap.sh b/UbuntuTrusty64_1404_NginxLuaLangRouting/bootstrap.sh new file mode 100644 index 0000000..fc7d931 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxLuaLangRouting/bootstrap.sh @@ -0,0 +1,375 @@ +#!/usr/bin/env bash + +sudo -s + +: ' +#Reference Links: +https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 +https://www.digitalocean.com/community/tutorials/how-to-use-vagrant-on-your-own-vps-running-ubuntu +http://wiki.nginx.org/Install +http://nginx.org/en/docs/http/server_names.html + +#Nginx server block: +https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts +https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 + +#community boxes: + http://www.vagrantbox.es/ + +#Node.js: +https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions + +# Ruby: +https://gorails.com/deploy/ubuntu/14.04 +http://www.centurylinklabs.com/tutorials/ubuntu/installing-ruby-2-1-2-on-rails-4-1-2-on-ubuntu-trusty-14-04/ +https://www.digitalocean.com/community/tutorials/how-to-install-ruby-2-1-0-and-sinatra-on-ubuntu-13-with-rvm +http://leonid.shevtsov.me/en/making-rvm-play-nicely-with-system-scripts +http://rvm.io/rvm/install + +# Ruby oneliners +http://reference.jumpingmonkey.org/programming_languages/ruby/ruby-one-liners.html + +#vsftpd +https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-on-ubuntu-12-04 +https://www.digitalocean.com/community/questions/var-www-to-home-user-public_html + +#Server setup +https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04 +https://www.digitalocean.com/community/tutorials/how-to-launch-your-site-on-a-new-ubuntu-12-04-server-with-lamp-sftp-and-dns +https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-12-04 + +# User control +https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-an-ubuntu-14-04-vps +https://www.linode.com/docs/tools-reference/linux-users-and-groups + + +# Limit an FTP or SFTP linux +http://www.faqs.org/docs/securing/chap29sec295.html +http://ubuntuforums.org/showthread.php?t=1980933 +http://stackoverflow.com/questions/24575033/restricting-sftp-user-to-home-directory +## best +https://survivalguides.wordpress.com/2011/05/20/chroot-sftp-connection/ + +vi /etc/ssh/sshd_config +Go to bottom +#Subsystem sftp /usr/lib/openssh/sftp-server +Subsystem sftp internal-sftp +Match group teamwww +ChrootDirectory /var/www +X11Forwarding no +AllowTcpForwarding no +ForceCommand internal-sftp + +sudo service ssh restart + +# Unix Permissions Calculator and check octal permissions +http://permissions-calculator.org/ +http://askubuntu.com/questions/152001/how-can-i-get-octal-file-permissions-from-command-line + +# IP +http://www.cyberciti.biz/faq/how-to-find-out-the-ip-address-assigned-to-eth0-and-display-ip-only/ + +#SED one-liners +http://sed.sourceforge.net/sed1line.txt +http://www.folkstalk.com/2013/03/sed-remove-lines-file-unix-examples.html +' + + + +# Install build and main packages +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# https://help.ubuntu.com/community/AptGet/Howto +echo -e "\x1B[01;95m =========== Install build and main packages [STARTED]=========== \x1B[0m" + +# build-essential is available on Main repository for 14.04. So first enable repository. Didint use for RVM ruby +# sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" + +# Run this command periodically to make sure your source list is up-to-date +echo -e "\x1B[01;90m =========== Update source list =========== \x1B[0m" +#sudo apt-get update + +#aptitude update +#aptitude -y upgrade + +#sudo apt-get install -y git-core curl zlib1g-dev build-essential checkinstall python-software-properties +echo -e "\x1B[01;95m =========== Install build and main packages [COMPLETE]=========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Install build and main packages + + +# User setup +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[STARTED] User setup =========== \x1B[0m" +USER1="dev1" +USER2="dev2" +GROUP1="teamwww" + +# Add group +echo -e "\x1B[01;90m =========== Add groups =========== \x1B[0m" +addgroup $GROUP1 + +# Add users +echo -e "\x1B[01;90m =========== Add users =========== \x1B[0m" + +# Create user [pass: london5] quietly add a user without password +adduser $USER1 --quiet --disabled-password --shell /bin/bash --home /home/$USER1 --gecos "Developer One" +adduser $USER2 --quiet --disabled-password --shell /bin/bash --home /home/$USER2 --gecos "Developer Two" + + + +# Set passwords +echo -e "\x1B[01;90m =========== Set passwords =========== \x1B[0m" +# Additonal usermod option -G SECONDARYGROUP1,SECONDARYGROUP2 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london5") $USER1 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london55") $USER2 +#echo "dev1:london5" | chpasswd + +# Providing SSH creds +echo -e "\x1B[01;90m =========== Providing SSH creds =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER1@localhost =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER2@localhost =========== \x1B[0m" + +# Create www group and add dev1 to it [to undo: sudo deluser user group] +#usermod -a -G teamwww dev1 + +# Give team privages to user www-data, then check +echo -e "\x1B[01;90m =========== Add user www-data to teamwww, then check =========== \x1B[0m" +gpasswd -a www-data teamwww +groups www-data + +echo -e "\x1B[01;95m ===========[COMPLETE] User setup =========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# User control + + + + + +# Setup webspaces in preparation of server +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[STARTED] Setup webspaces in preparation of server =========== \x1B[0m" + +# Remove bs down the line +echo -e "\x1B[01;90m =========== Remove bs down the line /var/www =========== \x1B[0m" +rm -rf /var/www + +# Setup vhost directories +echo -e "\x1B[01;90m =========== Setup vhost directories =========== \x1B[0m" +VHOST1="vhost1" +VHOST2="vhost2" +VHOST3="vhost3" + +PROJ1="projectNameOrRepo" +PROJ2="projectNameOrRepo" +PROJ3="projectNameOrRepo" + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/{$VHOST1,$VHOST2,$VHOST3}/{$PROJ1,$PROJ2,$PROJ3}/www +mkdir -p /var/www/$VHOST2/$PROJ2/www +mkdir -p /var/www/$VHOST3/$PROJ3/www + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www/$VHOST1 +chown -R dev1:teamwww /var/www/$VHOST2 +chown -R dev2:teamwww /var/www/$VHOST3 + +#chmod -R 755 /var/www +# 2 = all files and directories newly created within it inherit the group from that directory +chmod -R 2774 /var/www/$VHOST1 +chmod -R 2774 /var/www/$VHOST2 +chmod -R 2774 /var/www/$VHOST3 + +# Set user or group ID on execution +chmod -R g+s /var/www/$VHOST1 +chmod -R g+s /var/www/$VHOST2 +chmod -R g+s /var/www/$VHOST3 + +# List directories +echo -e "\x1B[01;90m =========== List directories =========== \x1B[0m" +# '-print' arg is optional - it's default. also if a specific listing format is required it can be fed into xargs to run ls with any desired options, e.g. find /path/ -type d -print0 | xargs -0 -r ls -ld. Note the -print0 for NULL terminated output, and the matching -0 xargs arg +find /var/www/ -type d -print0 | xargs -0 -r ls -ld + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Check octal permissions on vhost1 =========== \x1B[0m" +stat -c "%a %n" /var/www/$VHOST1 + +echo -e "\x1B[01;95m ===========[COMPLETE] Setup webspaces in preparation of server =========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Setup webspaces in preparation of server + + +# Synce Vagrant home directory with /var/www +echo -e "\x1B[01;90m =========== Synce Vagrant home directory with /var/www =========== \x1B[0m" +ln -fs /vagrant/www /var/www +#ln -l /vagrant/www/ /var/www/pt80/ + + + + +# Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[STARTED] Nginx install and setup =========== \x1B[0m" +# use nginx=development for latest development version +nginx=stable +add-apt-repository ppa:nginx/$nginx +apt-get update + +#https://packages.debian.org/sid/nginx-extras +#apt-get install -y nginx +apt-get install -y nginx-extras +nginx -v +echo -e "\x1B[01;90m =========== Nginx installed =========== \x1B[0m" + + + +echo -e "\x1B[01;90m =========== Nginx: Remove active default =========== \x1B[0m" +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +echo -e "\x1B[01;90m =========== Nginx: Backup default config =========== \x1B[0m" +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +echo -e "\x1B[01;90m =========== Nginx: mv default to my default page =========== \x1B[0m" +mv /etc/nginx/sites-available/default /etc/nginx/sites-available/$VHOST1.conf + +echo -e "\x1B[01;90m =========== Nginx: symlink all new vhosts =========== \x1B[0m" +# Nginx: symlink all new vhosts +sudo ln -s /etc/nginx/sites-available/$VHOST1.conf /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +echo -e "\x1B[01;90m =========== Nginx: Replace default vhost root =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:/usr/share/nginx/html:/var/www/$VHOST1/$PROJ1/www:" /etc/nginx/sites-available/$VHOST1.conf +sed -i "s:/var/www/html:/var/www/$VHOST1/$PROJ1/www:" /etc/nginx/sites-available/$VHOST1.conf + + +# Nginx: Change ports 3000, 3001, 3002 +echo -e "\x1B[01;90m =========== Nginx: Change ports 3000 - 1 =========== \x1B[0m" +sed -i "s:listen 80:listen 3000:" /etc/nginx/sites-available/$VHOST1.conf + +echo -e "\x1B[01;90m =========== Nginx: Change ports 3000 - 2 =========== \x1B[0m" +sed -i 's_:80_:3000_' /etc/nginx/sites-available/$VHOST1.conf + +echo -e "\x1B[01;90m =========== Nginx: LUA Routing =========== \x1B[0m" +export ROUTING_LUA=$(cat < /tmp/$VHOST1.conf && mv /tmp/$VHOST1.conf /etc/nginx/sites-available/$VHOST1.conf + +# Nginx: Allow long domain names +echo -e "\x1B[01;90m =========== Nginx: Allow long domain names =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" /etc/nginx/nginx.conf + +# Nginx: Restart +sudo nginx -t && service nginx restart +# /etc/init.d/nginx configtest && sudo /etc/init.d/nginx reload + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/$VHOST1/$PROJ1/www/index.html + + +echo -e "\x1B[01;95m ===========[COMPLETE] Nginx install and setup =========== \x1B[0m" +echo -e "\x1B[01;95m =========== http://127.0.0.1:4444/ =========== \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Nginx + +echo -e "\x1B[01;95m =========== EXITING BOOTSTRAP SCRIPT =========== \x1B[0m" +exit 0 + +# Node.js +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Node.js: Download and pipe to bash, https://github.com/nodesource/distributions +curl -sL https://deb.nodesource.com/setup | sudo bash - + +# Node.js: Then install with Ubuntu: +sudo apt-get install -y nodejs +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Nginx + +# Delete lock file for the following error: +# E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) + + +echo -e "\x1B[01;95m \n\n\n\n======================================== \x1B[0m" +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;90m =========== Version No [STARTED]=========== \x1B[0m" +echo -e "\x1B[01;90m ======================================== \x1B[0m" +# Nginx: Version No +nginx -v + +# Node.js: Version No +node --version + +# Python: Version No +python --version + +echo -e "\x1B[01;90m =========== Version No [COMPLETE]=========== \x1B[0m" +echo "\n\n\n\n" + +# Ruby one-liner to print first 10 lines of file +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-enabled/pt80 + + +# htpasswd +sudo apt-get install apache2-utils +sudo htpasswd -c /etc/nginx/.htpasswd tool +vi /etc/nginx/sites-enabled/pt80 +sudo /etc/init.d/nginx reload +# Nginx: To ensure that nginx will be up after reboots, it’s best to add it to the startup. +sudo apt-get purge apache2-utils + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /etc/nginx/sites-protected +cd /etc/nginx/sites-protected + +# Password file +touch .pt80WebrootPasswd + +# Manual operations +perl -le 'print crypt("car21train", "salt-hash")' +# vi .pt80WebrootPasswd + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" diff --git a/UbuntuTrusty64_1404_NginxLuaLangRouting/bootstrapLoopTest.sh b/UbuntuTrusty64_1404_NginxLuaLangRouting/bootstrapLoopTest.sh new file mode 100644 index 0000000..22d3917 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxLuaLangRouting/bootstrapLoopTest.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# bootstrapLoopTest.sh +# +# +# Created by vtool on 12/12/14. +# +repos_array=("ibm-us-open-2014" "land-rover-beyond-epic-2014.git" "Google-360" "airbnb-interactiveMap-2014" "airbnb-oneLessStranger-2014") + +for index in ${!repos_array[*]}; + +do + +#printf "%4d: %s\n" $index ${repos_array[$index]} + +indexWithColor="\033[42m$index\033[0m" + +printf "\033[42m$index ${repos_array[$index]} \033[0m\n" + +#printf "\e[40;38;5;82m Hello \e[30;48;5;82m World \e[0m\n" +#printf "\e[31m\e[43m World \e[0m\n"%n +echo "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" +done +echo "\n\n \ No newline at end of file diff --git a/UbuntuTrusty64_1404_NginxLuaLangRouting/www/index.html b/UbuntuTrusty64_1404_NginxLuaLangRouting/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxLuaLangRouting/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful
diff --git a/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/action_provision b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/action_provision new file mode 100644 index 0000000..9cc7cc7 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:d4ce445b-6cb4-41a8-9c68-e10181c2d1a1 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/action_set_name b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/action_set_name new file mode 100644 index 0000000..6a67bb6 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/action_set_name @@ -0,0 +1 @@ +1424877781 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/id b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/id new file mode 100644 index 0000000..4626bfa --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/id @@ -0,0 +1 @@ +d4ce445b-6cb4-41a8-9c68-e10181c2d1a1 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/index_uuid b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/index_uuid new file mode 100644 index 0000000..fa79982 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/index_uuid @@ -0,0 +1 @@ +06bcbb69a9424fc89cea25afe3b74de9 \ No newline at end of file diff --git a/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/synced_folders b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/synced_folders new file mode 100644 index 0000000..76906cd --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/.vagrant/machines/default/virtualbox/synced_folders @@ -0,0 +1 @@ +{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Volumes/stereo_2/virtualSims/ubuntuTrusty64_1404_NginxMongoDB","disabled":false}}} \ No newline at end of file diff --git a/UbuntuTrusty64_1404_NginxMongoDB/Vagrantfile b/UbuntuTrusty64_1404_NginxMongoDB/Vagrantfile new file mode 100644 index 0000000..9e32f89 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/Vagrantfile @@ -0,0 +1,127 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.network :forwarded_port, host: 4444, guest: 3000 + config.vm.network :forwarded_port, host: 4445, guest: 3001 + config.vm.network :forwarded_port, host: 4446, guest: 3002 + config.vm.network :forwarded_port, host: 4447, guest: 27017 + + # 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 forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/UbuntuTrusty64_1404_NginxMongoDB/bootstrap.sh b/UbuntuTrusty64_1404_NginxMongoDB/bootstrap.sh new file mode 100644 index 0000000..85ca23a --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/bootstrap.sh @@ -0,0 +1,298 @@ +#!/usr/bin/env bash + +sudo -s + +# Install build and main packages +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# https://help.ubuntu.com/community/AptGet/Howto +echo -e "\x1B[01;95m =========== Install build and main packages [STARTED]=========== \x1B[0m" + +# build-essential is available on Main repository for 14.04. So first enable repository. Didint use for RVM ruby +# sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" + +# Run this command periodically to make sure your source list is up-to-date +echo -e "\x1B[01;90m =========== Update source list =========== \x1B[0m" +#sudo apt-get update + +#aptitude update +#aptitude -y upgrade + +#sudo apt-get install -y git-core curl zlib1g-dev build-essential checkinstall python-software-properties +echo -e "\x1B[01;95m =========== Install build and main packages [COMPLETE]=========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Install build and main packages + + +# User setup +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[STARTED] User setup =========== \x1B[0m" +USER1="dev1" +USER2="dev2" +GROUP1="teamwww" + +# Add group +echo -e "\x1B[01;90m =========== Add groups =========== \x1B[0m" +addgroup $GROUP1 + +# Add users +echo -e "\x1B[01;90m =========== Add users =========== \x1B[0m" + +# Create user [pass: london5] quietly add a user without password +adduser $USER1 --quiet --disabled-password --shell /bin/bash --home /home/$USER1 --gecos "Developer One" +adduser $USER2 --quiet --disabled-password --shell /bin/bash --home /home/$USER2 --gecos "Developer Two" + + + +# Set passwords +echo -e "\x1B[01;90m =========== Set passwords =========== \x1B[0m" +# Additonal usermod option -G SECONDARYGROUP1,SECONDARYGROUP2 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london5") $USER1 +usermod -G $GROUP1 -p $(openssl passwd -1 -salt shaker "london55") $USER2 +#echo "dev1:london5" | chpasswd + +# Providing SSH creds +echo -e "\x1B[01;90m =========== Providing SSH creds =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER1@localhost =========== \x1B[0m" +echo -e "\x1B[01;90m =========== ssh -p 2222 $USER2@localhost =========== \x1B[0m" + +# Create www group and add dev1 to it [to undo: sudo deluser user group] +#usermod -a -G teamwww dev1 + +# Give team privages to user www-data, then check +echo -e "\x1B[01;90m =========== Add user www-data to teamwww, then check =========== \x1B[0m" +gpasswd -a www-data teamwww +groups www-data + +echo -e "\x1B[01;95m ===========[COMPLETE] User setup =========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# User control + + + + + +# Setup webspaces in preparation of server +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[STARTED] Setup webspaces in preparation of server =========== \x1B[0m" + +# Remove bs down the line +echo -e "\x1B[01;90m =========== Remove bs down the line /var/www =========== \x1B[0m" +rm -rf /var/www + +# Setup vhost directories +echo -e "\x1B[01;90m =========== Setup vhost directories =========== \x1B[0m" +VHOST1="vhost1" +VHOST2="vhost2" +VHOST3="vhost3" + +PROJ1="projectNameOrRepo" +PROJ2="projectNameOrRepo" +PROJ3="projectNameOrRepo" + +# recursive mkdir for vhost1 / create any necessary parent directories +mkdir -p /var/www/{$VHOST1,$VHOST2,$VHOST3}/{$PROJ1,$PROJ2,$PROJ3}/www +mkdir -p /var/www/$VHOST2/$PROJ2/www +mkdir -p /var/www/$VHOST3/$PROJ3/www + +# http://permissions-calculator.org/ +# Own it all chown -R $USER:teamwww /var/www +chown -R dev1:teamwww /var/www/$VHOST1 +chown -R dev1:teamwww /var/www/$VHOST2 +chown -R dev2:teamwww /var/www/$VHOST3 + +#chmod -R 755 /var/www +# 2 = all files and directories newly created within it inherit the group from that directory +chmod -R 2774 /var/www/$VHOST1 +chmod -R 2774 /var/www/$VHOST2 +chmod -R 2774 /var/www/$VHOST3 + +# Set user or group ID on execution +chmod -R g+s /var/www/$VHOST1 +chmod -R g+s /var/www/$VHOST2 +chmod -R g+s /var/www/$VHOST3 + +# List directories +echo -e "\x1B[01;90m =========== List directories =========== \x1B[0m" +# '-print' arg is optional - it's default. also if a specific listing format is required it can be fed into xargs to run ls with any desired options, e.g. find /path/ -type d -print0 | xargs -0 -r ls -ld. Note the -print0 for NULL terminated output, and the matching -0 xargs arg +find /var/www/ -type d -print0 | xargs -0 -r ls -ld + +# Check octal permissions on vhost1 +echo -e "\x1B[01;90m =========== Check octal permissions on vhost1 =========== \x1B[0m" +stat -c "%a %n" /var/www/$VHOST1 + +echo -e "\x1B[01;95m ===========[COMPLETE] Setup webspaces in preparation of server =========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Setup webspaces in preparation of server + + +# Synce Vagrant home directory with /var/www +echo -e "\x1B[01;90m =========== Synce Vagrant home directory with /var/www =========== \x1B[0m" +ln -fs /vagrant/www /var/www +#ln -l /vagrant/www/ /var/www/pt80/ + + + + +# Nginx +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[STARTED] Nginx install and setup =========== \x1B[0m" +# use nginx=development for latest development version +nginx=stable +add-apt-repository ppa:nginx/$nginx +apt-get update + +#https://packages.debian.org/sid/nginx-extras +#apt-get install -y nginx +apt-get install -y nginx-extras +nginx -v +echo -e "\x1B[01;90m =========== Nginx installed =========== \x1B[0m" + + + +echo -e "\x1B[01;90m =========== Nginx: Remove active default =========== \x1B[0m" +# Remove active default +rm /etc/nginx/sites-enabled/default + +# Nginx: Backup default config/server block and create new vhost at 80 +echo -e "\x1B[01;90m =========== Nginx: Backup default config =========== \x1B[0m" +cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak + +# Nginx: mv default to my default page +echo -e "\x1B[01;90m =========== Nginx: mv default to my default page =========== \x1B[0m" +mv /etc/nginx/sites-available/default /etc/nginx/sites-available/$VHOST1.conf + +echo -e "\x1B[01;90m =========== Nginx: symlink all new vhosts =========== \x1B[0m" +# Nginx: symlink all new vhosts +sudo ln -s /etc/nginx/sites-available/$VHOST1.conf /etc/nginx/sites-enabled/ + +# Nginx: Replace default vhost root: /usr/share/nginx/html +echo -e "\x1B[01;90m =========== Nginx: Replace default vhost root =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:/usr/share/nginx/html:/var/www/$VHOST1/$PROJ1/www:" /etc/nginx/sites-available/$VHOST1.conf +sed -i "s:/var/www/html:/var/www/$VHOST1/$PROJ1/www:" /etc/nginx/sites-available/$VHOST1.conf + + +# Nginx: Change ports 3000, 3001, 3002 +echo -e "\x1B[01;90m =========== Nginx: Change ports 3000 - 1 =========== \x1B[0m" +sed -i "s:listen 80:listen 3000:" /etc/nginx/sites-available/$VHOST1.conf + +echo -e "\x1B[01;90m =========== Nginx: Change ports 3000 - 2 =========== \x1B[0m" +sed -i 's_:80_:3000_' /etc/nginx/sites-available/$VHOST1.conf + +echo -e "\x1B[01;90m =========== Nginx: Remove unnecessary example file towards bottom of conf =========== \x1B[0m" +# Delete lines starting from a pattern till the last line +sed -i '/# Virtual Host configuration for/,$d' /etc/nginx/sites-available/$VHOST1.conf + +# Nginx: Allow long domain names +echo -e "\x1B[01;90m =========== Nginx: Allow long domain names =========== \x1B[0m" +# -i edit files in place (makes backup if extension supplied) -i[SUFFIX], --in-place[=SUFFIX] +sed -i "s:# server_names_hash_bucket_size 64:server_names_hash_bucket_size 64:" /etc/nginx/nginx.conf + +# Nginx: Restart +sudo nginx -t && service nginx restart +# /etc/init.d/nginx configtest && sudo /etc/init.d/nginx reload + +# Nginx: Store my default page inside variable heredoc then create index.html +# html-minifier --remove-comments --collapse-whitespace --minify-js --minify-css genericHTMLPage.html -o plainhtml.html +export EASY_WEB=$(cat <ivhost1
Wonderful
+END +) ; echo $EASY_WEB + + +# html: Create default page +#printf $EASY_WEB > /var/www/pt80/index.html +echo $EASY_WEB >> /var/www/$VHOST1/$PROJ1/www/index.html + + +echo -e "\x1B[01;95m ===========[COMPLETE] Nginx install and setup =========== \x1B[0m" +echo -e "\x1B[01;95m =========== http://127.0.0.1:4444/ =========== \x1B[0m" + +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Nginx + + + +# Node.js +#echo -e "\x1B[01;95m ===========[STARTED] Node.js install and setup =========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# Node.js: Download and pipe to bash, https://github.com/nodesource/distributions +#curl -sL https://deb.nodesource.com/setup | sudo bash - + +# Node.js: Then install with Ubuntu: +#sudo apt-get install -y nodejs +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +#echo -e "\x1B[01;95m ===========[COMPLETE] Node.js install and setup =========== \x1B[0m" +# Node.js + + +# MongoDB +#http://www.mongodbspain.com/en/2014/08/30/install-mongodb-on-ubuntu-14-04/ +echo -e "\x1B[01;95m ===========[STARTED] MongoDB install and setup =========== \x1B[0m" +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +# MongoDB: Install key +sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 + +# MongoDB: Generate a file with the MongoDB repository url +echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list + +# MongoDB: Update local repos +sudo apt-get update + +# MongoDB: Install +apt-get install -y mongodb-org + +# MongoDB: Check it +ps -ef | grep mongo + +# MongoDB: Open port = 27017 + +echo -e "\x1B[01;90m =========== MongoDB: Open port 27017 in mongod.conf =========== \x1B[0m" +sed -i "s:#port = 27017:port = 27017:" /etc/mongod.conf + +echo -e "\x1B[01;90m =========== MongoDB: Listen on all interfaces 0.0.0.0 =========== \x1B[0m" +sed -i "s:bind_ip:#bind_ip:" /etc/mongod.conf + +sudo service mongod restart +# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +echo -e "\x1B[01;95m ===========[COMPLETE] MongoDB install and setup =========== \x1B[0m" +# MongoDB + +# Delete lock file for the following error: +# E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) + + +echo -e "\x1B[01;95m \n\n\n\n======================================== \x1B[0m" +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;90m =========== Version No [STARTED]=========== \x1B[0m" +echo -e "\x1B[01;90m ======================================== \x1B[0m" +# MongoDB: Version No +mongo --version + +# Nginx: Version No +nginx -v + +# Node.js: Version No +#node --version + +# Python: Version No +python --version + +echo -e "\x1B[01;90m =========== Version No [COMPLETE]=========== \x1B[0m" +printf "\n\n" + +# Ruby one-liner to print first 10 lines of file +echo -e "\x1B[01;90m =========== Nginx: First ten lines of $VHOST1.conf =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /etc/nginx/sites-available/$VHOST1.conf +echo -e "\x1B[01;90m =========== MongoDB: First ten lines of log =========== \x1B[0m" +ruby -pe 'exit if $. > 10' < /var/log/mongodb/mongod.log +printf "\n\n" + +# Get IP of instance +IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +echo -e "\x1B[01;95m ======================================== \x1B[0m" +echo -e "\x1B[01;95mhttp://$IP \x1B[0m" + +echo -e "\x1B[01;95m =========== EXITING BOOTSTRAP SCRIPT =========== \x1B[0m" +exit 0 +# DB restore from dump: mongorestore --drop -d db3--host mongodb1.example.net --port 27017 --username user --password pass /opt/backup/mongodump-2011-10-24 diff --git a/UbuntuTrusty64_1404_NginxMongoDB/www/index.html b/UbuntuTrusty64_1404_NginxMongoDB/www/index.html new file mode 100644 index 0000000..dadd5e5 --- /dev/null +++ b/UbuntuTrusty64_1404_NginxMongoDB/www/index.html @@ -0,0 +1 @@ +ivhost1 slash www
Wonderful