Add initial code
[ta/build-tools.git] / dib_elements / myproduct / finalise.d / 99-generate-binary-checksum
1 #!/bin/bash
2 # Copyright 2019 Nokia
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 if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
17     set -x
18 fi
19 set -eu
20 set -o pipefail
21
22 md5sum $(find / ! -path "/tmp/*" -executable -type f) > /root/binary_checksum.md5
23 sha256sum $(find / ! -path "/tmp/*" -executable -type f) > /root/binary_checksum.sha256
24
25 # Remove checksum that has been modified during deployment
26 changed_checksums=( "resolv.conf" "mariadb.sg" "rabbitmq-server.sg" "audit.rules" "influxdb.conf" "influxdb-1" )
27 for checksum in ${changed_checksums[@]}
28 do
29     sed -i "/${checksum}/d" /root/binary_checksum.md5
30     sed -i "/${checksum}/d" /root/binary_checksum.sha256
31 done
32
33 # Add checksums that will be added during deployment
34 checksums_to_add=(\
35 "/etc/openstack-dashboard/enabled/_2200_ironic.py" \
36 "/etc/openstack-dashboard/enabled/_2200_ironic.pyc" \
37 "/etc/openstack-dashboard/enabled/_2200_ironic.pyo" \
38 "/etc/openstack-dashboard/local_settings" \
39 "/etc/openstack-dashboard/nova_policy.json" \
40 "/etc/openstack-dashboard/neutron_policy.json" \
41 "/etc/openstack-dashboard/keystone_policy.json" \
42 "/etc/openstack-dashboard/glance_policy.json" \
43 "/etc/openstack-dashboard/cinder_policy.json" \
44 "/etc/openstack-dashboard/cinder_policy.d/consistencygroup.yaml" \
45 "/etc/openstack-dashboard/nova_policy.d/api-extensions.yaml" \
46 )
47 for f in ${checksums_to_add[@]}; do
48     if test -f ${f}; then
49         md5sum ${f} >> /root/binary_checksum.md5
50         sha256sum ${f} >> /root/binary_checksum.sha256
51     fi
52 done
53
54 # Include docker images
55 docker_images=$( find /var/lib/crf-images/docker-images/infra/ -type f ) || :
56 if [ -n "${docker_images}" ]; then
57     md5sum ${docker_images} >> /root/binary_checksum.md5
58     sha256sum ${docker_images} >> /root/binary_checksum.sha256
59 fi
60
61 # Sort the checksum files
62 sort -k2 -o /root/binary_checksum.md5 /root/binary_checksum.md5
63 sort -k2 -o /root/binary_checksum.sha256 /root/binary_checksum.sha256