Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2015 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 17 | # Version: 1.3-a11 |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 18 | # |
| 19 | set -o nounset |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 20 | BASE_UMASK=$(umask) |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 21 | umask 077 |
| 22 | |
| 23 | # |
| 24 | # Settings |
| 25 | # |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 26 | JACK_HOME="${JACK_HOME:=$HOME/.jack-server}" |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 27 | JACK_CLIENT_SETTING="${JACK_CLIENT_SETTING:=$HOME/.jack-settings}" |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 28 | TMPDIR=${TMPDIR:=/tmp} |
Yohann Roussel | 2960f69 | 2016-09-20 17:33:21 +0200 | [diff] [blame] | 29 | JACK_SERVER_VM_ARGUMENTS="${JACK_SERVER_VM_ARGUMENTS:=-Dfile.encoding=UTF-8}" |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 30 | JACK_EXTRA_CURL_OPTIONS=${JACK_EXTRA_CURL_OPTIONS:=} |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 31 | |
| 32 | LAUNCHER_JAR="$JACK_HOME/launcher.jar" |
| 33 | LAUNCHER_NAME=com.android.jack.launcher.ServerLauncher |
| 34 | CURRENT_CHARSET=$(locale charmap) |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 35 | if [ -z "$CURRENT_CHARSET" ]; then |
| 36 | CHARSET_ARGUMENT= |
| 37 | else |
| 38 | CHARSET_ARGUMENT=";charset=$CURRENT_CHARSET" |
| 39 | fi |
| 40 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 41 | JACK_LOGS_DIR="$JACK_HOME"/logs |
| 42 | JACK_OUT_ERR="$JACK_LOGS_DIR"/outputs.txt |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 43 | JACK_CONNECTION_TIMEOUT=300 |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 44 | |
| 45 | # |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 46 | # Load client settings |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 47 | # |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 48 | if [ -f "$JACK_CLIENT_SETTING" ]; then |
| 49 | source "$JACK_CLIENT_SETTING" |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 50 | fi |
| 51 | |
| 52 | # |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 53 | # Create or update client settings if needed |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 54 | # |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 55 | if [[ ! -f "$JACK_CLIENT_SETTING" || $SETTING_VERSION -lt 4 ]]; then |
| 56 | echo "Writing client settings in" $JACK_CLIENT_SETTING |
| 57 | cat >"$JACK_CLIENT_SETTING.$$" <<-EOT |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 58 | # Server settings |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 59 | SERVER_HOST=${SERVER_HOST:=localhost} |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 60 | SERVER_PORT_SERVICE=${SERVER_PORT_SERVICE:=8076} |
| 61 | SERVER_PORT_ADMIN=${SERVER_PORT_ADMIN:=8077} |
| 62 | |
| 63 | # Internal, do not touch |
| 64 | SETTING_VERSION=4 |
| 65 | EOT |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 66 | ln -f "$JACK_CLIENT_SETTING.$$" "$JACK_CLIENT_SETTING" |
| 67 | rm "$JACK_CLIENT_SETTING.$$" |
| 68 | source "$JACK_CLIENT_SETTING" |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 69 | fi |
| 70 | |
| 71 | usage () { |
Yohann Roussel | 2960f69 | 2016-09-20 17:33:21 +0200 | [diff] [blame] | 72 | echo "Usage : $0 [ install-server <launcher.jar> <server.jar> | uninstall-server | list <program> | update <program> <program.jar> | start-server | stop-server | kill-server | list-server | server-stat | server-stat-reset | server-log | server-gc | cleanup-server | dump-report]" |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | abort () { exit 255; } |
| 76 | |
| 77 | # |
| 78 | # $1: curl command status |
| 79 | # $2: HTTP status |
| 80 | # |
| 81 | handleHttpErrors() { |
| 82 | if [ $1 -eq 0 ]; then |
| 83 | # No problem, let's go |
| 84 | return 0; |
| 85 | elif [ $1 -eq 7 ]; then |
| 86 | echo "No Jack server running. Try 'jack-admin start-server'" >&2 |
| 87 | abort |
| 88 | elif [ $1 -eq 35 ]; then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 89 | echo "SSL error when connecting to the Jack server. Try 'jack-diagnose'" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 90 | abort |
| 91 | elif [ $1 -eq 58 ]; then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 92 | echo "Failed to contact Jack server: Problem reading ${JACK_HOME}/client.pem. Try 'jack-diagnose'" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 93 | abort |
| 94 | elif [ $1 -eq 60 ]; then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 95 | echo "Failed to authenticate Jack server certificate. Try 'jack-diagnose'" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 96 | abort |
| 97 | elif [ $1 -eq 77 ]; then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 98 | echo "Failed to contact Jack server: Problem reading ${JACK_HOME}/server.pem. Try 'jack-diagnose'" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 99 | abort |
| 100 | elif [ $1 -eq 22 ]; then |
| 101 | # Http code not OK, let's decode and abort |
| 102 | if [ $2 -eq 400 ]; then |
| 103 | # 400: Bad request |
| 104 | echo "Bad request, see Jack server log" >&2 |
| 105 | abort |
| 106 | else |
| 107 | # Other |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 108 | echo "Internal unknown error ($2), try 'jack-diagnose' or see Jack server log" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 109 | abort |
| 110 | fi |
| 111 | else |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 112 | echo "Communication error with Jack server $1. Try 'jack-diagnose'" >&2 |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 113 | abort |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 114 | fi |
| 115 | } |
| 116 | |
| 117 | checkCurlVersion () { |
| 118 | curl --version | grep -q "SecureTransport" |
| 119 | if [ "$?" -eq 0 ]; then |
| 120 | echo "Unsupported curl, please use a curl not based on SecureTransport" >&2 |
| 121 | abort |
| 122 | fi |
| 123 | } |
| 124 | |
| 125 | # |
| 126 | # $1: program name |
| 127 | # $2: jar of the program |
| 128 | # |
| 129 | updateProgram () { |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 130 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 131 | --cert "${JACK_HOME}/client.pem" \ |
| 132 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 133 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 134 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 135 | -X PUT \ |
| 136 | -F "jar=@$2;type=application/octet-stream" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 137 | -F "force=$FORCE_INSTALLATION;type=text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 138 | --noproxy ${SERVER_HOST} \ |
| 139 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/$1 \ |
| 140 | ) |
| 141 | handleHttpErrors $? $HTTP_CODE |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 142 | |
| 143 | if [ "$1" == server ]; then |
| 144 | echo "Server updated, waiting for restart" |
| 145 | waitServerStarted |
| 146 | fi |
| 147 | } |
| 148 | |
| 149 | isServerRunning () { |
| 150 | RETRY_SESSION=3 |
| 151 | DONE=1 |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 152 | let DATE_TIMEOUT=$(date +%s)+$JACK_CONNECTION_TIMEOUT |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 153 | while [ "$DONE" -ne 0 ]; do |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 154 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 155 | --cert "${JACK_HOME}/client.pem" \ |
| 156 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 157 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 158 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 159 | -X GET \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 160 | -H "Accept: text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 161 | --noproxy ${SERVER_HOST} \ |
| 162 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/server \ |
| 163 | ) |
| 164 | CURL_CODE=$? |
| 165 | if [ $CURL_CODE -eq 0 ]; then |
| 166 | # No problem, let's go |
| 167 | return 0; |
| 168 | elif [ $CURL_CODE -eq 7 ]; then |
| 169 | return 1 |
| 170 | else |
| 171 | # In case of partial, timeout, empty response, network error, let's retry |
| 172 | if [ $RETRY_SESSION -eq 0 ]; then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 173 | echo "Communication error with Jack server ($CURL_CODE), try 'jack-diagnose' or see Jack server log" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 174 | abort |
| 175 | else |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 176 | if [ $(date +%s) -lt $DATE_TIMEOUT ]; then |
| 177 | let RETRY_SESSION=RETRY_SESSION-1 |
| 178 | else |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 179 | echo "Communication error with Jack server ($CURL_CODE), try 'jack-diagnose' or see Jack server log" >&2 |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 180 | abort |
| 181 | fi |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 182 | fi |
| 183 | fi |
| 184 | done |
| 185 | } |
| 186 | |
| 187 | waitServerStarted () { |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 188 | DONE=1 |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 189 | let DATE_TIMEOUT=$(date +%s)+$JACK_CONNECTION_TIMEOUT |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 190 | while [ "$DONE" -ne 0 ]; do |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 191 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 192 | --cert "${JACK_HOME}/client.pem" \ |
| 193 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 194 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 195 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 196 | -X GET \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 197 | -H "Accept: text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 198 | --noproxy ${SERVER_HOST} \ |
| 199 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/server \ |
| 200 | ) |
| 201 | CURL_CODE=$? |
| 202 | if [ $CURL_CODE -eq 7 ] || [ $CURL_CODE -eq 35 ] || [ $CURL_CODE -eq 58 ] || [ $CURL_CODE -eq 60 ] || [ $CURL_CODE -eq 77 ]; then |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 203 | if [ $(date +%s) -ge $DATE_TIMEOUT ]; then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 204 | echo "Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log" >&2 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 205 | abort |
| 206 | else |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 207 | sleep 1 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 208 | fi |
| 209 | else |
| 210 | # A connection was opened, no need to know if it went well |
| 211 | DONE=0; |
| 212 | fi |
| 213 | done |
| 214 | } |
| 215 | |
| 216 | # |
| 217 | # $1: program name |
| 218 | # |
| 219 | listProgramVersion () { |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 220 | exec 3>&1 |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 221 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 222 | --cert "${JACK_HOME}/client.pem" \ |
| 223 | --cacert "${JACK_HOME}/server.pem" \ |
| 224 | --output >(tr -d '\015' >&3) \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 225 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 226 | -X GET \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 227 | -H "Accept: text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 228 | --noproxy ${SERVER_HOST} \ |
| 229 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/$1 \ |
| 230 | ) |
| 231 | handleHttpErrors $? $HTTP_CODE |
| 232 | exec 3>&- |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 233 | } |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 234 | |
| 235 | # |
| 236 | # Decoding argument |
| 237 | # |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 238 | if [ $# -eq 0 ] |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 239 | then |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 240 | usage |
| 241 | abort |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 242 | fi |
| 243 | |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 244 | set +o errexit |
| 245 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 246 | FORCE_INSTALLATION=false |
| 247 | case $1 in |
| 248 | force-update) |
| 249 | FORCE_INSTALLATION=true |
| 250 | COMMAND=update;; |
| 251 | *) |
| 252 | COMMAND=$1;; |
| 253 | esac |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 254 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 255 | case $COMMAND in |
| 256 | install-server) |
| 257 | if [ $# -ne 3 ]; then |
| 258 | usage |
| 259 | abort |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 260 | fi |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 261 | if [ ! -r "$2" ]; then |
| 262 | echo "Jack server launcher jar \"$2\" is not readable" >&2 |
| 263 | abort |
| 264 | fi |
| 265 | if [ ! -r "$3" ]; then |
| 266 | echo "Jack server jar \"$3\" is not readable" >&2 |
| 267 | abort |
| 268 | fi |
| 269 | |
| 270 | checkCurlVersion |
| 271 | |
| 272 | if [ ! -d "$JACK_HOME" ]; then |
| 273 | echo Installing jack server in \"$JACK_HOME\" |
| 274 | mkdir -p "$JACK_HOME" |
| 275 | cp $2 "$LAUNCHER_JAR" |
| 276 | cp $3 "$JACK_HOME/server-1.jar" |
| 277 | mkdir "$JACK_LOGS_DIR" |
| 278 | keytool -genkeypair -validity 3650 -alias server -keyalg RSA -keysize 2048 -keypass Jack-Server -storepass Jack-Server -dname "CN=$SERVER_HOST" -keystore "$JACK_HOME/server.jks" |
| 279 | keytool -genkeypair -validity 3650 -alias client -keyalg RSA -keysize 2048 -keypass Jack-Server -storepass Jack-Server -dname "CN=$(id -un)@$(uname -n)" -keystore "$JACK_HOME/client.jks" |
| 280 | else |
| 281 | echo "Jack server already installed in \"$JACK_HOME\"" >&2 |
| 282 | abort |
| 283 | fi |
| 284 | exit 0 ;; |
| 285 | |
| 286 | |
| 287 | uninstall-server) |
Yohann Roussel | 2960f69 | 2016-09-20 17:33:21 +0200 | [diff] [blame] | 288 | SERVERS_PID=$(ps -A -o "pid args" -u `id -u -n` | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}') |
| 289 | if [ -n "$SERVERS_PID" ]; then |
| 290 | echo "Jack server is running, please stop it before uninstall" >&2 |
| 291 | echo "If you want to proceeed anyway, use '$0 force-uninstall-server'" >&2 |
| 292 | exit 2 |
| 293 | fi |
| 294 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 295 | if [ ! -d "$JACK_HOME" ]; then |
| 296 | echo "Jack server in \"$JACK_HOME\" not found" >&2 |
| 297 | abort |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 298 | fi |
Yohann Roussel | 2960f69 | 2016-09-20 17:33:21 +0200 | [diff] [blame] | 299 | |
| 300 | echo "Removing jack server from \"$JACK_HOME\"" |
| 301 | rm -rf "$JACK_HOME" |
| 302 | exit 0 ;; |
| 303 | |
| 304 | |
| 305 | force-uninstall-server) |
| 306 | if [ ! -d "$JACK_HOME" ]; then |
| 307 | echo "Jack server in \"$JACK_HOME\" not found" >&2 |
| 308 | abort |
| 309 | fi |
| 310 | |
| 311 | echo "Removing jack server from \"$JACK_HOME\"" |
| 312 | rm -rf "$JACK_HOME" |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 313 | exit 0 ;; |
| 314 | |
| 315 | |
| 316 | list) |
| 317 | if [ $# -ne 2 ] |
| 318 | then |
| 319 | usage |
| 320 | abort |
| 321 | fi |
| 322 | |
| 323 | listProgramVersion $2 ;; |
| 324 | |
| 325 | |
| 326 | update) |
| 327 | if [ $# -lt 3 ]; then |
| 328 | usage |
| 329 | abort |
| 330 | fi |
| 331 | |
| 332 | if [ $# -gt 4 ]; then |
| 333 | usage |
| 334 | abort |
| 335 | fi |
| 336 | |
| 337 | if [ ! -r "$3" ]; then |
| 338 | echo "Failed to update $2 of Jack server: \"$3\" is not readable" >&2 |
| 339 | abort |
| 340 | fi |
| 341 | |
| 342 | checkCurlVersion |
| 343 | |
| 344 | if [ $FORCE_INSTALLATION = true ]; then |
| 345 | updateProgram $2 $3 |
| 346 | else |
| 347 | if [ $# -eq 4 ]; then |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 348 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 349 | --cert "${JACK_HOME}/client.pem" \ |
| 350 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 351 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 352 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 353 | -X HEAD \ |
| 354 | --data "$4" \ |
| 355 | -H "Content-Type:application/vnd.jack.select-exact;version=1" \ |
| 356 | --noproxy ${SERVER_HOST} \ |
| 357 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/$2 \ |
| 358 | ) |
| 359 | CURL_CODE=$? |
| 360 | if [ $CURL_CODE -eq 22 ]; then |
| 361 | if [ $HTTP_CODE -eq 404 ]; then |
| 362 | # version not found, proceed to installation |
| 363 | updateProgram $2 $3 |
| 364 | exit 0 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 365 | fi |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 366 | fi |
| 367 | handleHttpErrors $CURL_CODE $HTTP_CODE |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 368 | else |
| 369 | # No version provided, proceed directly without testing |
| 370 | updateProgram $2 $3 |
| 371 | fi |
| 372 | fi |
| 373 | exit 0;; |
| 374 | |
| 375 | |
| 376 | stop-server) |
| 377 | echo "Stopping background server" |
| 378 | |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 379 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 380 | --cert "${JACK_HOME}/client.pem" \ |
| 381 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 382 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 383 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 384 | -X POST \ |
| 385 | --noproxy ${SERVER_HOST} \ |
| 386 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/server/stop \ |
| 387 | ) |
| 388 | handleHttpErrors $? $HTTP_CODE ;; |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 389 | |
| 390 | |
| 391 | server-stat) |
| 392 | echo "Getting statistic from background server" |
| 393 | |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 394 | exec 3>&1 |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 395 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 396 | --cert "${JACK_HOME}/client.pem" \ |
| 397 | --cacert "${JACK_HOME}/server.pem" \ |
| 398 | --output >(tr -d '\015' >&3) \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 399 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 400 | -X GET \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 401 | -H "Accept: text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 402 | --noproxy ${SERVER_HOST} \ |
| 403 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/stat \ |
| 404 | ) |
| 405 | handleHttpErrors $? $HTTP_CODE |
| 406 | exec 3>&- ;; |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 407 | |
| 408 | |
Yohann Roussel | 2960f69 | 2016-09-20 17:33:21 +0200 | [diff] [blame] | 409 | server-stat-reset) |
| 410 | echo "Reseting peak statistics from the background server" |
| 411 | |
| 412 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
| 413 | --cert "${JACK_HOME}/client.pem" \ |
| 414 | --cacert "${JACK_HOME}/server.pem" \ |
| 415 | --output /dev/null \ |
| 416 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
| 417 | -X DELETE \ |
| 418 | --noproxy ${SERVER_HOST} \ |
| 419 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/stat \ |
| 420 | ) |
| 421 | handleHttpErrors $? $HTTP_CODE ;; |
| 422 | |
| 423 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 424 | server-log) |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 425 | exec 3>&1 |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 426 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 427 | --cert "${JACK_HOME}/client.pem" \ |
| 428 | --cacert "${JACK_HOME}/server.pem" \ |
| 429 | --output >(tr -d '\015' >&3) \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 430 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 431 | -X GET \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 432 | -H "Accept: text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 433 | --noproxy ${SERVER_HOST} \ |
| 434 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/launcher/log \ |
| 435 | ) |
| 436 | handleHttpErrors $? $HTTP_CODE |
| 437 | exec 3>&- ;; |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 438 | |
| 439 | |
| 440 | kill-server) |
| 441 | echo "Killing background server" |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 442 | SERVERS_PID=$(ps -A -o "pid args" -u `id -u -n` | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}') |
| 443 | if [ -z "$SERVERS_PID" ]; then |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 444 | echo "No Jack server to kill" >&2 |
| 445 | exit 2 |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 446 | fi |
| 447 | |
| 448 | for PID in $SERVERS_PID; do |
| 449 | kill $PID 2>/dev/null |
| 450 | TIMEOUT=30 |
| 451 | while [ "$TIMEOUT" -ne 0 ]; do |
| 452 | kill -0 $PID 2>/dev/null |
| 453 | if [ $? -ne 0 ]; then |
| 454 | continue 2 |
| 455 | fi |
| 456 | sleep 1 |
| 457 | let TIMEOUT=TIMEOUT-1 |
| 458 | done |
| 459 | kill -KILL $PID 2>/dev/null |
| 460 | DONE=$? |
| 461 | while [ $DONE -eq 0 ]; do |
| 462 | kill -0 $PID 2>/dev/null |
| 463 | DONE=$? |
| 464 | sleep 1 |
| 465 | done |
| 466 | done |
| 467 | |
| 468 | exit 0 ;; |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 469 | |
| 470 | |
| 471 | list-server) |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 472 | ps -A -o "user pid args" | grep $LAUNCHER_NAME | grep -v grep |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 473 | exit $? ;; |
| 474 | |
| 475 | |
| 476 | start-server) |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 477 | if [ ! -d "$JACK_HOME" ]; then |
| 478 | echo "Jack server installation not found" >&2 |
| 479 | abort |
| 480 | fi |
| 481 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 482 | isServerRunning |
| 483 | RUNNING=$? |
| 484 | if [ "$RUNNING" = 0 ]; then |
| 485 | echo "Server is already running" |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 486 | else |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 487 | JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -cp $LAUNCHER_JAR $LAUNCHER_NAME" |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 488 | echo "Launching Jack server" $JACK_SERVER_COMMAND |
| 489 | ( |
| 490 | trap "" SIGHUP |
| 491 | for i in $(seq 3 255); do |
| 492 | eval exec "$i"'>&-' |
| 493 | done |
| 494 | cd "$JACK_HOME" |
| 495 | umask $BASE_UMASK |
| 496 | exec $JACK_SERVER_COMMAND |
| 497 | abort |
| 498 | ) >"$JACK_OUT_ERR" 2>&1 & |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 499 | fi |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 500 | |
| 501 | waitServerStarted |
| 502 | exit 0 ;; |
| 503 | |
| 504 | |
| 505 | server-log-level) |
| 506 | if [ $# -eq 4 ] |
| 507 | then |
| 508 | LIMIT=$3 |
| 509 | COUNT=$4 |
| 510 | elif [ $# -eq 2 ] |
| 511 | then |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 512 | COUNT=5 |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 513 | if [ \( "$2" = "ERROR" \) -o \( "$2" = "WARNING" \) ] |
| 514 | then |
| 515 | LIMIT=1048576 |
| 516 | else |
| 517 | LIMIT=10485760 |
| 518 | fi |
| 519 | else |
| 520 | usage |
| 521 | abort |
| 522 | fi |
| 523 | |
| 524 | echo "Setting logging parameters of background server" |
| 525 | |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 526 | HTTP_CODE=$(curl --fail $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 527 | --cert "${JACK_HOME}/client.pem" \ |
| 528 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 529 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 530 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 531 | --request PUT \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 532 | --form "level=$2;type=text/plain$CHARSET_ARGUMENT" \ |
| 533 | --form "limit=$LIMIT;type=text/plain$CHARSET_ARGUMENT" \ |
| 534 | --form "count=$COUNT;type=text/plain$CHARSET_ARGUMENT" \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 535 | --noproxy ${SERVER_HOST} \ |
| 536 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/launcher/log/level \ |
| 537 | ) |
| 538 | handleHttpErrors $? $HTTP_CODE ;; |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 539 | |
| 540 | |
| 541 | server-gc) |
| 542 | echo "Requesting a garbage collection to the background server" |
| 543 | |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 544 | HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 545 | --cert "${JACK_HOME}/client.pem" \ |
| 546 | --cacert "${JACK_HOME}/server.pem" \ |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 547 | --output /dev/null \ |
Yohann Roussel | aaa3e80 | 2015-11-02 14:21:33 +0100 | [diff] [blame] | 548 | --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \ |
Yohann Roussel | 664ef35 | 2015-10-23 18:09:02 +0200 | [diff] [blame] | 549 | -X POST \ |
| 550 | --noproxy ${SERVER_HOST} \ |
| 551 | https://${SERVER_HOST}:$SERVER_PORT_ADMIN/gc \ |
| 552 | ) |
| 553 | handleHttpErrors $? $HTTP_CODE ;; |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 554 | |
| 555 | |
| 556 | # |
| 557 | # Should be run when server is off. Allows to clean files that could be forgotten on disk in case of |
| 558 | # server VM crash after an update. |
| 559 | # |
| 560 | cleanup-server) |
| 561 | shopt -s nullglob |
| 562 | for file in $JACK_HOME/jack/*.deleted; do |
| 563 | rm "${file%.deleted}" |
| 564 | rm "$file" |
| 565 | done |
| 566 | exit 0 ;; |
| 567 | |
| 568 | |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 569 | dump-report) |
| 570 | if [ ! -d "$JACK_HOME" ]; then |
| 571 | echo "Failed to locate Jack server installation" >&2 |
| 572 | abort |
| 573 | fi |
| 574 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 575 | echo "Creating report..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 576 | REPORT="jack-report.$$.zip" |
| 577 | REPORT_PATH="$(pwd)/$REPORT" |
| 578 | REPORT_INFO="$JACK_HOME/report.$$.txt" |
| 579 | |
| 580 | if [ -e "$REPORT" ]; then |
| 581 | echo "Failed to create Jack server report '$REPORT', file already exists" >&2 |
| 582 | abort |
| 583 | fi |
| 584 | |
| 585 | trap 'rm -f "$REPORT_INFO" 2>/dev/null;' EXIT |
| 586 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 587 | date >>"$REPORT_INFO" 2>&1 |
| 588 | |
| 589 | echo "Dumping Jack server stacks..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 590 | echo >>"$REPORT_INFO" |
| 591 | echo "\$ ps -A -o \"pid args\" | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}' | xargs kill -3" >>"$REPORT_INFO" |
| 592 | (ps -A -o "pid args" | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}' | xargs kill -3) >>"$REPORT_INFO" 2>&1 |
| 593 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 594 | echo "Getting current user id..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 595 | echo >>"$REPORT_INFO" |
| 596 | echo "\$ id -u" >>"$REPORT_INFO" |
| 597 | id -u >>"$REPORT_INFO" |
| 598 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 599 | echo "Listing Jack server process..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 600 | echo >>"$REPORT_INFO" |
| 601 | echo "\$ ps -A -o \"uid pid args\" | grep $LAUNCHER_NAME | grep -v grep" >>"$REPORT_INFO" |
| 602 | (ps -A -o "uid pid args" | grep $LAUNCHER_NAME | grep -v grep) >>"$REPORT_INFO" 2>&1 |
| 603 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 604 | echo "Listing process using Jack server service port $SERVER_PORT_SERVICE..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 605 | echo >>"$REPORT_INFO" |
| 606 | echo "\$ lsof -i TCP:$SERVER_PORT_SERVICE -l" >>"$REPORT_INFO" |
| 607 | lsof -i TCP:$SERVER_PORT_SERVICE -l >>"$REPORT_INFO" 2>&1 |
| 608 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 609 | echo "Listing process using Jack server admin port $SERVER_PORT_ADMIN..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 610 | echo >>"$REPORT_INFO" |
| 611 | echo "\$ lsof -i TCP:$SERVER_PORT_ADMIN -l" >>"$REPORT_INFO" |
| 612 | lsof -i TCP:$SERVER_PORT_ADMIN -l >>"$REPORT_INFO" 2>&1 |
| 613 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 614 | echo "Collecting Jack client configuration..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 615 | echo >>"$REPORT_INFO" |
Yohann Roussel | 90c63e6 | 2016-11-18 18:12:50 +0100 | [diff] [blame] | 616 | echo "\$ cat \"\$JACK_CLIENT_SETTING\"" >>"$REPORT_INFO" |
| 617 | cat "$JACK_CLIENT_SETTING" >>"$REPORT_INFO" 2>&1 |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 618 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 619 | echo "Listing Jack server installation dir..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 620 | echo >>"$REPORT_INFO" |
| 621 | echo "\$ cd \"\$JACK_HOME\"; ls -l -R -n ." >>"$REPORT_INFO" |
| 622 | (cd "$JACK_HOME" ; ls -l -R -n . >>"$REPORT_INFO" 2>&1) |
| 623 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 624 | echo "Collecting curl version..." |
| 625 | echo >>"$REPORT_INFO" |
| 626 | echo "\$ curl --version" >>"$REPORT_INFO" |
| 627 | curl --version >>"$REPORT_INFO" 2>&1 |
| 628 | |
| 629 | echo "Collecting curl connection info..." |
| 630 | echo >>"$REPORT_INFO" |
| 631 | echo "\$ JACK_EXTRA_CURL_OPTIONS=-v jack-admin list server" >>"$REPORT_INFO" |
| 632 | JACK_EXTRA_CURL_OPTIONS=-v "$0" list server >>"$REPORT_INFO" 2>&1 |
| 633 | |
| 634 | echo "Collecting Jack server stats..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 635 | echo >>"$REPORT_INFO" |
| 636 | echo "\$ jack-admin server-stat" >>"$REPORT_INFO" |
| 637 | "$0" server-stat >>"$REPORT_INFO" 2>&1 |
| 638 | |
Yohann Roussel | 2960f69 | 2016-09-20 17:33:21 +0200 | [diff] [blame] | 639 | echo "Collecting base64 info..." |
| 640 | echo >>"$REPORT_INFO" |
| 641 | echo "\$ base64 --version" >>"$REPORT_INFO" |
| 642 | base64 --version >>"$REPORT_INFO" 2>&1 |
| 643 | echo >>"$REPORT_INFO" |
| 644 | echo "\$ (echo amFjaw==;echo LXNlcnZlcg==) | base64 --decode" >>"$REPORT_INFO" |
| 645 | (echo amFjaw==;echo LXNlcnZlcg==) | base64 --decode >>"$REPORT_INFO" 2>&1 |
| 646 | |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 647 | echo "Zipping Jack server installation dir except keys and certificates..." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 648 | (cd "$JACK_HOME"; zip --exclude \*.pem \*.jks --recurse-paths "$REPORT_PATH" .) >/dev/null |
Yohann Roussel | e3f18c2 | 2016-02-24 16:16:42 +0100 | [diff] [blame] | 649 | echo "Jack server report saved in '$REPORT'. Consider reviewing content before publishing." |
Yohann Roussel | 5b90920 | 2016-01-04 14:01:05 +0100 | [diff] [blame] | 650 | exit 0 ;; |
| 651 | |
| 652 | |
Yohann Roussel | b6b1f82 | 2015-07-01 16:54:15 +0200 | [diff] [blame] | 653 | *) |
| 654 | usage |
| 655 | abort ;; |
| 656 | esac |
| 657 | |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 658 | |
| 659 | # Exit |
Yohann Roussel | 1b697cb | 2015-04-15 15:01:33 +0200 | [diff] [blame] | 660 | |
| 661 | exit 0 |