Skip to content
Snippets Groups Projects
Unverified Commit 3d32f0e9 authored by yjqg6666's avatar yjqg6666 Committed by GitHub
Browse files

[#9067] archive offline-files and support env-var NO_HTTP_SERVER to skip nginx-running (#9068)

parent d821bed2
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
**/vagrant_ansible_inventory **/vagrant_ansible_inventory
*.iml *.iml
temp temp
offline-files contrib/offline/offline-files
contrib/offline/offline-files.tar.gz
.idea .idea
.vscode .vscode
.tox .tox
......
#!/bin/bash #!/bin/bash
CURRENT_DIR=$(cd $(dirname $0); pwd) CURRENT_DIR=$( dirname "$(readlink -f "$0")" )
OFFLINE_FILES_DIR="${CURRENT_DIR}/offline-files" OFFLINE_FILES_DIR_NAME="offline-files"
OFFLINE_FILES_DIR="${CURRENT_DIR}/${OFFLINE_FILES_DIR_NAME}"
OFFLINE_FILES_ARCHIVE="${CURRENT_DIR}/offline-files.tar.gz"
FILES_LIST=${FILES_LIST:-"${CURRENT_DIR}/temp/files.list"} FILES_LIST=${FILES_LIST:-"${CURRENT_DIR}/temp/files.list"}
NGINX_PORT=8080 NGINX_PORT=8080
# download files # download files
if [ ! -f ${FILES_LIST} ]; then if [ ! -f "${FILES_LIST}" ]; then
echo "${FILES_LIST} should exist." echo "${FILES_LIST} should exist, run ./generate_list.sh first."
exit 1 exit 1
fi fi
rm -rf ${OFFLINE_FILES_DIR}
mkdir ${OFFLINE_FILES_DIR} rm -rf "${OFFLINE_FILES_DIR}"
wget -x -P ${OFFLINE_FILES_DIR} -i ${FILES_LIST} rm "${OFFLINE_FILES_ARCHIVE}"
mkdir "${OFFLINE_FILES_DIR}"
wget -x -P "${OFFLINE_FILES_DIR}" -i "${FILES_LIST}"
tar -czvf "${OFFLINE_FILES_ARCHIVE}" "${OFFLINE_FILES_DIR_NAME}"
[ -n "$NO_HTTP_SERVER" ] && echo "skip to run nginx" && exit 0
# run nginx container server # run nginx container server
if command -v nerdctl 1>/dev/null 2>&1; then if command -v nerdctl 1>/dev/null 2>&1; then
...@@ -25,11 +33,12 @@ else ...@@ -25,11 +33,12 @@ else
echo "No supported container runtime found" echo "No supported container runtime found"
exit 1 exit 1
fi fi
sudo "${runtime}" container inspect nginx >/dev/null 2>&1 sudo "${runtime}" container inspect nginx >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
sudo "${runtime}" run \ sudo "${runtime}" run \
--restart=always -d -p ${NGINX_PORT}:80 \ --restart=always -d -p ${NGINX_PORT}:80 \
--volume ${OFFLINE_FILES_DIR}:/usr/share/nginx/html/download \ --volume "${OFFLINE_FILES_DIR}:/usr/share/nginx/html/download" \
--volume "$(pwd)"/nginx.conf:/etc/nginx/nginx.conf \ --volume "$(pwd)"/nginx.conf:/etc/nginx/nginx.conf \
--name nginx nginx:alpine --name nginx nginx:alpine
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment