-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add manage offline files script (#8956)
Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
- Loading branch information
Showing
5 changed files
with
108 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
**/vagrant_ansible_inventory | ||
*.iml | ||
temp | ||
offline-files | ||
.idea | ||
.vscode | ||
.tox | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
CURRENT_DIR=$(cd $(dirname $0); pwd) | ||
OFFLINE_FILES_DIR="${CURRENT_DIR}/offline-files" | ||
FILES_LIST=${FILES_LIST:-"${CURRENT_DIR}/temp/files.list"} | ||
NGINX_PORT=8080 | ||
|
||
# download files | ||
if [ ! -f ${FILES_LIST} ]; then | ||
echo "${FILES_LIST} should exist." | ||
exit 1 | ||
fi | ||
rm -rf ${OFFLINE_FILES_DIR} | ||
mkdir ${OFFLINE_FILES_DIR} | ||
wget -x -P ${OFFLINE_FILES_DIR} -i ${FILES_LIST} | ||
|
||
# run nginx container server | ||
if command -v nerdctl 1>/dev/null 2>&1; then | ||
runtime="nerdctl" | ||
elif command -v podman 1>/dev/null 2>&1; then | ||
runtime="podman" | ||
elif command -v docker 1>/dev/null 2>&1; then | ||
runtime="docker" | ||
else | ||
echo "No supported container runtime found" | ||
exit 1 | ||
fi | ||
sudo "${runtime}" container inspect nginx >/dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
sudo "${runtime}" run \ | ||
--restart=always -d -p ${NGINX_PORT}:80 \ | ||
--volume ${OFFLINE_FILES_DIR}:/usr/share/nginx/html/download \ | ||
--volume "$(pwd)"/nginx.conf:/etc/nginx/nginx.conf \ | ||
--name nginx nginx:alpine | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
user nginx; | ||
worker_processes auto; | ||
error_log /var/log/nginx/error.log; | ||
pid /run/nginx.pid; | ||
include /usr/share/nginx/modules/*.conf; | ||
events { | ||
worker_connections 1024; | ||
} | ||
http { | ||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
access_log /var/log/nginx/access.log main; | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
default_type application/octet-stream; | ||
include /etc/nginx/conf.d/*.conf; | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
server_name _; | ||
include /etc/nginx/default.d/*.conf; | ||
location / { | ||
root /usr/share/nginx/html/download; | ||
autoindex on; | ||
autoindex_exact_size off; | ||
autoindex_localtime on; | ||
} | ||
error_page 404 /404.html; | ||
location = /40x.html { | ||
} | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters