-
Notifications
You must be signed in to change notification settings - Fork 177
/
calamari-server.spec.in
164 lines (147 loc) · 4.97 KB
/
calamari-server.spec.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#
# Calamari Spec File
#
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif
%if 0%{?fedora} || 0%{?rhel}
# get selinux policy version
%{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null || echo 0.0.0)}
%global selinux_types %(%{__awk} '/^#[[:space:]]*SELINUXTYPE=/,/^[^#]/ { if ($3 == "-") printf "%s ", $2 }' /etc/selinux/config 2>/dev/null)
%global selinux_variants %([ -z "%{selinux_types}" ] && echo mls targeted || echo %{selinux_types})
%endif
#################################################################################
# common
#################################################################################
Name: calamari-server
Summary: Manage and monitor Ceph with a REST API
Group: System/Filesystems
BuildRequires: python-setuptools
BuildRequires: python-virtualenv
BuildRequires: redhat-lsb-core
Requires: cairo
Requires: pycairo
Requires: logrotate
Requires: redhat-lsb-core
Requires: openssl
Requires: sqlite
Requires: python-setuptools
%if 0%{?rhel} || 0%{?fedora}
# SELinux deps
BuildRequires: checkpolicy
BuildRequires: selinux-policy-devel
BuildRequires: /usr/share/selinux/devel/policyhelp
BuildRequires: hardlink
Requires: policycoreutils, libselinux-utils
Requires(post): selinux-policy >= %{_selinux_policy_version}, policycoreutils
Requires(postun): policycoreutils
%endif
Version: @VERSION@
Release: @RELEASE@%{?dist}
License: LGPL-2.1+
URL: http://ceph.com/
Source0: %{name}_%{version}.tar.gz
%prep
%setup -q -n %{name}-%{version}
%build
%if 0%{?fedora} || 0%{?rhel}
cd selinux
for selinuxvariant in %{selinux_variants}
do
make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
mv calamari-server.pp calamari-server.pp.${selinuxvariant}
make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
done
cd -
%endif
%install
make DESTDIR=${RPM_BUILD_ROOT} install-rpm
%if 0%{?fedora} || 0%{?rhel}
# Install SELinux policy
for selinuxvariant in %{selinux_variants}
do
install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
install -p -m 644 selinux/calamari-server.pp.${selinuxvariant} \
%{buildroot}%{_datadir}/selinux/${selinuxvariant}/calamari-server.pp
done
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
%endif
%description -n calamari-server
Calamari is a webapp to monitor and control a Ceph cluster via a web
browser.
%files -n calamari-server
/opt/calamari/alembic
/opt/calamari/conf
/opt/calamari/venv
%attr (-, apache, apache) /opt/calamari/webapp/calamari
%{_sysconfdir}/graphite/
%{_sysconfdir}/logrotate.d/calamari
%{_sysconfdir}/calamari/
/usr/bin/calamari-ctl
%dir /var/lib/calamari
%dir /var/lib/cthulhu
%dir %attr (755, apache, apache) /var/log/calamari
%dir %attr (755, apache, apache) /var/log/graphite
%dir %attr(-, apache, apache) /var/lib/graphite
%dir %attr(-, apache, apache) /var/lib/graphite/log
%dir %attr(-, apache, apache) /var/lib/graphite/log/webapp
%dir %attr(-, apache, apache) /var/lib/graphite/whisper
%if 0%{?fedora} || 0%{?rhel}
%doc selinux/*
%{_datadir}/selinux/*/calamari-server.pp
%{_exec_prefix}/lib/systemd/system/calamari.service
%endif
%post -n calamari-server
%if 0%{?fedora} || 0%{?rhel}
calamari_selinux()
{
# Set some SELinux booleans
setsebool httpd_can_network_connect=on
setsebool httpd_can_network_connect_db=on
# Load the policy
for selinuxvariant in %{selinux_variants}
do
/usr/sbin/semodule -s ${selinuxvariant} -i \
%{_datadir}/selinux/${selinuxvariant}/calamari-server.pp &> /dev/null || :
done
}
calamari_selinux
%endif
# Prompt the user to proceed with the final script-driven
# part of the installation process
echo "Thank you for installing Calamari."
echo ""
echo "Please run 'sudo calamari-ctl initialize' to complete the installation."
exit 0
%preun -n calamari-server
if [ $1 == 0 ] ; then
rm /etc/httpd/conf.d/calamari.conf
rm /etc/httpd/conf.d/wsgi.conf
mv /etc/httpd/conf.d/welcome.conf.orig /etc/httpd/conf.d/welcome.conf
service supervisord stop
sed -i '/^### START calamari-server/,/^### END calamari-server/d' /etc/supervisord.conf
service supervisord start
fi
exit 0
%postun -n calamari-server
# Remove anything left behind in the calamari and graphite
# virtual environment directories, if this is a "last-instance" call
if [ $1 == 0 ] ; then
%if 0%{?fedora} || 0%{?rhel}
for selinuxvariant in %{selinux_variants}
do
/usr/sbin/semodule -s ${selinuxvariant} -r calamari-server &> /dev/null || :
done
# Turn off some sebools
setsebool httpd_can_network_connect=off
setsebool httpd_can_network_connect_db=off
%endif
rm -rf /opt/graphite
rm -rf /opt/calamari
rm -rf /var/log/graphite
rm -rf /var/log/calamari
rm -rf /var/lib/graphite/whisper
fi
exit 0
%changelog