Skip to content

Commit

Permalink
Docker: verify output dirs are writable
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Jun 18, 2021
1 parent 8f3b91e commit 9bf9553
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,46 @@ OUTPUT_DIR_HTML="/root/arouteserver_html"

if [[ ! -e "${OUTPUT_DIR}" && ! -d "${OUTPUT_DIR}" ]]; then
error "The output directory ${OUTPUT_DIR} can't be found.
This is the directory where the configurations generate by ARouteServer will be saved.
This is the directory where the configurations generated by ARouteServer will be saved.
Please be sure to mount the desired directory of the host to the ${OUTPUT_DIR} directory on the container.
You can run the container passing the '-v PATH_OF_DIRECTORY_ON_THE_HOST:${OUTPUT_DIR}' argument."
fi

TEST_WRITABLE_FILE="${OUTPUT_DIR}/.test_dir_is_writable"

set +e
touch ${TEST_WRITABLE_FILE} &>/dev/null
EXIT_CODE=$?
set -e

if [[ ${EXIT_CODE} -ne 0 ]]; then
error "It seems that the output directory ${OUTPUT_DIR} is not writable.
This is the directory where the configurations generated by ARouteServer will be saved.
Please be sure to mount the desired directory of the host to the ${OUTPUT_DIR} directory on the container.
You can run the container passing the '-v PATH_OF_DIRECTORY_ON_THE_HOST:${OUTPUT_DIR}' argument."
fi

rm ${TEST_WRITABLE_FILE} &>/dev/null

if [[ -e "${OUTPUT_DIR_HTML}" && -d "${OUTPUT_DIR_HTML}" ]]; then

TEST_WRITABLE_FILE="${OUTPUT_DIR_HTML}/.test_dir_is_writable"

set +e
touch ${TEST_WRITABLE_FILE} &>/dev/null
EXIT_CODE=$?
set -e

if [[ ${EXIT_CODE} -ne 0 ]]; then
error "It seems that the HTML output directory ${OUTPUT_DIR_HTML} is not writable.
This is the directory where the textual representation of route server policy generated by ARouteServer will be saved.
Please be sure to mount the desired directory of the host to the ${OUTPUT_DIR_HTML} directory on the container.
You can run the container passing the '-v PATH_OF_DIRECTORY_ON_THE_HOST:${OUTPUT_DIR_HTML}' argument."
fi

rm ${TEST_WRITABLE_FILE} &>/dev/null
fi

if [[ -z "${DAEMON}" ]]; then
error_envvar_not_set "DAEMON"
fi
Expand Down

0 comments on commit 9bf9553

Please sign in to comment.