Updated on 2023-02-23 GMT+08:00

Step 4: Generating an Installation Package/Command

Generate the installation command for Linux servers and the package for Windows servers.

Generating the Installation Command for Linux Servers

  1. Run the following command to access the /tmp directory:

    cd /tmp

  2. Run the following commands in sequence to check whether the IP address in private_ip.conf is available:

    echo `hostname -I` > private_ip.conf

    cat private_ip.conf

    Figure 1 Checking the IP address
    • Check whether the IP address in private_ip.conf is available for the proxy server. Ensure that the IP address can be connected by off-cloud servers.
    • If the IP address is not available, manually change it.

  3. After confirming that the IP address is available, run the following commands in sequence to generate the installation command:

    • x86 RPM software package image:

      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 software package image:

      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 software package image:

      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 software package image:

      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

    • Change to an available IP address:

      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

    • All the five commands must be executed. The last command that is used to change to an available IP address must be executed at last.
    • The installation commands in x86_rpm_install.sh are suitable for images managed by the RPM software package in the x86 architecture, such as CentOS, EulerOS, OpenSUSE, and Fedora.
    • The installation commands in x86_deb_install.sh are suitable for images managed by the .deb software package in the x86 architecture, such as Ubuntu and Debian.
    • The installation commands in arm_rpm_install.sh are suitable for images managed by the RPM software package in the ARM architecture, such as CentOS, EulerOS, OpenSUSE, Fedora, UOS, and Kylin.
    • The installation commands in arm_deb_install.sh are suitable for images managed by the .deb software package in the ARM architecture, such as Ubuntu and Debian.

  4. View the generated installation command, which will be used to install agents on the off-cloud Linux servers.

    Figure 2 Linux installation commands

Generating the Installation Package for Windows Servers

  1. Run the following command to access the /tmp directory:

    cd /tmp

  2. Run the following commands in sequence to generate the agent installation package for Windows servers:

    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

    If the proxy server does not have zip commands, run the following command to install the zip plugin:

    yum install -y zip

  3. View the generated installation package, which will be used to install agents on the off-cloud Windows servers.

    Figure 3 Windows installation package