Skip to content

Instantly share code, notes, and snippets.

@natsumerinchan
Created May 14, 2024 08:52
Show Gist options
  • Save natsumerinchan/1c7c2c0ff852b6f5fc88f120e989a70b to your computer and use it in GitHub Desktop.
Save natsumerinchan/1c7c2c0ff852b6f5fc88f120e989a70b to your computer and use it in GitHub Desktop.
#!/bin/bash
#Install Latest Stable 1Panel Release
osCheck=`uname -a`
if [[ $osCheck =~ 'x86_64' ]];then
architecture="amd64"
elif [[ $osCheck =~ 'arm64' ]] || [[ $osCheck =~ 'aarch64' ]];then
architecture="arm64"
elif [[ $osCheck =~ 'armv7l' ]];then
architecture="armv7"
elif [[ $osCheck =~ 'ppc64le' ]];then
architecture="ppc64le"
elif [[ $osCheck =~ 's390x' ]];then
architecture="s390x"
else
echo "暂不支持的系统架构,请参阅官方文档,选择受支持的系统。"
exit 1
fi
if [[ ! ${INSTALL_MODE} ]];then
INSTALL_MODE="stable"
else
if [[ ${INSTALL_MODE} != "dev" && ${INSTALL_MODE} != "stable" ]];then
echo "请输入正确的安装模式(dev or 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}
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}
bash install.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment