xcat-core/xCAT-nbroot/overlay/etc/init.d/S11stunnel

36 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#Stunnel init for xcat:
XCATDEST=""
XCATPORT=3001
killall stunnel > /dev/null 2>&1
for parm in `cat /proc/cmdline`; do
key=`echo $parm|awk -F= '{print $1}'`
if [ "$key" = "xcatd" ]; then
XCATDEST=`echo $parm|awk -F= '{print $2}'`
XCATPORT=`echo $XCATDEST|awk -F: '{print $2}'`
fi
done
mkdir -p /etc/stunnel
echo 'client=yes' > /etc/stunnel/stunnel.conf
echo 'foreground=yes' >> /etc/stunnel/stunnel.conf
echo 'output=/dev/null' >> /etc/stunnel/stunnel.conf
echo 'verify=0' >> /etc/stunnel/stunnel.conf
if [ ! -z "$XCATDEST" ]; then
echo '[xcatds]' >> /etc/stunnel/stunnel.conf
echo 'accept=127.0.0.1:301' >> /etc/stunnel/stunnel.conf
echo 'connect='$XCATDEST >> /etc/stunnel/stunnel.conf
fi
if [ -r /tmp/dhcpserver ]; then
((i=400));
for srv in `cat /tmp/dhcpserver`; do
echo "[xcatd$i]" >> /etc/stunnel/stunnel.conf
echo "accept=127.0.0.1:$i" >> /etc/stunnel/stunnel.conf
echo "connect="$srv":"$XCATPORT >> /etc/stunnel/stunnel.conf
((i=i+1))
done
fi
mkdir -p /usr/var/run/stunnel
stunnel &
sleep 2