#!/bin/bash

. $dracutfunctions
if [ -f $dsrc/modules.d/95osr-cluster/cluster-lib.sh ]; then
  . $dsrc/modules.d/95osr-cluster/cluster-lib.sh
else
  dwarning "osr-cluster: Cannot load cluster library. OSR-Cluster functionality will be reduced."
fi 


[ -z "$osr_querymap" ] && osr_querymap=/etc/osr/query-map.cfg

echo > /tmp/osr-nodeids
for nodeid in `com-queryclusterconf nodeids`; do 
	echo "$nodeid "`com-queryclusterconf -m $osr_querymap macs $nodeid` >> /tmp/osr-nodeids
	osr_generate_nodevalues $nodeid $osr_querymap > /tmp/osr-nodeidvalues-${nodeid}.conf
	inst_simple /tmp/osr-nodeidvalues-${nodeid}.conf /etc/conf.d/osr-nodeidvalues-${nodeid}.conf
done

dracut_install tr
dracut_install expr
dracut_install mkdir
dracut_install basename

inst "$moddir/lib/cluster-lib.sh" /lib/osr/

inst_simple /tmp/osr-nodeids
inst_simple /tmp/osr-nodeidvalues-${nodeid}.conf /etc/conf.d/osr-nodeidvalues-${nodeid}.conf

# Next the nodeid detection should be done as it can influence every other setting following afterwards.
inst "$moddir/osr-detect-nodeid.sh" "/sbin/osr-detect-nodeid"
inst "$moddir/osr-set-nodeconfig-net.sh" "/sbin/osr-set-nodeconfig-net"
inst "$moddir/osr-detect-root.sh" "/sbin/osr-detect-root"
inst "$moddir/osr-detect-syslog.sh" "/sbin/osr-detect-syslog"

inst_hook pre-udev 59 "$moddir/osr-net-genrules.sh"
inst_hook netroot  11 "$moddir/osr-detect-chroot.sh"
inst_hook netroot  50 "$moddir/osr-mount-chroot.sh"
