Zabbix Linux 客户端自动化安装RPM包制作

1、安装 rpmbuild

yum -y install rpm-build

2、编写specs文件

#zabbix_agent_1.8.4TS_x86_64-1.0-1.specs

Summary: RPM for zabbix_agent_1.8.4

#生成的RPM安装包名称

Name: zabbix_agent_1.8.4TS

 

Version: 1.0

Release: 1

 

Vendor:Mayulin

 

License: Share

 

Group: Applications/Text

 

Source:zabbix_agent_1.8.4_linux_x86_64.tar.bz2

#安装包描述

%description

Install zabbix_agent_1.8.4 to the host

#安装部分

%post

tar xf /root/zabbix_agent_1.8.4_linux_x86_64.tar.bz2 -C /usr/local/

/bin/sh /usr/local/zabbix/install.sh

/bin/sh /usr/local/zabbix/ipmi.sh

/bin/sed -i 's/^\(Server=\).*$/\1 10.0.101.248/g' /etc/zabbix/zabbix_agentd.conf

#卸载部分

%postun

/etc/init.d/zabbix_agentd stop

rm -rf /etc/init.d/zabbix_agentd

rm -rf /usr/local/zabbix

rm -rf /etc/zabbix

/bin/sed -i '/^\zabbix.*$/d' /etc/services

/bin/sed -i '/^\/etc\/init.d\/zabbix_agentd.*$/d' /etc/rc.local

/usr/sbin/userdel zabbix

#tar安装包所在位置

%files

/root/zabbix_agent_1.8.4_linux_x86_64.tar.bz2

3、将源码包放在/root/zabbix_agent_1.8.4_linux_x86_64.tar.bz2

 

4、执行命令rpmbuild –bb /usr/src/redhat/SPECS/zabbix_agent_1.8.4TS_x86_64-1.0-1.specs

 

5、生成的rpm安装包存放在:

/usr/src/redhat/RPMS/x86_64/zabbix_agent_1.8.4TS-1.0-1.x86_64.rpm

你可能感兴趣的:(linux,rpm,自动化,监控,zabbix)