infrastructure/roles/minecraft_blockmap/templates/render.sh

48 lines
2.2 KiB
Bash
Raw Normal View History

2020-08-10 01:37:13 +02:00
#!/bin/sh
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
echo "Creating snapshot:"
lvcreate -L 1G -n {{ minecraft_blockmap_lv_name }}_mc_snap -s {{ minecraft_blockmap_vg_name }}/{{ minecraft_blockmap_lv_name }}
echo "Mount snapshots:"
mount -o ro,nosuid,noexec{% if minecraft_blockmap_fstype is defined and minecraft_blockmap_fstype == "xfs" %},nouuid{% endif %} -t {{ minecraft_blockmap_fstype | default("ext4") }} /dev/{{ minecraft_blockmap_vg_name }}/{{ minecraft_blockmap_lv_name }}_mc_snap /blockmap_snapshot
echo "Start blockmap container:"
docker pull {{ minecraft_blockmap_image }}:{{ minecraft_blockmap_image_version }}
docker run --name=blockmap-renderer \
--security-opt "label=disable" \
--security-opt "no-new-privileges" \
--cap-drop=ALL \
--cap-add=DAC_OVERRIDE \
--rm \
-v "/blockmap_snapshot/{{ minecraft_blockmap_input_location }}:/input:ro" \
-v "{{ minecraft_blockmap_config_location }}/blockmap.json:/config.json:ro" \
-v "{{ minecraft_blockmap_output_location }}:/output" \
{{ minecraft_blockmap_image }}:{{ minecraft_blockmap_image_version }} {{ minecraft_blockmap_parameters }}
echo "Archive render output..."
cp -rf {{ minecraft_blockmap_output_location }} "{{ minecraft_blockmap_archive_location }}/$(date +"%d-%m-%Y")"
echo "Unmount snapshot:"
umount /dev/{{ minecraft_blockmap_vg_name }}/{{ minecraft_blockmap_lv_name }}_mc_snap
echo "Remove snapshot:"
lvremove -f {{ minecraft_blockmap_vg_name }}/{{ minecraft_blockmap_lv_name }}_mc_snap
echo "Finished"