rpmbuild線上實戰

最近部門忙着系統整改,全部服務器須要重裝應用,爲了提升效率,使用rpmbuild
小試牛刀了一把,廢話不說直接貼spec配置:
++++++++++++++++++++++START-spec+++++++++++++++++++++++++++
# online rpmbulid for total_hulu

Name:             total_hulu
Version:          2015.12.09
Release:          01%{?dist}
Summary:          program for hulu
Group:            Applications/File
License:          BSD
URL:              http://www.youyuan.com/
Source0:          %{name}-%{version}.tar.gz
Source1:          hulu_root_crontab
Source2:          hulu_hosts
Source3:          hulu_rc.local
Source4:          hulu_profile
BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

#BuildRequires:    jdk >= 1.7
ExcludeArch:      ppc64

#Requires(post):   /usr/bin/svn
Requires(post):   /bin/bash
#Requires(post):   /bin/rpm
#Requires(post):   /bin/su
Requires(postun): /bin/rm

%description
autoinstall for hulu Platform

%prep
%setup -q

%install
%{__mkdir_p} %{buildroot}/www/
%{__mkdir_p} %{buildroot}%{_usr}/local/resin
%{__cp} -r ${RPM_BUILD_DIR}/%{name}-%{version}/* %{buildroot}/www/.

###基礎服務直接所有拷貝
#copy basic environment
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_var}/spool/cron/root
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/hosts
install -p -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/rc.d/rc.local
install -p -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/profile

%clean
rm -fr %{buildroot}

%post
###/usr/local/resin 也一併部署了
%{__cp} -rp /share/yunwei/project/fast_op/hulu_resin/* /usr/local/resin/.
###copy svn 認證
%{__cp} -rp /share/yunwei/project/fast_op/.subversion /root/.
###rpm安裝完以後,直接初始化運行腳本,啓動服務
bash /share/yunwei/project/fast_op/hulu_install_per_01.sh


%postun
###rpm 卸載後直接清理目錄
if [ $1 = 0 ]; then
   /bin/rm -rf /www/youyuan.com.1
   /bin/rm -rf /www/youyuan.com.android
   /bin/rm -rf /usr/local/resin
fi

%files
%defattr(-,www,www)
/www
%dir /usr/local/resin
%attr(0755, root, root) /var/spool/cron/root
%attr(0755, root, root) /etc/hosts
%attr(0755, root, root) /etc/profile
%attr(0755, root, root) /etc/rc.d/rc.local

%changelog
* Fri Dec 09 2015 yanliang wang <wangyl@youyuan.com> -2015.12.09
- hulu rpmbuild

++++++++++++++++++++++END-spec+++++++++++++++++++++++++++

rpmbuild打包:
rpmbuild  -ba hulu.spec

一鍵安裝應用:
 pkill java ; rpm -Uvh  --force --replacefiles --allfiles total_hulu-
 2015.12.14-01.el6.x86_64.rpm jdk-xxx.rpm 

 命令執行完後: crontab,rc.local,profile,hosts文件,業務resin服務所有完成並啓動。
 整個業務部署20s!
相關文章
相關標籤/搜索