From 3b126be985d577dea39a4ab476995f2ff5059beb Mon Sep 17 00:00:00 2001 From: zhizhisheng Date: Fri, 30 Dec 2022 13:36:37 +0800 Subject: [PATCH] feature: add new parking method, make one *.run file to adapt all hardware and software environments. --- packing/README.md | 42 +++++++++++++++++ packing/filelist.txt | 4 ++ packing/gen_run.sh | 31 +++++++++++++ packing/install.sh | 107 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 packing/README.md create mode 100644 packing/filelist.txt create mode 100644 packing/gen_run.sh create mode 100644 packing/install.sh diff --git a/packing/README.md b/packing/README.md new file mode 100644 index 0000000..ba377e2 --- /dev/null +++ b/packing/README.md @@ -0,0 +1,42 @@ +# Toneagent Client Pack + +生成 run 安装文件,适配 deb 和 rpm 的 x86_64 与 arm 的双平台. + +## 使用 + +```bash +chmod +x gen_run.sh +bash gen_run.sh +``` + +## 文件 + +```sh +├── filelist.txt +├── gen_run.sh +├── install.sh +├── README.md +└── toneagent.run +``` + +- filelist 存放全平台的 Toneagent Client 下载 url +- gen_run.sh 用于生成 run 文件 +- install.sh run 文件生成时的安装脚本 +- README.md +- toneagent.run 生成的 run 文件 + +## 客户端文件 filelist + +目前已有客户端文件如下 + +- debian-x86_64-1.0.3 https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-x86_64.deb +- debian-aarch64-1.0.3 https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-aarch64.deb +- linux-x86_64-1.0.3 https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-1.an8.x86_64.rpm +- linux-aarch64-1.0.3 https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-1.an8.aarch64.rpm + +## 注意事项 + +install.sh + +- 当需要更换 客户端文件 时,需要在 `install.sh` 更新文件名. +- **请勿删除 install.sh 最后一行的空白行** 这是正确解包 run 文件必要的空白行 \ No newline at end of file diff --git a/packing/filelist.txt b/packing/filelist.txt new file mode 100644 index 0000000..811c118 --- /dev/null +++ b/packing/filelist.txt @@ -0,0 +1,4 @@ +https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-x86_64.deb +https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-aarch64.deb +https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-1.an8.x86_64.rpm +https://anolis-service-pub.oss-cn-zhangjiakou.aliyuncs.com/biz-resource/tone/rpms/toneagent-1.0.3-1.an8.aarch64.rpm \ No newline at end of file diff --git a/packing/gen_run.sh b/packing/gen_run.sh new file mode 100644 index 0000000..c85168c --- /dev/null +++ b/packing/gen_run.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# set -x + +DIR_File="./file" + +toneagent_file_gz="toneagent.tar.gz" +toneagent_file="toneagent.run" + +if [ -d $DIR_File ]; then + echo $DIR_File "exists" + rm -rf $DIR_File +fi +# 下载全平台安装包 +mkdir $DIR_File +wget -i filelist.txt -P $DIR_File + +tar -zcvf $toneagent_file_gz ./file/* + +cat install.sh $toneagent_file_gz > $toneagent_file +chmod +x toneagent.run + +# 清理临时文件 +rm -rf $DIR_File +rm $toneagent_file_gz + +if [ -f $toneagent_file ]; then + echo "$toneagent_file gen success" +fi + + diff --git a/packing/install.sh b/packing/install.sh new file mode 100644 index 0000000..7602e82 --- /dev/null +++ b/packing/install.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# set -x + +DIR_TMP="/tmp/toneagent_install" + +toneagnet_deb_x86="toneagent-1.0.3-x86_64.deb" +toneagnet_deb_arm="toneagent-1.0.3-aarch64.deb" +toneagnet_rpm_x86="toneagent-1.0.3-1.an8.x86_64.rpm" +toneagnet_rpm_arm="toneagent-1.0.3-1.an8.aarch64.rpm" + +toneagent_file="toneagent.tar.gz" + +if [ -d $DIR_TMP ]; then + # echo $DIR_TMP "exists" + rm -rf $DIR_TMP +fi + +mkdir $DIR_TMP + +ARCHIVE=$(awk '/^__ARCHIVE_BOUNDARY__/ { print NR + 1; exit 0; }' $0) + +tail -n +$ARCHIVE $0 > $DIR_TMP/$toneagent_file +tar -zpxf $DIR_TMP/$toneagent_file -C $DIR_TMP/ + +check_sys(){ + local checkType=$1 + local value=$2 + + local release='' + local systemPackage='' + local arch='' + + if [[ -f /etc/redhat-release ]]; then + release='centos' + systemPackage='yum' + elif grep -Eqi 'debian|raspbian' /etc/issue; then + release='debian' + systemPackage='apt' + elif grep -Eqi 'ubuntu' /etc/issue; then + release='ubuntu' + systemPackage='apt' + elif grep -Eqi 'centos|red hat|redhat' /etc/issue; then + release='centos' + systemPackage='yum' + elif grep -Eqi 'debian|raspbian' /proc/version; then + release='debian' + systemPackage='apt' + elif grep -Eqi 'ubuntu' /proc/version; then + release='ubuntu' + systemPackage='apt' + elif grep -Eqi 'centos|red hat|redhat' /proc/version; then + release='centos' + systemPackage='yum' + fi + + if [[ "$systemPackage" == "" ]];then + if type apt > /dev/null 2>&1; then + systemPackage='apt' + elif type yum > /dev/null 2>&1; then + systemPackage='yum' + fi + fi + + case $(uname -m) in + x86_64) arch='x86';; + aarch64) arch='arm';; + esac + + if [[ "${checkType}" == 'sysRelease' ]]; then + if [ "${value}" == "${release}" ]; then + return 0 + else + return 1 + fi + elif [[ "${checkType}" == 'packageManager' ]]; then + if [ "${value}" == "${systemPackage}" ]; then + return 0 + else + return 1 + fi + elif [[ "${checkType}" == 'architecture' ]]; then + if [ "${value}" == "${arch}" ]; then + return 0 + else + return 1 + fi + fi +} + +if check_sys packageManager yum; then + if check_sys architecture x86; then + rpm -i $DIR_TMP/file/$toneagnet_rpm_x86 + elif check_sys architecture arm; then + rpm -i $DIR_TMP/file/$toneagnet_rpm_arm + fi + +elif check_sys packageManager apt; then + if check_sys architecture x86; then + dpkg -i $DIR_TMP/file/$toneagnet_deb_x86 + elif check_sys architecture arm; then + dpkg -i $DIR_TMP/file/$toneagnet_deb_arm + fi +fi + +exit 0 +__ARCHIVE_BOUNDARY__ -- Gitee