Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify quick install script #1523

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions script/install-rainbond.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,12 @@ function check_docker {
Write-ColoredText "Ops! Docker daemon is not running. Start docker first please.`n`t- For Windows, start the Docker Desktop for Windwos.`n`t- And re-exec this script." red
Exit
}
if (docker ps -a | Select-String "rainbond-allinone") {
Write-ColoredText "Ops! rainbond-allinone container already exists.`n`t- Ensure if rainbond-allinone is running.`n`t- Try to exec 'docker start rainbond-allinone' to start it.`n`t- Or you can remove it by 'docker rm -f rainbond-allinone'" red
if (docker ps -a | Select-String "rainbond") {
Write-ColoredText "Ops! rainbond container already exists.`n`t- Ensure if rainbond is running.`n`t- Try to exec 'docker start rainbond' to start it.`n`t- Or you can remove it by 'docker rm -f rainbond'" red
Exit
}
}

function check_ports {
$ports = @(80, 443, 6060, 7070)
foreach ($port in $ports) {
if (netstat -ano | Select-String -Pattern "LISTENING" | Select-String -Pattern ":$port\s") {
Write-ColoredText "Port $port is already in use" red
Exit
}
}
}

function MD5 {
$systemInfo = Get-CimInstance Win32_OperatingSystem | Select-Object Caption, OSArchitecture, Manufacturer, SerialNumber
$infoString = $systemInfo | ForEach-Object { $_.Caption + $_.OSArchitecture + $_.Manufacturer + $_.SerialNumber } | Out-String
Expand Down Expand Up @@ -152,7 +142,7 @@ function start_rainbond {
Write-Host "Generating the installation command:" -ForegroundColor green

$RBD_IMAGE = "$IMAGE_MIRROR/rainbond:$($RAINBOND_VERSION)-k3s"
$docker_run_cmd = "docker run --privileged -d --name=rainbond-allinone --restart=on-failure -p 7070:7070 -p 80:80 -p 443:443 -p 6060:6060 -v rainbond-opt:/opt/rainbond -e EIP=$EIP -e uuid=$UUID $RBD_IMAGE"
$docker_run_cmd = "docker run --privileged -d --name=rainbond --restart=always -p 7070:7070 -p 80:80 -p 443:443 -p 6060:6060 -p 30000-30010:30000-30010 -v rainbond-opt:/opt/rainbond -e EIP=$EIP -e uuid=$UUID $RBD_IMAGE"
Write-Host $docker_run_cmd
send_msg $docker_run_cmd

Expand All @@ -164,20 +154,17 @@ function start_rainbond {

$container_id = Invoke-Expression $docker_run_cmd
if ($container_id) {
Write-ColoredText "Rainbond container startup succeeded with $container_id. Please observe rainbond-allinone container startup logs." green
Write-ColoredText "Rainbond container startup succeeded, Execute the 'docker logs -f rainbond' command to view startup logs." green
} else {
Write-ColoredText "Ops! Rainbond container startup failed. please observe rainbond-allinone container startup logs." red
Write-ColoredText "Ops! Rainbond container startup failed, Execute the 'docker logs -f rainbond' command to view startup logs." red
Exit
}
docker logs -f rainbond-allinone
}

MD5

check_docker

check_ports

select_eip

start_rainbond
32 changes: 9 additions & 23 deletions script/install-rainbond.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ trap send_msg SIGINT
OS_TYPE=$(uname -s)
if [ "${OS_TYPE}" == "Linux" ]; then
MD5_CMD="md5sum"
if find /lib/modules/$(uname -r) -type f -name '*.ko*' | grep iptable_raw; then
if ! lsmod | grep iptable_raw; then
echo iptable_raw >/etc/modules-load.d/iptable_raw.conf
modprobe iptable_raw
fi
fi
elif [ "${OS_TYPE}" == "Darwin" ]; then
MD5_CMD="md5"
else
Expand Down Expand Up @@ -126,12 +120,12 @@ if ! (docker info &>/dev/null); then
fi
fi
else
if docker ps -a | grep rainbond-allinone 2>&1 >/dev/null; then
if docker ps -a | grep rainbond 2>&1 >/dev/null; then
if [ "$LANG" == "zh_CN.UTF-8" ]; then
send_error "rainbond-allinone 容器已存在.\n\t- 确保 rainbond-allinone 是否在运行.\n\t- 尝试执行 'docker start rainbond-allinone' 命令启动.\n\t- 或者你可以选择删除该容器 'docker rm -f rainbond-allinone'"
send_error "rainbond 容器已存在.\n\t- 确保 rainbond 是否在运行.\n\t- 尝试执行 'docker start rainbond' 命令启动.\n\t- 或者你可以选择删除该容器 'docker rm -f rainbond'"
exit 1
else
send_error "Ops! rainbond-allinone container already exists.\n\t- Ensure if rainbond-allinone is running.\n\t- Try to exec 'docker start rainbond-allinone' to start it.\n\t- Or you can remove it by 'docker rm -f rainbond-allinone'"
send_error "Ops! rainbond container already exists.\n\t- Ensure if rainbond is running.\n\t- Try to exec 'docker start rainbond' to start it.\n\t- Or you can remove it by 'docker rm -f rainbond'"
exit 1
fi
fi
Expand Down Expand Up @@ -384,7 +378,7 @@ elif [ "$OS_TYPE" = "Darwin" ]; then
fi

# Generate cmd
docker_run_cmd="docker run --privileged -d -p 7070:7070 -p 80:80 -p 443:443 -p 6060:6060 --name=rainbond-allinone --restart=always \
docker_run_cmd="docker run --privileged -d -p 7070:7070 -p 80:80 -p 443:443 -p 6060:6060 -p 30000-30010:30000-30010 --name=rainbond --restart=always \
${VOLUME_OPTS} -e EIP=$EIP -e UUID=${UUID} ${RBD_IMAGE}"
send_info "$docker_run_cmd"

Expand All @@ -410,29 +404,21 @@ else
fi
sleep 3

# Run container
if [ "$LANG" == "zh_CN.UTF-8" ]; then
send_info "Rainbond 正在安装中...\n"
else
send_info "Rainbond distribution is installing...\n"
fi
docker_run_meg=$(bash -c "$docker_run_cmd" 2>&1)
send_info "$docker_run_meg"
sleep 3

# Verify startup
container_id=$(docker ps -a | grep rainbond-allinone | awk '{print $1}')
if docker ps | grep rainbond-allinone 2>&1 >/dev/null; then
if docker ps | grep rainbond 2>&1 >/dev/null; then
if [ "$LANG" == "zh_CN.UTF-8" ]; then
send_info "Rainbond 启动成功,容器 ID 为: $container_id. 请观察 rainbond-allinone 容器启动日志.\n"
send_info "Rainbond 启动成功, 执行 'docker logs -f rainbond' 查看启动日志."
else
send_info "Rainbond container startup succeeded with $container_id. Please observe rainbond-allinone container startup logs.\n"
send_info "Rainbond container startup succeeded, Execute the 'docker logs -f rainbond' command to view startup logs."
fi
else
if [ "$LANG" == "zh_CN.UTF-8" ]; then
send_warn "Rainbond 容器启动失败. 请查看 rainbond-allinone 容器启动日志.\n"
send_warn "Rainbond 容器启动失败, 执行 'docker logs -f rainbond' 命令查看启动日志."
else
send_warn "Ops! Rainbond container startup failed. please observe rainbond-allinone container startup logs.\n"
send_warn "Ops! Rainbond container startup failed, Execute the 'docker logs -f rainbond' command to view startup logs."
fi
send_msg "$(docker logs rainbond-allinone)" # Msg maybe too lang
fi
Loading
Loading