You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by andreaturli <gi...@git.apache.org> on 2014/09/09 11:59:52 UTC

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

GitHub user andreaturli opened a pull request:

    https://github.com/apache/incubator-brooklyn/pull/157

    BROOKLYN-55 install script for brooklyn

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/andreaturli/incubator-brooklyn brooklyn-55

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-brooklyn/pull/157.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #157
    
----
commit fb0416b684e63c861a707e40666eb3bd3162c295
Author: Andrea Turli <an...@gmail.com>
Date:   2014-09-08T15:40:26Z

    BROOKLYN-55 install script for brooklyn

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17292797
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    --- End diff --
    
    Add a log message to say we're doing this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17390172
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    --- End diff --
    
    I think @sjcorbett means use the words "set up". The previous line used "Setup". For consistency we should say "Set up".
    
    A "setup" is a noun. To "set up" is a verb (see http://dictionary.reference.com/browse/setup).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-56680194
  
    OK, I fixed a couple of issues, and made a new PR based on this, as it doesn't work o n images that do not allow remote root access.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17292854
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    --- End diff --
    
    `Setup` and `set up`. Suggest we always use `set up`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17293084
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "...done"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Installing Brooklyn..."
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    --- End diff --
    
    Could supply a base-dir, rather than installing directly into root of user's dir. But that can be a future enhancement.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17389859
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,272 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Setup random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "done!"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn... "
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "done!"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "done!"
    +
    +# Run Brooklyn
    +log "Starting Brooklyn..."
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +sleep 10
    +
    +URL=$(ssh ${SSH_OPTS} ${USER}@${HOST} "grep 'Started Brooklyn console at' ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log | cut -d' ' -f9 | tr -d ," 2>&1)
    +
    +log "Brooklyn Console URL at ${URL}"
    +
    +if wget -qO- --retry-connrefused --no-check-certificate ${URL} &> /dev/null; then
    --- End diff --
    
    Used `curl` on commands being executed over ssh. Good to be consistent - any reason to use `wget` instead of `curl` here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17389822
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,272 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Setup random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "done!"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn... "
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "done!"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "done!"
    +
    +# Run Brooklyn
    +log "Starting Brooklyn..."
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +sleep 10
    +
    +URL=$(ssh ${SSH_OPTS} ${USER}@${HOST} "grep 'Started Brooklyn console at' ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log | cut -d' ' -f9 | tr -d ," 2>&1)
    +
    +log "Brooklyn Console URL at ${URL}"
    +
    +if wget -qO- --retry-connrefused --no-check-certificate ${URL} &> /dev/null; then
    --- End diff --
    
    `wget` will return exit code `6` (Username/password authentication failure) if there is a username:password required for login.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17538323
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,274 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Set up random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    --- End diff --
    
    Thanks @Nakomis I think `-e` will be removed as it is always needed.
    
    for `-devel` this script should work as it is downloading binaries for brooklyn-examples so it doesn't need to build them, but probably it is safer to install `-devel- anyway


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-54952648
  
    Looks good. A few comments. I haven't tested it yet though.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by Nakomis <gi...@git.apache.org>.
Github user Nakomis commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-55407345
  
    Tested on a SoftLayer Ubuntu VM, and brooklyn was installed OK, but the Console URL wasn't output: https://gist.github.com/Nakomis/d9482d84d774d91a68eb


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17293222
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "...done"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Installing Brooklyn..."
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "...done"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn..."
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "...done"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "...done"
    +
    +# Run Brooklyn
    +log -n "Starting Brooklyn..."
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +log "...done"
    +echo "Console URL is http://${HOST}:8081/"
    --- End diff --
    
    There are a lot of options one might specify (e.g. also supply the port to override 8081). Eventually, we might want to take a config file that supplies all the values rather than more and more command line options. But that can be for the future. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17389430
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,272 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Setup random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    --- End diff --
    
    I wonder if what we should do about expectations of things like `curl` and `tar` being installed. Should we check early and fail?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17292610
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "...done"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Installing Brooklyn..."
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "...done"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn..."
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "...done"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    --- End diff --
    
    Perhaps we should keep this as a resource to be uploaded, rather than embedded inside the script?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17292843
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    --- End diff --
    
    Why Java 6 instead of Java 7 out of interest? No particularly strong feelings, but in 6 months(ish) we'll probably deprecate Java 6 support when upgrading to the next major jclouds version.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-56514173
  
    @andreaturli I'll test this on **CentOS 6** (maybe 7 as well) and also **Ubuntu 14.04 LTS** would be sensible, as 12.04 is getting old now. If they all work, I'll merge :frog: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17390267
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,272 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Setup random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    --- End diff --
    
    the script installs `curl` and `tar` during install dependencies step, it shouldn't fail because of them


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by Nakomis <gi...@git.apache.org>.
Github user Nakomis commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17477357
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,274 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Set up random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    --- End diff --
    
    java-1.7.0-openjdk-devel is required if -e is specified


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17292751
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "...done"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Installing Brooklyn..."
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "...done"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn..."
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    --- End diff --
    
    Should we really be using `AnyoneSecurityProvider`? Or should we generate a new password? Or upload a pre-defined `admin:password` combo that uses the hashed password approach (and obviously write out at the end of this script what that credential is)?
    
    FYI see @sjcorbett 's recent change for https://github.com/apache/incubator-brooklyn/pull/154. But we'd need to write out the user:password at the end of this script (rather than just in the remote host's log), so not applicable here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by Nakomis <gi...@git.apache.org>.
Github user Nakomis commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17478144
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,274 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Set up random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    --- End diff --
    
    On a CentOS VM on SoftLayer AMS01, `yum intall java-1.7.0-openjdk-devel` installs javac at `/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/bin/javac`. `which ${check}` may be more reliable


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17389325
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,272 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Setup random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "done!"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn... "
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "done!"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "done!"
    +
    +# Run Brooklyn
    +log "Starting Brooklyn..."
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +sleep 10
    --- End diff --
    
    Would prefer a poll (i.e. a loop) rather than a `sleep 10`. On a really slow machine it might take more than 10 secs (not that I've ever seen that), and in other cases we're waiting longer than is necessary.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17294063
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    --- End diff --
    
    you mean by default we should setup entropy and user account?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17293013
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "...done"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Installing Brooklyn..."
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "...done"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn..."
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "...done"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "...done"
    +
    +# Run Brooklyn
    +log -n "Starting Brooklyn..."
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +log "...done"
    --- End diff --
    
    Should we also wait for it to be running? `nohup` command will return immediately so the URL will not be accessible for a few more seconds potentially.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17293057
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:$PORT as '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'..."
    +
    +# Install packages
    +log "Installing packages on '${HOST}:${PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log -n "..."
    +
    +# Install Java 6
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.6.0-openjdk || apt-get update && apt-get -y install openjdk-6-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.6.0-openjdk" "java-1.6.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log -n "..."
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "...done"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "...done"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    --- End diff --
    
    Future enhancement: could supply an ssh key to be uploaded, rather than generating a new one.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-55629535
  
    I've tested it extensively on ubuntu 12.04
    Before merging, it would probably be good to test it on another OS (centos 6?)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-brooklyn/pull/157


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17292952
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    +    -p  The SSH port to connect to (default 22)
    +    -r  Setup random entropy for SSH
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -q  Quiet install
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${PORT:-22}"
    --- End diff --
    
    Does `${PORT:-22}` set `$PORT` to 22, or just give the value 22 if `$PORT` is not set? You subsequently use `$PORT` so assumes it is the former.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17389980
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,272 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Setup random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "done!"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn... "
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "done!"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "done!"
    +
    +# Run Brooklyn
    +log "Starting Brooklyn..."
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +sleep 10
    +
    +URL=$(ssh ${SSH_OPTS} ${USER}@${HOST} "grep 'Started Brooklyn console at' ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log | cut -d' ' -f9 | tr -d ," 2>&1)
    +
    +log "Brooklyn Console URL at ${URL}"
    +
    +if wget -qO- --retry-connrefused --no-check-certificate ${URL} &> /dev/null; then
    --- End diff --
    
    Could do something like:
        curl -sL -w "%{http_code} %{url_effective}\\n" "http://localhost:8081" -o /dev/null
        401 http://localhost:8081/
    
    and get the response code. If this is a 401 (unauthorized) or is >=200 && < 300, then success.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by Nakomis <gi...@git.apache.org>.
Github user Nakomis commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-55407974
  
    As a future improvement, it might be nice to add the ability to set provide the name of the user used to connect to the VM instead of assuming root. This would be useful where root is not available, e.g. certain AWS Ubuntu VMs that require you to connect as 'ubuntu2'


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by Nakomis <gi...@git.apache.org>.
Github user Nakomis commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17478304
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,274 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Set up random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    --- End diff --
    
    Similar issue on Ubuntu with openjdk-7-jre-headless vs openjds-7-jdk


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17293162
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,260 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -e  Install example blueprint files
    --- End diff --
    
    In general, good to keep order consistent. i.e. in usage one liner, in this verbose listing, and in `getopts` case statement below. It makes it easier to spot if anything is missing (e.g. `-h` is not listed in options below).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#issuecomment-55181388
  
    @aledsage have you got the chance to look at the new commit? @grkvlt do you have thoughts on that?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...

Posted by Nakomis <gi...@git.apache.org>.
Github user Nakomis commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/157#discussion_r17480128
  
    --- Diff: brooklyn-install.sh ---
    @@ -0,0 +1,274 @@
    +#!/bin/bash
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +# Brooklyn Install Script
    +#
    +# Usage:
    +#     brooklyn-install.sh [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +#
    +#set -x # DEBUG
    +
    +function help() {
    +    cat <<EOF
    +
    +Brooklyn Install Script
    +
    +Options
    +
    +    -q  Quiet install
    +    -r  Set up random entropy for SSH
    +    -e  Install example blueprint files
    +    -s  Create and set up user account
    +    -u  Change the Brooklyn username (default 'brooklyn')
    +    -k  The private key to use for SSH (default '~/.ssh/id_rsa')
    +    -p  The SSH port to connect to (default 22)
    +
    +Usage
    +
    +    brooklyn-install.sh [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname
    +
    +Installs Brooklyn on the given hostname as 'brooklyn' or the specified
    +user. Optionally installs example blueprints and creates and
    +configures the Brooklyn user. Passwordless SSH access as root to
    +the remote host must be enabled with the given key.
    +
    +EOF
    +    exit 0
    +}
    +
    +function log() {
    +    if ! ${QUIET}; then
    +        echo $@
    +    fi
    +    date +"Timestamp: %Y-%m-%d %H:%M:%S.%s" >> ${LOG}
    +    if [ "$1" == "-n" ]; then
    +        shift
    +    fi
    +    if [ "$*" != "..." ]; then
    +        echo "Log: $*" | sed -e "s/\.\.\.//" >> ${LOG}
    +    fi
    +}
    +
    +function fail() {
    +    log "...failed!"
    +    error "$*"
    +}
    +
    +function error() {
    +    echo "Error: $*" | tee -a "${LOG}"
    +    usage
    +}
    +
    +function usage() {
    +    echo "Usage: $(basename ${0}) [-h] [-q] [-r] [-e] [-s] [-u user] [-k key] [-p port] hostname"
    +    exit 1
    +}
    +
    +QUIET=false
    +LOG="brooklyn-install.log"
    +BROOKLYN_VERSION="0.7.0-M1"
    +SSH=ssh
    +
    +while getopts ":hesu:k:q:p:r" o; do
    +    case "${o}" in
    +        h)  help
    +            ;;
    +        e)  INSTALL_EXAMPLES=true
    +            ;;
    +        s)  SETUP_USER=true
    +            ;;
    +        u)  BROOKLYN_USER="${OPTARG}"
    +            ;;
    +        k)  PRIVATE_KEY_FILE="${OPTARG}"
    +            ;;
    +        r)  SETUP_RANDOM=true
    +            ;;
    +        q)  QUIET=true
    +            ;;
    +        p)  PORT="${OPTARG}"
    +            ;;            
    +        *)  usage "Invalid option: $*"
    +            ;;
    +    esac
    +done
    +shift $((OPTIND-1))
    +
    +if [ $# -ne 1 ]; then
    +    error "Must specify remote hostname as last argument"
    +fi
    +
    +HOST="$1"
    +USER="${BROOKLYN_USER:-brooklyn}"
    +PRIVATE_KEY_FILE="${PRIVATE_KEY_FILE:-${HOME}/.ssh/id_rsa}"
    +SSH_PORT=${PORT:-22}
    +
    +SSH_OPTS="-o StrictHostKeyChecking=no -p ${SSH_PORT}"
    +if [ -f "${PRIVATE_KEY_FILE}" ]; then
    +    SSH_OPTS="${SSH_OPTS} -i ${PRIVATE_KEY_FILE}"
    +else
    +    error "SSH private key '${PRIVATE_KEY_FILE}' not found"
    +fi
    +SSH_PUBLIC_KEY_DATA=$(ssh-keygen -y -f ${PRIVATE_KEY_FILE})
    +
    +echo "Installing Brooklyn ${BROOKLYN_VERSION} on ${HOST}:${SSH_PORT} as user: '${USER}'"
    +
    +# Pre-requisites for this script
    +log "Configuring '${HOST}:${PORT}'... "
    +
    +# Install packages
    +log -n "Installing packages for curl, sed, tar, wget on '${HOST}:${SSH_PORT}'..."
    +ssh ${SSH_OPTS} root@${HOST} "yum check-update || apt-get update" >> ${LOG} 2>&1
    +for package in "curl" "sed" "tar" "wget"; do
    +    ssh ${SSH_OPTS} root@${HOST} "which ${package} || { yum check-update && yum -y --nogpgcheck -q install ${package} || apt-get update && apt-get -y --allow-unauthenticated install ${package}; }" >> ${LOG} 2>&1
    +done
    +log " done!"
    +
    +# Install Java 7
    +log -n "Installing java 7 on '${HOST}:${SSH_PORT}'... "
    +if [ "${INSTALL_EXAMPLES}" ]; then
    +    check="javac"
    +else
    +    check="java"
    +    JAVA_HOME="/usr"
    +fi
    +ssh ${SSH_OPTS} root@${HOST} "which ${check} || { yum -y -q install java-1.7.0-openjdk || apt-get update && apt-get -y install openjdk-7-jre-headless; }" >> ${LOG} 2>&1
    +for java in "jre" "jdk" "java-1.7.0-openjdk" "java-1.7.0-openjdk-amd64"; do
    +    if ssh ${SSH_OPTS} root@${HOST} "test -d /usr/lib/jvm/${java}"; then
    +        JAVA_HOME="/usr/lib/jvm/${java}/" && echo "Java: ${JAVA_HOME}" >> ${LOG}
    +    fi
    +done
    +ssh ${SSH_OPTS} root@${HOST}  "test -x ${JAVA_HOME}/bin/${check}" >> ${LOG} 2>&1 || fail "Java is not installed"
    +log "done!"
    +
    +# Increase linux kernel entropy for faster ssh connections
    +if [ "${SETUP_RANDOM}" ]; then
    +    log -n "Installing rng-tool to increase entropy on '${HOST}:${SSH_PORT}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "which rng-tools || { yum -y -q install rng-tools || apt-get -y install rng-tools; }" >> ${LOG} 2>&1
    +    if ssh ${SSH_OPTS} root@${HOST} "test -f /etc/default/rng-tools"; then
    +        echo "HRNGDEVICE=/dev/urandom" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/default/rng-tools"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rng-tools start" >> ${LOG} 2>&1
    +    else
    +        echo "EXTRAOPTIONS=\"-r /dev/urandom\"" | ssh ${SSH_OPTS} root@${HOST} "cat >> /etc/sysconfig/rngd"
    +        ssh ${SSH_OPTS} root@${HOST} "/etc/init.d/rngd start" >> ${LOG} 2>&1
    +    fi
    +    log "done!"
    +fi
    +
    +# Create Brooklyn user if required
    +if ! ssh ${SSH_OPTS} root@${HOST} "id ${USER} > /dev/null 2>&1"; then
    +    if [ -z "${SETUP_USER}" ]; then
    +        error "User '${USER}' does not exist on ${HOST}"
    +    fi
    +    log -n "Creating user '${USER}'..."
    +    ssh ${SSH_OPTS} root@${HOST}  "useradd ${USER} -s /bin/bash -d /home/${USER} -m" >> ${LOG} 2>&1
    +    ssh ${SSH_OPTS} root@${HOST}  "id ${USER}" >> ${LOG} 2>&1 || fail "User was not created"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn user
    +if [ "${SETUP_USER}" ]; then
    +    log -n "Setting up user '${USER}'... "
    +    ssh ${SSH_OPTS} root@${HOST} "echo '${USER} ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' /etc/sudoers"
    +    ssh ${SSH_OPTS} root@${HOST} "mkdir -p /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "chmod 700 /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} root@${HOST} "echo ${SSH_PUBLIC_KEY_DATA} >> /home/${USER}/.ssh/authorized_keys"
    +    ssh ${SSH_OPTS} root@${HOST} "chown -R ${USER}.${USER} /home/${USER}/.ssh"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -q -t rsa -N \"\" -f .ssh/id_rsa"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "ssh-keygen -y -f .ssh/id_rsa >> .ssh/authorized_keys"
    +    log "done!"
    +fi
    +
    +# Setup Brooklyn
    +log -n "Downloading Brooklyn... "
    +ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o brooklyn-${BROOKLYN_VERSION}.tar.gz http://search.maven.org/remotecontent?filepath=io/brooklyn/brooklyn-dist/${BROOKLYN_VERSION}/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
    +ssh ${SSH_OPTS} ${USER}@${HOST} "tar zxvf brooklyn-${BROOKLYN_VERSION}.tar.gz" >> ${LOG} 2>&1
    +ssh ${SSH_OPTS} ${USER}@${HOST} "test -x brooklyn-${BROOKLYN_VERSION}/bin/brooklyn" || fail "Brooklyn was not downloaded correctly"
    +log "done!"
    +
    +# Configure Brooklyn if no brooklyn.properties
    +if ! ssh ${SSH_OPTS} ${USER}@${HOST} "test -f .brooklyn/brooklyn.properties"; then
    +    log -n "Configuring Brooklyn... "
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "mkdir -p .brooklyn"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/brooklyn.properties http://brooklyncentral.github.io/use/guide/quickstart/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "sed -i.bak 's/^# brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/brooklyn.webconsole.security.provider = brooklyn.rest.security.provider.AnyoneSecurityProvider/' .brooklyn/brooklyn.properties"
    +    ssh ${SSH_OPTS} ${USER}@${HOST} "curl -s -o .brooklyn/catalog.xml http://brooklyncentral.github.io/use/guide/quickstart/catalog.xml"
    +    log "done!"
    +fi
    +
    +# Install example Jars and catalog
    +log -n "Installing examples and configure catalog.xml ..."
    +
    +ssh ${SSH_OPTS} ${USER}@${HOST} "cat > .brooklyn/catalog.xml" <<EOF
    +<?xml version="1.0"?>
    +<catalog>
    +    <name>Brooklyn Demos</name>
    +
    +    <template type="brooklyn.demo.WebClusterDatabaseExample" name="Demo Web Cluster with DB">
    +      <description>Deploys a demonstration web application to a managed JBoss cluster with elasticity, persisting to a MySQL</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.GlobalWebFabricExample" name="Demo GeoDNS Web Fabric DB">
    +      <description>Deploys a demonstration web application to JBoss clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/JBoss_by_Red_Hat.png</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.NodeJsTodoApplication" name="NodeJs TODO application">
    +      <description>Deploys a Nodejs TODO application around the world</description>
    +      <iconUrl>classpath://nodejs-logo.png</iconUrl>
    +    </template>    
    +
    +    <template type="brooklyn.demo.SimpleCassandraCluster" name="Demo Cassandra Cluster">
    +      <description>Deploys a demonstration Cassandra clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/cassandra-sq-icon.jpg</iconUrl>
    +    </template>
    +
    +    <template type="brooklyn.demo.SimpleCouchDBCluster" name="Demo CouchDB">
    +      <description>Deploys a demonstration CouchDB clusters around the world</description>
    +      <iconUrl>http://downloads.cloudsoftcorp.com/brooklyn/catalog/logos/couchdb-logo-icon.png</iconUrl>
    +    </template>
    +
    +    <classpath>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar</entry>
    +      <entry>http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar</entry>
    +    </classpath>
    +
    +
    +</catalog>
    +
    +EOF
    +
    +log "done!"
    +
    +# Run Brooklyn
    +log "Starting Brooklyn..."
    +
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "nohup ./brooklyn-${BROOKLYN_VERSION}/bin/brooklyn launch >> ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log 2>&1 &"
    +ssh -n -f ${SSH_OPTS} ${USER}@${HOST} "until !(grep -q 'Started Brooklyn console at' ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log); do sleep 2; done"
    +URL=$(ssh ${SSH_OPTS} ${USER}@${HOST} "grep 'Started Brooklyn console at' ./brooklyn-${BROOKLYN_VERSION}/brooklyn-console.log | cut -d' ' -f9 | tr -d ," 2>&1)
    --- End diff --
    
    Having  `UserKnownHostsFile /dev/null` and `StrictHostKeyChecking no`[1] set will cause this part to fail as URL contains `Warning: Permanently added '5.153.39.50' (RSA) to the list of known hosts.`
    
    [1] I was getting tired of ssh complaining about possible man-in-the-middle attacks when SL re-issued IP addresses


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---