Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8BE2511EF4 for ; Tue, 9 Sep 2014 10:49:56 +0000 (UTC) Received: (qmail 12363 invoked by uid 500); 9 Sep 2014 10:49:56 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 12328 invoked by uid 500); 9 Sep 2014 10:49:56 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 12317 invoked by uid 99); 9 Sep 2014 10:49:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Sep 2014 10:49:56 +0000 X-ASF-Spam-Status: No, hits=-2001.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 09 Sep 2014 10:49:32 +0000 Received: (qmail 11734 invoked by uid 99); 9 Sep 2014 10:49:30 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Sep 2014 10:49:30 +0000 Date: Tue, 9 Sep 2014 10:49:30 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@brooklyn.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BROOKLYN-55) Documentation for a server install MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/BROOKLYN-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14126857#comment-14126857 ] ASF GitHub Bot commented on BROOKLYN-55: ---------------------------------------- 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 <> ${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" < + + Brooklyn Demos + + + + + + + + + + + + + http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-web-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-web-cluster-${BROOKLYN_VERSION}.jar + http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-simple-nosql-cluster/${BROOKLYN_VERSION}/brooklyn-example-simple-nosql-cluster-${BROOKLYN_VERSION}.jar + + + + + +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. > Documentation for a server install > ---------------------------------- > > Key: BROOKLYN-55 > URL: https://issues.apache.org/jira/browse/BROOKLYN-55 > Project: Brooklyn > Issue Type: Sub-task > Affects Versions: 0.7.0-M1 > Reporter: Richard Downer > Assignee: Andrea Turli > Fix For: 0.7.0 > > > Document how to install Brooklyn onto a server (not onto a local workstation) - include typical considerations such as where to install files, remote access, automatic startup. -- This message was sent by Atlassian JIRA (v6.3.4#6332)