Fix deploy.sh CRLF line endings for Linux compatibility

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-27 10:59:59 +08:00
parent 65f5caf4d9
commit b9ee546bc1
20 changed files with 2142 additions and 2118 deletions
+10
View File
@@ -0,0 +1,10 @@
* text=auto
*.sh text eol=lf
Dockerfile text eol=lf
*.yml text eol=lf
*.py text eol=lf
*.md text eol=lf
*.html text eol=lf
*.js text eol=lf
*.css text eol=lf
.env.example text eol=lf
+16 -1
View File
@@ -174,7 +174,22 @@ firewall-cmd --reload
## 八、常见问题
### 部署脚本提示非 root 用户
### 部署脚本报错 `set: pipefail: invalid option`
脚本在 Windows 编辑后可能带 CRLF 换行符,在 Linux 上会报错。修复:
```bash
sed -i 's/\r$//' /opt/cloud-browser/deploy.sh
bash /opt/cloud-browser/deploy.sh
```
或重新拉取最新代码:
```bash
cd /opt/cloud-browser && git pull && bash deploy.sh
```
---
```bash
sudo su -
+9 -10
View File
@@ -6,7 +6,7 @@
# 默认端口: 32450
# 默认账号: admin / admin
#
set -euo pipefail
set -eu
INSTALL_DIR="/opt/cloud-browser"
REPO_URL="https://git.bz121.com/dekun/cloud-browser.git"
@@ -21,13 +21,13 @@ log() { echo -e "${GREEN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
if [[ "$(id -u)" -ne 0 ]]; then
if [ "$(id -u)" -ne 0 ]; then
err "请使用 root 用户运行此脚本"
exit 1
fi
install_docker() {
if command -v docker &>/dev/null; then
if command -v docker >/dev/null 2>&1; then
log "Docker 已安装: $(docker --version)"
return
fi
@@ -39,7 +39,7 @@ install_docker() {
}
install_compose() {
if docker compose version &>/dev/null; then
if docker compose version >/dev/null 2>&1; then
log "Docker Compose 已就绪"
return
fi
@@ -48,7 +48,7 @@ install_compose() {
}
clone_or_update() {
if [[ -d "${INSTALL_DIR}/.git" ]]; then
if [ -d "${INSTALL_DIR}/.git" ]; then
log "更新代码: ${INSTALL_DIR}"
git -C "${INSTALL_DIR}" pull --rebase
else
@@ -60,7 +60,7 @@ clone_or_update() {
setup_env() {
cd "${INSTALL_DIR}"
if [[ ! -f .env ]]; then
if [ ! -f .env ]; then
cp .env.example .env
log "已创建 .env 配置文件"
fi
@@ -75,10 +75,10 @@ start_service() {
}
wait_health() {
local retries=30
retries=30
log "等待服务启动..."
while [[ $retries -gt 0 ]]; do
if curl -sf "http://127.0.0.1:${APP_PORT}/api/health" &>/dev/null; then
while [ "$retries" -gt 0 ]; do
if curl -sf "http://127.0.0.1:${APP_PORT}/api/health" >/dev/null 2>&1; then
log "服务已就绪"
return 0
fi
@@ -90,7 +90,6 @@ wait_health() {
}
print_summary() {
local ip
ip=$(curl -s --max-time 3 ifconfig.me 2>/dev/null || hostname -I 2>/dev/null | awk '{print $1}' || echo "YOUR_SERVER_IP")
echo ""
echo "=========================================="