2009-06-24 23:46:34 +00:00
|
|
|
Summary: Web Client for xCAT 2
|
|
|
|
Name: xCAT-UI
|
|
|
|
Version: %(cat Version)
|
|
|
|
Release: snap%(date +"%Y%m%d%H%M")
|
|
|
|
License: EPL
|
|
|
|
Group: Applications/System
|
2011-02-16 15:30:56 +00:00
|
|
|
URL: http://xcat.sourceforge.net/
|
|
|
|
Packager: IBM
|
|
|
|
Vendor: IBM
|
|
|
|
|
2009-06-29 18:59:31 +00:00
|
|
|
Source: xCAT-UI-%(cat Version).tar.gz
|
2009-06-24 23:46:34 +00:00
|
|
|
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
|
2011-12-22 13:53:53 +00:00
|
|
|
%ifos linux
|
2009-06-24 23:46:34 +00:00
|
|
|
BuildArch: noarch
|
2011-12-22 13:53:53 +00:00
|
|
|
%endif
|
2009-06-29 18:59:31 +00:00
|
|
|
Provides: xCAT-UI = %{version}
|
2011-01-20 15:28:15 +00:00
|
|
|
Requires: xCAT-UI-deps >= 2.6
|
2009-06-24 23:46:34 +00:00
|
|
|
|
2011-02-16 15:30:56 +00:00
|
|
|
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
|
|
|
|
Prefix: /opt/xcat
|
|
|
|
|
2009-06-24 23:46:34 +00:00
|
|
|
%ifos linux
|
2011-02-16 15:30:56 +00:00
|
|
|
# httpd is provided as apache2 on SLES and httpd on RHEL
|
2009-12-15 06:32:32 +00:00
|
|
|
Requires: httpd
|
2009-06-24 23:46:34 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
%description
|
2010-11-17 18:53:40 +00:00
|
|
|
Provides a browser-based interface for xCAT (Extreme Cloud Administration Toolkit).
|
2009-06-24 23:46:34 +00:00
|
|
|
|
|
|
|
%prep
|
2009-06-29 18:59:31 +00:00
|
|
|
%setup -q -n xCAT-UI
|
2011-02-16 15:30:56 +00:00
|
|
|
|
2009-06-24 23:46:34 +00:00
|
|
|
%build
|
2011-04-13 14:13:20 +00:00
|
|
|
#********** Build **********
|
2011-03-01 15:09:46 +00:00
|
|
|
# Minify Javascript files using Google Compiler
|
2011-03-02 14:22:58 +00:00
|
|
|
echo "Minifying Javascripts... This will take a couple of minutes."
|
|
|
|
|
2011-03-14 13:47:31 +00:00
|
|
|
COMPILER_JAR='/xcat2/build/tools/compiler.jar'
|
|
|
|
UI_JS="js/"
|
|
|
|
|
2011-04-22 06:45:33 +00:00
|
|
|
%ifos linux
|
|
|
|
JAVA='/opt/ibm/java-ppc64-60/jre/bin/java'
|
2011-03-01 15:09:46 +00:00
|
|
|
# Find all Javascript files
|
2011-04-13 14:13:20 +00:00
|
|
|
declare -a FILES
|
2011-03-14 10:09:53 +00:00
|
|
|
FILES=`find ${UI_JS} -name '*.js'`
|
2011-03-01 15:09:46 +00:00
|
|
|
for i in ${FILES[*]}; do
|
|
|
|
# Ignore Javascripts that are already minified
|
|
|
|
if [[ ! $i =~ '.*\.min\.js$' ]]; then
|
2011-12-27 10:44:55 +00:00
|
|
|
echo " Minifying $i ..."
|
2011-03-01 15:09:46 +00:00
|
|
|
`${JAVA} -jar ${COMPILER_JAR} --warning_level=QUIET --js=$i --js_output_file=$i.min`
|
|
|
|
|
|
|
|
# Remove old Javascript and replace it with minified version
|
|
|
|
rm -rf $i
|
|
|
|
mv $i.min $i
|
|
|
|
fi
|
|
|
|
done
|
2011-04-13 14:13:20 +00:00
|
|
|
|
|
|
|
%else # AIX
|
2011-03-14 13:24:14 +00:00
|
|
|
JAVA='/usr/java6_64/bin/java'
|
2011-04-22 06:45:33 +00:00
|
|
|
# Find all Javascript files
|
|
|
|
FILES=`find ${UI_JS} -name '*.js'`
|
2011-03-14 13:24:14 +00:00
|
|
|
for i in ${FILES[*]}; do
|
|
|
|
# Ignore Javascripts that are already minified
|
|
|
|
if [[ ! $i = @(*.min.js) ]]; then
|
2011-12-27 10:44:55 +00:00
|
|
|
echo " Minifying $i ..."
|
2011-03-14 13:24:14 +00:00
|
|
|
`${JAVA} -jar ${COMPILER_JAR} --warning_level=QUIET --js=$i --js_output_file=$i.min`
|
|
|
|
|
|
|
|
# Remove old Javascript and replace it with minified version
|
|
|
|
rm -rf $i
|
|
|
|
mv $i.min $i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
%endif
|
|
|
|
|
|
|
|
IFS='
|
|
|
|
'
|
2011-03-01 15:09:46 +00:00
|
|
|
|
2009-06-24 23:46:34 +00:00
|
|
|
%install
|
2011-04-13 14:13:20 +00:00
|
|
|
#********** Install **********
|
2009-06-24 23:46:34 +00:00
|
|
|
rm -rf $RPM_BUILD_ROOT
|
2009-06-29 18:59:31 +00:00
|
|
|
mkdir -p $RPM_BUILD_ROOT%{prefix}/ui
|
|
|
|
cp -r * $RPM_BUILD_ROOT%{prefix}/ui
|
|
|
|
chmod 755 $RPM_BUILD_ROOT%{prefix}/ui/*
|
2009-06-24 23:46:34 +00:00
|
|
|
|
2012-04-24 15:24:16 +00:00
|
|
|
# Copy over xCAT UI plugins
|
2012-04-24 15:55:37 +00:00
|
|
|
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin
|
2012-04-24 16:01:41 +00:00
|
|
|
cp xcat/plugins/* $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin
|
2012-04-24 15:24:16 +00:00
|
|
|
chmod 644 $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/web.pm
|
|
|
|
chmod 644 $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/webportal.pm
|
|
|
|
|
|
|
|
# Create symbolic link to webportal command
|
2012-04-24 16:10:55 +00:00
|
|
|
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
|
2012-04-24 15:24:16 +00:00
|
|
|
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/webportal
|
|
|
|
|
2009-06-24 23:46:34 +00:00
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
2012-04-24 21:02:40 +00:00
|
|
|
%{prefix}
|
2009-06-24 23:46:34 +00:00
|
|
|
|
2009-12-15 06:32:32 +00:00
|
|
|
%pre
|
2011-04-13 14:13:20 +00:00
|
|
|
#********** Pre-install **********
|
2010-11-17 18:53:40 +00:00
|
|
|
# Inspect whether PHP related RPM packages are installed
|
2009-12-15 06:32:32 +00:00
|
|
|
%ifos linux
|
2011-04-13 14:13:20 +00:00
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
2014-09-16 06:26:10 +00:00
|
|
|
if [ ! -e "/etc/httpd/conf.d/php.conf" ]; then
|
2011-04-13 14:13:20 +00:00
|
|
|
echo ""
|
|
|
|
echo "Error! php has not been installed. Please run 'yum install php' before installing xCAT-UI.";
|
|
|
|
exit -1;
|
|
|
|
fi
|
|
|
|
else # SUSE
|
2014-09-16 06:26:10 +00:00
|
|
|
if [ ! -e "/etc/apache2/conf.d/php5.conf" ]; then
|
2011-04-13 14:13:20 +00:00
|
|
|
echo ""
|
|
|
|
echo "Error! apache2-mod_php5 and php5 have not been installed. Please run 'zypper install apache2-mod_php5 php5' before installing xCAT-UI."
|
|
|
|
exit -1;
|
|
|
|
fi
|
2009-12-15 06:32:32 +00:00
|
|
|
fi
|
2010-11-17 18:53:40 +00:00
|
|
|
%else # AIX
|
2009-12-22 03:14:23 +00:00
|
|
|
if [ -e "/usr/IBM/HTTPServer/conf/httpd.conf" ]; then
|
|
|
|
echo "Installing xCAT-UI on AIX..."
|
|
|
|
else
|
|
|
|
echo ""
|
2012-05-01 23:43:11 +00:00
|
|
|
echo "Error! IBM HTTP Server has not been installed or has not been installed in the default directory (/usr/IBM/HTTPServer/)."
|
2009-12-22 03:14:23 +00:00
|
|
|
exit -1;
|
|
|
|
fi
|
2009-12-15 06:32:32 +00:00
|
|
|
%endif
|
2009-06-24 23:46:34 +00:00
|
|
|
|
|
|
|
%post
|
2011-04-13 14:13:20 +00:00
|
|
|
#********** Post-install **********
|
2010-11-17 18:53:40 +00:00
|
|
|
# Get apache name
|
2009-06-24 23:46:34 +00:00
|
|
|
%ifos linux
|
2011-04-13 14:13:20 +00:00
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
|
|
|
apachedaemon='httpd'
|
|
|
|
apacheuser='apache'
|
|
|
|
else # SUSE
|
|
|
|
apachedaemon='apache2'
|
|
|
|
apacheuser='wwwrun'
|
|
|
|
fi
|
2009-06-24 23:46:34 +00:00
|
|
|
|
2011-04-13 14:13:20 +00:00
|
|
|
if [ "$1" = 1 ] # Install
|
2011-05-09 18:25:31 +00:00
|
|
|
then
|
2011-04-13 14:39:39 +00:00
|
|
|
# Update apache conf
|
|
|
|
/bin/rm -f /etc/$apachedaemon/conf.d/xcat-ui.conf
|
|
|
|
/bin/ln -s %{prefix}/ui/etc/apache2/conf.d/xcat-ui.conf /etc/$apachedaemon/conf.d/xcat-ui.conf
|
2011-05-09 18:25:31 +00:00
|
|
|
|
|
|
|
# Automatically put encrypted password into the xCAT passwd database
|
2011-04-13 14:13:20 +00:00
|
|
|
%{prefix}/sbin/chtab key=xcat,username=root passwd.password=`grep root /etc/shadow|cut -d : -f 2`
|
|
|
|
|
|
|
|
echo "To use xCAT-UI, point your browser to http://"`hostname -f`"/xcat"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = 1 ] || [ "$1" = 2 ] # Install or upgrade
|
2011-09-26 21:12:06 +00:00
|
|
|
then
|
2012-04-25 23:36:32 +00:00
|
|
|
# Restart xCAT
|
2011-09-26 21:12:06 +00:00
|
|
|
/etc/init.d/xcatd restart
|
|
|
|
|
2011-05-09 18:25:31 +00:00
|
|
|
# Copy php.ini file into /opt/xcat/ui and turn off output_buffering
|
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
|
|
|
/bin/sed /etc/php.ini -e 's/output_buffering = 4096/output_buffering = Off/g' > %{prefix}/ui/php.ini
|
|
|
|
else # SUSE
|
|
|
|
/bin/sed /etc/php5/apache2/php.ini -e 's/output_buffering = 4096/output_buffering = Off/g' > %{prefix}/ui/php.ini
|
|
|
|
fi
|
|
|
|
|
2012-04-25 23:36:32 +00:00
|
|
|
# Restart Apache Server
|
2011-09-26 21:12:06 +00:00
|
|
|
/etc/init.d/$apachedaemon restart
|
2011-04-13 14:13:20 +00:00
|
|
|
true
|
|
|
|
fi
|
2011-02-16 15:30:56 +00:00
|
|
|
%else # AIX
|
2011-04-13 14:13:20 +00:00
|
|
|
ihs_config_dir='/usr/IBM/HTTPServer/conf'
|
|
|
|
if [ "$1" = 1 ] #initial install
|
|
|
|
then
|
|
|
|
# Check if IBM HTTP Server is installed in the default directory
|
|
|
|
# Update the apache config
|
|
|
|
echo "Updating IBM HTTP server configuration for xCAT..."
|
|
|
|
bin/rm -f /usr/IBM/HTTPServer/conf/xcat-ui.conf
|
|
|
|
cp /usr/IBM/HTTPServer/conf/httpd.conf /usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak
|
2012-04-20 03:50:58 +00:00
|
|
|
cat ../ui/etc/apache2/conf.d/xcat-ui.conf >> /usr/IBM/HTTPServer/conf/httpd.conf
|
2011-04-13 14:13:20 +00:00
|
|
|
/usr/IBM/HTTPServer/bin/apachectl restart
|
|
|
|
|
|
|
|
# Put the encrypted password in /etc/security/passwd into the xcat passwd database
|
|
|
|
CONT=`cat /etc/security/passwd`
|
|
|
|
%{prefix}/sbin/chtab key=xcat,username=root passwd.password=`echo $CONT |cut -d ' ' -f 4`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = 1 ] || [ "$1" = 2 ] # Install or upgrade
|
|
|
|
then
|
|
|
|
# Uncomment this if we change xcat-ui.conf again
|
2011-09-26 21:12:06 +00:00
|
|
|
# /etc/init.d/$apachedaemon restart
|
2011-04-13 14:13:20 +00:00
|
|
|
true
|
|
|
|
fi
|
2009-06-24 23:46:34 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
%preun
|
2011-09-09 19:34:59 +00:00
|
|
|
#********** Pre-uninstall **********
|
2009-06-24 23:46:34 +00:00
|
|
|
%ifos linux
|
2011-04-13 14:13:20 +00:00
|
|
|
if [ "$1" = 0 ] # RPM being removed
|
|
|
|
then
|
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
|
|
|
apachedaemon='httpd'
|
|
|
|
apacheuser='apache'
|
|
|
|
else # SUSE
|
|
|
|
apachedaemon='apache2'
|
|
|
|
apacheuser='wwwrun'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove links made during the post install script
|
|
|
|
echo "Undoing $apachedaemon configuration for xCAT..."
|
|
|
|
/bin/rm -f /etc/$apachedaemon/conf.d/xcat-ui.conf
|
2011-04-13 14:39:39 +00:00
|
|
|
/bin/rm -f %{prefix}/ui/php.ini
|
2011-04-13 14:13:20 +00:00
|
|
|
/etc/init.d/$apachedaemon reload
|
|
|
|
fi
|
2010-11-17 18:53:40 +00:00
|
|
|
%else # AIX
|
2011-04-13 14:13:20 +00:00
|
|
|
# Remove links made during the post install script
|
|
|
|
echo "Undoing IBM HTTP Server configuration for xCAT..."
|
|
|
|
if [ -e "/usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak" ];then
|
|
|
|
cp /usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak /usr/IBM/HTTPServer/conf/httpd.conf
|
|
|
|
rm -rf /usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak
|
|
|
|
fi
|
|
|
|
/usr/IBM/HTTPServer/bin/apachectl restart
|
2012-04-20 04:06:16 +00:00
|
|
|
%endif
|