rpm build (三)

在SOURCE 下面放源码包ppszabbix-2.0.9.tar.gz(下载的为 zabbix-2.0.9.tar.gz,需要根据name 修改为相匹配的) 与启动脚本zabbix_agentd


.SPEC 文件


# Example spec file for zabbix

Summary: A Monitoring program

Name: ppszabbix

Version: 2.0.9

Release: 1

License: GPL

Group: Applications/Server

Source0: %{name}-%{version}.tar.gz

Source1: zabbix_agentd

URL: http://zabbix.org/

Packager: xbz

BuildPreReq: gcc,make

BuildRequires: /bin/cp,/bin/mkdir,/bin/rm,/usr/bin/yum

Requires:/bin/bash,/bin/sh

#BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXX)

Requires(post): chkconfig


%define zabbixpath  /opt/zabbix

%description

The ppszabbix is a distributed monitoring and control system

:: List of Improvements included into 2.0.9

       [ZBX-2616] upgraded the bundled DejaVu font from 2.33 to 2.34

       [ZBX-1357] updated Brazilian Portuguese, Chinese (China), Italian, Lithuanian, Romanian and Slovak translations; thanks to Zabbix translators

:: Complete List of Bug Fixes and Improvements included into 2.0.9

       [ZBX-7036] fixed "Discovery status" widget being displayed on top of a customized dashboard when enabling a discovery rule

       [ZBX-3878] fixed not being able to move dashboard widget the second time

       [ZBX-2616] upgraded the bundled DejaVu font from 2.33 to 2.34

       [ZBX-1357] updated Brazilian Portuguese, Chinese (China), Italian, Lithuanian, Romanian and Slovak translations; thanks to Zabbix translators

       [ZBX-7091] fixed SQL injection vulnerabilities in page filtering; thanks to Bernhard Schildendorfer from SEC Consult for the report

#       [ZBX-7091] fixed SQL inection vulnerabilities dashboard favourite managing; thanks to Lincoln, a member of Corelan Team, for the report

       [ZBX-3878] fixed memory leaks in slide shows

       [ZBX-6950] fixed termination character sequence for smtp connection termination

       [ZBX-6952] fixed XSS vulnerability in user themes, thanks to Lincoln and Bernhard Schildendorfer for reporting

       [ZBX-6992] fixed PostreSQL query errors due to missing "AS" keyword for aggregate functions in Monitoring > IT Services

       [ZBX-6804] much faster graphs; optimized min item clock calculation for graph; thanks to Volker Frhlich

       [ZBX-6902] reverting Solaris system.swap.size calculation from "swap -s" (used in 2.0.7, 2.0.8) to "swap -l"-like algorithm (as in 2.0.6)

       [ZBX-6936] fixed MySQL errors when updating configuration of the proxy

       [ZBX-6929] fixed updating of lastlogsize and mtime in the proxy's database

       [ZBX-6923] fixed mass delete in template list, 'Delete selected' and 'Delete selected with linked elements' functions

       [ZBX-6922] fixed host interface importing

       [ZBX-6249] fixed data loss in proxy "Data sender" process caused by unfinished transactions; thanks to MATSUDA Daiki for patch

       [ZBXNEXT-1056] improved active checks error messages

%prep

#%setup -q

rm -rf $RPM_BUILD_DIR/%{name}-%{version}

zcat $RPM_SOURCE_DIR/%{name}-%{version}.tar.gz | tar -xvf -

%build

cd %{name}-%{version}

./configure --prefix=/opt/zabbix --enable-agent

make

%install

cd %{name}-%{version}

make install DESTDIR=$RPM_BUILD_ROOT


install -p -D -m 0755  %{SOURCE1}  %{buildroot}%{_initrddir}/zabbix_agentd



%pre

rm -rf %{zabbixpath}


%preun

if [ $1 == 0 ];then

#if test $(pgrep -f zabbix_agentd | wc -l) -ne 0; then #(这样写无论是否有进程在都会执行)

ps -ef |grep zabbix_agentd |grep -v "grep" |grep -v "rpm" > /dev/null #(修改为这样,原因是卸载时会有rpm -e zabbix_agentd 这个进程在,从而影响了if 判断 )

if [ $? -eq 0 ];then 

 /etc/init.d/zabbix_agentd stop

chkconfig --add zabbix_agentd

fi

fi

%post

if [ $1 == 1 ];then

USZA=`cat /etc/passwd|grep zabbix`

if [ -z $USZA ];then

groupadd zabbix

useradd zabbix -g zabbix -s /sbin/nologin

fi

unset USZA

#cp /opt/zabbix/zabbix_agentd /etc/init.d/

#chmod 755 /etc/init.d/zabbix_agentd

chkconfig --add zabbix_agentd

chkconfig --level 35 zabbix_agentd on

chown -R  zabbix.zabbix /tmp/

/etc/init.d/zabbix_agentd start

fi

%postun

if [ $1 == 0 ];then

userdel -r zabbix

rm -f /etc/init.d/zabbix_agentd (这个是没有必要做的,因为卸载时本身包管理系统会删除掉安装的所有文件,所以卸载时不需要再执行删除动作,但需要注意安装后的动作,这个需要处理)

echo "success uninstall"

else

    /etc/init.d/zabbix_agentd  condrestart

fi

#if [ $1 -ge 1 ];then

#/sbin/service httpd condrestart > /dev/null 2>&1

#fi

%clean

rm -rf $RPM_BUILD_ROOT

rm -rf %{_builddir}/%{name}-%{version}

%files

%{zabbixpath}

%attr(0755,root,root)%{_initrddir}/zabbix_agentd

%changelog

* Thu Oct 21 2013  xbz <[email protected]>

- Add rpm package


本文出自 “xbzy” 博客,谢绝转载!

你可能感兴趣的:(包,自己动手做rpm)