SPECS: template-webapp.spec - make template for common cases where...
glen
glen at pld-linux.org
Mon Dec 5 12:30:54 CET 2005
Author: glen Date: Mon Dec 5 11:30:54 2005 GMT
Module: SPECS Tag: HEAD
---- Log message:
- make template for common cases where sysconfdir is in webapps
---- Files affected:
SPECS:
template-webapp.spec (1.31 -> 1.32)
---- Diffs:
================================================================
Index: SPECS/template-webapp.spec
diff -u SPECS/template-webapp.spec:1.31 SPECS/template-webapp.spec:1.32
--- SPECS/template-webapp.spec:1.31 Sat Dec 3 22:09:28 2005
+++ SPECS/template-webapp.spec Mon Dec 5 12:30:41 2005
@@ -21,6 +21,9 @@
%define _webapp %{name}
%define _sysconfdir %{_webapps}/%{_webapp}
+# in case _sysconfdir is not in webapps dir, run this replace pattern
+# before copy-pasting to your spec: :%s#%{_sysconfdir}#%{_webapps}/%{_webapp}#g
+
%description
This .spec is for demonstrating triggers used for linking webapp
configuration to webserver config dir.
@@ -39,11 +42,6 @@
install -d $RPM_BUILD_ROOT%{_sysconfdir}
#install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
-install config.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
-install config.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
-install config.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
-
-# in case %{_sysconfdir} is %{_webapps}/%{_webapp}
install config.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
install config.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
install config.conf $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf
@@ -78,9 +76,9 @@
# rescue app configs. issue this in old config dir to get a list:
# rpm -qfl .|grep `pwd`/|awk -F/ '{print $NF}'|egrep -v 'apache|httpd'|xargs
for i in config.inc.php; do
- if [ -f /etc/phpPgAdmin/$i.rpmsave ]; then
+ if [ -f /etc/%{name}/$i.rpmsave ]; then
mv -f %{_sysconfdir}/$i{,.rpmnew}
- mv -f /etc/phpPgAdmin/$i.rpmsave %{_sysconfdir}/$i
+ mv -f /etc/%{name}/$i.rpmsave %{_sysconfdir}/$i
fi
done
@@ -92,21 +90,21 @@
# migrate from httpd (apache2) config dir
if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
- cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
- mv -f /etc/httpd/%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
+ cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
+ mv -f /etc/httpd/%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
httpd_reload=1
fi
# migrate from apache-config macros
if [ -f /etc/%{name}/apache.conf.rpmsave ]; then
if [ -d /etc/apache/webapps.d ]; then
- cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
- cp -f /etc/%{name}/apache.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
+ cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
+ cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/apache.conf
fi
if [ -d /etc/httpd/webapps.d ]; then
- cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
- cp -f /etc/%{name}/apache.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
+ cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
+ cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/httpd.conf
fi
rm -f /etc/%{name}/apache.conf.rpmsave
fi
@@ -114,13 +112,13 @@
# same but without separate %{_sysconfdir} for package
if [ -f /etc/apache-%{name}.conf.rpmsave ]; then
if [ -d /etc/apache/webapps.d ]; then
- cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
- cp -f /etc/apache-%{name}.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
+ cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
+ cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/apache.conf
fi
if [ -d /etc/httpd/webapps.d ]; then
- cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
- cp -f /etc/apache-%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
+ cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
+ cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
fi
rm -f /etc/apache-%{name}.conf.rpmsave
fi
@@ -136,6 +134,20 @@
/usr/sbin/webapp register httpd %{_webapp}
httpd_reload=1
fi
+# or if we're migrating from %apache_install macros we can depend on symlinks in conf.d/http.conf dirs
+# place new config location, as trigger puts config only on first install, do it here.
+# apache1
+if [ -L /etc/apache/conf.d/99_%{name}.conf ]; then
+ rm -f /etc/apache/conf.d/99_%{name}.conf
+ /usr/sbin/webapp register apache %{_webapp}
+ apache_reload=1
+fi
+# apache2
+if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
+ rm -f /etc/httpd/httpd.conf/99_%{name}.conf
+ /usr/sbin/webapp register httpd %{_webapp}
+ httpd_reload=1
+fi
if [ "$httpd_reload" ]; then
if [ -f /var/lock/subsys/httpd ]; then
@@ -154,12 +166,11 @@
%files
%defattr(644,root,root,755)
-%dir %attr(750,root,http) %{_webapps}/%{_webapp}
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/lighttpd.conf
-
-#%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/*.php
+%dir %attr(750,root,http) %{_sysconfdir}
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/httpd.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lighttpd.conf
+%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*.php
%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
%changelog
@@ -167,6 +178,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.32 2005/12/05 11:30:41 glen
+- make template for common cases where sysconfdir is in webapps
+
Revision 1.31 2005/12/03 21:09:28 glen
- spec more to the real life for easier copy paste
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SPECS/template-webapp.spec?r1=1.31&r2=1.32&f=u
More information about the pld-cvs-commit
mailing list