From: Mike Croft Date: Thu, 18 Jun 2015 14:07:06 +0000 (+0100) Subject: Parameterised shell script, extracted to separate file and cleaned Vagrantfile. Added... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e09a44751794433e566e0774f8d93ecb54e82162;p=payara-vagrant.git Parameterised shell script, extracted to separate file and cleaned Vagrantfile. Added support for version 4.1.152 --- diff --git a/Vagrantfile b/Vagrantfile index e806dd7..5dc323d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,95 +1,13 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "ubuntu/trusty64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # 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" - - # 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.box = "ubuntu/trusty64" + config.vm.provider "virtualbox" do |vb| - # Display the VirtualBox GUI when booting the machine - # vb.gui = true - - # Customize the amount of memory on the VM: - vb.memory = "4096" + vb.memory = "1024" end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # + + config.vm.provision "shell", path: "provision.sh" - # The below wget gets Payara 4.1.151 Full profile. The list of links for - # Payara 4.1.151 are: - # Full....................http://bit.ly/1CGCtI9 - # Web.....................http://bit.ly/1DmWTUY - # Minimal.................http://bit.ly/163XP6f - # Embedded Full...........http://bit.ly/1zG59ls - # Embedded Web............http://bit.ly/1KdVP87 - # Embedded Nucleus........http://bit.ly/1ydQTKw - # Multi-language Full.....https://bit.ly/1zv1YeB - # Multi-language Web......https://bit.ly/1wVXaZR - # - # - config.vm.provision "shell", inline: <<-SHELL - sudo apt-get -qqy update # Update the repos - sudo apt-get -qqy install openjdk-7-jdk # Install JDK 7 - sudo apt-get -qqy install unzip # Install unzip - wget -q http://bit.ly/1CGCtI9 -O temp.zip # Download Payara - sudo mkdir -p /opt/payara/startup # Make dirs for Payara - unzip -qq temp.zip -d /opt/payara # unzip Payara to dir - sudo cp /vagrant/payara_service-4.1.151 /opt/payara/startup/ - sudo chmod +x /opt/payara/startup/payara_service-4.1.151 - ln -s /opt/payara/startup/payara_service-4.1.151 /etc/init.d/payara - sudo update-rc.d payara defaults - sudo chown -R vagrant:vagrant /opt/payara # Make sure vagrant owns dir - service payara start - SHELL end diff --git a/payara_service-4.1.151 b/payara_service-4.1.151 index 9f527bb..47c1061 100644 --- a/payara_service-4.1.151 +++ b/payara_service-4.1.151 @@ -3,28 +3,28 @@ # Basic Payara service # -PAYARA_HOME=/opt/payara/payara41 +PAYARA_HOME=/opt/payara/payara-4.1.151/payara41 export PAYARA_HOME start() { echo -n "Starting Payara: " - $PAYARA_HOME/bin/asadmin start-domain + $PAYARA_HOME/bin/asadmin start-domain $1 } stop() { echo -n "Stopping Payara: " - $PAYARA_HOME/bin/asadmin stop-domain + $PAYARA_HOME/bin/asadmin stop-domain $1 } case "$1" in start) - start + start $2 ;; stop) - stop + stop $2 ;; restart) $PAYARA_HOME/bin/asadmin restart-domain >/dev/null diff --git a/payara_service-4.1.152 b/payara_service-4.1.152 new file mode 100644 index 0000000..8df8e13 --- /dev/null +++ b/payara_service-4.1.152 @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Basic Payara service +# + +PAYARA_HOME=/opt/payara/payara-4.1.152/payara41 +export PAYARA_HOME + + + +start() { + echo -n "Starting Payara: " + $PAYARA_HOME/bin/asadmin start-domain $1 +} + +stop() { + echo -n "Stopping Payara: " + $PAYARA_HOME/bin/asadmin stop-domain $1 +} + + +case "$1" in +start) + start $2 + ;; +stop) + stop $2 + ;; +restart) + $PAYARA_HOME/bin/asadmin restart-domain >/dev/null + ;; +\*) + echo "usage: $0 (start|stop|restart|help)" +esac diff --git a/provision.sh b/provision.sh new file mode 100644 index 0000000..7fbd0ed --- /dev/null +++ b/provision.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +# Properties +#source PROPERTIES.sh + + +########################################## +# +# Setting properties +# + +# Payara Version +PAYARA_VERSION=4.1.152 + +# Payara URLs +case "$PAYARA_VERSION" in + 4.1.151) + FULL=http://bit.ly/1CGCtI9 + WEB=http://bit.ly/1DmWTUY + MINIMAL=http://bit.ly/163XP6f + EMBEDDED_FULL=http://bit.ly/1zG59ls + EMBEDDED_WEB=http://bit.ly/1KdVP87 + EMBEDDED_NUCLEUS=http://bit.ly/1ydQTKw + MULTI_LANGUAGE_FULL=https://bit.ly/1zv1YeB + MULTI_LANGUAGE_WEB=https://bit.ly/1wVXaZ + ;; + 4.1.152) + FULL=http://bit.ly/1bGAaLi + WEB=http://bit.ly/1Kxvt2C + MINIMAL=http://bit.ly/1zue2io + MICRO=http://bit.ly/1EUuZoj + EMBEDDED_FULL=http://bit.ly/1JbWacf + EMBEDDED_WEB=http://bit.ly/1GKDanG + MULTI_LANGUAGE_FULL=http://bit.ly/1JUQByV + MULTI_LANGUAGE_WEB=http://bit.ly/1HUIIKN + ;; +\*) + echo "unknown version number" +esac + +# Payara directory +PAYARA_HOME=/opt/payara/payara-$PAYARA_VERSION +# +# +# +########################################## + + +echo "Provisioning Payara-$PAYARA_VERSION to $PAYARA_HOME" + +# Download and unzip to /opt/payara +echo "running update..." +sudo apt-get -qqy update # Update the repos + +echo "installing openjdk and unzip" +sudo apt-get -qqy install openjdk-7-jdk # Install JDK 7 +sudo apt-get -qqy install unzip # Install unzip + +echo "Downloading Payara $PAYARA_VERSION" +wget -q $WEB -O temp.zip > /dev/null # Download Payara +sudo mkdir -p $PAYARA_HOME/startup # Make dirs for Payara +unzip -qq temp.zip -d $PAYARA_HOME # unzip Payara to dir + +# Copy startup script, and create service +echo "installing startup scripts" +sudo cp /vagrant/payara_service-$PAYARA_VERSION $PAYARA_HOME/startup/ +sudo chmod +x $PAYARA_HOME/startup/payara_service-$PAYARA_VERSION +ln -s $PAYARA_HOME/startup/payara_service-$PAYARA_VERSION /etc/init.d/payara + +echo "Adding payara system startup..." +sudo update-rc.d payara defaults > /dev/null + +sudo chown -R vagrant:vagrant $PAYARA_HOME # Make sure vagrant owns dir + +echo "starting Payara..." + +case "$PAYARA_VERSION" in + 4.1.151) + service payara start domain1 + ;; + 4.1.152) + service payara start payaradomain + ;; + /*) + echo "Unknown Payara version, attempting to start domain1..." + service payara start domain1 +esac