xref: /prebuilts/sdk/tools/jack-admin (revision 692a2a62)
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#
17# Version: 1.3-a11
18#
19set -o nounset
20BASE_UMASK=$(umask)
21umask 077
22
23#
24# Settings
25#
26JACK_HOME="${JACK_HOME:=$HOME/.jack-server}"
27JACK_CLIENT_SETTING="${JACK_CLIENT_SETTING:=$HOME/.jack-settings}"
28TMPDIR=${TMPDIR:=/tmp}
29JACK_SERVER_VM_ARGUMENTS="${JACK_SERVER_VM_ARGUMENTS:=-Dfile.encoding=UTF-8}"
30JACK_EXTRA_CURL_OPTIONS=${JACK_EXTRA_CURL_OPTIONS:=}
31
32LAUNCHER_JAR="$JACK_HOME/launcher.jar"
33LAUNCHER_NAME=com.android.jack.launcher.ServerLauncher
34CURRENT_CHARSET=$(locale charmap)
35if [ -z "$CURRENT_CHARSET" ]; then
36  CHARSET_ARGUMENT=
37else
38  CHARSET_ARGUMENT=";charset=$CURRENT_CHARSET"
39fi
40
41JACK_LOGS_DIR="$JACK_HOME"/logs
42JACK_OUT_ERR="$JACK_LOGS_DIR"/outputs.txt
43JACK_CONNECTION_TIMEOUT=300
44
45#
46# Load client settings
47#
48if [ -f "$JACK_CLIENT_SETTING" ]; then
49  source "$JACK_CLIENT_SETTING"
50fi
51
52#
53# Create or update client settings if needed
54#
55if [[ ! -f "$JACK_CLIENT_SETTING" || $SETTING_VERSION -lt 4 ]]; then
56  echo "Writing client settings in" $JACK_CLIENT_SETTING
57  cat >"$JACK_CLIENT_SETTING.$$" <<-EOT
58	# Server settings
59	SERVER_HOST=${SERVER_HOST:=localhost}
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
65EOT
66  ln -f "$JACK_CLIENT_SETTING.$$" "$JACK_CLIENT_SETTING"
67  rm "$JACK_CLIENT_SETTING.$$"
68  source "$JACK_CLIENT_SETTING"
69fi
70
71usage () {
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]"
73}
74
75abort () { exit 255; }
76
77#
78# $1: curl command status
79# $2: HTTP status
80#
81handleHttpErrors() {
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
89    echo "SSL error when connecting to the Jack server. Try 'jack-diagnose'" >&2
90    abort
91  elif [ $1 -eq 58 ]; then
92    echo "Failed to contact Jack server: Problem reading ${JACK_HOME}/client.pem. Try 'jack-diagnose'" >&2
93    abort
94  elif [ $1 -eq 60 ]; then
95    echo "Failed to authenticate Jack server certificate. Try 'jack-diagnose'" >&2
96    abort
97   elif [ $1 -eq 77 ]; then
98    echo "Failed to contact Jack server: Problem reading ${JACK_HOME}/server.pem. Try 'jack-diagnose'" >&2
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
108      echo "Internal unknown error ($2), try 'jack-diagnose' or see Jack server log" >&2
109      abort
110    fi
111  else
112    echo "Communication error with Jack server $1. Try 'jack-diagnose'" >&2
113    abort
114  fi
115}
116
117checkCurlVersion () {
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#
129updateProgram () {
130  HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
131       --cert "${JACK_HOME}/client.pem" \
132       --cacert "${JACK_HOME}/server.pem" \
133       --output /dev/null \
134       --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
135       -X PUT \
136       -F "jar=@$2;type=application/octet-stream" \
137       -F "force=$FORCE_INSTALLATION;type=text/plain$CHARSET_ARGUMENT" \
138       --noproxy ${SERVER_HOST} \
139       https://${SERVER_HOST}:$SERVER_PORT_ADMIN/$1 \
140       )
141  handleHttpErrors $? $HTTP_CODE
142
143  if [ "$1" == server ]; then
144    echo "Server updated, waiting for restart"
145    waitServerStarted
146  fi
147}
148
149isServerRunning () {
150  RETRY_SESSION=3
151  DONE=1
152  let DATE_TIMEOUT=$(date +%s)+$JACK_CONNECTION_TIMEOUT
153  while [ "$DONE" -ne 0 ]; do
154    HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
155         --cert "${JACK_HOME}/client.pem" \
156         --cacert "${JACK_HOME}/server.pem" \
157         --output /dev/null \
158         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
159         -X GET \
160         -H "Accept: text/plain$CHARSET_ARGUMENT" \
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
173        echo "Communication error with Jack server ($CURL_CODE), try 'jack-diagnose' or see Jack server log"  >&2
174        abort
175      else
176        if [ $(date +%s) -lt $DATE_TIMEOUT ]; then
177          let RETRY_SESSION=RETRY_SESSION-1
178        else
179          echo "Communication error with Jack server ($CURL_CODE), try 'jack-diagnose' or see Jack server log"  >&2
180          abort
181        fi
182      fi
183    fi
184  done
185}
186
187waitServerStarted () {
188  DONE=1
189  let DATE_TIMEOUT=$(date +%s)+$JACK_CONNECTION_TIMEOUT
190  while [ "$DONE" -ne 0 ]; do
191    HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
192         --cert "${JACK_HOME}/client.pem" \
193         --cacert "${JACK_HOME}/server.pem" \
194         --output /dev/null \
195         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
196         -X GET \
197         -H "Accept: text/plain$CHARSET_ARGUMENT" \
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
203      if [ $(date +%s) -ge $DATE_TIMEOUT ]; then
204        echo "Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log" >&2
205        abort
206      else
207        sleep 1
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#
219listProgramVersion () {
220  exec 3>&1
221  HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
222       --cert "${JACK_HOME}/client.pem" \
223       --cacert "${JACK_HOME}/server.pem" \
224       --output >(tr -d '\015' >&3) \
225       --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
226       -X GET \
227       -H "Accept: text/plain$CHARSET_ARGUMENT" \
228       --noproxy ${SERVER_HOST} \
229       https://${SERVER_HOST}:$SERVER_PORT_ADMIN/$1 \
230       )
231  handleHttpErrors $? $HTTP_CODE
232  exec 3>&-
233}
234
235#
236# Decoding argument
237#
238if [ $# -eq 0 ]
239then
240  usage
241  abort
242fi
243
244set +o errexit
245
246FORCE_INSTALLATION=false
247case $1 in
248  force-update)
249    FORCE_INSTALLATION=true
250    COMMAND=update;;
251  *)
252    COMMAND=$1;;
253esac
254
255case $COMMAND in
256  install-server)
257    if [ $# -ne 3 ]; then
258      usage
259      abort
260    fi
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)
288    SERVERS_PID=$(ps -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
295    if [ ! -d "$JACK_HOME" ]; then
296      echo "Jack server in \"$JACK_HOME\" not found" >&2
297      abort
298    fi
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"
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
348        HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
349             --cert "${JACK_HOME}/client.pem" \
350             --cacert "${JACK_HOME}/server.pem" \
351             --output /dev/null \
352             --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
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
365          fi
366        fi
367        handleHttpErrors $CURL_CODE $HTTP_CODE
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
379    HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
380         --cert "${JACK_HOME}/client.pem" \
381         --cacert "${JACK_HOME}/server.pem" \
382         --output /dev/null \
383         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
384         -X POST \
385         --noproxy ${SERVER_HOST} \
386         https://${SERVER_HOST}:$SERVER_PORT_ADMIN/server/stop \
387         )
388    handleHttpErrors $? $HTTP_CODE ;;
389
390
391  server-stat)
392    echo "Getting statistic from background server"
393
394    exec 3>&1
395    HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
396         --cert "${JACK_HOME}/client.pem" \
397         --cacert "${JACK_HOME}/server.pem" \
398         --output >(tr -d '\015' >&3) \
399         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
400         -X GET \
401         -H "Accept: text/plain$CHARSET_ARGUMENT" \
402         --noproxy ${SERVER_HOST} \
403         https://${SERVER_HOST}:$SERVER_PORT_ADMIN/stat \
404         )
405    handleHttpErrors $? $HTTP_CODE
406    exec 3>&- ;;
407
408
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
424  server-log)
425    exec 3>&1
426    HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
427         --cert "${JACK_HOME}/client.pem" \
428         --cacert "${JACK_HOME}/server.pem" \
429         --output >(tr -d '\015' >&3) \
430         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
431         -X GET \
432         -H "Accept: text/plain$CHARSET_ARGUMENT" \
433        --noproxy ${SERVER_HOST} \
434         https://${SERVER_HOST}:$SERVER_PORT_ADMIN/launcher/log \
435         )
436    handleHttpErrors $? $HTTP_CODE
437    exec 3>&- ;;
438
439
440  kill-server)
441    echo "Killing background server"
442    SERVERS_PID=$(ps -o "pid args" -u `id -u -n` | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}')
443    if [ -z "$SERVERS_PID" ]; then
444      echo "No Jack server to kill" >&2
445      exit 2
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 ;;
469
470
471  list-server)
472    ps -A -o "user pid args" | grep $LAUNCHER_NAME | grep -v grep
473    exit $? ;;
474
475
476  start-server)
477    if [ ! -d "$JACK_HOME" ]; then
478      echo "Jack server installation not found" >&2
479      abort
480    fi
481
482    isServerRunning
483    RUNNING=$?
484    if [ "$RUNNING" = 0 ]; then
485      echo "Server is already running"
486    else
487      JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -cp $LAUNCHER_JAR $LAUNCHER_NAME"
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 &
499    fi
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
512      COUNT=5
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
526    HTTP_CODE=$(curl --fail $JACK_EXTRA_CURL_OPTIONS \
527         --cert "${JACK_HOME}/client.pem" \
528         --cacert "${JACK_HOME}/server.pem" \
529         --output /dev/null \
530         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
531         --request PUT \
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" \
535         --noproxy ${SERVER_HOST} \
536         https://${SERVER_HOST}:$SERVER_PORT_ADMIN/launcher/log/level \
537         )
538    handleHttpErrors $? $HTTP_CODE ;;
539
540
541  server-gc)
542    echo "Requesting a garbage collection to the background server"
543
544    HTTP_CODE=$(curl -f $JACK_EXTRA_CURL_OPTIONS \
545         --cert "${JACK_HOME}/client.pem" \
546         --cacert "${JACK_HOME}/server.pem" \
547         --output /dev/null \
548         --no-buffer --write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT \
549         -X POST \
550         --noproxy ${SERVER_HOST} \
551         https://${SERVER_HOST}:$SERVER_PORT_ADMIN/gc \
552         )
553    handleHttpErrors $? $HTTP_CODE ;;
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
569  dump-report)
570    if [ ! -d "$JACK_HOME" ]; then
571      echo "Failed to locate Jack server installation" >&2
572      abort
573    fi
574
575    echo "Creating report..."
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
587    date >>"$REPORT_INFO" 2>&1
588
589    echo "Dumping Jack server stacks..."
590    echo >>"$REPORT_INFO"
591    echo "\$ ps -o \"pid args\" | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}' |  xargs kill -3" >>"$REPORT_INFO"
592            (ps -o  "pid args"  | grep $LAUNCHER_NAME | grep -v grep | awk '{print $1}' |  xargs kill -3) >>"$REPORT_INFO" 2>&1
593
594    echo "Getting current user id..."
595    echo >>"$REPORT_INFO"
596    echo "\$ id -u" >>"$REPORT_INFO"
597             id -u  >>"$REPORT_INFO"
598
599    echo "Listing Jack server process..."
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
604    echo "Listing process using Jack server service port $SERVER_PORT_SERVICE..."
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
609    echo "Listing process using Jack server admin port $SERVER_PORT_ADMIN..."
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
614    echo "Collecting Jack client configuration..."
615    echo >>"$REPORT_INFO"
616    echo "\$ cat \"\$JACK_CLIENT_SETTING\"" >>"$REPORT_INFO"
617             cat   "$JACK_CLIENT_SETTING"   >>"$REPORT_INFO" 2>&1
618
619    echo "Listing Jack server installation dir..."
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
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..."
635    echo >>"$REPORT_INFO"
636    echo "\$ jack-admin server-stat" >>"$REPORT_INFO"
637             "$0"       server-stat  >>"$REPORT_INFO" 2>&1
638
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
647    echo "Zipping Jack server installation dir except keys and certificates..."
648    (cd "$JACK_HOME"; zip --exclude \*.pem \*.jks --recurse-paths "$REPORT_PATH" .) >/dev/null
649    echo "Jack server report saved in '$REPORT'. Consider reviewing content before publishing."
650    exit 0 ;;
651
652
653  *)
654    usage
655    abort ;;
656esac
657
658
659# Exit
660
661exit 0
662