python-django-horizon: install the init script
[pti/rtp.git] / meta-stx / recipes-devtools / python / python-django-horizon_15.1.0.bbappend
1 #
2 ## Copyright (C) 2019 Wind River Systems, Inc.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15
16 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
17 SRC_URI += " \
18         file://${BPN}/guni_config.py \
19         file://${BPN}/horizon-assets-compress \
20         file://${BPN}/horizon-clearsessions \
21         file://${BPN}/horizon.init \
22         file://${BPN}/horizon-patching-restart \
23         file://${BPN}/openstack-dashboard-httpd-2.4.conf \
24         file://${BPN}/openstack-dashboard-httpd-logging.conf \
25         file://${BPN}/python-django-horizon-logrotate.conf \
26         file://${BPN}/python-django-horizon-systemd.conf \
27         "
28
29 do_configure_prepend () {
30         cd ${S}
31
32         # STX remove troublesome files introduced by tox
33         rm -f openstack_dashboard/test/.secret_key_store
34         rm -f openstack_dashboard/test/*.secret_key_store.lock
35         rm -f openstack_dashboard/local/.secret_key_store
36         rm -f openstack_dashboard/local/*.secret_key_store.lock
37         rm -rf horizon.egg-info
38
39         # drop config snippet
40         cp -p ${WORKDIR}/${BPN}/openstack-dashboard-httpd-logging.conf .
41         cp -p ${WORKDIR}/${BPN}/guni_config.py .
42
43         # customize default settings
44         # WAS [PATCH] disable debug, move web root
45         sed -i "/^DEBUG =.*/c\DEBUG = False" openstack_dashboard/local/local_settings.py.example
46         sed -i "/^WEBROOT =.*/c\WEBROOT = '/dashboard/'" openstack_dashboard/local/local_settings.py.example
47         sed -i "/^.*ALLOWED_HOSTS =.*/c\ALLOWED_HOSTS = ['horizon.example.com', 'localhost']" openstack_dashboard/local/local_settings.py.example
48         sed -i "/^.*LOCAL_PATH =.*/c\LOCAL_PATH = '/tmp'" openstack_dashboard/local/local_settings.py.example
49         sed -i "/^.*POLICY_FILES_PATH =.*/c\POLICY_FILES_PATH = '/etc/openstack-dashboard'" openstack_dashboard/local/local_settings.py.example
50
51         sed -i "/^BIN_DIR = .*/c\BIN_DIR = '/usr/bin'" openstack_dashboard/settings.py
52         sed -i "/^COMPRESS_PARSER = .*/a COMPRESS_OFFLINE = True" openstack_dashboard/settings.py
53
54         # set COMPRESS_OFFLINE=True
55         sed -i 's:COMPRESS_OFFLINE.=.False:COMPRESS_OFFLINE = True:' openstack_dashboard/settings.py
56
57         # STX: MANIFEST needs .eslintrc files for angular
58         echo "include .eslintrc"   >> MANIFEST.in
59
60         # MANIFEST needs to include json and pot files under openstack_dashboard
61         echo "recursive-include openstack_dashboard *.json *.pot .eslintrc"   >> MANIFEST.in
62
63         # MANIFEST needs to include pot files  under horizon
64         echo "recursive-include horizon *.pot .eslintrc"   >> MANIFEST.in
65 }
66
67 do_install_append () {
68         cd ${S}
69
70         # STX
71         install -d -m 755 ${D}/opt/branding
72         mkdir -p ${D}${sysconfdir}/rc.d/init.d
73         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon.init ${D}${sysconfdir}/rc.d/init.d/horizon
74         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon.init ${D}${sysconfdir}/init.d/horizon
75         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-clearsessions ${D}/${bindir}/horizon-clearsessions
76         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-patching-restart ${D}/${bindir}/horizon-patching-restart
77         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-assets-compress ${D}/${bindir}/horizon-assets-compress
78
79         # drop httpd-conf snippet
80         install -m 0644 -D -p ${WORKDIR}/${BPN}/openstack-dashboard-httpd-2.4.conf ${D}${sysconfdir}/httpd/conf.d/openstack-dashboard.conf
81         install -d -m 755 ${D}${datadir}/openstack-dashboard
82         install -d -m 755 ${D}${sysconfdir}/openstack-dashboard
83
84         # create directory for systemd snippet
85         mkdir -p ${D}${systemd_system_unitdir}/httpd.service.d/
86         cp ${WORKDIR}/${BPN}/python-django-horizon-systemd.conf ${D}${systemd_system_unitdir}/httpd.service.d/openstack-dashboard.conf
87
88         # Copy everything to /usr/share
89         mv ${D}${libdir}/python2.7/site-packages/openstack_dashboard \
90            ${D}${datadir}/openstack-dashboard
91         cp manage.py ${D}${datadir}/openstack-dashboard
92
93         # STX
94         cp guni_config.py ${D}${datadir}/openstack-dashboard
95         rm -rf ${D}${libdir}/python2.7/site-packages/openstack_dashboard
96
97         # remove unnecessary .po files
98         find ${D} -name django.po -exec rm '{}' \;
99         find ${D} -name djangojs.po -exec rm '{}' \;
100
101         # Move config to /etc, symlink it back to /usr/share
102         mv ${D}${datadir}/openstack-dashboard/openstack_dashboard/local/local_settings.py.example ${D}${sysconfdir}/openstack-dashboard/local_settings
103
104         mv ${D}${datadir}/openstack-dashboard/openstack_dashboard/conf/*.json ${D}${sysconfdir}/openstack-dashboard
105         cp -a  ${S}/openstack_dashboard/conf/cinder_policy.d ${D}${sysconfdir}/openstack-dashboard
106         cp -a  ${S}/openstack_dashboard/conf/nova_policy.d ${D}${sysconfdir}/openstack-dashboard
107
108         # copy static files to ${datadir}/openstack-dashboard/static
109         mkdir -p ${D}${datadir}/openstack-dashboard/static
110         cp -a openstack_dashboard/static/* ${D}${datadir}/openstack-dashboard/static
111         cp -a horizon/static/* ${D}${datadir}/openstack-dashboard/static
112
113         # create /var/run/openstack-dashboard/ and /var/log/horizon
114         install -m 0755 -d ${D}/${sysconfdir}/tmpfiles.d
115         echo "d ${localstatedir}/run/openstack-dashboard 0755 root root -" >> ${D}/${sysconfdir}/tmpfiles.d/openstack-dashboard.conf
116         echo "d ${localstatedir}/log/horizon 0755 root root -" >> ${D}/${sysconfdir}/tmpfiles.d/openstack-dashboard.conf
117
118         # place logrotate config:
119         mkdir -p ${D}${sysconfdir}/logrotate.d
120         cp -a ${WORKDIR}/${BPN}/python-django-horizon-logrotate.conf ${D}${sysconfdir}/logrotate.d/openstack-dashboard
121
122         chown -R root:root ${D}
123 }
124
125 FILES_${PN} += "\
126         ${datadir}/openstack-dashboard \
127         ${systemd_system_unitdir} \
128         ${localstatedir} \
129         /opt \
130         "
131
132 RPROVIDES_${PN} = "openstack-dashboard"