%file区域增加如下行:
%files
%defattr (-,root,root,0755)
/etc/%{name}
/etc/%{name}-%{version}/*
/etc/profile.d/%{name}.sh
/etc/nginx/conf.d/hostmonitor.conf
%attr(0755,root,root) /etc/rc.d/init.d/zabbix_agentd
以下为完整的SPEC文件:
Name: zabbix
Version: 3.0.3
Release: 1%{?dist}
Summary: zabbix_agentd
Group: zabbix
License: GPL
URL: www.yang.com
Source0: zabbix-3.0.3.tar.gz
Source1: zabbix_agentd
Source2: nginx_monitor.sh
Source3: userparameter_nginx.conf
Source4: hostmonitor.conf
Source5: process.discovery
Source6: userparameter_process.conf
Source7: redis_check.conf
Source8: redis_cluster_check.py
Source9: redis_multiport_check.py
Source10: tcp_connections.sh
Source11: iostat-collect.sh
Source12: iostat-parse.sh
Source13: iostat-zabbix.conf
BuildRequires: gcc, gcc-c++
Requires: gcc, gcc-c++, chkconfig
%description
Zabbix agentd 3.0.3
%pre
grep zabbix /etc/passwd > /dev/null
if [ $? != 0 ]
then useradd zabbix -M -s /sbin/nologin
fi
[ -d /etc/zabbix ]||rm -rf /etc/zabbix
[ -d /etc/zabbix ]||rm -rf /etc/zabbix-3.0.3
%post
sed -i "/^ServerActive=/cServerActive=172.30.17." /etc/zabbix/etc/zabbix_agentd.conf
sed -i "/^Server=/cServer=172.30.17." /etc/zabbix/etc/zabbix_agentd.conf
sed -i "/Timeout=3/cTimeout=30" /etc/zabbix/etc/zabbix_agentd.conf
sed -i "/HostMetadata=/cHostMetadata=OPS-TMP" /etc/zabbix/etc/zabbix_agentd.conf
sed -i "/^Hostname=/cHostname=OPS-TMP" /etc/zabbix/etc/zabbix_agentd.conf
echo "UnsafeUserParameters=1" >>/etc/zabbix/etc/zabbix_agentd.conf
echo "EnableRemoteCommands=1" >>/etc/zabbix/etc/zabbix_agentd.conf
echo "Include=/etc/zabbix/etc/zabbix_agentd.conf.d/*.conf" >>/etc/zabbix/etc/zabbix_agentd.conf
chkconfig zabbix_agentd on
%preun
systemctl stop zabbix_agentd
%postun
userdel zabbix
rm -rf /etc/zabbix*
%prep
%setup -q
%build
./configure --prefix=/etc/%{name}-%{version} --enable-agent
make -j16 %{?_smp_mflags}
%install
test -L %{buildroot}/etc/%{name} && rm -f %{buildroot}/etc/%{name}
install -d %{buildroot}/etc/profile.d
make install DESTDIR=%{buildroot}
install -p -D -m 0755 %{SOURCE1} %{buildroot}/etc/init.d/zabbix_agentd
install -p -D %{SOURCE2} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/nginx_monitor.sh
install -p -D %{SOURCE3} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/userparameter_nginx.conf
install -p -D %{SOURCE4} %{buildroot}/etc/nginx/conf.d/hostmonitor.conf
install -p -D %{SOURCE5} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/process.discovery
install -p -D %{SOURCE6} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/userparameter_process.conf
install -p -D %{SOURCE7} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/redis_check.conf
install -p -D %{SOURCE8} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/redis_cluster_check.py
install -p -D %{SOURCE9} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/redis_multiport_check.py
install -p -D %{SOURCE10} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/tcp_connections.sh
install -p -D %{SOURCE11} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/iostat-collect.sh
install -p -D %{SOURCE12} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/iostat-parse.sh
install -p -D %{SOURCE13} %{buildroot}/etc/%{name}-%{version}/etc/zabbix_agentd.conf.d/iostat-zabbix.conf
echo 'export PATH=/etc/zabbix/bin:/etc/zabbix/sbin:$PATH' > %{buildroot}/etc/profile.d/%{name}.sh
ln -sf /etc/%{name}-%{version} %{buildroot}/etc/%{name}
%files
%defattr (-,root,root,0755)
/etc/%{name}
/etc/%{name}-%{version}/*
/etc/profile.d/%{name}.sh
/etc/nginx/conf.d/hostmonitor.conf
%attr(0755,root,root) /etc/rc.d/init.d/zabbix_agentd
%changelog
%clean
rm -rf %{buildroot}








