|
2 | 2 | # shellcheck shell=dash |
3 | 3 | # shellcheck disable=SC2039 # local is non-POSIX |
4 | 4 |
|
| 5 | +temp_nodejs_tmp_root="" |
| 6 | +temp_iojs_tmp_root="" |
5 | 7 | cleanup () { |
6 | 8 | unset -f die cleanup NVM_NODEJS_ORG_MIRROR |
7 | 9 | docker stop ferron-nodejs-mirror && docker rm ferron-nodejs-mirror |
8 | 10 | docker stop ferron-iojs-mirror && docker rm ferron-iojs-mirror |
| 11 | + if [ -n "${temp_nodejs_tmp_root}" ]; then |
| 12 | + rm -rf -- "${temp_nodejs_tmp_root}" |
| 13 | + fi |
| 14 | + if [ -n "${temp_iojs_tmp_root}" ]; then |
| 15 | + rm -rf -- "${temp_iojs_tmp_root}" |
| 16 | + fi |
9 | 17 | } |
10 | 18 | die () { echo "$@" ; cleanup ; exit 1; } |
11 | 19 |
|
12 | 20 | set -e |
13 | 21 |
|
14 | | -{ [ -e "ferron-nodejs-mirror.kdl" ] && [ -e "ferron-iojs-mirror.kdl" ]; } || die nvm_ls_remote_with_proxy_requiring_basic_auth Need to set working directory of script to Unit tests directory. |
15 | | - |
16 | 22 | # shellcheck source=/dev/null # The nvm.sh script is checked separately. |
17 | 23 | \. ../../../nvm.sh |
18 | 24 |
|
19 | | -docker run --detach --name ferron-nodejs-mirror --publish 8080:8080 --volume "$(pwd):/mnt/cwd" ferronserver/ferron:2 ferron --config /mnt/cwd/ferron-nodejs-mirror.kdl |
20 | | -docker run --detach --name ferron-iojs-mirror --publish 8081:8081 --volume "$(pwd):/mnt/cwd" ferronserver/ferron:2 ferron --config /mnt/cwd/ferron-iojs-mirror.kdl |
| 25 | +# Setup the temporary directories to host the mock nodejs and iojs mirrors. |
| 26 | +MOCKS_DIR="$PWD/mocks" |
| 27 | +temp_nodejs_tmp_root="$(mktemp --directory)" |
| 28 | +mkdir -p "${temp_nodejs_tmp_root}/dist" |
| 29 | +cp "$MOCKS_DIR/nodejs.org-dist-index.tab" "${temp_nodejs_tmp_root}/dist/index.tab" |
| 30 | +temp_iojs_tmp_root="$(mktemp --directory)" |
| 31 | +mkdir -p "${temp_iojs_tmp_root}/dist" |
| 32 | +cp "$MOCKS_DIR/iojs.org-dist-index.tab" "${temp_iojs_tmp_root}/dist/index.tab" |
| 33 | + |
| 34 | +# Add necessary ferron config file needed for both containers. |
| 35 | +# NOTE: The valid credentials for these test servers are 'test:123?45>6'. |
| 36 | +cat <<EOF >"${temp_nodejs_tmp_root}/ferron.kdl" |
| 37 | +:8080 { |
| 38 | + log "/dev/stderr" |
| 39 | + error_log "/dev/stderr" |
| 40 | + status 401 users="test" brute_protection=#false |
| 41 | + user "test" "\$argon2id\$v=19\$m=19456,t=2,p=1\$emTillHaS3OqFuvITdXxzg\$G00heP8QSXk5H/ruTiLt302Xk3uETfU5QO8hBIwUq08" |
| 42 | + root "/mnt/www" |
| 43 | +} |
| 44 | +EOF |
| 45 | +cat <<EOF >"${temp_iojs_tmp_root}/ferron.kdl" |
| 46 | +:8081 { |
| 47 | + log "/dev/stderr" |
| 48 | + error_log "/dev/stderr" |
| 49 | + status 401 users="test" brute_protection=#false |
| 50 | + user "test" "\$argon2id\$v=19\$m=19456,t=2,p=1\$emTillHaS3OqFuvITdXxzg\$G00heP8QSXk5H/ruTiLt302Xk3uETfU5QO8hBIwUq08" |
| 51 | + root "/mnt/www" |
| 52 | +} |
| 53 | +EOF |
| 54 | +# Need to adjust permissions to ensure ferron running under container can read the files in the temp directories. |
| 55 | +chmod a+rx "${temp_nodejs_tmp_root}" |
| 56 | +chmod a+rx "${temp_iojs_tmp_root}" |
| 57 | + |
| 58 | +# Start containers |
| 59 | +docker run --detach --name ferron-nodejs-mirror --publish 8080:8080 --volume "${temp_nodejs_tmp_root}:/mnt/www" --workdir "/mnt/www" ferronserver/ferron:2 ferron --config /mnt/www/ferron.kdl |
| 60 | +docker run --detach --name ferron-iojs-mirror --publish 8081:8081 --volume "${temp_iojs_tmp_root}:/mnt/www" --workdir "/mnt/www" ferronserver/ferron:2 ferron --config /mnt/www/ferron.kdl |
21 | 61 | sleep 1 # wait for ferron containers to start |
22 | 62 |
|
23 | 63 | export NVM_NODEJS_ORG_MIRROR="http://localhost:8080/dist" |
|
0 commit comments