#!/bin/sh -eu

# This script basically takes storage.cfg
# generated by alterator-blivet's virtualization module
# and calls create_pmxcfs_db on it (similar to original pve-installer)
#
# This script actually should be postinstall
# (because there's no need for it at preinstall)
# But it's kinda impossible to populate files from before
# pkg-install step straight into stage3 environment
# without preinstall script anyway
  
. install2-init-functions

[ -d "/tmp/pve" ] || exit 0

mkdir -p "$destdir/tmp/pve/" ||:

cp -a /tmp/pve/* "$destdir/tmp/pve/" ||:
exec_chroot /usr/bin/create_pmxcfs_db /tmp/pve /var/lib/pve-cluster/config.db >/dev/null
