- 论坛徽章:
- 0
|
本帖最后由 e66478 于 2014-12-12 11:37 编辑
比如想先检测一下网络是否正常,如果正常就继续安装
现在遇到的情况是,判断网络是否正常这一步能做判断. 但是判断后还会继续执行安装
Preparing... ########################################### [100%]
ping: unknown host aidu.com
Installation failed
chek file '/etc/resolv.conf' is set DNS!
1:panpu-lnmp ########################################### [100%]
我希望判断PING 百度得不到TTL 的时候就不要继续上面那个进度
.spec 文件内容
Summary:example
Name:panpu-lnmp
Version:1.0
Release:2
AutoReqProv:no
Group:Application/User
License:Share
Packager:i386
BuildRoot:%{_tmppath}/%{name}-%{version}-%{release}-root
Prefix:/panpu
%description
#rpmtest example
%define userpath /
%changlog
*Oct 25 2010
-build for the first time.
%prep
cp -r /panpu /usr/src/redhat/SOURCES/
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%userpath
cp -r /usr/src/redhat/SOURCES/. $RPM_BUILD_ROOT%userpath
%clean
rm -rf $RPM_BUILD_ROOT
rm -rf /usr/src/redhat/SOURCES/*
%files
%defattr(-,root,root)
%{userpath}
%pre
R=`ping -c 2 baidu.com`
if [[ "$R" =~ "ttl" ]];then
yum -y install libxml2-devel libcurl-devel libevent libevent-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib-devel pcre-devel openssl-devel
/usr/sbin/groupadd -g 1008 -r nginx
/usr/sbin/useradd -u 1008 -r -g 1008 nginx
mkdir -p /wwwroot/test/logs
mkdir -p /wwwroot/test/web
mkdir /panpu
mkdir -p /tmp/xcache
/bin/chown -R nginx:nginx /wwwroot
/usr/sbin/groupadd -r mysql
/usr/sbin/useradd -g mysql -r -s /sbin/nologin -M -d /panpu/soft/mysql/data mysql
/bin/chown -R mysql:mysql %{userpath}/soft/mysql
else
echo "Installation failed"
echo "chek file '/etc/resolv.conf' is set DNS!"
exit 0
fi
%post
echo "---------------------------------------------------------------------"
echo "---------------------------------------------------------------------"
echo "--------------------- service nginx start ---------------------------"
echo "--------------------- service mysqld start --------------------------"
echo "--------------------- service php-fpm start -------------------------" |
|