Author: nextgens Date: 2006-04-26 18:20:10 +0000 (Wed, 26 Apr 2006) New Revision: 8579
Modified: trunk/apps/installer/installclasspath/run.sh Log: installer: fix https://bugs.freenetproject.org/view.php?id=320, thanks to ljn1981 Modified: trunk/apps/installer/installclasspath/run.sh =================================================================== --- trunk/apps/installer/installclasspath/run.sh 2006-04-26 00:05:18 UTC (rev 8578) +++ trunk/apps/installer/installclasspath/run.sh 2006-04-26 18:20:10 UTC (rev 8579) @@ -48,6 +48,12 @@ # Do not modify anything beyond this point #----------------------------------------------------------------------------- +if [ "X`id -u`" = "X0" ] +then + echo "Do not run this script as root." + exit 1 +fi + # Get the fully qualified path to the script case $0 in /*) @@ -122,19 +128,6 @@ LOCKFILE="$LOCKDIR/$APP_NAME" pid="" -# Resolve the location of the 'ps' command -PSEXE="/usr/bin/ps" -if [ ! -x $PSEXE ] -then - PSEXE="/bin/ps" - if [ ! -x $PSEXE ] - then - echo "Unable to locate 'ps'." - echo "Please report this message along with the location of the command on your system." - exit 1 - fi -fi - # Resolve the os DIST_OS=`uname -s | tr [:upper:] [:lower:] | tr -d [:blank:]` case "$DIST_OS" in @@ -336,10 +329,10 @@ # It is possible that 'a' process with the pid exists but that it is not the # correct process. This can happen in a number of cases, but the most # common is during system startup after an unclean shutdown. - # The ps statement below looks for the specific wrapper command running as - # the pid. If it is not found then the pid file is considered to be stale. - pidtest=`$PSEXE -p $pid -o args | grep $WRAPPER_CMD | tail -1` - if [ "X$pidtest" = "X" ] + # So make sure the process is one of "ours" -- that we can send + # a signal to it. (We don't use ps(1) because that's neither + # safe nor portable. + if ! kill -0 $pid 2>/dev/null then # This is a stale pid file. rm -f $PIDFILE @@ -355,8 +348,7 @@ } testpid() { - pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` - if [ "X$pid" = "X" ] + if ! kill -0 $pid 2>/dev/null then # Process is gone so remove the pid file. rm -f $PIDFILE
