Skip to content

Commit cc25328

Browse files
committed
reformat bourne shell scripts
using shfmt -l -w <scriptname>
1 parent e88d26b commit cc25328

File tree

15 files changed

+318
-291
lines changed

15 files changed

+318
-291
lines changed

irods/test/login_auth_test.sh

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,82 @@ LOCAL_ACCOUNT_ENV_FILE=~/.irods/irods_environment.json
99
cannot_iinit=''
1010
tries=8
1111
while true; do
12-
iinit_as_rods >/dev/null 2>&1 && break
13-
[ $((--tries)) -le 0 ] && { cannot_iinit=1; break; }
14-
sleep 5
12+
iinit_as_rods >/dev/null 2>&1 && break
13+
[ $((--tries)) -le 0 ] && {
14+
cannot_iinit=1
15+
break
16+
}
17+
sleep 5
1518
done
16-
[ -n "$cannot_iinit" ] && { echo >&2 "Could not iinit as rods."; exit 2; }
19+
[ -n "$cannot_iinit" ] && {
20+
echo >&2 "Could not iinit as rods."
21+
exit 2
22+
}
1723

1824
setup_preconnect_preference DONT_CARE
1925

2026
add_irods_to_system_pam_configuration
2127

22-
2328
# set up /etc/irods/ssl directory and files
2429
set_up_ssl sudo
2530

2631
sudo useradd -ms/bin/bash alissa
2732
sudo chpasswd <<<"alissa:test123"
2833

2934
update_json_file $IRODS_SERVICE_ACCOUNT_ENV_FILE \
30-
"$(newcontent $IRODS_SERVICE_ACCOUNT_ENV_FILE ssl_keys)"
35+
"$(newcontent $IRODS_SERVICE_ACCOUNT_ENV_FILE ssl_keys)"
3136

3237
# 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; }
38+
activate_virtual_env_with_prc_installed >/dev/null 2>&1 || {
39+
echo >&2 "couldn't set up virtual environment"
40+
exit 1
41+
}
3442

3543
server_hup=
3644
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)"
45+
server_hup="y"
46+
update_json_file $IRODS_SERVER_CONFIG \
47+
"$(newcontent $IRODS_SERVER_CONFIG tls_server_items tls_client_items)"
4048

41-
sudo su - irods -c "$IRODS_CONTROL_PATH/manage_irods5_procs rescan-config"
49+
sudo su - irods -c "$IRODS_CONTROL_PATH/manage_irods5_procs rescan-config"
4250
fi
4351

4452
# Configure clients with admin user + TLS
4553

4654
update_json_file $LOCAL_ACCOUNT_ENV_FILE \
47-
"$(newcontent $LOCAL_ACCOUNT_ENV_FILE ssl_keys encrypt_keys)"
55+
"$(newcontent $LOCAL_ACCOUNT_ENV_FILE ssl_keys encrypt_keys)"
4856

4957
update_time=0
5058
# We won't time out, however we will warn for each minute the server
5159
# has not returned to readiness.
5260
if [ "$server_hup" = "y" ]; then
53-
# wait for server to be ready after configuration reload
54-
while true; do
55-
sleep 2
56-
if ils >/dev/null 2>&1; then
57-
break
58-
else
59-
now=$(date +%s)
60-
if [ $now -ge $((update_time + 60)) ]; then
61-
echo >&2 "At [$(date)] ... still waiting on server reload";
62-
update_time=$now
63-
fi
64-
fi
65-
done
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
6674
fi
6775

6876
if [ -n "$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT" ]; then
69-
original_script="/prc/$ORIGINAL_SCRIPT_RELATIVE_TO_ROOT"
70-
71-
# Run tests.
72-
if [ -x "$original_script" ]; then
73-
command "$original_script" $*
74-
elif [[ $original_script =~ \.py$ ]]; then
75-
python "$original_script" $*
76-
elif [[ $original_script =~ \.bats$ ]]; then
77-
bats "$original_script"
78-
else
79-
echo >&2 "I don't know how to run this: original_script=[$original_script]"
80-
fi
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
8189

8290
fi

irods/test/scripts/run_suite_locally.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ SCRIPT_DIR=$(dirname "$0")
55
. "$SCRIPT_DIR"/test_support_functions
66

77
report_environment_variables() {
8-
echo "PRC under test with these environment variables active:"
9-
python -c "
8+
echo "PRC under test with these environment variables active:"
9+
python -c "
1010
import os, sys
1111
for name in ['IRODS_PACKAGE_VERSION','PYTHON_VERSION']:
1212
value = os.environ.get(name)
@@ -17,8 +17,8 @@ print(f'{sys.version = }')
1717
}
1818

