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