From 40f8f06cf09dd1abe7c4dda322cd4ed1d60e6478 Mon Sep 17 00:00:00 2001 From: eball Date: Fri, 19 Jul 2024 13:00:28 +0800 Subject: [PATCH] feat: quick install script for macos & wsl & Raspberry Pi (#229) Co-authored-by: liuyu <> --- .github/workflows/release-daily.yaml | 40 ++++++++++++++++++++++++-- .github/workflows/release.yaml | 1 + .github/workflows/upload-full.yaml | 30 +++++++++++++++++++ build/installer/change_ip.sh | 32 ++++++++++++++++++++- build/installer/install.sh | 27 ++++++++++++++++- build/installer/install_cmd.sh | 1 + build/installer/publicAddnode.sh | 1 + build/installer/publicInstaller.latest | 26 ++++++++++++++++- build/installer/uninstall_cmd.sh | 1 + build/manifest/images | 2 +- 10 files changed, 155 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-daily.yaml b/.github/workflows/release-daily.yaml index 5e44376e..f580429e 100644 --- a/.github/workflows/release-daily.yaml +++ b/.github/workflows/release-daily.yaml @@ -28,7 +28,7 @@ jobs: run: | v=1.6.0-$(date +"%Y%m%d") echo "tag_version=$v" >> $GITHUB_OUTPUT - echo "latest_version=1.4.4" >> $GITHUB_OUTPUT + echo "latest_version=1.6.0-alpha" >> $GITHUB_OUTPUT - name: 'Checkout source code' uses: actions/checkout@v3 @@ -45,8 +45,44 @@ jobs: run: | aws s3 cp install-wizard-v${{ steps.vars.outputs.tag_version }}.tar.gz s3://terminus-os-install/install-wizard-v${{ steps.vars.outputs.tag_version }}.tar.gz --acl=public-read + upload-full-arm64: + runs-on: self-hosted + + steps: + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + root-reserve-mb: 21200 + swap-size-mb: 1024 + remove-dotnet: 'true' + remove-android: 'true' + remove-haskell: 'true' + remove-codeql: 'true' + + - name: 'Daily tag version' + id: vars + run: | + v=1.7.0-$(date +"%Y%m%d") + echo "tag_version=$v" >> $GITHUB_OUTPUT + echo "latest_version=1.6.0-alpha" >> $GITHUB_OUTPUT + + - name: 'Checkout source code' + uses: actions/checkout@v3 + + - name: Package installer + run: | + bash scripts/build-full.sh ${{ steps.vars.outputs.tag_version }} linux/arm64 + + - name: Upload to S3 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: 'us-east-1' + run: | + aws s3 cp install-wizard-v${{ steps.vars.outputs.tag_version }}.tar.gz s3://terminus-os-install/install-wizard-v${{ steps.vars.outputs.tag_version }}-arm64.tar.gz --acl=public-read + release: - needs: upload-full + needs: [upload-full, upload-full-arm64] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 503693a2..26c79547 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -60,6 +60,7 @@ jobs: build/installer/publicAddnode.sh build/installer/version.hint build/installer/publicRestoreInstaller.sh + build/installer/install.sh # prerelease: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/upload-full.yaml b/.github/workflows/upload-full.yaml index 42aa7377..bba382f8 100644 --- a/.github/workflows/upload-full.yaml +++ b/.github/workflows/upload-full.yaml @@ -39,3 +39,33 @@ jobs: run: | aws s3 cp install-wizard-v${{ github.event.inputs.tags }}.tar.gz s3://terminus-os-install/install-wizard-v${{ github.event.inputs.tags }}.tar.gz --acl=public-read + release-arm64: + runs-on: self-hosted + + steps: + # - name: Maximize build space + # uses: easimon/maximize-build-space@master + # with: + # root-reserve-mb: 21200 + # swap-size-mb: 1024 + # remove-dotnet: 'true' + # remove-android: 'true' + # remove-haskell: 'true' + # remove-codeql: 'true' + - name: 'Checkout source code' + uses: actions/checkout@v3 + with: + ref: ${{ github.event.inputs.tags }} + + - name: Package installer + run: | + bash scripts/build-full.sh ${{ github.event.inputs.tags }} linux/arm64 + + - name: Upload to S3 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: 'us-east-1' + run: | + aws s3 cp install-wizard-v${{ github.event.inputs.tags }}.tar.gz s3://terminus-os-install/install-wizard-v${{ github.event.inputs.tags }}-arm64.tar.gz --acl=public-read + diff --git a/build/installer/change_ip.sh b/build/installer/change_ip.sh index 71c154e1..8aff7358 100644 --- a/build/installer/change_ip.sh +++ b/build/installer/change_ip.sh @@ -77,6 +77,22 @@ is_k3s(){ } precheck_os() { + # check os type and arch and os vesion + os_type=$(uname -s) + os_arch=$(uname -m) + os_verion=$(lsb_release -d 2>&1 | awk -F'\t' '{print $2}') + + case "$os_arch" in + arm64) ARCH=arm64; ;; + x86_64) ARCH=amd64; ;; + armv7l) ARCH=arm; ;; + aarch64) ARCH=arm64; ;; + ppc64le) ARCH=ppc64le; ;; + s390x) ARCH=s390x; ;; + *) echo "unsupported arch, exit ..."; + exit -1; ;; + esac + # try to resolv hostname ensure_success $sh_c "hostname -i >/dev/null" @@ -98,6 +114,17 @@ precheck_os() { local_ip="$ip" } +is_wsl(){ + wsl=$(uname -a 2>&1) + if [[ ${wsl} == *WSL* ]]; then + echo 1 + return + fi + + echo 0 +} + + regen_cert_conf(){ old_IFS=$IFS for pem in $1 ; do @@ -414,7 +441,10 @@ main() { fi fi - update_juicefs + if [[ $(is_wsl) -eq 0 ]]; then + update_juicefs + fi + update_etcd if is_k3s ; then diff --git a/build/installer/install.sh b/build/installer/install.sh index 26582df6..aa98883c 100644 --- a/build/installer/install.sh +++ b/build/installer/install.sh @@ -11,8 +11,29 @@ if [ "x${VERSION}" = "x" ]; then exit fi +# check os type and arch and os vesion +os_type=$(uname -s) +os_arch=$(uname -m) +os_verion=$(lsb_release -d 2>&1 | awk -F'\t' '{print $2}') + +case "$os_arch" in + arm64) ARCH=arm64; ;; + x86_64) ARCH=amd64; ;; + armv7l) ARCH=arm; ;; + aarch64) ARCH=arm64; ;; + ppc64le) ARCH=ppc64le; ;; + s390x) ARCH=s390x; ;; + *) echo "unsupported arch, exit ..."; + exit -1; ;; +esac + + DOWNLOAD_URL="https://dc3p1870nn3cj.cloudfront.net/install-wizard-v${VERSION}.tar.gz" +if [ x"${ARCH}" == x"arm64" ]; then + DOWNLOAD_URL="https://dc3p1870nn3cj.cloudfront.net/install-wizard-v${VERSION}-arm64.tar.gz" +fi + echo "" echo " Downloading Install-Wizard ${VERSION} from ${DOWNLOAD_URL} ... " echo "" @@ -45,4 +66,8 @@ echo "Install-Wizard ${VERSION} Download Complete!" echo "" -bash ./install_cmd.sh +if [[ x"$os_type" == x"Darwin" ]]; then + bash ./install_macos.sh +else + bash ./install_cmd.sh +fi diff --git a/build/installer/install_cmd.sh b/build/installer/install_cmd.sh index 711d488a..5a9ad17f 100644 --- a/build/installer/install_cmd.sh +++ b/build/installer/install_cmd.sh @@ -189,6 +189,7 @@ precheck_os() { os_verion=$(lsb_release -d 2>&1 | awk -F'\t' '{print $2}') case "$os_arch" in + arm64) ARCH=arm64; ;; x86_64) ARCH=amd64; ;; armv7l) ARCH=arm; ;; aarch64) ARCH=arm64; ;; diff --git a/build/installer/publicAddnode.sh b/build/installer/publicAddnode.sh index 946f25d5..3553f81a 100644 --- a/build/installer/publicAddnode.sh +++ b/build/installer/publicAddnode.sh @@ -231,6 +231,7 @@ precheck_os() { os_verion=$(lsb_release -d 2>&1 | awk -F'\t' '{print $2}') case "$os_arch" in + arm64) ARCH=arm64; ;; x86_64) ARCH=amd64; ;; armv7l) ARCH=arm; ;; aarch64) ARCH=arm64; ;; diff --git a/build/installer/publicInstaller.latest b/build/installer/publicInstaller.latest index de4add4b..10ba8f54 100644 --- a/build/installer/publicInstaller.latest +++ b/build/installer/publicInstaller.latest @@ -15,8 +15,28 @@ if [ "x${VERSION}" = "x" ]; then exit 1 fi +# check os type and arch and os vesion +os_type=$(uname -s) +os_arch=$(uname -m) +os_verion=$(lsb_release -d 2>&1 | awk -F'\t' '{print $2}') + +case "$os_arch" in + arm64) ARCH=arm64; ;; + x86_64) ARCH=amd64; ;; + armv7l) ARCH=arm; ;; + aarch64) ARCH=arm64; ;; + ppc64le) ARCH=ppc64le; ;; + s390x) ARCH=s390x; ;; + *) echo "unsupported arch, exit ..."; + exit -1; ;; +esac + DOWNLOAD_URL="https://dc3p1870nn3cj.cloudfront.net/install-wizard-v${VERSION}.tar.gz" +if [ x"${ARCH}" == x"arm64" ]; then + DOWNLOAD_URL="https://dc3p1870nn3cj.cloudfront.net/install-wizard-v${VERSION}-arm64.tar.gz" +fi + echo "" echo " Downloading Install-Wizard ${VERSION} from ${DOWNLOAD_URL} ... " echo "" @@ -46,6 +66,10 @@ echo "" echo "Install-Wizard ${VERSION} Download Complete!" echo "" -bash ./install_cmd.sh +if [[ x"$os_type" == x"Darwin" ]]; then + bash ./install_macos.sh +else + bash ./install_cmd.sh +fi exit \ No newline at end of file diff --git a/build/installer/uninstall_cmd.sh b/build/installer/uninstall_cmd.sh index cf8d9eb8..bcfc23f5 100644 --- a/build/installer/uninstall_cmd.sh +++ b/build/installer/uninstall_cmd.sh @@ -27,6 +27,7 @@ precheck_os() { os_verion=$(lsb_release -d 2>&1 | awk -F'\t' '{print $2}') case "$os_arch" in + arm64) ARCH=arm64; ;; x86_64) ARCH=amd64; ;; armv7l) ARCH=arm; ;; aarch64) ARCH=arm64; ;; diff --git a/build/manifest/images b/build/manifest/images index 12ed5eb5..51d9f054 100644 --- a/build/manifest/images +++ b/build/manifest/images @@ -10,7 +10,7 @@ calico/pod2daemon-flexvol:v3.23.2 beclab/citus:12.0 coredns/coredns:1.8.0 csiplugin/snapshot-controller:v4.0.0 -beclab/ks-installer-ext:v0.1.8-ext +beclab/ks-installer-ext:v0.1.9-ext kubesphere/k8s-dns-node-cache:1.15.12 kubesphere/ks-console:v3.3.0 kubesphere/ks-controller-manager:v3.3.0