
## package.sh 介绍

[scripts/package.sh](../../scripts/package.sh) 主要是将 SmartAgent 安装目录下所有内容（脚本无自动去除无用目录或内容功能）压缩，
通过`base64`编码后写入 [scripts/install_temp.sh](../../scripts/install_temp.sh) 中，
最终生成安装文件 `cwserveragent-installer-version.sh` (version为SmartSgent版本)。

### 安装帮助

执行命令 `sh scripts/package.sh -h` 即可查看安装帮助详情。详情如下：

```
Usage: package.sh [-h] [-v] [DEBUG=true|false] [AGENT_VERSION=8.6]


-h, --help     Display this help and exit.
-v, --version  Print version and exit.

RELEASE        Default true; Whether to delete the publish parameter in the script.
VERSION        Configure the Cloudwise SmartAgent version.
DEBUG          Default false; 1、Debug mode executed script package.sh；
               2、Remove the debug log from the scripts (Cloudwise-SmartAgent-Linux-1.2.0.sh、smartagent、uninstall.sh).

```

### smartagent目录结构

打包前目录结构(请保持目录及内容最简)
```
smartagent
├── cwserveragent-installer-1.1.0.sh
├── bin
│   ├── CW-ServerAgent
│   └── safe-rm
├── conf
│   └── server-agent.ini
└── scripts
    ├── install_temp.sh
    ├── package.sh
    ├── cw-serveragent
    ├── uninstall.sh
    ├── uninstall_temp.sh
    └── xzdec
```

打包后目录结构
```
smartagent
├── cwserveragent-installer-1.1.0.sh
├── installer.version
├── bin
│   ├── CW-ServerAgent
│   └── safe-rm
├── conf
│   └── server-agent.ini
└── scripts
    ├── install_temp.sh
    ├── package.sh
    ├── cw-serveragent
    ├── uninstall.sh
    ├── uninstall_temp.sh
    └── xzdec
```

安装后目录结构

```
├── bin
│   ├── CW-ServerAgent
│   └── safe-rm
├── conf
│   ├── cwserveragent.conf
│   ├── installation.conf
│   └── server-agent.ini
├── installer.version
├── logs
│   └── serveragent
│       ├── CW-ServerAgent.error.log
│       ├── CW-ServerAgent.fatal.log
│       └── CW-ServerAgent.panic.log
├── runtime
│   └── .pid
├── scripts
│   ├── cw-serveragent
│   └── uninstall.sh
└── uninstall.sh
```