#!/usr/bin/awk -f
#
# Copyright (c) 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#pragma ident	"@(#)convert_did.sh	1.2	99/03/16 SMI"
#

# This script is a temporary solution to allow manual upgrades
# of SC 2.2 clusters to SC 3.x clusters. Eventually, didadm will
# support a convert option, and this script will no longer be
# necessary. No references should be made in gate code to this
# script.

BEGIN { instance = 0; subpath = 1}
/^instance/{
	instance = $2
	subpath = 1;
}
/^\tsubpath/{
	paths[subpath++] = $2;
}
/^\tdiskid/{
	diskid = $2
}
/^\ttype/{
	type = $2
}
/^# /{
	diskid_text = substr($0,3);	
}
/^#$/{
	if (instance > 0) {
		if (diskid_text > 0) {
			printf("%s\tdisk|%s|%s|%s", instance, type, diskid_text, diskid);
			for (i = 1; i < subpath; ++i) {
				printf("|%s", paths[i]);
			}
			printf("\n");
		}
		instance = 0;
		subpath = 1;
		diskid_text = "";  
	}
	
}
END{
	if (instance > 0) {
		if (diskid_text > 0) {
			printf("%s\tdisk|%s|%s|%s", instance, type, diskid_text, diskid);
			for (i = 1; i < subpath; ++i) {
				printf("|%s", paths[i]);
			}
			printf("\n");
		}
	}
}
