QAUP_Management/deploy/fix-paths.sh

30 lines
1.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# 修复所有脚本中的路径问题
echo "修复脚本路径问题..."
# 修复docker目录下的脚本除了postgres子目录和prepare-offline-images.sh
for script in docker/*.sh; do
if [ -f "$script" ] && [ "$script" != "docker/prepare-offline-images.sh" ]; then
echo "修复: $script"
# 先检查是否还有BASH_SOURCE
if grep -q 'BASH_SOURCE\[0\]' "$script"; then
sed -i.bak 's|\${BASH_SOURCE\[0\]}|$0|g' "$script"
fi
# 修复PROJECT_ROOT路径
sed -i.bak 's|PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"|PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"|g' "$script"
fi
done
# 修复test-paths.sh
if [ -f "test-paths.sh" ]; then
echo "修复: test-paths.sh"
if grep -q 'BASH_SOURCE\[0\]' "test-paths.sh"; then
sed -i.bak 's|\${BASH_SOURCE\[0\]}|$0|g' "test-paths.sh"
fi
sed -i.bak 's|PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"|PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"|g' "test-paths.sh"
fi
echo "路径修复完成!"
echo "备份文件已保存为 .bak 后缀"