|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed with |
| 5 | +# this work for additional information regarding copyright ownership. |
| 6 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | +# (the "License"); you may not use this file except in compliance with |
| 8 | +# the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +set -e |
| 19 | + |
| 20 | +usage() { |
| 21 | + echo " |
| 22 | +usage: $0 <options> |
| 23 | + Required not-so-options: |
| 24 | + --build-dir=DIR path to dist.dir |
| 25 | + --source-dir=DIR path to package shared files dir |
| 26 | + --prefix=PREFIX path to install into |
| 27 | + Optional options: |
| 28 | + --doc-dir=DIR path to install docs into [/usr/share/doc/trino] |
| 29 | + --lib-dir=DIR path to install trino home [/usr/lib/trino] |
| 30 | + --installed-lib-dir=DIR path where lib-dir will end up on target system |
| 31 | + --bin-dir=DIR path to install bins [/usr/bin] |
| 32 | + ... [ see source for more similar options ] |
| 33 | + " |
| 34 | + exit 1 |
| 35 | +} |
| 36 | + |
| 37 | +OPTS=$(getopt \ |
| 38 | + -n $0 \ |
| 39 | + -o '' \ |
| 40 | + -l 'prefix:' \ |
| 41 | + -l 'lib-dir:' \ |
| 42 | + -l 'installed-lib-dir:' \ |
| 43 | + -l 'bin-dir:' \ |
| 44 | + -l 'trino-version:' \ |
| 45 | + -l 'source-dir:' \ |
| 46 | + -l 'cli-dir:' \ |
| 47 | + -l 'build-dir:' -- "$@") |
| 48 | + |
| 49 | +if [ $? != 0 ] ; then |
| 50 | + usage |
| 51 | +fi |
| 52 | + |
| 53 | +eval set -- "$OPTS" |
| 54 | +while true ; do |
| 55 | + case "$1" in |
| 56 | + --prefix) |
| 57 | + PREFIX=$2 ; shift 2 |
| 58 | + ;; |
| 59 | + --build-dir) |
| 60 | + BUILD_DIR=$2 ; shift 2 |
| 61 | + ;; |
| 62 | + --source-dir) |
| 63 | + SOURCE_DIR=$2 ; shift 2 |
| 64 | + ;; |
| 65 | + --cli-dir) |
| 66 | + CLI_BUILD_DIR=$2 ; shift 2 |
| 67 | + ;; |
| 68 | + --lib-dir) |
| 69 | + LIB_DIR=$2 ; shift 2 |
| 70 | + ;; |
| 71 | + --installed-lib-dir) |
| 72 | + INSTALLED_LIB_DIR=$2 ; shift 2 |
| 73 | + ;; |
| 74 | + --bin-dir) |
| 75 | + BIN_DIR=$2 ; shift 2 |
| 76 | + ;; |
| 77 | + --) |
| 78 | + shift ; break |
| 79 | + ;; |
| 80 | + *) |
| 81 | + echo "Unknown option: $1" |
| 82 | + usage |
| 83 | + exit 1 |
| 84 | + ;; |
| 85 | + esac |
| 86 | +done |
| 87 | + |
| 88 | +for var in PREFIX BUILD_DIR SOURCE_DIR ; do |
| 89 | + if [ -z "$(eval "echo \$$var")" ]; then |
| 90 | + echo Missing param: $var |
| 91 | + usage |
| 92 | + fi |
| 93 | +done |
| 94 | + |
| 95 | +if [ -f "$SOURCE_DIR/bigtop.bom" ]; then |
| 96 | + . $SOURCE_DIR/bigtop.bom |
| 97 | +fi |
| 98 | + |
| 99 | +MAN_DIR=${MAN_DIR:-/usr/share/man}/man1 |
| 100 | +DOC_DIR=${DOC_DIR:-/usr/share/doc/trino} |
| 101 | +CLI_DIR=${CLI_DIR:-/usr/lib/trino-cli} |
| 102 | +LIB_DIR=${TRINO_DIR:-/usr/lib/trino} |
| 103 | +VAR_DIR=${VAR_DIR:-/var/lib/trino} |
| 104 | +LOG_DIR=${LOG_DIR:-/var/log/trino} |
| 105 | +RUN_DIR=${RUN_DIR:-/var/run/trino} |
| 106 | +INSTALLED_LIB_DIR=${INSTALLED_LIB_DIR:-/usr/lib/trino} |
| 107 | +BIN_DIR=${BIN_DIR:-/usr/bin} |
| 108 | +CONF_DIR=${CONF_DIR:-/etc/trino} |
| 109 | +CONF_DIST_DIR=${CONF_DIST_DIR:-/etc/trino.dist} |
| 110 | +DEFAULT_DIR=${DEFAULT_DIR:-/etc/default} |
| 111 | + |
| 112 | +install -d -m 0755 $PREFIX/$CONF_DIST_DIR |
| 113 | +install -d -m 0755 $PREFIX/$LIB_DIR |
| 114 | +install -d -m 0755 $PREFIX/$CLI_DIR |
| 115 | +install -d -m 0755 $PREFIX/$DOC_DIR |
| 116 | +install -d -m 0755 $PREFIX/$VAR_DIR |
| 117 | +install -d -m 0755 $PREFIX/$LOG_DIR |
| 118 | +install -d -m 0755 $PREFIX/$RUN_DIR |
| 119 | +install -d -m 0755 $PREFIX/$DEFAULT_DIR |
| 120 | + |
| 121 | +cp -ra ${BUILD_DIR}/* $PREFIX/$LIB_DIR/ |
| 122 | +cp -ra ${CLI_BUILD_DIR}/* $PREFIX/$CLI_DIR/ |
| 123 | + |
| 124 | +chmod +x $PREFIX/$LIB_DIR/bin/launcher |
| 125 | + |
| 126 | +install -d -m 0755 $PREFIX/$CONF_DIST_DIR |
| 127 | +install -d -m 0755 $PREFIX/$CONF_DIST_DIR/catalog |
| 128 | + |
| 129 | +cat > $PREFIX/$CONF_DIST_DIR/node.properties <<EOF |
| 130 | +node.environment=production |
| 131 | +node.id=ffffffff-ffff-ffff-ffff-ffffffffffff |
| 132 | +node.data-dir=/var/trino/data |
| 133 | +EOF |
| 134 | + |
| 135 | +cat > $PREFIX/$CONF_DIST_DIR/jvm.config <<EOF |
| 136 | +-server |
| 137 | +-Xmx16G |
| 138 | +-XX:G1HeapRegionSize=32M |
| 139 | +-XX:+ExplicitGCInvokesConcurrent |
| 140 | +-XX:+ExitOnOutOfMemoryError |
| 141 | +-XX:+HeapDumpOnOutOfMemoryError |
| 142 | +-XX:-OmitStackTraceInFastThrow |
| 143 | +-XX:ReservedCodeCacheSize=512M |
| 144 | +-XX:PerMethodRecompilationCutoff=10000 |
| 145 | +-XX:PerBytecodeRecompilationCutoff=10000 |
| 146 | +-Djdk.attach.allowAttachSelf=true |
| 147 | +-Djdk.nio.maxCachedBufferSize=2000000 |
| 148 | +-XX:+UnlockDiagnosticVMOptions |
| 149 | +EOF |
| 150 | + |
| 151 | +cat > $PREFIX/$CONF_DIST_DIR/config.properties <<EOF |
| 152 | +# A single machine for testing that will function as both a coordinator and worker |
| 153 | +coordinator=true |
| 154 | +node-scheduler.include-coordinator=true |
| 155 | +http-server.http.port=8080 |
| 156 | +query.max-memory=4GB |
| 157 | +query.max-memory-per-node=1GB |
| 158 | +discovery-server.enabled=true |
| 159 | +discovery.uri=http://localhost:8080 |
| 160 | +# Minimal configuration for the coordinator: |
| 161 | +#coordinator=true |
| 162 | +#node-scheduler.include-coordinator=false |
| 163 | +#http-server.http.port=8080 |
| 164 | +#query.max-memory=4GB |
| 165 | +#query.max-memory-per-node=1GB |
| 166 | +#discovery-server.enabled=true |
| 167 | +#discovery.uri=http://example.net:8080 |
| 168 | +# Minimal configuration for the workers: |
| 169 | +#coordinator=false |
| 170 | +#http-server.http.port=8080 |
| 171 | +#query.max-memory=4GB |
| 172 | +#query.max-memory-per-node=1GB |
| 173 | +#discovery.uri=http://example.net:8080 |
| 174 | +http-server.log.path=/var/log/presto/http-request.log |
| 175 | +EOF |
| 176 | + |
| 177 | +cat > $PREFIX/$CONF_DIST_DIR/log.properties <<EOF |
| 178 | +io.trino=INFO |
| 179 | +EOF |
| 180 | + |
| 181 | +cat > $PREFIX/$CONF_DIST_DIR/catalog/tpch.properties <<EOF |
| 182 | +connector.name=tpch |
| 183 | +EOF |
| 184 | + |
| 185 | +cat > $PREFIX/$CONF_DIST_DIR/catalog/tpcds.properties <<EOF |
| 186 | +connector.name=tpcds |
| 187 | +EOF |
| 188 | + |
| 189 | +cat > $PREFIX/$CONF_DIST_DIR/catalog/jmx.properties <<EOF |
| 190 | +connector.name=jmx |
| 191 | +EOF |
| 192 | + |
| 193 | +ln -s ${CONF_DIR} $PREFIX/$LIB_DIR/etc |
0 commit comments