#!/bin/ash
#
#
#
 killall stunnel 2>/dev/null
 if [ ! -e /tmp/.stunnel.tmp ]; then
   cat /etc/stunnel/stunnel.conf | grep cert > /tmp/.stunnel.tmp
   sed -i s/" "//g /tmp/.stunnel.tmp
   . /tmp/.stunnel.tmp
   chmod 600 $cert
 fi
 ln -s /usr/share/server/services /etc/services 2>/dev/null
 mkdir /var/run/stunnel 2>/dev/null
 . /etc/server/daemon.conf
 . /etc/httpd/thttpd.conf
 . /etc/httpd/httpd.port
 if [ ! -e /etc/inetd/http.conf ]; then
   if [ ! -e $PID ]; then
     HTTPS=no
   fi
 fi
 if [ $HTTPS = yes ]; then
   sed -i /connect/d /etc/stunnel/stunnel.conf
   echo "connect = $PORT" >> /etc/stunnel/stunnel.conf
   sleep 0.25
   stunnel 2>/dev/null
 fi
