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