|
| 1 | +#!/bin/bash |
| 2 | +. "$(dirname "$0")/scripts/test_support_functions" |
| 3 | +. "$(dirname "$0")/scripts/update_json_for_test" |
| 4 | + |
| 5 | +IRODS_SERVER_CONFIG=/etc/irods/server_config.json |
| 6 | +IRODS_SERVICE_ACCOUNT_ENV_FILE=~irods/.irods/irods_environment.json |
| 7 | +LOCAL_ACCOUNT_ENV_FILE=~/.irods/irods_environment.json |
| 8 | + |
| 9 | +cannot_iinit='' |
| 10 | +tries=8 |
| 11 | +while true; do |
| 12 | + iinit_as_rods >/dev/null 2>&1 && break |
| 13 | + [ $((--tries)) -le 0 ] && { |
| 14 | + cannot_iinit=1 |
| 15 | + break |
| 16 | + } |
| 17 | + sleep 5 |
| 18 | +done |
| 19 | +[ -n "$cannot_iinit" ] && { |
| 20 | + echo >&2 "Could not iinit as rods." |
| 21 | + exit 2 |
| 22 | +} |
| 23 | + |
| 24 | +setup_preconnect_preference DONT_CARE |
| 25 | + |
| 26 | +add_irods_to_system_pam_configuration |
| 27 | + |
| 28 | +# set up /etc/irods/ssl directory and files |
| 29 | +set_up_ssl sudo |
| 30 | + |
| 31 | +sudo useradd -ms/bin/bash alissa |
| 32 | +sudo chpasswd <<<"alissa:test123" |
| 33 | + |
| 34 | +update_json_file $IRODS_SERVICE_ACCOUNT_ENV_FILE \ |
| 35 | + "$(newcontent $IRODS_SERVICE_ACCOUNT_ENV_FILE ssl_keys)" |
| 36 | + |
| 37 | +# This is mostly so we can call python3 as just "python" |
| 38 | +activate_virtual_env_with_prc_installed >/dev/null 2>&1 || { |
| 39 | + echo >&2 "couldn't set up virtual environment" |
| 40 | + exit 1 |
| 41 | +} |
| 42 | + |
| 43 | +server_hup= |
| 44 | +if irods_server_version ge 5.0.0; then |
| 45 | + server_hup="y" |
| 46 | + update_json_file $IRODS_SERVER_CONFIG \ |
| 47 | + "$(newcontent $IRODS_SERVER_CONFIG tls_server_items tls_client_items)" |
| 48 | + |
| 49 | + sudo su - irods -c "$IRODS_CONTROL_PATH/manage_irods5_procs rescan-config" |
| 50 | +fi |
| 51 | + |
| 52 | +# Configure clients with admin user + TLS |
| 53 | + |
| 54 | +update_json_file $LOCAL_ACCOUNT_ENV_FILE \ |
| 55 | + "$(newcontent $LOCAL_ACCOUNT_ENV_FILE ssl_keys encrypt_keys)" |
| 56 | + |
| 57 | +update_time=0 |
| 58 | +# We won't time out, however we will warn for each minute the server |
| 59 | +# has not returned to readiness. |
| 60 | +if [ "$server_hup" = "y" ]; then |
| 61 | + # wait for server to be ready after configuration reload |
| 62 | + while true; do |
| 63 | + sleep 2 |
| 64 | + if ils >/dev/null 2>&1; then |
| 65 | + break |
| 66 | + else |
| 67 | + now=$(date +%s) |
| 68 | + if [ $now -ge $((update_time + 60)) ]; then |
| 69 | + echo >&2 "At [$(date)] ... still waiting on server reload" |
| 70 | + update_time=$now |
| 71 | + fi |
| 72 | + fi |
| 73 | + done |
| 74 | +fi |
| 75 | + |
| 76 | +if [ -n "$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" ]; then |
| 77 | + original_script="/prc/$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" |
| 78 | + |
| 79 | + # Run tests. |
| 80 | + if [ -x "$original_script" ]; then |
| 81 | + command "$original_script" $* |
| 82 | + elif [[ $original_script =~ \.py$ ]]; then |
| 83 | + python "$original_script" $* |
| 84 | + elif [[ $original_script =~ \.bats$ ]]; then |
| 85 | + bats "$original_script" |
| 86 | + else |
| 87 | + echo >&2 "I don't know how to run this: original_script=[$original_script]" |
| 88 | + fi |
| 89 | + |
| 90 | +fi |
0 commit comments