Merge branch 'maint/7.0'
[ninja.git] / op5build / monitor-ninja.spec
blob2f14b3c0265b7a6974de8b1ebf61b63ea8543b21
1 %define daemon_user monitor
2 %if 0%{?suse_version}
3 %define htmlroot /srv/www/htdocs
4 %define httpconfdir apache2/conf.d
5 %define phpdir /usr/share/php5
6 %define daemon_group www
7 %else
8 %define htmlroot /var/www/html
9 %define httpconfdir httpd/conf.d
10 %define phpdir /usr/share/php
11 %define daemon_group apache
12 %endif
14 Name: monitor-ninja
15 Version: %{op5version}
16 Release: %{op5release}%{?dist}
17 License: GPLv2 and LGPLv2 and ASL 2.0 and BSD and MIT and (MIT or GPL+) and (MIT or GPLv2+)
18 Vendor: op5 AB
19 BuildRoot: %{_tmppath}/%{name}-%{version}
20 Summary: op5 monitor ninja
21 Group: op5/monitor
22 Prefix: /opt/monitor/op5/ninja
23 Requires: monitor-gui-core
24 Requires: merlin-apps >= 0.8.0
25 Requires: merlin
26 Requires: monitor-merlin
27 Requires: php-op5lib >= 1.1.0
28 Requires: wkhtmltopdf
29 Requires: op5-mysql
30 Requires: op5-monitor-supported-webserver
31 Requires: monitor-livestatus
32 Requires: monitor-nacoma
33 Requires: monitor-backup
34 Requires: op5-bootstrap
35 BuildRequires: php-op5lib >= 1.1.0-beta14
36 BuildRequires: rubygem(compass)
37 BuildRequires: doxygen
38 BuildRequires: graphviz
39 %if 0%{?suse_version}
40 Requires: php53
41 Requires: php53-gettext
42 Requires: php53-json
43 Requires: php53-posix
44 Requires: php53-ctype
45 Requires: php53-iconv
46 Requires: php53-mbstring
47 BuildRequires: php53-json
48 BuildRequires: php53-posix
49 BuildRequires: php53-ctype
50 BuildRequires: util-linux
51 BuildRequires: pwdutils
52 BuildRequires: graphviz-gnome
53 BuildRequires: ghostscript-fonts-std
54 %else
55 Requires: php >= 5.3
56 BuildRequires: php >= 5.3
57 BuildRequires: shadow-utils
58 %if 0%{?rhel} >= 6 || 0%{?rhel_version} >=600 || 0%{?centos_version} >=600
59 Requires: php-process
60 Requires: php-mbstring
61 BuildRequires: php-process
62 %else
63 Requires: php-json
64 %endif
65 %endif
67 Source: %name-%version.tar.gz
68 %description
69 Webgui for Nagios.
71 %package test
72 Summary: Test files for ninja
73 Group: op5/Monitor
74 Requires: monitor-ninja = %version
75 Requires: merlin monitor-merlin op5-nagios
76 Requires: merlin-apps
77 Requires: monitor-livestatus monitor-nagvis
78 Requires: rubygem20-op5cucumber
79 Requires: portal
80 Requires: op5license-generator
81 Requires: op5-phpunit
82 # For performance graph links on extinfo
83 Requires: monitor-pnp
85 %description test
86 Additional test files for ninja
88 %package devel
89 Summary: Development files for ninja
90 Group: op5/monitor
91 Requires: monitor-ninja = %version
93 %description devel
94 Development files files for ninja
96 %prep
97 %setup -q
98 %if 0%{?suse_version}
99 find -type f -exec %{__sed} '{}' -i -e 's#var/www/html#srv/www/htdocs#g' \;
100 find -type f -exec %{__sed} '{}' -i -e 's#var/www#srv/www#g' \;
101 %endif
103 %build
104 pushd cli-helpers
105 make
106 popd
107 make
108 make docs
111 %install
112 rm -rf %buildroot
113 mkdir -p -m 755 %buildroot%prefix
114 mkdir -p -m 775 %buildroot%prefix/upload
115 mkdir -p -m 775 %buildroot%prefix/application/logs
117 make install-devel SYSCONFDIR=%buildroot%_sysconfdir PREFIX=%buildroot%prefix PHPDIR=%buildroot%phpdir ETC_USER=$(id -un) ETC_GROUP=$(id -gn)
119 # copy everything and then remove what we don't want to ship
120 cp -r * %buildroot%prefix
121 for d in op5build monitor-ninja.spec ninja.doxy \
122 php2doxy.sh example.htaccess cli-helpers/apr_md5_validate.c \
123 README docs/README xdoc
125 rm -rf %buildroot%prefix/$d
126 done
128 sed -i "s/\(IN_PRODUCTION', \)FALSE/\1TRUE/" \
129 %buildroot%prefix/index.php
130 sed -i \
131 -e 's,^\(.config..site_domain.. = .\)/ninja/,\1/monitor/,' \
132 -e 's/^\(.config..product_name.. = .\)Nagios/\1op5 Monitor/' \
133 -e 's/^\(.config..version_info.. = .\)\/etc\/ninja-release/\1\/etc\/op5-monitor-release/' \
134 %buildroot%prefix/application/config/config.php
136 cp op5build/login.png \
137 %buildroot%prefix/application/views/css/default/images
138 cp op5build/favicon.ico \
139 %buildroot%prefix/application/views/icons/16x16/
140 cp op5build/icon.png \
141 %buildroot%prefix/application/views/icons/
143 find %buildroot -print0 | xargs -0 chmod a+r
144 find %buildroot -type d -print0 | xargs -0 chmod a+x
146 mkdir -p %buildroot/etc/cron.d/
147 install -m 644 install_scripts/scheduled_reports.crontab %buildroot/etc/cron.d/scheduled-reports
148 install -m 644 install_scripts/recurring_downtime.crontab %buildroot/etc/cron.d/recurring-downtime
150 # executables
151 for f in cli-helpers/apr_md5_validate \
152 install_scripts/ninja_db_init.sh; do
153 chmod 755 %buildroot%prefix/$f
154 done
156 # The custom_widgets dir need to be writable by the apache user
157 chmod 775 %buildroot%prefix/application/custom_widgets
159 mkdir -p %buildroot/opt/monitor/op5/nacoma/hooks/save
160 install -m 755 install_scripts/nacoma_hooks.py %buildroot/opt/monitor/op5/nacoma/hooks/save/ninja_hooks.py
161 %if 0%{?sles_version}
162 %{py_compile %buildroot/opt/monitor/op5/nacoma/hooks/save}
163 %{py_compile -O %buildroot/opt/monitor/op5/nacoma/hooks/save}
164 %endif
166 mkdir -p %buildroot%_sysconfdir/%{httpconfdir}
167 install -m 640 op5build/ninja.httpd-conf %buildroot/etc/%{httpconfdir}/monitor-ninja.conf
169 # we don't need the git directories
170 rm -rf %buildroot%prefix/application/vendor/phptap/.git
172 sed -i 's/Ninja/op5 Monitor/' %buildroot%prefix/application/media/report_footer.html
174 mkdir -p %buildroot%prefix/application/config/custom
175 install -m 755 test/configs/kohana-configs/exception.php %buildroot%prefix/application/config/custom/exception.php
176 rm %buildroot%prefix/test/configs/kohana-configs/exception.php
178 %pre
179 # This needs to be removed for us to be able to upgrade ninja 2.0.7
180 # for some reason.
181 if test -d %buildroot%prefix/application/vendor/phptap/.git; then
182 rm -rf %buildroot%prefix/application/vendor/phptap/.git
186 %post
187 # Verify that mysql-server is installed and running before executing sql scripts
188 $(mysql -Be "quit" 2>/dev/null) && MYSQL_AVAILABLE=1
189 if [ -n "$MYSQL_AVAILABLE" ]; then
190 pushd %prefix
191 sh install_scripts/ninja_db_init.sh
192 popd
193 else
194 echo "WARNING: mysql-server is not installed or not running."
195 echo "If Oracle database is to be used this is ok."
196 echo "If MySQL database is to be used you need to maually run:"
197 echo " %prefix/install_scripts/ninja_db_init.sh"
198 echo "to complete the setup of %name"
201 $(php %prefix/index.php cli/save_widget --page 'tac/index' --name nagvis --friendly_name "Nagvis" &> /dev/null)
202 $(php %prefix/index.php cli/save_widget --page 'tac/index' --name listview --friendly_name "List view" &> /dev/null)
203 if [ "$?" -ne 0 ]; then
204 echo "WARNING: mysql-server is not installed or not running."
205 echo "If Oracle database is to be used this is ok."
206 echo "If MySQL database is to be used you need to maually"
207 echo "setup the merlin database to complete the setup of %name"
210 # Cleanup symlinks we don't use anymore
211 for link in %{htmlroot}/monitor %{htmlroot}/ninja /op5/monitor/op5/ninja/op5 /opt/monitor/op5/ninja/css /opt/monitor/op5/ninja/js /opt/monitor/op5/ninja/images /opt/monitor/op5/ninja/stylesheets
213 if [ -f $link ]; then
214 rm -f $link
216 done
218 %files
219 %defattr(-,%daemon_user,%daemon_group)
220 %prefix
221 %attr(644,root,root) /etc/cron.d/*
222 %attr(755,root,root) /opt/monitor/op5/nacoma/hooks/save/ninja_hooks.py
223 %attr(644,root,root) /opt/monitor/op5/nacoma/hooks/save/ninja_hooks.pyc
224 %attr(644,root,root) /opt/monitor/op5/nacoma/hooks/save/ninja_hooks.pyo
225 %attr(-,root,%daemon_group) /etc/%{httpconfdir}/monitor-ninja.conf
226 %exclude %prefix/src
227 %exclude %prefix/test
228 %exclude %prefix/modules/test
229 %exclude %prefix/Makefile
230 %exclude %prefix/features
231 %exclude %prefix/application/config/custom/exception.php
233 %files devel
234 %defattr(-,root,root)
235 %phpdir/op5/ninja_sdk
238 %files test
239 %defattr(-,monitor,%daemon_group)
240 %prefix/src
241 %prefix/features
242 %prefix/test
243 %prefix/modules/test
244 %prefix/Makefile
245 %prefix/application/config/custom/exception.php
247 %clean
248 rm -rf %buildroot