修改了离线部署脚本,增加了部署验证脚本
This commit is contained in:
parent
5479261cd8
commit
02e6dac4d6
@ -49,21 +49,55 @@ cd "${PACKAGES_DIR}" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Download system dependencies
|
||||
log_info "Downloading system packages..."
|
||||
yum install --downloadonly --downloaddir=. \
|
||||
cmake3 \
|
||||
git \
|
||||
nlohmann-json-devel \
|
||||
boost-devel \
|
||||
openssl-devel \
|
||||
python3 \
|
||||
python3-pip \
|
||||
"Development Tools" || {
|
||||
log_error "Failed to download system packages"
|
||||
exit 1
|
||||
# Function to get package dependencies
|
||||
get_dependencies() {
|
||||
local pkg=$1
|
||||
yum deplist "$pkg" | grep provider: | awk '{print $2}' | sort -u
|
||||
}
|
||||
|
||||
# Download system dependencies
|
||||
log_info "Downloading system packages and their dependencies..."
|
||||
|
||||
# Define base packages
|
||||
PACKAGES=(
|
||||
"cmake3"
|
||||
"nlohmann-json-devel"
|
||||
"boost-devel"
|
||||
"openssl-devel"
|
||||
"python3"
|
||||
"python3-pip"
|
||||
"@Development Tools"
|
||||
)
|
||||
|
||||
# Create a temporary file for all packages including dependencies
|
||||
TEMP_PKGS=$(mktemp)
|
||||
|
||||
# Get all dependencies
|
||||
for pkg in "${PACKAGES[@]}"; do
|
||||
log_info "Checking dependencies for $pkg..."
|
||||
if [[ "$pkg" == @* ]]; then
|
||||
# Handle package groups
|
||||
yum groupinfo "${pkg#@}" | grep "Mandatory Packages:" -A 100 | grep "^[[:space:]]*[^[:space:]]*" >> "$TEMP_PKGS"
|
||||
else
|
||||
echo "$pkg" >> "$TEMP_PKGS"
|
||||
get_dependencies "$pkg" >> "$TEMP_PKGS"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove duplicates and sort
|
||||
sort -u "$TEMP_PKGS" -o "$TEMP_PKGS"
|
||||
|
||||
# Download all packages
|
||||
log_info "Downloading packages..."
|
||||
while read -r pkg; do
|
||||
log_info "Downloading $pkg..."
|
||||
yum install --downloadonly --downloaddir=. "$pkg" || {
|
||||
log_warn "Failed to download $pkg, continuing..."
|
||||
}
|
||||
done < "$TEMP_PKGS"
|
||||
|
||||
rm "$TEMP_PKGS"
|
||||
|
||||
# Create Python requirements file
|
||||
log_info "Creating Python requirements file..."
|
||||
cat > requirements.txt << EOL
|
||||
@ -93,6 +127,14 @@ ls *.rpm > offline-deps.txt || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Sort package list to handle dependencies
|
||||
log_info "Sorting package list for dependency order..."
|
||||
# Move boost packages to the beginning of the list
|
||||
grep "boost-.*\.rpm" offline-deps.txt > boost-deps.txt
|
||||
grep -v "boost-.*\.rpm" offline-deps.txt > other-deps.txt
|
||||
cat boost-deps.txt other-deps.txt > offline-deps.txt
|
||||
rm boost-deps.txt other-deps.txt
|
||||
|
||||
# Return to project root directory
|
||||
cd "${PROJECT_ROOT}" || {
|
||||
log_error "Failed to return to project root directory"
|
||||
|
||||
84
scripts/verify_offline_packages.sh
Normal file
84
scripts/verify_offline_packages.sh
Normal file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Color definitions for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Get script directory and project root
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
PROJECT_NAME="$(basename "${PROJECT_ROOT}")"
|
||||
|
||||
# Check if the archive exists
|
||||
ARCHIVE_PATH="${PROJECT_ROOT}/../${PROJECT_NAME}.tar.gz"
|
||||
if [ ! -f "${ARCHIVE_PATH}" ]; then
|
||||
log_error "Archive file not found: ${ARCHIVE_PATH}"
|
||||
log_error "Please run prepare_offline_packages.sh first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a temporary test directory
|
||||
TEST_DIR=$(mktemp -d)
|
||||
log_info "Creating test directory: ${TEST_DIR}"
|
||||
|
||||
# Copy archive to test directory
|
||||
cp "${ARCHIVE_PATH}" "${TEST_DIR}/"
|
||||
|
||||
# Print verification steps
|
||||
echo -e "\n${GREEN}Verification Steps:${NC}"
|
||||
echo "1. Prepare a clean CentOS 7 system (physical machine or VM)"
|
||||
echo "2. Copy these files to the test system:"
|
||||
echo " - ${ARCHIVE_PATH}"
|
||||
echo ""
|
||||
echo "3. On the test system, run:"
|
||||
echo " cd /tmp"
|
||||
echo " tar xzf ${PROJECT_NAME}.tar.gz"
|
||||
echo " cd ${PROJECT_NAME}"
|
||||
echo " sudo ./scripts/deploy.sh"
|
||||
echo ""
|
||||
echo "4. Verify the installation:"
|
||||
echo " - Check if all packages are installed:"
|
||||
echo " rpm -qa | grep -E 'boost|cmake3|python3'"
|
||||
echo ""
|
||||
echo " - Check Python packages:"
|
||||
echo " pip3 list | grep -E 'flask|werkzeug|click|itsdangerous|Jinja2|MarkupSafe'"
|
||||
echo ""
|
||||
echo " - Check if service is running:"
|
||||
echo " systemctl status collision-avoidance"
|
||||
echo ""
|
||||
echo " - Check service logs:"
|
||||
echo " journalctl -u collision-avoidance"
|
||||
echo ""
|
||||
echo " - Check ports:"
|
||||
echo " ss -tunlp | grep -E '8010|8081'"
|
||||
echo ""
|
||||
echo "5. Test the service:"
|
||||
echo " - Open http://localhost:8010 in browser"
|
||||
echo " - Check if mock server is running on port 8081"
|
||||
echo ""
|
||||
echo "If any step fails, please check:"
|
||||
echo "1. /var/log/messages for system errors"
|
||||
echo "2. journalctl -u collision-avoidance for service errors"
|
||||
echo "3. Check if all required ports are available"
|
||||
echo "4. Verify system requirements (memory, disk space)"
|
||||
echo ""
|
||||
log_info "Verification guide has been created"
|
||||
echo -e "Follow the steps above to verify the installation in a clean environment"
|
||||
|
||||
# Clean up
|
||||
rm -rf "${TEST_DIR}"
|
||||
Loading…
Reference in New Issue
Block a user