Skip to content

Commit 3d32f0e

Browse files
authored
[kubernetes-sigs#9067] archive offline-files and support env-var NO_HTTP_SERVER to skip nginx-running (kubernetes-sigs#9068)
1 parent d821bed commit 3d32f0e

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
**/vagrant_ansible_inventory
44
*.iml
55
temp
6-
offline-files
6+
contrib/offline/offline-files
7+
contrib/offline/offline-files.tar.gz
78
.idea
89
.vscode
910
.tox
+17-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
#!/bin/bash
22

3-
CURRENT_DIR=$(cd $(dirname $0); pwd)
4-
OFFLINE_FILES_DIR="${CURRENT_DIR}/offline-files"
3+
CURRENT_DIR=$( dirname "$(readlink -f "$0")" )
4+
OFFLINE_FILES_DIR_NAME="offline-files"
5+
OFFLINE_FILES_DIR="${CURRENT_DIR}/${OFFLINE_FILES_DIR_NAME}"
6+
OFFLINE_FILES_ARCHIVE="${CURRENT_DIR}/offline-files.tar.gz"
57
FILES_LIST=${FILES_LIST:-"${CURRENT_DIR}/temp/files.list"}
68
NGINX_PORT=8080
79

810
# download files
9-
if [ ! -f ${FILES_LIST} ]; then
10-
echo "${FILES_LIST} should exist."
11+
if [ ! -f "${FILES_LIST}" ]; then
12+
echo "${FILES_LIST} should exist, run ./generate_list.sh first."
1113
exit 1
1214
fi
13-
rm -rf ${OFFLINE_FILES_DIR}
14-
mkdir ${OFFLINE_FILES_DIR}
15-
wget -x -P ${OFFLINE_FILES_DIR} -i ${FILES_LIST}
15+
16+
rm -rf "${OFFLINE_FILES_DIR}"
17+
rm "${OFFLINE_FILES_ARCHIVE}"
18+
mkdir "${OFFLINE_FILES_DIR}"
19+
20+
wget -x -P "${OFFLINE_FILES_DIR}" -i "${FILES_LIST}"
21+
tar -czvf "${OFFLINE_FILES_ARCHIVE}" "${OFFLINE_FILES_DIR_NAME}"
22+
23+
[ -n "$NO_HTTP_SERVER" ] && echo "skip to run nginx" && exit 0
1624

1725
# run nginx container server
1826
if command -v nerdctl 1>/dev/null 2>&1; then
@@ -25,11 +33,12 @@ else
2533
echo "No supported container runtime found"
2634
exit 1
2735
fi
36+
2837
sudo "${runtime}" container inspect nginx >/dev/null 2>&1
2938
if [ $? -ne 0 ]; then
3039
sudo "${runtime}" run \
3140
--restart=always -d -p ${NGINX_PORT}:80 \
32-
--volume ${OFFLINE_FILES_DIR}:/usr/share/nginx/html/download \
41+
--volume "${OFFLINE_FILES_DIR}:/usr/share/nginx/html/download" \
3342
--volume "$(pwd)"/nginx.conf:/etc/nginx/nginx.conf \
3443
--name nginx nginx:alpine
3544
fi

0 commit comments

Comments
 (0)