1919
run_tests() {
20-
setup_pyN
21-
su - testuser -c "
20+
setup_pyN
21+
su - testuser -c "
2222
set -e
2323
source /pyN/bin/activate
2424
pip install -e /prc.rw[tests]
@@ -34,17 +34,17 @@ run_tests() {
3434
python runner.py --output_tests_skipped /tmp/skipped.txt -e PYTHON_RULE_ENGINE_INSTALLED
3535
"
3636

37-
# Install PREP (Python Rule Engine Plugin).
38-
(
39-
set -e
40-
cd "/prc/test_harness/single_node"
41-
apt update
42-
./install_python_rule_engine
43-
su irods -c './setup_python_rule_engine --wait'
44-
)
37+
# Install PREP (Python Rule Engine Plugin).
38+
(
39+
set -e
40+
cd "/prc/test_harness/single_node"
41+
apt update
42+
./install_python_rule_engine
43+
su irods -c './setup_python_rule_engine --wait'
44+
)
4545

46-
# Run PREP-dependent tests that were previously skipped.
47-
su - testuser -c "
46+
# Run PREP-dependent tests that were previously skipped.
47+
su - testuser -c "
4848
set -e
4949
source /pyN/bin/activate
5050
cd /prc.rw/irods/test

irods/test/scripts/update_json_for_test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ update_json_file() {
4949

5050
restore_json_files() {
5151
local kk
52-
for kk in ${!RESTORE_FILES[@]};do
52+
for kk in ${!RESTORE_FILES[@]}; do
5353
sudo mv -f "${RESTORE_FILES["$kk"]}" "$kk"
5454
done
5555
}
5656

57-
newcontent () {
58-
local file=$1
59-
shift
60-
local j=$(sudo cat "$file")
61-
while [ $# -gt 0 ]; do
62-
eval '
57+
newcontent() {
58+
local file=$1
59+
shift
60+
local j=$(sudo cat "$file")
61+
while [ $# -gt 0 ]; do
62+
eval '
6363
for kk in ${!'$1'[@]}; do
6464
j=$(jq ".$kk=${'$1'[$kk]}" <<<"$j")
6565
done'
66-
shift
67-
done
68-
echo "$j"
66+
shift
67+
done
68+
echo "$j"
6969
}

test_harness/multiple_node/irods_catalog_provider_4/entrypoint.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ catalog_db_hostname=irods-catalog
44

55
echo "Waiting for iRODS catalog database to be ready"
66

7-
until pg_isready -h ${catalog_db_hostname} -d ICAT -U irods -q
8-
do
7+
until pg_isready -h ${catalog_db_hostname} -d ICAT -U irods -q; do
98
sleep 1
109
done
1110

@@ -15,7 +14,7 @@ setup_input_file=/irods_setup.input
1514

1615
if [ -e "${setup_input_file}" ]; then
1716
echo "Running iRODS setup"
18-
python3 /var/lib/irods/scripts/setup_irods.py < "${setup_input_file}"
17+
python3 /var/lib/irods/scripts/setup_irods.py <"${setup_input_file}"
1918
rm /irods_setup.input
2019
fi
2120

@@ -26,23 +25,25 @@ chown -R irods:irods /irods_shared
2625

2726
{
2827
[ -f ~/provider-address.do_not_remove ] || {
29-
jq <$ORIG_SERVER_CONFIG >$MOD_SERVER_CONFIG \
30-
'.host_resolution.host_entries += [
28+
jq <$ORIG_SERVER_CONFIG >$MOD_SERVER_CONFIG \
29+
'.host_resolution.host_entries += [
3130
{
3231
"address_type": "local",
3332
"addresses": [
3433
"irods-catalog-provider",
3534
"'$(hostname)'"
3635
]
3736
}
38-
]' && \
39-
cat <$MOD_SERVER_CONFIG >$ORIG_SERVER_CONFIG && \
40-
touch ~/provider-address.do_not_remove
37+
]' &&
38+
cat <$MOD_SERVER_CONFIG >$ORIG_SERVER_CONFIG &&
39+
touch ~/provider-address.do_not_remove
4140
}
42-
} || { echo >&2 "Error modifying $ORIG_SERVER_CONFIG"; exit 1; }
41+
} || {
42+
echo >&2 "Error modifying $ORIG_SERVER_CONFIG"
43+
exit 1
44+
}
4345

4446
echo "Starting server"
4547

4648
cd /usr/sbin
4749
su irods -c './irodsServer -u'
48-

test_harness/multiple_node/irods_catalog_provider_5/entrypoint.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ catalog_db_hostname=irods-catalog
44

55
echo "Waiting for iRODS catalog database to be ready"
66

7-
until pg_isready -h ${catalog_db_hostname} -d ICAT -U irods -q
8-
do
7+
until pg_isready -h ${catalog_db_hostname} -d ICAT -U irods -q; do
98
sleep 1
109
done
1110

@@ -15,7 +14,7 @@ setup_input_file=/irods_setup.input
1514

1615
if [ -e "${setup_input_file}" ]; then
1716
echo "Running iRODS setup"
18-
python3 /var/lib/irods/scripts/setup_irods.py < "${setup_input_file}"
17+
python3 /var/lib/irods/scripts/setup_irods.py <"${setup_input_file}"
1918
rm /irods_setup.input
2019
fi
2120

@@ -27,23 +26,25 @@ chmod 0777 /irods_shared
2726

2827
{
2928
[ -f ~/provider-address.do_not_remove ] || {
30-
jq <$ORIG_SERVER_CONFIG >$MOD_SERVER_CONFIG \
31-
'.host_resolution.host_entries += [
29+
jq <$ORIG_SERVER_CONFIG >$MOD_SERVER_CONFIG \
30+
'.host_resolution.host_entries += [
3231
{
3332
"address_type": "local",
3433
"addresses": [
3534
"irods-catalog-provider",
3635
"'$(hostname)'"
3736
]
3837
}
39-
]' && \
40-
cat <$MOD_SERVER_CONFIG >$ORIG_SERVER_CONFIG && \
41-
touch ~/provider-address.do_not_remove
38+
]' &&
39+
cat <$MOD_SERVER_CONFIG >$ORIG_SERVER_CONFIG &&
40+
touch ~/provider-address.do_not_remove
4241
}
43-
} || { echo >&2 "Error modifying $ORIG_SERVER_CONFIG"; exit 1; }
42+
} || {
43+
echo >&2 "Error modifying $ORIG_SERVER_CONFIG"
44+
exit 1
45+
}
4446

4547
echo "Starting server"
4648

4749
cd /usr/sbin
4850
su irods -c './irodsServer -p /tmp/irods.pid --stdout'
49-

test_harness/multiple_node/start_containers.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ set -e
44
# This script is launched on the docker host.
55

66
usage() {
7-
echo >&2 "usage: $0 [-n] [-b '<docker compose build args>'] irods_version python_version"; exit 2;
7+
echo >&2 "usage: $0 [-n] [-b '<docker compose build args>'] irods_version python_version"
8+
exit 2
89
}
910

1011
SHELL_DOCKER_COMPOSE_BUILD_ARGS=""
1112
DO_NOT_RUN=""
1213

1314
while [[ $1 = -* ]]; do
14-
if [ "$1" = "-b" ]; then
15-
SHELL_DOCKER_COMPOSE_BUILD_ARGS=$2
16-
shift 2
17-
fi
18-
if [ "$1" = "-n" ]; then
19-
DO_NOT_RUN=1
20-
shift
21-
fi
15+
if [ "$1" = "-b" ]; then
16+
SHELL_DOCKER_COMPOSE_BUILD_ARGS=$2
17+
shift 2
18+
fi
19+
if [ "$1" = "-n" ]; then
20+
DO_NOT_RUN=1
21+
shift
22+
fi
2223
done
2324

2425
if [ $# -eq 2 ]; then
@@ -29,9 +30,8 @@ else
2930
usage
3031
fi
3132

32-
3333
[ -n "$PYTHON_VERSION" -a -n "$IRODS_VERSION" ] || {
34-
usage
34+
usage
3535
}
3636

3737
IRODS_MAJOR=${IRODS_VERSION//.*/}

test_harness/multiple_node/stop_containers.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ set -e
44
# This script is launched on the docker host.
55

66
usage() {
7-
echo >&2 "usage: $0 irods_version"; exit 1;
7+
echo >&2 "usage: $0 irods_version"
8+
exit 1
89
}
910

1011
if [ $# -eq 1 ]; then
@@ -14,9 +15,8 @@ else
1415
usage
1516
fi
1617

17-
1818
[ -n "$IRODS_VERSION" ] || {
19-
usage
19+
usage
2020
}
2121

2222
IRODS_MAJOR=${IRODS_VERSION//.*/}

test_harness/single_node/create_docker_images.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export IRODS_PACKAGE_VERSION=$1
44
export PYTHON_VERSION=$2
55

66
[ -z "$1" -o -z "$2" ] && {
7-
echo >&2 "usage: $0 <irods-version> <python-version>"; exit 2;
7+
echo >&2 "usage: $0 <irods-version> <python-version>"
8+
exit 2
89
}
910
shift 2
1011

0 commit comments

Comments
 (0)