From 07370c937936934ae431e599b4d2b501f4cc7f95 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Sat, 15 Jun 2024 15:37:23 +0800 Subject: [PATCH 1/3] dev --- install/install_docker.sh | 124 +++++++++++++++++++++++++++----------- 1 file changed, 88 insertions(+), 36 deletions(-) diff --git a/install/install_docker.sh b/install/install_docker.sh index f103c457..0511bd39 100644 --- a/install/install_docker.sh +++ b/install/install_docker.sh @@ -60,47 +60,99 @@ Install_Docker(){ if [ "$mirror" = "Official" ]; then mirror="" fi + + curl -fsSL --max-time 5 https://get.docker.com -o /dev/null - # For redhat family - if [[ -f /etc/redhat-release ]] || command -v amazon-linux-extras >/dev/null 2>&1; then - # For CentOS, Fedora, or RHEL(only s390x) - if [[ $(cat /etc/redhat-release) =~ "Red Hat" ]] && [[ $(uname -m) == "s390x" ]] || [[ $(cat /etc/redhat-release) =~ "CentOS" ]] || [[ $(cat /etc/redhat-release) =~ "Fedora" ]]; then + if [ $? -eq 0 ]; then + # For redhat family + if [[ -f /etc/redhat-release ]] || command -v amazon-linux-extras >/dev/null 2>&1; then + # For CentOS, Fedora, or RHEL(only s390x) + if [[ $(cat /etc/redhat-release) =~ "Red Hat" ]] && [[ $(uname -m) == "s390x" ]] || [[ $(cat /etc/redhat-release) =~ "CentOS" ]] || [[ $(cat /etc/redhat-release) =~ "Fedora" ]]; then + curl -fsSL https://get.docker.com -o get-docker.sh + timeout $timeout sh get-docker.sh --channel stable --mirror $mirror + else + # For other distributions(Redhat and Rocky linux ...) + dnf --version >/dev/null 2>&1 + dnf_status=$? + yum --version >/dev/null 2>&1 + yum_status=$? + + if [ $dnf_status -eq 0 ]; then + sudo dnf install dnf-utils -y > /dev/null + sudo dnf config-manager --add-repo $repo_url + timeout $timeout sudo dnf install $docker_packages -y + elif [ $yum_status -eq 0 ]; then + sudo yum install yum-utils -y > /dev/null + sudo yum-config-manager --add-repo $repo_url + if command -v amazon-linux-extras >/dev/null 2>&1; then + wget -O /etc/yum.repos.d/CentOS7-Base.repo https://websoft9.github.io/stackhub/apps/roles/role_common/files/CentOS7-Base.repo + sudo sed -i "s/\$releasever/7/g" /etc/yum.repos.d/docker-ce.repo + timeout $timeout sudo yum install $docker_packages --disablerepo='amzn2-extras,amzn2-core' -y + else + timeout $timeout sudo yum install $docker_packages -y + fi + + else + echo "None of the required package managers are installed." + fi + fi + fi + + # For Ubuntu, Debian, or Raspbian + if type apt >/dev/null 2>&1; then + # Wait for apt to be unlocked curl -fsSL https://get.docker.com -o get-docker.sh timeout $timeout sh get-docker.sh --channel stable --mirror $mirror - else - # For other distributions(Redhat and Rocky linux ...) - dnf --version >/dev/null 2>&1 - dnf_status=$? - yum --version >/dev/null 2>&1 - yum_status=$? - - if [ $dnf_status -eq 0 ]; then - sudo dnf install dnf-utils -y > /dev/null - sudo dnf config-manager --add-repo $repo_url - timeout $timeout sudo dnf install $docker_packages -y - elif [ $yum_status -eq 0 ]; then - sudo yum install yum-utils -y > /dev/null - sudo yum-config-manager --add-repo $repo_url - if command -v amazon-linux-extras >/dev/null 2>&1; then - wget -O /etc/yum.repos.d/CentOS7-Base.repo https://websoft9.github.io/stackhub/apps/roles/role_common/files/CentOS7-Base.repo - sudo sed -i "s/\$releasever/7/g" /etc/yum.repos.d/docker-ce.repo - timeout $timeout sudo yum install $docker_packages --disablerepo='amzn2-extras,amzn2-core' -y - else - timeout $timeout sudo yum install $docker_packages -y - fi - - else - echo "None of the required package managers are installed." - fi fi + else + echo "can not install by installation script, use special way to install docker" + dnf --version >/dev/null 2>&1 + dnf_status=$? + yum --version >/dev/null 2>&1 + yum_status=$? + apt --version >/dev/null 2>&1 + apt_status=$? + + if [ $dnf_status -eq 0 ]; then + sudo dnf install yum-utils -y + sudo dnf config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo + sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + elif [ $yum_status -eq 0 ]; then + sudo yum install yum-utils -y + sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo + sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + elif [ $apt_status -eq 0 ]; then + sudo apt-get update + sudo apt-get install -y ca-certificates curl gnupg lsb-release + curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + else + echo "don't know package tool" + fi + + sudo systemctl enable docker + sudo systemctl restart docker + + DOCKER_CONFIG_FILE="/etc/docker/daemon.json" + MIRROR_ADDRESS="http://119.8.39.15:5000" + + if [ ! -f "$DOCKER_CONFIG_FILE" ]; then + echo "{}" > "$DOCKER_CONFIG_FILE" + fi + + if command -v jq >/dev/null 2>&1; then + jq ".\"registry-mirrors\" = [\"$MIRROR_ADDRESS\"]" "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE" + else + echo "jq not installed!" + exit 1 + fi + + sudo systemctl daemon-reload + sudo systemctl restart docker fi - - # For Ubuntu, Debian, or Raspbian - if type apt >/dev/null 2>&1; then - # Wait for apt to be unlocked - curl -fsSL https://get.docker.com -o get-docker.sh - timeout $timeout sh get-docker.sh --channel stable --mirror $mirror - fi + } Upgrade_Docker(){ From 7f7e89b2dfee240923d6674708f1e6c8aa7d3ccc Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Wed, 19 Jun 2024 16:53:34 +0800 Subject: [PATCH 2/3] install websoft9 on china --- install/install.sh | 26 +++++++++++++++++++++++++- install/install_docker.sh | 16 ---------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/install/install.sh b/install/install.sh index af8ec753..c11737fc 100644 --- a/install/install.sh +++ b/install/install.sh @@ -428,20 +428,44 @@ install_backends() { echo "No containers to delete." fi + DOCKER_CONFIG_FILE="/etc/docker/daemon.json" + MIRROR_ADDRESS="https://dockerregistry.test2.websoft9.cn" sudo docker compose -f $composefile pull + if [ $? -eq 0 ]; then + echo "Docker Compose pull succeeded" + else + + if [ ! -f "$DOCKER_CONFIG_FILE" ]; then + echo "{}" > "$DOCKER_CONFIG_FILE" + fi + + if command -v jq >/dev/null 2>&1; then + jq ".\"registry-mirrors\" = [\"$MIRROR_ADDRESS\"]" "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE" + else + echo "jq not installed!" + exit 1 + fi + + sudo systemctl daemon-reload + sudo systemctl restart docker + fi sudo docker compose -p websoft9 -f $composefile up -d --build if [ $? -ne 0 ]; then echo "Failed to start docker services." exit 1 fi + if jq -e 'has("registry-mirrors")' "$DOCKER_CONFIG_FILE" > /dev/null; then + jq 'del(.["registry-mirrors"])' "$DOCKER_CONFIG_FILE" > "${DOCKER_CONFIG_FILE}.tmp" && mv "${DOCKER_CONFIG_FILE}.tmp" "$DOCKER_CONFIG_FILE" + systemctl restart docker + fi + if [ "$execute_mode" = "install" ]; then sudo docker exec -i websoft9-apphub apphub setconfig --section domain --key wildcard_domain --value "" sudo docker exec -i websoft9-apphub apphub setconfig --section initial_apps --key keys --value $apps fi } - install_systemd() { echo -e "\n\n-------- Systemd --------" echo_prefix_systemd=$'\n[Systemd] - ' diff --git a/install/install_docker.sh b/install/install_docker.sh index 0511bd39..24e30041 100644 --- a/install/install_docker.sh +++ b/install/install_docker.sh @@ -134,23 +134,7 @@ Install_Docker(){ sudo systemctl enable docker sudo systemctl restart docker - - DOCKER_CONFIG_FILE="/etc/docker/daemon.json" - MIRROR_ADDRESS="http://119.8.39.15:5000" - if [ ! -f "$DOCKER_CONFIG_FILE" ]; then - echo "{}" > "$DOCKER_CONFIG_FILE" - fi - - if command -v jq >/dev/null 2>&1; then - jq ".\"registry-mirrors\" = [\"$MIRROR_ADDRESS\"]" "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE" - else - echo "jq not installed!" - exit 1 - fi - - sudo systemctl daemon-reload - sudo systemctl restart docker fi } From 49118f128b0d8a1a10881191e184b350a3b0f2e1 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Thu, 20 Jun 2024 08:43:35 +0800 Subject: [PATCH 3/3] websoft9 --- install/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.sh b/install/install.sh index c11737fc..7d5068d9 100644 --- a/install/install.sh +++ b/install/install.sh @@ -429,7 +429,7 @@ install_backends() { fi DOCKER_CONFIG_FILE="/etc/docker/daemon.json" - MIRROR_ADDRESS="https://dockerregistry.test2.websoft9.cn" + MIRROR_ADDRESS="https://registry.test2.websoft9.cn" sudo docker compose -f $composefile pull if [ $? -eq 0 ]; then echo "Docker Compose pull succeeded"