dev_1.0.0_yuyr 完成 log和bind模块开发部署测试 #8
2
src/log/.gitignore
vendored
2
src/log/.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
|
||||
private/
|
||||
|
||||
|
||||
images/
|
||||
|
140
src/log/scripts/save_images.sh
Executable file
140
src/log/scripts/save_images.sh
Executable file
@ -0,0 +1,140 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "======================================="
|
||||
echo "ARGUS Log System - Image Export Tool"
|
||||
echo "======================================="
|
||||
echo ""
|
||||
|
||||
# 获取脚本所在目录和输出目录
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
output_dir="$script_dir/../images"
|
||||
|
||||
# 确保输出目录存在
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
# 定义镜像名称和版本
|
||||
ES_IMAGE="argus-elasticsearch:latest"
|
||||
KIBANA_IMAGE="argus-kibana:latest"
|
||||
|
||||
# 定义输出文件名
|
||||
ES_TAR="argus-elasticsearch-latest.tar"
|
||||
KIBANA_TAR="argus-kibana-latest.tar"
|
||||
|
||||
# 函数:检查镜像是否存在
|
||||
check_image() {
|
||||
local image_name="$1"
|
||||
if docker images --format "table {{.Repository}}:{{.Tag}}" | grep -q "^$image_name$"; then
|
||||
echo "✅ Image found: $image_name"
|
||||
return 0
|
||||
else
|
||||
echo "❌ Image not found: $image_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 函数:保存镜像
|
||||
save_image() {
|
||||
local image_name="$1"
|
||||
local output_file="$2"
|
||||
local output_path="$output_dir/$output_file"
|
||||
|
||||
echo "🔄 Saving $image_name to $output_file..."
|
||||
|
||||
# 删除旧的镜像文件(如果存在)
|
||||
if [[ -f "$output_path" ]]; then
|
||||
echo " Removing existing file: $output_file"
|
||||
rm "$output_path"
|
||||
fi
|
||||
|
||||
# 保存镜像
|
||||
docker save "$image_name" -o "$output_path"
|
||||
|
||||
# 检查文件大小
|
||||
local file_size=$(du -h "$output_path" | cut -f1)
|
||||
echo "✅ Saved successfully: $output_file ($file_size)"
|
||||
}
|
||||
|
||||
# 函数:显示镜像信息
|
||||
show_image_info() {
|
||||
local image_name="$1"
|
||||
echo "📋 Image info for $image_name:"
|
||||
docker images "$image_name" --format " Size: {{.Size}}, Created: {{.CreatedSince}}, ID: {{.ID}}"
|
||||
}
|
||||
|
||||
echo "🔍 Checking for ARGUS custom images..."
|
||||
echo ""
|
||||
|
||||
# 检查镜像是否存在
|
||||
es_exists=false
|
||||
kibana_exists=false
|
||||
|
||||
if check_image "$ES_IMAGE"; then
|
||||
show_image_info "$ES_IMAGE"
|
||||
es_exists=true
|
||||
else
|
||||
echo "⚠️ Elasticsearch image not found. Please build it first with:"
|
||||
echo " cd ../elasticsearch/build && docker build -t $ES_IMAGE ."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
if check_image "$KIBANA_IMAGE"; then
|
||||
show_image_info "$KIBANA_IMAGE"
|
||||
kibana_exists=true
|
||||
else
|
||||
echo "⚠️ Kibana image not found. Please build it first with:"
|
||||
echo " cd ../kibana/build && docker build -t $KIBANA_IMAGE ."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 如果没有镜像存在,退出
|
||||
if [[ "$es_exists" == false && "$kibana_exists" == false ]]; then
|
||||
echo "❌ No ARGUS images found to export. Please build the images first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "💾 Starting image export process..."
|
||||
echo ""
|
||||
|
||||
# 保存 Elasticsearch 镜像
|
||||
if [[ "$es_exists" == true ]]; then
|
||||
save_image "$ES_IMAGE" "$ES_TAR"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 保存 Kibana 镜像
|
||||
if [[ "$kibana_exists" == true ]]; then
|
||||
save_image "$KIBANA_IMAGE" "$KIBANA_TAR"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "======================================="
|
||||
echo "📦 Export Summary"
|
||||
echo "======================================="
|
||||
|
||||
# 显示导出的文件
|
||||
echo "📁 Exported files in $output_dir:"
|
||||
for file in "$ES_TAR" "$KIBANA_TAR"; do
|
||||
full_path="$output_dir/$file"
|
||||
if [[ -f "$full_path" ]]; then
|
||||
size=$(du -h "$full_path" | cut -f1)
|
||||
echo " ✅ $file ($size)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "🚀 Usage instructions:"
|
||||
echo " To load these images on another system:"
|
||||
if [[ -f "$script_dir/$ES_TAR" ]]; then
|
||||
echo " docker load -i $ES_TAR"
|
||||
fi
|
||||
if [[ -f "$script_dir/$KIBANA_TAR" ]]; then
|
||||
echo " docker load -i $KIBANA_TAR"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Image export completed successfully!"
|
||||
echo ""
|
Loading…
x
Reference in New Issue
Block a user