Sophie

Sophie

distrib > Mandriva > 7.2 > i586 > media > updates > by-pkgid > f9f85a36e562929ff0b3ce873fe9fadb > scriptlet

ApacheJServ-1.1.2-6.2mdk.i586.rpm

PREUN

/bin/sh
# do not remove the configured stuff if we upgrade.
# the $1 argument contains the number of packages _after_ installation.
if [ ! $1 -eq 0 ] ; then
   exit 0
fi

# Remove 'jserv' service (manual mode)
#/etc/rc.d/init.d/jserv stop
#/sbin/chkconfig --del jserv

# remove old logs
/bin/rm -fr /var/log/httpd/jserv/mod_jserv.log
/bin/rm -fr /var/log/httpd/jserv/jserv.log

perl -pi -e "s|Include conf/jserv/jserv.conf\n||g;" \
	/etc/httpd/conf/httpd.conf

POSTIN

/bin/sh

echo "Include conf/jserv/jserv.conf" >> /etc/httpd/conf/httpd.conf

# use fortune + install-date + process-list to create pseudo-random, hardly
# guessable secret key. Use md5sum to create a hash from this, if available:
(/usr/games/fortune 2>/dev/null ; date ; ps -eal 2>/dev/null)   \
		    | (md5sum 2>/dev/null || cat)   		\
		    > /etc/httpd/conf/jserv/jserv.secret.key 
chmod 600 /etc/httpd/conf/jserv/jserv.secret.key

#
# determine apache-USER and chown the jserv.secrect.key - file
#
APACHEUSER=`grep "^User[	 ]\+" /etc/httpd/conf/httpd.conf | awk '{print $2}'`
if test ! "x$APACHEUSER" = x ; then
   USERCOMMENT="(which is '$APACHEUSER' ?)"
else
   # assumption:
   APACHEUSER=apache
fi
chown $APACHEUSER /etc/httpd/conf/jserv/jserv.secret.key

#
# determine apache-GROUP and allow this group to write to /var/log/httpd
APACHEGROUP=`grep "^Group[	 ]\+" /etc/httpd/conf/httpd.conf | awk '{print $2}'`
if test "x$APACHEGROUP" = x ; then
   APACHEGROUP=apache
fi
chown $APACHEUSER.$APACHEGROUP /var/log/httpd/jserv

#
# Add 'jserv' as an independent service (manual mode)
#/sbin/chkconfig --add jserv
#/etc/rc.d/init.d/jserv start


#
# Search vor JAVA at possible locations and edit wrapper.bin
#
unset JAVABIN
for lookfor in java jre ; do
  for loc in \
    $JAVA_HOME	          \
    $JDK_HOME	          \
    /usr/jdk-sun1.2.2 \
    /usr/local/java       \
    /usr/local/jdk       \
    /usr/local/jdk117_v3  \
    /usr/local/jdk117_v1a
  do
    if test -x "$loc/bin/$lookfor" ; then
       JAVABIN="$loc/bin/$lookfor"
       break
    fi
  done

  if test -z "$JAVABIN" ; then
    for prefix in /usr/jdk /usr/jdk- /usr/local/jdk /usr/local/jdk- ; do
      for jplatform in 3 2 1 ; do
        for subvers in .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 "" ; do
          if test -x "${prefix}1.$jplatform$subvers/bin/$lookfor" ; then
	     JAVABIN="${prefix}1.$jplatform$subvers/bin/$lookfor"
	     break
	  fi
        done
	if test ! -z "$JAVABIN" ; then break ; fi
      done
      if test ! -z "$JAVABIN" ; then break ; fi
    done
  fi
  if test ! -z "$JAVABIN" ; then break ; fi
done

if test ! -z "$JAVABIN" ; then
   sed "s|^wrapper.bin=.*$|wrapper.bin=$JAVABIN|" \
       < /etc/httpd/conf/jserv/jserv.properties \
       > /etc/httpd/conf/jserv/jserv.properties.new
   mv /etc/httpd/conf/jserv/jserv.properties.new /etc/httpd/conf/jserv/jserv.properties
fi

#
# Get Server Port to echo right URL below
#
SERVERPORT=`grep "^Port" /etc/httpd/conf/httpd.conf | \
			head -1 | awk '{print ":" $2}'`
if test "$SERVERPORT" = ":80" ; then
	SERVERPORT=""
fi

#FIXME: make this i18n-aware

if test ! "x$JAVABIN" = x ; then
   echo "using java VM $JAVABIN"
else
   echo "## didn't find java or jre. Please install it and edit the"
   echo "## wrapper.bin property in /etc/httpd/conf/jserv/jserv.properties"
fi
echo ""
echo "In order to enable JServ, restart the webserver and try"
echo "		 http://localhost$SERVERPORT/servlets/IsItWorking"
echo "	 	(or  http://localhost$SERVERPORT/servlets/Hello"
echo "	 and"
echo "		 http://localhost$SERVERPORT/jserv/"
echo "-- ENJOY! --"
echo ""

## we hopefully may distribute SUN-jsdk.jar with jserv once ..
echo " | NOTE that this distribution contains a fully functional"
echo " | free jsdk replacement, see <http://www.euronet.nl/~pauls/java/servlet/>."
echo " | If you want to use the SUN-jsdk, replace the servlet-2.0.jar"
echo " | in the wrapper.classpath - line in the file"
echo " |		 /etc/httpd/conf/jserv/jserv.properties"
echo " | with the SUN jsdk."
echo " | Get it from <http://java.sun.com/products/servlet/>."
echo " | Only JSDK 2.0 (Java Servlet Development Kit)"
echo " | is supported (_EXACTLY_ 2.0)."
echo ""

echo "Please send comments/suggestions regarding"
echo "this RPM to <jmdault@mandrakesoft.com>."

AESctl update

POSTUN

/bin/sh
/usr/sbin/AESctl update