dev_1.0.0_yuyr 完成 log和bind模块开发部署测试 #8
138
build/build_images.sh
Executable file
138
build/build_images.sh
Executable file
@ -0,0 +1,138 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# 帮助信息
|
||||||
|
show_help() {
|
||||||
|
cat << EOF
|
||||||
|
ARGUS Unified Build System - Image Build Tool
|
||||||
|
|
||||||
|
Usage: $0 [OPTIONS]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--intranet Use intranet mirror for Ubuntu 22.04 packages
|
||||||
|
-h, --help Show this help message
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$0 # Build with default sources
|
||||||
|
$0 --intranet # Build with intranet mirror
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# 解析命令行参数
|
||||||
|
use_intranet=false
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--intranet)
|
||||||
|
use_intranet=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option: $1"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# 获取项目根目录
|
||||||
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$root"
|
||||||
|
|
||||||
|
echo "======================================="
|
||||||
|
echo "ARGUS Unified Build System"
|
||||||
|
echo "======================================="
|
||||||
|
|
||||||
|
if [[ "$use_intranet" == true ]]; then
|
||||||
|
echo "🌐 Mode: Intranet (Using internal mirror: 10.68.64.1)"
|
||||||
|
build_args="--build-arg USE_INTRANET=true"
|
||||||
|
else
|
||||||
|
echo "🌐 Mode: Public (Using default package sources)"
|
||||||
|
build_args=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📁 Build context: $root"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 构建镜像的函数
|
||||||
|
build_image() {
|
||||||
|
local image_name=$1
|
||||||
|
local dockerfile_path=$2
|
||||||
|
local tag=$3
|
||||||
|
|
||||||
|
echo "🔄 Building $image_name image..."
|
||||||
|
echo " Dockerfile: $dockerfile_path"
|
||||||
|
echo " Tag: $tag"
|
||||||
|
|
||||||
|
if docker build $build_args -f "$dockerfile_path" -t "$tag" .; then
|
||||||
|
echo "✅ $image_name image built successfully"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "❌ Failed to build $image_name image"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 构建所有镜像
|
||||||
|
images_built=()
|
||||||
|
build_failed=false
|
||||||
|
|
||||||
|
# 构建 Elasticsearch 镜像
|
||||||
|
if build_image "Elasticsearch" "src/log/elasticsearch/build/Dockerfile" "argus-elasticsearch:latest"; then
|
||||||
|
images_built+=("argus-elasticsearch:latest")
|
||||||
|
else
|
||||||
|
build_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 构建 Kibana 镜像
|
||||||
|
if build_image "Kibana" "src/log/kibana/build/Dockerfile" "argus-kibana:latest"; then
|
||||||
|
images_built+=("argus-kibana:latest")
|
||||||
|
else
|
||||||
|
build_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 构建 BIND9 镜像
|
||||||
|
if build_image "BIND9" "src/bind/build/Dockerfile" "argus-bind9:latest"; then
|
||||||
|
images_built+=("argus-bind9:latest")
|
||||||
|
else
|
||||||
|
build_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "======================================="
|
||||||
|
echo "📦 Build Summary"
|
||||||
|
echo "======================================="
|
||||||
|
|
||||||
|
if [[ ${#images_built[@]} -gt 0 ]]; then
|
||||||
|
echo "✅ Successfully built images:"
|
||||||
|
for image in "${images_built[@]}"; do
|
||||||
|
echo " • $image"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$build_failed" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "❌ Some images failed to build. Please check the errors above."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$use_intranet" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "🌐 Built with intranet mirror configuration"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🚀 Next steps:"
|
||||||
|
echo " cd src/log && ./scripts/save_images.sh # Export log images"
|
||||||
|
echo " cd src/bind && ./scripts/save_images.sh # Export bind images"
|
||||||
|
echo " cd src/log/tests && ./scripts/02_up.sh # Start log services"
|
||||||
|
echo ""
|
222
build/save_images.sh
Executable file
222
build/save_images.sh
Executable file
@ -0,0 +1,222 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# 帮助信息
|
||||||
|
show_help() {
|
||||||
|
cat << EOF
|
||||||
|
ARGUS Unified Build System - Image Export Tool
|
||||||
|
|
||||||
|
Usage: $0 [OPTIONS]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--compress Compress exported images with gzip
|
||||||
|
-h, --help Show this help message
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$0 # Export all images without compression
|
||||||
|
$0 --compress # Export all images with gzip compression
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# 解析命令行参数
|
||||||
|
use_compression=false
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--compress)
|
||||||
|
use_compression=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option: $1"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# 获取项目根目录
|
||||||
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$root"
|
||||||
|
|
||||||
|
# 创建镜像输出目录
|
||||||
|
images_dir="$root/images"
|
||||||
|
mkdir -p "$images_dir"
|
||||||
|
|
||||||
|
echo "======================================="
|
||||||
|
echo "ARGUS Unified Build System - Image Export"
|
||||||
|
echo "======================================="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [[ "$use_compression" == true ]]; then
|
||||||
|
echo "🗜️ Mode: With gzip compression"
|
||||||
|
else
|
||||||
|
echo "📦 Mode: No compression"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📁 Output directory: $images_dir"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 定义镜像列表
|
||||||
|
declare -A images=(
|
||||||
|
["argus-elasticsearch:latest"]="argus-elasticsearch-latest.tar"
|
||||||
|
["argus-kibana:latest"]="argus-kibana-latest.tar"
|
||||||
|
["argus-bind9:latest"]="argus-bind9-latest.tar"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 函数:检查镜像是否存在
|
||||||
|
check_image() {
|
||||||
|
local image_name="$1"
|
||||||
|
if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^$image_name$"; then
|
||||||
|
echo "✅ Image found: $image_name"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "❌ Image not found: $image_name"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:显示镜像信息
|
||||||
|
show_image_info() {
|
||||||
|
local image_name="$1"
|
||||||
|
echo "📋 Image info for $image_name:"
|
||||||
|
docker images "$image_name" --format " Size: {{.Size}}, Created: {{.CreatedSince}}, ID: {{.ID}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:保存镜像
|
||||||
|
save_image() {
|
||||||
|
local image_name="$1"
|
||||||
|
local output_file="$2"
|
||||||
|
local output_path="$images_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
|
||||||
|
|
||||||
|
if [[ "$use_compression" == true && -f "$output_path.gz" ]]; then
|
||||||
|
echo " Removing existing compressed file: $output_file.gz"
|
||||||
|
rm "$output_path.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 保存镜像
|
||||||
|
docker save "$image_name" -o "$output_path"
|
||||||
|
|
||||||
|
if [[ "$use_compression" == true ]]; then
|
||||||
|
echo " Compressing with gzip..."
|
||||||
|
gzip "$output_path"
|
||||||
|
output_path="$output_path.gz"
|
||||||
|
output_file="$output_file.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查文件大小
|
||||||
|
local file_size=$(du -h "$output_path" | cut -f1)
|
||||||
|
echo "✅ Saved successfully: $output_file ($file_size)"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "🔍 Checking for ARGUS images..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 检查所有镜像
|
||||||
|
available_images=()
|
||||||
|
missing_images=()
|
||||||
|
|
||||||
|
for image_name in "${!images[@]}"; do
|
||||||
|
if check_image "$image_name"; then
|
||||||
|
show_image_info "$image_name"
|
||||||
|
available_images+=("$image_name")
|
||||||
|
else
|
||||||
|
missing_images+=("$image_name")
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
# 如果没有镜像存在,提示构建
|
||||||
|
if [[ ${#available_images[@]} -eq 0 ]]; then
|
||||||
|
echo "❌ No ARGUS images found to export."
|
||||||
|
echo ""
|
||||||
|
echo "🔧 Please build the images first with:"
|
||||||
|
echo " ./build/build_images.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 显示缺失的镜像
|
||||||
|
if [[ ${#missing_images[@]} -gt 0 ]]; then
|
||||||
|
echo "⚠️ Missing images (will be skipped):"
|
||||||
|
for image_name in "${missing_images[@]}"; do
|
||||||
|
echo " • $image_name"
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "💾 Starting image export process..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 保存所有可用的镜像
|
||||||
|
exported_files=()
|
||||||
|
for image_name in "${available_images[@]}"; do
|
||||||
|
output_file="${images[$image_name]}"
|
||||||
|
save_image "$image_name" "$output_file"
|
||||||
|
|
||||||
|
if [[ "$use_compression" == true ]]; then
|
||||||
|
exported_files+=("$output_file.gz")
|
||||||
|
else
|
||||||
|
exported_files+=("$output_file")
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "======================================="
|
||||||
|
echo "📦 Export Summary"
|
||||||
|
echo "======================================="
|
||||||
|
|
||||||
|
# 显示导出的文件
|
||||||
|
echo "📁 Exported files in $images_dir:"
|
||||||
|
total_size=0
|
||||||
|
for file in "${exported_files[@]}"; do
|
||||||
|
full_path="$images_dir/$file"
|
||||||
|
if [[ -f "$full_path" ]]; then
|
||||||
|
size=$(du -h "$full_path" | cut -f1)
|
||||||
|
size_bytes=$(du -b "$full_path" | cut -f1)
|
||||||
|
total_size=$((total_size + size_bytes))
|
||||||
|
echo " ✅ $file ($size)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 显示总大小
|
||||||
|
if [[ $total_size -gt 0 ]]; then
|
||||||
|
total_size_human=$(numfmt --to=iec --suffix=B $total_size)
|
||||||
|
echo ""
|
||||||
|
echo "📊 Total size: $total_size_human"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🚀 Usage instructions:"
|
||||||
|
echo " To load these images on another system:"
|
||||||
|
|
||||||
|
if [[ "$use_compression" == true ]]; then
|
||||||
|
for file in "${exported_files[@]}"; do
|
||||||
|
if [[ -f "$images_dir/$file" ]]; then
|
||||||
|
base_name="${file%.gz}"
|
||||||
|
echo " gunzip $file && docker load -i $base_name"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for file in "${exported_files[@]}"; do
|
||||||
|
if [[ -f "$images_dir/$file" ]]; then
|
||||||
|
echo " docker load -i $file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ Image export completed successfully!"
|
||||||
|
echo ""
|
@ -38,19 +38,20 @@ RUN if [ "$USE_INTRANET" = "true" ]; then \
|
|||||||
RUN mkdir -p /etc/supervisor/conf.d
|
RUN mkdir -p /etc/supervisor/conf.d
|
||||||
|
|
||||||
# Copy supervisor configuration
|
# Copy supervisor configuration
|
||||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY src/bind/build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# Copy BIND9 configuration files
|
# Copy BIND9 configuration files
|
||||||
COPY named.conf.local /etc/bind/named.conf.local
|
COPY src/bind/build/named.conf.local /etc/bind/named.conf.local
|
||||||
COPY db.argus.com /etc/bind/db.argus.com
|
COPY src/bind/build/db.argus.com /etc/bind/db.argus.com
|
||||||
|
|
||||||
# Copy startup and reload scripts
|
# Copy startup and reload scripts
|
||||||
COPY startup.sh /usr/local/bin/startup.sh
|
COPY src/bind/build/startup.sh /usr/local/bin/startup.sh
|
||||||
COPY reload-bind9.sh /usr/local/bin/reload-bind9.sh
|
COPY src/bind/build/reload-bind9.sh /usr/local/bin/reload-bind9.sh
|
||||||
COPY argus_dns_sync.sh /usr/local/bin/argus_dns_sync.sh
|
COPY src/bind/build/argus_dns_sync.sh /usr/local/bin/argus_dns_sync.sh
|
||||||
|
COPY src/bind/build/update-dns.sh /usr/local/bin/update-dns.sh
|
||||||
|
|
||||||
# Make scripts executable
|
# Make scripts executable
|
||||||
RUN chmod +x /usr/local/bin/startup.sh /usr/local/bin/reload-bind9.sh /usr/local/bin/argus_dns_sync.sh
|
RUN chmod +x /usr/local/bin/startup.sh /usr/local/bin/reload-bind9.sh /usr/local/bin/argus_dns_sync.sh /usr/local/bin/update-dns.sh
|
||||||
|
|
||||||
# Set proper ownership for BIND9 files
|
# Set proper ownership for BIND9 files
|
||||||
RUN chown bind:bind /etc/bind/named.conf.local /etc/bind/db.argus.com
|
RUN chown bind:bind /etc/bind/named.conf.local /etc/bind/db.argus.com
|
||||||
|
68
src/bind/build/dns-monitor.sh
Normal file
68
src/bind/build/dns-monitor.sh
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# DNS监控脚本 - 每10秒检查dns.conf是否有变化
|
||||||
|
# 如果有变化则执行update-dns.sh脚本
|
||||||
|
|
||||||
|
DNS_CONF="/private/argus/etc/dns.conf"
|
||||||
|
DNS_BACKUP="/tmp/dns.conf.backup"
|
||||||
|
UPDATE_SCRIPT="/private/argus/etc/update-dns.sh"
|
||||||
|
LOG_FILE="/var/log/supervisor/dns-monitor.log"
|
||||||
|
|
||||||
|
# 确保日志文件存在
|
||||||
|
touch "$LOG_FILE"
|
||||||
|
|
||||||
|
log_message() {
|
||||||
|
echo "$(date '+%Y-%m-%d %H:%M:%S') [DNS-Monitor] $1" >> "$LOG_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message "DNS监控脚本启动"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if [ -f "$DNS_CONF" ]; then
|
||||||
|
if [ -f "$DNS_BACKUP" ]; then
|
||||||
|
# 比较文件内容
|
||||||
|
if ! cmp -s "$DNS_CONF" "$DNS_BACKUP"; then
|
||||||
|
log_message "检测到DNS配置变化"
|
||||||
|
|
||||||
|
# 更新备份文件
|
||||||
|
cp "$DNS_CONF" "$DNS_BACKUP"
|
||||||
|
|
||||||
|
# 执行更新脚本
|
||||||
|
if [ -x "$UPDATE_SCRIPT" ]; then
|
||||||
|
log_message "执行DNS更新脚本: $UPDATE_SCRIPT"
|
||||||
|
"$UPDATE_SCRIPT" >> "$LOG_FILE" 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log_message "DNS更新脚本执行成功"
|
||||||
|
else
|
||||||
|
log_message "DNS更新脚本执行失败"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "警告: 更新脚本不存在或不可执行: $UPDATE_SCRIPT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
|
||||||
|
# 第一次检测到配置文件,执行更新脚本
|
||||||
|
if [ -x "$UPDATE_SCRIPT" ]; then
|
||||||
|
log_message "执行DNS更新脚本: $UPDATE_SCRIPT"
|
||||||
|
"$UPDATE_SCRIPT" >> "$LOG_FILE" 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log_message "DNS更新脚本执行成功"
|
||||||
|
|
||||||
|
# 第一次运行,创建备份并执行更新
|
||||||
|
cp "$DNS_CONF" "$DNS_BACKUP"
|
||||||
|
log_message "创建DNS配置备份文件"
|
||||||
|
|
||||||
|
else
|
||||||
|
log_message "DNS更新脚本执行失败"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "警告: 更新脚本不存在或不可执行: $UPDATE_SCRIPT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "警告: DNS配置文件不存在: $DNS_CONF"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
done
|
@ -16,6 +16,11 @@ if [ ! -f /private/argus/bind/db.argus.com ]; then
|
|||||||
cp /etc/bind/db.argus.com /private/argus/bind/db.argus.com
|
cp /etc/bind/db.argus.com /private/argus/bind/db.argus.com
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Copy update-dns.sh to /private/argus/etc/
|
||||||
|
cp /usr/local/bin/update-dns.sh /private/argus/etc/update-dns.sh
|
||||||
|
chown bind:bind /private/argus/etc/update-dns.sh
|
||||||
|
chmod a+x /private/argus/etc/update-dns.sh
|
||||||
|
|
||||||
# Create symlinks to use persistent configs
|
# Create symlinks to use persistent configs
|
||||||
ln -sf /private/argus/bind/named.conf.local /etc/bind/named.conf.local
|
ln -sf /private/argus/bind/named.conf.local /etc/bind/named.conf.local
|
||||||
ln -sf /private/argus/bind/db.argus.com /etc/bind/db.argus.com
|
ln -sf /private/argus/bind/db.argus.com /etc/bind/db.argus.com
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# 帮助信息
|
|
||||||
show_help() {
|
|
||||||
cat << EOF
|
|
||||||
ARGUS BIND9 DNS System - Image Build Tool
|
|
||||||
|
|
||||||
Usage: $0 [OPTIONS]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--intranet Use intranet mirror for Ubuntu 22.04 packages
|
|
||||||
-h, --help Show this help message
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$0 # Build with default sources
|
|
||||||
$0 --intranet # Build with intranet mirror
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# 解析命令行参数
|
|
||||||
use_intranet=false
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--intranet)
|
|
||||||
use_intranet=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
show_help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown option: $1"
|
|
||||||
show_help
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
||||||
cd "$root"
|
|
||||||
|
|
||||||
echo "======================================="
|
|
||||||
echo "ARGUS BIND9 DNS System - Image Build Tool"
|
|
||||||
echo "======================================="
|
|
||||||
|
|
||||||
if [[ "$use_intranet" == true ]]; then
|
|
||||||
echo "🌐 Mode: Intranet (Using internal mirror: 10.68.64.1)"
|
|
||||||
build_args="--build-arg USE_INTRANET=true"
|
|
||||||
else
|
|
||||||
echo "🌐 Mode: Public (Using default package sources)"
|
|
||||||
build_args=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# 构建 BIND9 镜像
|
|
||||||
echo "🔄 Building BIND9 DNS container image..."
|
|
||||||
echo "Image: argus-bind9:latest"
|
|
||||||
echo "Build directory: $root/build"
|
|
||||||
|
|
||||||
if [[ "$use_intranet" == true ]]; then
|
|
||||||
echo "Building with intranet mirror sources..."
|
|
||||||
else
|
|
||||||
echo "Building with default public apt sources..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if docker build $build_args -t argus-bind9:latest ./build; then
|
|
||||||
echo "✅ Build completed successfully!"
|
|
||||||
else
|
|
||||||
echo "❌ Failed to build BIND9 image"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "======================================="
|
|
||||||
echo "📦 Build Summary"
|
|
||||||
echo "======================================="
|
|
||||||
echo "✅ Successfully built image:"
|
|
||||||
echo " • argus-bind9:latest"
|
|
||||||
|
|
||||||
if [[ "$use_intranet" == true ]]; then
|
|
||||||
echo ""
|
|
||||||
echo "🌐 Built with intranet mirror configuration"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Image details:"
|
|
||||||
docker images argus-bind9:latest
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "🚀 Next steps:"
|
|
||||||
echo " ./scripts/save_images.sh # Export images"
|
|
||||||
echo " cd tests && ./scripts/00_e2e_test.sh # Run tests"
|
|
||||||
echo ""
|
|
@ -1,46 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Save BIND DNS container images to tar files
|
|
||||||
# Usage: ./save_images.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
||||||
IMAGES_DIR="$PROJECT_ROOT/images"
|
|
||||||
|
|
||||||
IMAGE_NAME="argus-bind9"
|
|
||||||
TAG="latest"
|
|
||||||
|
|
||||||
echo "Saving BIND9 DNS container images..."
|
|
||||||
|
|
||||||
# Create images directory if it doesn't exist
|
|
||||||
mkdir -p "$IMAGES_DIR"
|
|
||||||
|
|
||||||
# Check if image exists
|
|
||||||
if ! docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^$IMAGE_NAME:$TAG$"; then
|
|
||||||
echo "Error: Image $IMAGE_NAME:$TAG not found"
|
|
||||||
echo "Please build the image first using: ./build_images.sh"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save the image
|
|
||||||
echo "Saving $IMAGE_NAME:$TAG to $IMAGES_DIR/argus-bind9.tar..."
|
|
||||||
docker save "$IMAGE_NAME:$TAG" -o "$IMAGES_DIR/argus-bind9.tar"
|
|
||||||
|
|
||||||
# Compress the tar file to save space
|
|
||||||
echo "Compressing image archive..."
|
|
||||||
gzip -f "$IMAGES_DIR/argus-bind9.tar"
|
|
||||||
|
|
||||||
echo "Image saved successfully!"
|
|
||||||
echo "Location: $IMAGES_DIR/argus-bind9.tar.gz"
|
|
||||||
|
|
||||||
# Show file size
|
|
||||||
if [ -f "$IMAGES_DIR/argus-bind9.tar.gz" ]; then
|
|
||||||
echo "File size: $(du -h "$IMAGES_DIR/argus-bind9.tar.gz" | cut -f1)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "To load the image later, use:"
|
|
||||||
echo " gunzip $IMAGES_DIR/argus-bind9.tar.gz"
|
|
||||||
echo " docker load -i $IMAGES_DIR/argus-bind9.tar"
|
|
@ -36,14 +36,14 @@ RUN mkdir -p /var/log/supervisor
|
|||||||
|
|
||||||
|
|
||||||
# 复制 supervisor 配置文件
|
# 复制 supervisor 配置文件
|
||||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY src/log/elasticsearch/build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# 复制启动脚本
|
# 复制启动脚本
|
||||||
COPY start-es-supervised.sh /usr/local/bin/start-es-supervised.sh
|
COPY src/log/elasticsearch/build/start-es-supervised.sh /usr/local/bin/start-es-supervised.sh
|
||||||
RUN chmod +x /usr/local/bin/start-es-supervised.sh
|
RUN chmod +x /usr/local/bin/start-es-supervised.sh
|
||||||
|
|
||||||
# 复制DNS监控脚本
|
# 复制DNS监控脚本
|
||||||
COPY dns-monitor.sh /usr/local/bin/dns-monitor.sh
|
COPY src/log/elasticsearch/build/dns-monitor.sh /usr/local/bin/dns-monitor.sh
|
||||||
RUN chmod +x /usr/local/bin/dns-monitor.sh
|
RUN chmod +x /usr/local/bin/dns-monitor.sh
|
||||||
|
|
||||||
# 保持 root 用户,由 supervisor 管理用户切换
|
# 保持 root 用户,由 supervisor 管理用户切换
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# DNS监控脚本 - 每10秒检查dns.conf是否有变化
|
|
||||||
# 如果有变化则执行update-dns.sh脚本
|
|
||||||
|
|
||||||
DNS_CONF="/private/argus/etc/dns.conf"
|
|
||||||
DNS_BACKUP="/tmp/dns.conf.backup"
|
|
||||||
UPDATE_SCRIPT="/private/argus/etc/update-dns.sh"
|
|
||||||
LOG_FILE="/var/log/supervisor/dns-monitor.log"
|
|
||||||
|
|
||||||
# 确保日志文件存在
|
|
||||||
touch "$LOG_FILE"
|
|
||||||
|
|
||||||
log_message() {
|
|
||||||
echo "$(date '+%Y-%m-%d %H:%M:%S') [DNS-Monitor] $1" >> "$LOG_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
log_message "DNS监控脚本启动"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
if [ -f "$DNS_CONF" ]; then
|
|
||||||
if [ -f "$DNS_BACKUP" ]; then
|
|
||||||
# 比较文件内容
|
|
||||||
if ! cmp -s "$DNS_CONF" "$DNS_BACKUP"; then
|
|
||||||
log_message "检测到DNS配置变化"
|
|
||||||
|
|
||||||
# 更新备份文件
|
|
||||||
cp "$DNS_CONF" "$DNS_BACKUP"
|
|
||||||
|
|
||||||
# 执行更新脚本
|
|
||||||
if [ -x "$UPDATE_SCRIPT" ]; then
|
|
||||||
log_message "执行DNS更新脚本: $UPDATE_SCRIPT"
|
|
||||||
"$UPDATE_SCRIPT" >> "$LOG_FILE" 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
log_message "DNS更新脚本执行成功"
|
|
||||||
else
|
|
||||||
log_message "DNS更新脚本执行失败"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_message "警告: 更新脚本不存在或不可执行: $UPDATE_SCRIPT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# 第一次运行,创建备份并执行更新
|
|
||||||
cp "$DNS_CONF" "$DNS_BACKUP"
|
|
||||||
log_message "创建DNS配置备份文件"
|
|
||||||
|
|
||||||
# 第一次检测到配置文件,执行更新脚本
|
|
||||||
if [ -x "$UPDATE_SCRIPT" ]; then
|
|
||||||
log_message "执行DNS更新脚本: $UPDATE_SCRIPT"
|
|
||||||
"$UPDATE_SCRIPT" >> "$LOG_FILE" 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
log_message "DNS更新脚本执行成功"
|
|
||||||
else
|
|
||||||
log_message "DNS更新脚本执行失败"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_message "警告: 更新脚本不存在或不可执行: $UPDATE_SCRIPT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_message "警告: DNS配置文件不存在: $DNS_CONF"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 10
|
|
||||||
done
|
|
1
src/log/elasticsearch/build/dns-monitor.sh
Symbolic link
1
src/log/elasticsearch/build/dns-monitor.sh
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../bind/build/dns-monitor.sh
|
@ -36,15 +36,15 @@ RUN mkdir -p /var/log/supervisor
|
|||||||
|
|
||||||
|
|
||||||
# 复制 supervisor 配置文件
|
# 复制 supervisor 配置文件
|
||||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY src/log/kibana/build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# 复制启动脚本
|
# 复制启动脚本
|
||||||
COPY start-kibana-supervised.sh /usr/local/bin/start-kibana-supervised.sh
|
COPY src/log/kibana/build/start-kibana-supervised.sh /usr/local/bin/start-kibana-supervised.sh
|
||||||
COPY kibana-post-start.sh /usr/local/bin/kibana-post-start.sh
|
COPY src/log/kibana/build/kibana-post-start.sh /usr/local/bin/kibana-post-start.sh
|
||||||
RUN chmod +x /usr/local/bin/start-kibana-supervised.sh /usr/local/bin/kibana-post-start.sh
|
RUN chmod +x /usr/local/bin/start-kibana-supervised.sh /usr/local/bin/kibana-post-start.sh
|
||||||
|
|
||||||
# 复制DNS监控脚本
|
# 复制DNS监控脚本
|
||||||
COPY dns-monitor.sh /usr/local/bin/dns-monitor.sh
|
COPY src/log/kibana/build/dns-monitor.sh /usr/local/bin/dns-monitor.sh
|
||||||
RUN chmod +x /usr/local/bin/dns-monitor.sh
|
RUN chmod +x /usr/local/bin/dns-monitor.sh
|
||||||
|
|
||||||
# kibana需要用到 /root/.config/puppeteer 路径
|
# kibana需要用到 /root/.config/puppeteer 路径
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# DNS监控脚本 - 每10秒检查dns.conf是否有变化
|
|
||||||
# 如果有变化则执行update-dns.sh脚本
|
|
||||||
|
|
||||||
DNS_CONF="/private/argus/etc/dns.conf"
|
|
||||||
DNS_BACKUP="/tmp/dns.conf.backup"
|
|
||||||
UPDATE_SCRIPT="/private/argus/etc/update-dns.sh"
|
|
||||||
LOG_FILE="/var/log/supervisor/dns-monitor.log"
|
|
||||||
|
|
||||||
# 确保日志文件存在
|
|
||||||
touch "$LOG_FILE"
|
|
||||||
|
|
||||||
log_message() {
|
|
||||||
echo "$(date '+%Y-%m-%d %H:%M:%S') [DNS-Monitor] $1" >> "$LOG_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
log_message "DNS监控脚本启动"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
if [ -f "$DNS_CONF" ]; then
|
|
||||||
if [ -f "$DNS_BACKUP" ]; then
|
|
||||||
# 比较文件内容
|
|
||||||
if ! cmp -s "$DNS_CONF" "$DNS_BACKUP"; then
|
|
||||||
log_message "检测到DNS配置变化"
|
|
||||||
|
|
||||||
# 更新备份文件
|
|
||||||
cp "$DNS_CONF" "$DNS_BACKUP"
|
|
||||||
|
|
||||||
# 执行更新脚本
|
|
||||||
if [ -x "$UPDATE_SCRIPT" ]; then
|
|
||||||
log_message "执行DNS更新脚本: $UPDATE_SCRIPT"
|
|
||||||
"$UPDATE_SCRIPT" >> "$LOG_FILE" 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
log_message "DNS更新脚本执行成功"
|
|
||||||
else
|
|
||||||
log_message "DNS更新脚本执行失败"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_message "警告: 更新脚本不存在或不可执行: $UPDATE_SCRIPT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# 第一次运行,创建备份并执行更新
|
|
||||||
cp "$DNS_CONF" "$DNS_BACKUP"
|
|
||||||
log_message "创建DNS配置备份文件"
|
|
||||||
|
|
||||||
# 第一次检测到配置文件,执行更新脚本
|
|
||||||
if [ -x "$UPDATE_SCRIPT" ]; then
|
|
||||||
log_message "执行DNS更新脚本: $UPDATE_SCRIPT"
|
|
||||||
"$UPDATE_SCRIPT" >> "$LOG_FILE" 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
log_message "DNS更新脚本执行成功"
|
|
||||||
else
|
|
||||||
log_message "DNS更新脚本执行失败"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_message "警告: 更新脚本不存在或不可执行: $UPDATE_SCRIPT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_message "警告: DNS配置文件不存在: $DNS_CONF"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 10
|
|
||||||
done
|
|
1
src/log/kibana/build/dns-monitor.sh
Symbolic link
1
src/log/kibana/build/dns-monitor.sh
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../bind/build/dns-monitor.sh
|
@ -1,98 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# 帮助信息
|
|
||||||
show_help() {
|
|
||||||
cat << EOF
|
|
||||||
ARGUS Log System - Image Build Tool
|
|
||||||
|
|
||||||
Usage: $0 [OPTIONS]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--intranet Use intranet mirror for Ubuntu 22.04 packages
|
|
||||||
-h, --help Show this help message
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$0 # Build with default sources
|
|
||||||
$0 --intranet # Build with intranet mirror
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# 解析命令行参数
|
|
||||||
use_intranet=false
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--intranet)
|
|
||||||
use_intranet=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
show_help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown option: $1"
|
|
||||||
show_help
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
||||||
cd "$root"
|
|
||||||
|
|
||||||
echo "======================================="
|
|
||||||
echo "ARGUS Log System - Image Build Tool"
|
|
||||||
echo "======================================="
|
|
||||||
|
|
||||||
if [[ "$use_intranet" == true ]]; then
|
|
||||||
echo "🌐 Mode: Intranet (Using internal mirror: 10.68.64.1)"
|
|
||||||
build_args="--build-arg USE_INTRANET=true"
|
|
||||||
else
|
|
||||||
echo "🌐 Mode: Public (Using default package sources)"
|
|
||||||
build_args=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# 构建 Elasticsearch 镜像
|
|
||||||
echo "🔄 Building Elasticsearch image..."
|
|
||||||
if docker build $build_args -t argus-elasticsearch:latest ./elasticsearch/build; then
|
|
||||||
echo "✅ Elasticsearch image built successfully"
|
|
||||||
else
|
|
||||||
echo "❌ Failed to build Elasticsearch image"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# 构建 Kibana 镜像
|
|
||||||
echo "🔄 Building Kibana image..."
|
|
||||||
if docker build $build_args -t argus-kibana:latest ./kibana/build; then
|
|
||||||
echo "✅ Kibana image built successfully"
|
|
||||||
else
|
|
||||||
echo "❌ Failed to build Kibana image"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "======================================="
|
|
||||||
echo "📦 Build Summary"
|
|
||||||
echo "======================================="
|
|
||||||
echo "✅ Successfully built images:"
|
|
||||||
echo " • argus-elasticsearch:latest"
|
|
||||||
echo " • argus-kibana:latest"
|
|
||||||
|
|
||||||
if [[ "$use_intranet" == true ]]; then
|
|
||||||
echo ""
|
|
||||||
echo "🌐 Built with intranet mirror configuration"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "🚀 Next steps:"
|
|
||||||
echo " ./scripts/save_images.sh # Export images"
|
|
||||||
echo " ./scripts/02_up.sh # Start services"
|
|
||||||
echo ""
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
echo "======================================="
|
|
||||||
echo "ARGUS Log System - Image Import Tool"
|
|
||||||
echo "======================================="
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# 获取脚本所在目录和镜像目录
|
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
images_dir="$script_dir/../images"
|
|
||||||
|
|
||||||
# 定义镜像文件名
|
|
||||||
ES_TAR="argus-elasticsearch-latest.tar"
|
|
||||||
KIBANA_TAR="argus-kibana-latest.tar"
|
|
||||||
|
|
||||||
# 函数:检查文件是否存在
|
|
||||||
check_file() {
|
|
||||||
local file_path="$1"
|
|
||||||
local file_name="$2"
|
|
||||||
if [[ -f "$file_path" ]]; then
|
|
||||||
local size=$(du -h "$file_path" | cut -f1)
|
|
||||||
echo "✅ Found: $file_name ($size)"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "❌ Missing: $file_name"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# 函数:加载镜像
|
|
||||||
load_image() {
|
|
||||||
local file_path="$1"
|
|
||||||
local file_name="$2"
|
|
||||||
|
|
||||||
echo "🔄 Loading $file_name..."
|
|
||||||
|
|
||||||
if docker load -i "$file_path"; then
|
|
||||||
echo "✅ Successfully loaded: $file_name"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "❌ Failed to load: $file_name"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "🔍 Checking for ARGUS image files in $images_dir..."
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# 检查镜像文件是否存在
|
|
||||||
es_file="$images_dir/$ES_TAR"
|
|
||||||
kibana_file="$images_dir/$KIBANA_TAR"
|
|
||||||
|
|
||||||
es_exists=false
|
|
||||||
kibana_exists=false
|
|
||||||
|
|
||||||
if check_file "$es_file" "$ES_TAR"; then
|
|
||||||
es_exists=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if check_file "$kibana_file" "$KIBANA_TAR"; then
|
|
||||||
kibana_exists=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# 如果没有任何文件存在,退出
|
|
||||||
if [[ "$es_exists" == false && "$kibana_exists" == false ]]; then
|
|
||||||
echo "❌ No ARGUS image files found in $images_dir"
|
|
||||||
echo " Please run './scripts/save_images.sh' first to export images"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "💾 Starting image import process..."
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
loaded_count=0
|
|
||||||
failed_count=0
|
|
||||||
|
|
||||||
# 加载 Elasticsearch 镜像
|
|
||||||
if [[ "$es_exists" == true ]]; then
|
|
||||||
if load_image "$es_file" "$ES_TAR"; then
|
|
||||||
((loaded_count++))
|
|
||||||
else
|
|
||||||
((failed_count++))
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 加载 Kibana 镜像
|
|
||||||
if [[ "$kibana_exists" == true ]]; then
|
|
||||||
if load_image "$kibana_file" "$KIBANA_TAR"; then
|
|
||||||
((loaded_count++))
|
|
||||||
else
|
|
||||||
((failed_count++))
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "======================================="
|
|
||||||
echo "📦 Import Summary"
|
|
||||||
echo "======================================="
|
|
||||||
echo "✅ Successfully loaded: $loaded_count images"
|
|
||||||
|
|
||||||
if [[ $failed_count -gt 0 ]]; then
|
|
||||||
echo "❌ Failed to load: $failed_count images"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "🔍 Verifying loaded images:"
|
|
||||||
docker images | grep "argus-" || echo " No ARGUS images found"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
if [[ $failed_count -eq 0 ]]; then
|
|
||||||
echo "✅ All images imported successfully!"
|
|
||||||
echo ""
|
|
||||||
echo "🚀 Next steps:"
|
|
||||||
echo " You can now use the imported images with:"
|
|
||||||
echo " ./scripts/02_up.sh # Start services"
|
|
||||||
echo " ./scripts/00_e2e_test.sh # Run end-to-end test"
|
|
||||||
else
|
|
||||||
echo "⚠️ Some images failed to import. Please check the error messages above."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
@ -1,140 +0,0 @@
|
|||||||
#!/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 "{{.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 ""
|
|
@ -8,8 +8,6 @@ mkdir -p "$root/private/argus/log/elasticsearch"
|
|||||||
mkdir -p "$root/private/argus/log/kibana"
|
mkdir -p "$root/private/argus/log/kibana"
|
||||||
mkdir -p "$root/private/argus/etc/"
|
mkdir -p "$root/private/argus/etc/"
|
||||||
|
|
||||||
# 复制更新dns脚本
|
|
||||||
cp $root/scripts/update-dns.sh $root/private/argus/etc/
|
|
||||||
|
|
||||||
# 设置数据目录权限(ES 和 Kibana 容器都使用 UID 1000)
|
# 设置数据目录权限(ES 和 Kibana 容器都使用 UID 1000)
|
||||||
echo "[INFO] Setting permissions for data directories..."
|
echo "[INFO] Setting permissions for data directories..."
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# update-dns.sh
|
|
||||||
# 从 /private/argus/etc/dns.conf 读取 IP,写入 /etc/resolv.conf
|
|
||||||
|
|
||||||
DNS_CONF="/private/argus/etc/dns.conf"
|
|
||||||
RESOLV_CONF="/etc/resolv.conf"
|
|
||||||
|
|
||||||
# 检查配置文件是否存在
|
|
||||||
if [ ! -f "$DNS_CONF" ]; then
|
|
||||||
echo "配置文件不存在: $DNS_CONF" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 生成 resolv.conf 内容
|
|
||||||
{
|
|
||||||
while IFS= read -r ip; do
|
|
||||||
# 跳过空行和注释
|
|
||||||
case "$ip" in
|
|
||||||
\#*) continue ;;
|
|
||||||
"") continue ;;
|
|
||||||
esac
|
|
||||||
echo "nameserver $ip"
|
|
||||||
done < "$DNS_CONF"
|
|
||||||
} > "$RESOLV_CONF".tmp
|
|
||||||
|
|
||||||
# 替换写入 /etc/resolv.conf
|
|
||||||
cat "$RESOLV_CONF".tmp > "$RESOLV_CONF"
|
|
||||||
rm -f "$RESOLV_CONF".tmp
|
|
||||||
|
|
||||||
echo "已更新 $RESOLV_CONF"
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user