-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathquick_start.sh
72 lines (62 loc) · 2.33 KB
/
quick_start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
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 "The system architecture is not currently supported. Please refer to the official documentation to select a supported system."
exit 1
fi
if [[ ! ${INSTALL_MODE} ]]; then
INSTALL_MODE="stable"
else
if [[ ${INSTALL_MODE} != "dev" && ${INSTALL_MODE} != "stable" ]]; then
echo "Please enter the correct installation mode (dev or stable)"
exit 1
fi
fi
VERSION=$(curl -s https://resource.1panel.hk/${INSTALL_MODE}/latest)
HASH_FILE_URL="https://resource.1panel.hk/${INSTALL_MODE}/${VERSION}/release/checksums.txt"
if [[ "x${VERSION}" == "x" ]]; then
echo "Failed to obtain the latest version, please try again later"
exit 1
fi
PACKAGE_FILE_NAME="1panel-${VERSION}-linux-${architecture}.tar.gz"
PACKAGE_DOWNLOAD_URL="https://resource.1panel.hk/${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 "The installation package already exists. Skip downloading."
rm -rf 1panel-${VERSION}-linux-${architecture}
tar zxf ${PACKAGE_FILE_NAME}
cd 1panel-${VERSION}-linux-${architecture}
/bin/bash install.sh
exit 0
else
echo "The installation package already exists, but the hash value is inconsistent. Start downloading again"
rm -f ${PACKAGE_FILE_NAME}
fi
fi
echo "Start downloading 1Panel ${VERSION}"
echo "Installation package download address: ${PACKAGE_DOWNLOAD_URL}"
curl -LOk ${PACKAGE_DOWNLOAD_URL}
if [[ ! -f ${PACKAGE_FILE_NAME} ]]; then
echo "Failed to download the installation package"
exit 1
fi
tar zxf ${PACKAGE_FILE_NAME}
if [[ $? != 0 ]]; then
echo "Failed to download the installation package"
rm -f ${PACKAGE_FILE_NAME}
exit 1
fi
cd 1panel-${VERSION}-linux-${architecture}
/bin/bash install.sh