步骤四:制作安装包/安装命令
根据线下服务器系统制作对应的安装命令(Linux)或安装包(Windows)。
制作Linux安装命令
- 执行以下命令进入tmp目录。
cd /tmp
- 依次执行以下命令查看private_ip.conf中的ip是否为实际可用ip。
echo `hostname -I` > private_ip.conf
cat private_ip.conf
图1 查看ip
- 查看private_ip.conf中的ip是否为代理服务器实际可用ip,即线下服务器需可以正常连接该ip。
- 如果该ip不是实际可用ip,需手动将该ip修改为实际可用ip。
- 确认ip可用后依次执行以下命令生成安装命令。
- X86 rpm软件包镜像:
echo -e "# for Liunx x86 CentOS EulerOS OpenSUSE Fedora\n\ncurl -k -O 'https://private_ip:10180/package/agent/linux/x86/hostguard.x86_64.rpm' && echo 'MASTER_IP=private_ip:10180' > hostguard_setup_config.conf && echo 'SLAVE_IP=private_ip:10180' >> hostguard_setup_config.conf && echo 'ORG_ID=project_id' >> hostguard_setup_config.conf && rpm -ivh hostguard.x86_64.rpm && rm -f hostguard_setup_config.conf && rm -f hostguard*.rpm" > x86_rpm_install.sh
- X86 deb软件包镜像:
echo -e "# for Liunx x86 Ubuntu Debian\n\ncurl -k -O 'https://private_ip:10180/package/agent/linux/x86/hostguard.x86_64.deb' && echo 'MASTER_IP=private_ip:10180' > hostguard_setup_config.conf && echo 'SLAVE_IP=private_ip:10180' >> hostguard_setup_config.conf && echo 'ORG_ID=project_id' >> hostguard_setup_config.conf && dpkg -i hostguard.x86_64.deb && rm -f hostguard_setup_config.conf && rm -f hostguard*.deb" > x86_deb_install.sh
- ARM rpm软件包镜像:
echo -e "# for Liunx ARM CentOS EulerOS OpenSUSE Fedora UOS Kylin\n\ncurl -k -O 'https://private_ip:10180/package/agent/linux/arm/hostguard.aarch64.rpm' && echo 'MASTER_IP=private_ip:10180' > hostguard_setup_config.conf && echo 'SLAVE_IP=private_ip:10180' >> hostguard_setup_config.conf && echo 'ORG_ID=project_id' >> hostguard_setup_config.conf && rpm -ivh hostguard.aarch64.rpm && rm -f hostguard_setup_config.conf && rm -f hostguard*.rpm" > arm_rpm_install.sh
- ARM deb软件包镜像:
echo -e "# for Liunx ARM Ubuntu Debian\n\ncurl -k -O 'https://private_ip:10180/package/agent/linux/arm/hostguard.aarch64.deb' && echo 'MASTER_IP=private_ip:10180' > hostguard_setup_config.conf && echo 'SLAVE_IP=private_ip:10180' >> hostguard_setup_config.conf && echo 'ORG_ID=project_id' >> hostguard_setup_config.conf && dpkg -i hostguard.aarch64.deb && rm -f hostguard_setup_config.conf && rm -f hostguard*.deb" > arm_deb_install.sh
- 替换为可用IP:
sed -i "s#private_ip#`cat private_ip.conf`#g" *install.sh && sed -i "s#project_id#`cat /usr/local/hostguard/run/metadata.conf | grep -v enterprise_project_id | grep project_id | cut -d ":" -f 2 | cut -d " " -f 2`#g" *install.sh
- 5条命令需全部执行完成,最后一条“替换为可用IP”的命令必须执行且必须最后执行。
- x86_rpm_install.sh中的安装命令适用于x86架构,rpm软件包管理的镜像,如CentOS、EulerOS、OpenSUSE、Fedora。
- x86_deb_install.sh中的安装命令适用于x86架构,deb软件包管理的镜像,如Ubuntu、Debian。
- arm_rpm_install.sh中的安装命令适用于arm架构,rpm软件包管理的镜像,如CentOS、EulerOS、OpenSUSE、Fedora、UOS、Kylin。
- arm_deb_install.sh中的安装命令适用于arm架构,deb软件包管理的镜像,如Ubuntu、Debian。
- X86 rpm软件包镜像:
- 查看生成的命令,生成的目标命令将用于线下Linux服务器Agent的安装使用。
图2 Linux安装命令
制作Windows安装包
- 执行以下命令进入tmp目录。
cd /tmp
- 依次执行以下命令制作Windows的Agent安装压缩包。
curl -k -O https://`cat private_ip.conf`:10180/package/agent/windows/hostguard_setup.exe && echo '[system]' > hostguard_setup_config.ini && echo 'master='`cat private_ip.conf`':10180' >> hostguard_setup_config.ini && echo 'slave='`cat private_ip.conf`':10180' >> hostguard_setup_config.ini && echo 'orgid='`cat /usr/local/hostguard/run/metadata.conf | grep -v enterprise_project_id | grep project_id | cut -d ":" -f 2 | cut -d " " -f 2` >> hostguard_setup_config.ini
zip hostguard_setup.zip hostguard_setup.exe hostguard_setup_config.ini
如果代理服务器没有zip命令,需先执行以下命令安装zip插件。
yum install -y zip
- 查看生成的安装包,将用于线下Windows服务器Agent的安装使用。
图3 Windows安装包