Skip to content

Instantly share code, notes, and snippets.

@perfectfoolish
Created March 19, 2015 05:59
Show Gist options
  • Save perfectfoolish/9d476d59addae08121f3 to your computer and use it in GitHub Desktop.
Save perfectfoolish/9d476d59addae08121f3 to your computer and use it in GitHub Desktop.
# yum install -y gcc make mysql-devel net-snmp-devel curl-devel
%define path /usr/local/zabbix
%define real_name zabbix
Name:zabbix_server-ThoughtWorks
Version:2.2.3
Release:1.centos
Summary:zabbix_server for ThoughtWorks
Group:System Environment/Daemons
License:GPL
URL:http://www.sinoicity.com
Source0:%{real_name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{real_name}-%{version}-%{release}-XXXXXX)
BuildRequires: gcc make
Requires:httpd php php-mysql mysql-server mysql mysql-devel net-snmp net-snmp-libs net-snmp-devel net-snmp-utils
Requires:curl-devel perl-DBI php-gd php-bcmath php-mbstring php-xml
%description
zabbix_server for sinoicity
%prep
rm -rf $RPM_BUILD_ROOT
rm -rf $RPM_BUILD_DIR/%{real_name}-%{version}
%setup -q -n %{real_name}-%{version}
%build
./configure --prefix=/usr/local/zabbix \
--enable-server \
--enable-proxy \
--enable-agent \
--with-mysql \
--with-net-snmp \
--with-libcurl
make
%install
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}/var/www/html/zabbix
cp -a $RPM_BUILD_DIR/%{real_name}-%{version}/frontends/php/* %{buildroot}/var/www/html/zabbix
mkdir -p %{buildroot}/etc/rc.d/init.d
cp -a $RPM_BUILD_DIR/%{real_name}-%{version}/misc/init.d/fedora/core/zabbix_server %{buildroot}/etc/rc.d/init.d
cp -a $RPM_BUILD_DIR/%{real_name}-%{version}/misc/init.d/fedora/core/zabbix_agentd %{buildroot}/etc/rc.d/init.d
mkdir -p %{buildroot}/%{path}/sql
cp -a $RPM_BUILD_DIR/%{real_name}-%{version}/database/mysql/* %{buildroot}/%{path}/sql
mkdir -p %{buildroot}/var/log/zabbix
mkdir -p %{buildroot}/var/run/zabbix
%pre
if ! /usr/bin/id zabbix &>/dev/null; then
/usr/sbin/useradd zabbix &>/dev/null
fi
%post
echo "zabbix-agent 10050/tcp # Zabbix Agent" >> /etc/services
echo "zabbix-agent 10050/udp # Zabbix Agent" >> /etc/services
echo "zabbix-trapper 10051/tcp # Zabbix Trapper" >> /etc/services
echo "zabbix-trapper 10051/udp # Zabbix Trapper" >> /etc/services
chown -R apache:apache /var/www/html/zabbix
sed -i 's/^max_execution_time.*/max_execution_time = 300/g' /etc/php.ini
sed -i 's/^max_input_time.*/max_input_time = 300/g' /etc/php.ini
sed -i 's/^post_max_size.*/post_max_size = 32M/g' /etc/php.ini
sed -i 's/^;date.timezone.*/date.timezone = "Asia\/Shanghai"/g' /etc/php.ini
chmod +x /etc/init.d/zabbix*
chkconfig httpd on
chkconfig mysqld on
chkconfig snmpd on
chkconfig zabbix_server on
chkconfig zabbix_agentd on
sh %{path}/sql/install_db.sh &>/dev/null
chown -R zabbix:zabbix /var/log/zabbix
chown -R zabbix:zabbix /var/run/zabbix
%preun
/sbin/service zabbix_server stop >/dev/null 2>&1
/sbin/service zabbix_agentd stop >/dev/null 2>&1
/sbin/chkconfig --del zabbix_server
/sbin/chkconfig --del zabbix_agentd
%postun
rm -rf /var/www/html/zabbix &>/dev/null
rm -rf /usr/local/zabbix &>/dev/null
rm -rf /etc/init.d/zabbix* &>/dev/null
sed -i '/^zabbix.*/d' /etc/services
/usr/sbin/userdel zabbix &>/dev/null
%clean
rm -rf %{buildroot}
rm -rf $RPM_BUILD_DIR/%{real_name}-%{version}
%files
%defattr(-,root,root,-)
%doc
/
%changelog
* Tue Apr 29 2014 danhanwen <[email protected]>
- v1 compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment