#!/bin/bash

. ${TOOLKIT}-functions.sh

file=relink.cfg

# creates a new relink.cfg file, if not already here

[ -f /w/$file ] && exit 0	# NOTHING TO DO

out=$file.tmp
src=$(filepath $file)
cnt=0

echo "  creating new /w/$file ... "
cp $src $out


for uuid in $(ls -d /srv/dev-disk-by-uuid-* 2>/dev/null | sed -e 's#.*dev-disk-by-uuid-##')
do
	[ -f /w/$file ] && {
		buf=$(grep $uuid /w/$file || :)
		[ "X$buf" != "X" ] && {
			echo "  $buf  (already exists)"
			echo $buf >>$out
			continue
		}
	}
	echo >>$out
	echo "# added by kusa on $(date)" >>$out
	echo "# please change label with one of your choiche" >>$out
	echo "_CHANGE_ME_$cnt	$uuid" >>$out

	cnt=$(($cnt+1))
done

exit 0
