fdfb48
#!/bin/bash
fdfb48
#
fdfb48
# Launch the necessary OpenSM daemons for systemd
fdfb48
#
fdfb48
# sysconfig: /etc/sysconfig/opensm
fdfb48
# config: /etc/rdma/opensm.conf
fdfb48
#
fdfb48
fdfb48
shopt -s nullglob
fdfb48
fdfb48
prog=/usr/sbin/opensm
fdfb48
[ -f /etc/sysconfig/opensm ] && . /etc/sysconfig/opensm
fdfb48
fdfb48
[ -n "$PRIORITY" ] && prio="-p $PRIORITY"
fdfb48
fdfb48
if [ -z "$GUIDS" ]; then
fdfb48
	CONFIGS=""
fdfb48
	CONFIG_CNT=0
fdfb48
	for conf in /etc/rdma/opensm.conf.[0-9]*; do
fdfb48
		CONFIGS="$CONFIGS $conf"
fdfb48
		let CONFIG_CNT++
fdfb48
	done
fdfb48
else
fdfb48
	GUID_CNT=0
fdfb48
	for guid in $GUIDS; do
fdfb48
		let GUID_CNT++
fdfb48
	done
fdfb48
fi
fdfb48
# Start opensm
fdfb48
if [ -n "$GUIDS" ]; then
fdfb48
	SUBNET_COUNT=0
fdfb48
	for guid in $GUIDS; do
fdfb48
		SUBNET_PREFIX=`printf "0xfe800000000000%02d" $SUBNET_COUNT`
fdfb48
		(while true; do $prog $prio -g $guid --subnet_prefix $SUBNET_PREFIX; sleep 30; done) &
fdfb48
		let SUBNET_COUNT++
fdfb48
	done
fdfb48
elif [ -n "$CONFIGS" ]; then
fdfb48
	for config in $CONFIGS; do
fdfb48
		(while true; do $prog $prio -F $config; sleep 30; done) &
fdfb48
	done
fdfb48
else
fdfb48
	(while true; do $prog $prio; sleep 30; done) &
fdfb48
fi
fdfb48
exit 0