Added seed code for access-management.
[ta/access-management.git] / access-management.spec
1 # Copyright 2019 Nokia
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 Name:           access-management
16 Version:        %{_version}
17 Release:        1%{?dist}
18 Summary:        Access Management
19 License:        %{_platform_license}
20
21 Vendor:         %{_platform_vendor}
22 Source0:        %{name}-%{version}.tar.gz
23 BuildArch:      noarch
24 Requires:       python-flask, python2-flask-restful, python2-configparser, mod_wsgi, python2-peewee
25 BuildRequires:  python python-setuptools
26
27 %description
28 This RPM contains Access Management component for Akraino REC blueprint
29
30 %prep
31 %autosetup
32
33 %install
34 mkdir -p %{buildroot}%{_python_site_packages_path}/access_management
35 mkdir -p %{buildroot}/var/log/access_management
36
37 mkdir -p %{buildroot}%{_python_site_packages_path}/yarf/handlers/am
38 rsync -ra src/access_management/rest-plugin/* %{buildroot}/%{_python_site_packages_path}/yarf/handlers/am
39
40 mkdir -p %{buildroot}/etc/required-secrets/
41 cp secrets/am-secrets.yaml %{buildroot}/etc/required-secrets/am-secrets.yaml
42
43 mkdir -p %{buildroot}%{_unitdir}/
44 cp systemd/auth-server.service %{buildroot}%{_unitdir}/
45
46 cd src && python setup.py install --root %{buildroot} --no-compile --install-purelib %{_python_site_packages_path} --install-scripts %{_platform_bin_path} && cd -
47
48
49 %files
50 %defattr(0755,root,root)
51 %{_python_site_packages_path}/access_management*
52 %{_python_site_packages_path}/yarf/handlers/am/*
53 /etc/required-secrets/am-secrets.yaml
54 %dir %attr(0770, access-manager,access-manager) /var/log/access_management
55 %attr(0755,root, root) %{_platform_bin_path}/auth-server
56 %attr(0644,root, root) %{_unitdir}/auth-server.service
57
58 %pre
59 /usr/bin/getent passwd access-manager > /dev/null||/usr/sbin/useradd -r access-manager
60
61
62 %post
63 if [ $1 -eq 2 ]; then
64     if [ -f %{{aaa_backend_config_path}} ]; then
65         sudo /usr/bin/systemctl restart auth-server
66     fi
67 fi
68
69
70 %preun
71
72
73 %postun
74 if [ $1 -eq 0 ]; then
75     rm -rf /opt/access_management
76     /usr/sbin/userdel access-manager
77 fi
78
79 %clean
80 rm -rf %{buildroot}