1panel的安装脚本注释

脚本名称:quick_install.sh,来自ChatGPT3.5的注释。

#!/bin/bash
# Bash 脚本开始

# 检查系统架构
osCheck=$(uname -a)
if [[ $osCheck =~ 'x86_64' ]]; then
    architecture="amd64" # x86_64 架构
elif [[ $osCheck =~ 'arm64' ]] || [[ $osCheck =~ 'aarch64' ]]; then
    architecture="arm64" # ARM64 架构
elif [[ $osCheck =~ 'armv7l' ]]; then
    architecture="armv7" # ARMv7 架构
elif [[ $osCheck =~ 'ppc64le' ]]; then
    architecture="ppc64le" # ppc64le 架构
elif [[ $osCheck =~ 's390x' ]]; then
    architecture="s390x" # s390x 架构
else
    echo "暂不支持的系统架构,请参阅官方文档,选择受支持的系统。"
    exit 1
fi

# 检查安装模式,若未设置则默认为稳定版
if [[ ! ${INSTALL_MODE} ]]; then
    INSTALL_MODE="stable"
else
    # 确保安装模式为 "dev" 或 "stable"
    if [[ ${INSTALL_MODE} != "dev" && ${INSTALL_MODE} != "stable" ]]; then
        echo "请输入正确的安装模式(dev 或 stable)"
        exit 1
    fi
fi

# 获取最新版本号和哈希文件地址
VERSION=$(curl -s https://resource.fit2cloud.com/1panel/package/${INSTALL_MODE}/latest)
HASH_FILE_URL="https://resource.fit2cloud.com/1panel/package/${INSTALL_MODE}/${VERSION}/release/checksums.txt"

# 检查版本获取是否成功
if [[ "x${VERSION}" == "x" ]]; then
    echo "获取最新版本失败,请稍候重试"
    exit 1
fi

# 构建安装包文件名和下载地址
package_file_name="1panel-${VERSION}-linux-${architecture}.tar.gz"
package_download_url="https://resource.fit2cloud.com/1panel/package/${INSTALL_MODE}/${VERSION}/release/${package_file_name}"
expected_hash=$(curl -s "$HASH_FILE_URL" | grep "$package_file_name" | awk '{print $1}')

# 若安装包文件已存在,检查哈希值,一致则跳过下载,否则重新下载
if [ -f ${package_file_name} ]; then
    actual_hash=$(sha256sum "$package_file_name" | awk '{print $1}')
    if [[ "$expected_hash" == "$actual_hash" ]]; then
        echo "安装包已存在,跳过下载"
        rm -rf 1panel-${VERSION}-linux-${architecture}
        tar zxvf ${package_file_name}
        cd 1panel-${VERSION}-linux-${architecture}
        /bin/bash install.sh
        exit 0
    else
        echo "已存在安装包,但是哈希值不一致,开始重新下载"
        rm -f ${package_file_name}
    fi
fi

# 下载并解压安装包
echo "开始下载 1Panel ${VERSION} 版本在线安装包"
echo "安装包下载地址: ${package_download_url}"

curl -LOk -o ${package_file_name} ${package_download_url}
curl -sfL https://resource.fit2cloud.com/installation-log.sh | sh -s 1p install ${VERSION}
if [ ! -f ${package_file_name} ]; then
    echo "下载安装包失败,请稍候重试。"
    exit 1
fi

tar zxvf ${package_file_name}
if [ $? != 0 ]; then
    echo "下载安装包失败,请稍候重试。"
    rm -f ${package_file_name}
    exit 1
fi

cd 1panel-${VERSION}-linux-${architecture}
/bin/bash install.sh

1panel

官网:1panel.cn

官方GitHub:https://github.com/1Panel-dev/1Panel

一件安装地址:curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh