brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: BROOKLYN-55 install script for br...
Date Tue, 09 Sep 2014 10:38:12 GMT
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.
---

Mime
View raw message