|
| 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 ] && { cannot_iinit=1; break; } |
| 14 | + sleep 5 |
| 15 | +done |
| 16 | +[ -n "$cannot_iinit" ] && { echo >&2 "Could not iinit as rods."; exit 2; } |
| 17 | + |
| 18 | +setup_preconnect_preference DONT_CARE |
| 19 | + |
| 20 | +add_irods_to_system_pam_configuration |
| 21 | + |
| 22 | + |
| 23 | +# set up /etc/irods/ssl directory and files |
| 24 | +set_up_ssl sudo |
| 25 | + |
| 26 | +sudo useradd -ms/bin/bash alissa |
| 27 | +sudo chpasswd <<<"alissa:test123" |
| 28 | + |
| 29 | +update_json_file $IRODS_SERVICE_ACCOUNT_ENV_FILE \ |
| 30 | + "$(newcontent $IRODS_SERVICE_ACCOUNT_ENV_FILE ssl_keys)" |
| 31 | + |
| 32 | +# This is mostly so we can call python3 as just "python" |
| 33 | +activate_virtual_env_with_prc_installed >/dev/null 2>&1 || { echo >&2 "couldn't set up virtual environment"; exit 1; } |
| 34 | + |
| 35 | +server_hup= |
| 36 | +if irods_server_version ge 5.0.0; then |
| 37 | + server_hup="y" |
| 38 | + update_json_file $IRODS_SERVER_CONFIG \ |
| 39 | + "$(newcontent $IRODS_SERVER_CONFIG tls_server_items tls_client_items)" |
| 40 | + |
| 41 | + sudo su - irods -c "$IRODS_CONTROL_PATH/manage_irods5_procs rescan-config" |
| 42 | +fi |
| 43 | + |
| 44 | +# Configure clients with admin user + TLS |
| 45 | + |
| 46 | +update_json_file $LOCAL_ACCOUNT_ENV_FILE \ |
| 47 | + "$(newcontent $LOCAL_ACCOUNT_ENV_FILE ssl_keys encrypt_keys)" |
| 48 | + |
| 49 | +if [ "$server_hup" = y ]; then |
| 50 | + # wait for server to be ready after configuration reload |
| 51 | + while true; do |
| 52 | + sleep 2 |
| 53 | + if ils >/dev/null 2>&1; then |
| 54 | + break |
| 55 | + else |
| 56 | + # Allow ~16 secs of total wait time. |
| 57 | + [ $((++server_check)) -gt 8 ] && { |
| 58 | + echo >&2 "Timed out on server reload"; exit 3; } |
| 59 | + fi |
| 60 | + done |
| 61 | +fi |
| 62 | + |
| 63 | +if [ -n "$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" ]; then |
| 64 | + original_script="/prc/$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" |
| 65 | + |
| 66 | + # Run tests. |
| 67 | + if [ -x "$original_script" ]; then |
| 68 | + command "$original_script" $* |
| 69 | + elif [[ $original_script =~ \.py$ ]]; then |
| 70 | + python "$original_script" $* |
| 71 | + elif [[ $original_script =~ \.bats$ ]]; then |
| 72 | + bats "$original_script" |
| 73 | + else |
| 74 | + echo >&2 "I don't know how to run this: original_script=[$original_script]" |
| 75 | + fi |
| 76 | + |
| 77 | +fi |
0 commit comments