2005-04-07 21:19:42 +02:00
|
|
|
#!/bin/sh
|
2006-10-02 17:52:20 +02:00
|
|
|
JAVA="`which java`"
|
|
|
|
LOGFILE="yacy.log"
|
2007-07-27 23:56:49 +02:00
|
|
|
OS="`uname`"
|
2007-06-17 23:19:00 +02:00
|
|
|
|
|
|
|
#check if OS is Sun Solaris or one of the OpenSolaris distributions and use different version of id if necessary
|
2007-07-27 23:56:49 +02:00
|
|
|
if [ $OS = "SunOS" ]
|
2007-06-17 23:19:00 +02:00
|
|
|
then
|
|
|
|
# only this version of id supports the parameter -u
|
|
|
|
ID="/usr/xpg4/bin/id"
|
|
|
|
else
|
|
|
|
# regular id for any other case (especially Linux and OSX)
|
|
|
|
ID="id"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "`$ID -u`" -eq 0 ]
|
2005-04-07 21:19:42 +02:00
|
|
|
then
|
|
|
|
echo
|
2006-03-23 21:12:23 +01:00
|
|
|
echo "For security reasons you should not run this script as root!"
|
2005-04-07 21:19:42 +02:00
|
|
|
echo
|
2006-02-04 17:24:05 +01:00
|
|
|
exit 1
|
2006-10-02 17:52:20 +02:00
|
|
|
elif [ ! -x "$JAVA" ]
|
2006-02-04 17:24:05 +01:00
|
|
|
then
|
2006-02-04 16:56:21 +01:00
|
|
|
echo "The java command is not executable."
|
2006-02-04 16:59:45 +01:00
|
|
|
echo "Either you have not installed java or it is not in your PATH"
|
2006-10-02 17:52:20 +02:00
|
|
|
#Cron supports setting the path in
|
|
|
|
#echo "Has this script been invoked by CRON?"
|
|
|
|
#echo "if so, please set PATH in the crontab, or set the correct path in the variable in this script."
|
2006-02-04 17:24:05 +01:00
|
|
|
exit 1
|
2006-07-26 20:22:14 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#startup YaCy
|
2006-10-02 17:52:20 +02:00
|
|
|
cd "`dirname $0`"
|
2006-07-26 20:22:14 +02:00
|
|
|
|
2006-10-02 18:00:04 +02:00
|
|
|
options="`getopt -n YaCy -o d,l,p,t -- $@`"
|
2006-07-26 20:22:14 +02:00
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
isparameter=0; #options or parameter part of getopts?
|
|
|
|
parameter="" #parameters will be collected here
|
|
|
|
|
|
|
|
LOGGING=0
|
|
|
|
DEBUG=0
|
|
|
|
PRINTONLY=0
|
2006-10-02 18:00:04 +02:00
|
|
|
TAILLOG=0
|
2006-07-26 20:22:14 +02:00
|
|
|
for option in $options;do
|
|
|
|
if [ $isparameter -ne 1 ];then #option
|
2006-10-02 17:52:20 +02:00
|
|
|
if [ "$option" = "-l" ];then
|
2006-07-26 20:22:14 +02:00
|
|
|
LOGGING=1
|
|
|
|
if [ $DEBUG -eq 1 ];then
|
|
|
|
echo "can not combine -l and -d"
|
|
|
|
exit 1;
|
|
|
|
fi
|
2006-10-02 18:00:04 +02:00
|
|
|
elif [ "$option" = "-d" ];then
|
2006-07-26 20:22:14 +02:00
|
|
|
DEBUG=1
|
|
|
|
if [ $LOGGING -eq 1 ];then
|
|
|
|
echo "can not combine -l and -d"
|
|
|
|
exit 1;
|
|
|
|
fi
|
2006-10-02 18:00:04 +02:00
|
|
|
elif [ "$option" = "-p" ];then
|
2006-07-26 20:22:14 +02:00
|
|
|
PRINTONLY=1
|
2006-10-02 18:00:04 +02:00
|
|
|
elif [ "$option" = "-t" ];then
|
|
|
|
TAILLOG=1
|
2006-07-26 20:22:14 +02:00
|
|
|
fi #which option
|
|
|
|
else #parameter
|
2006-10-02 17:29:52 +02:00
|
|
|
if [ x$option = "--" ];then #option / parameter seperator
|
2006-07-26 20:22:14 +02:00
|
|
|
isparameter=1;
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
parameter="$parameter $option"
|
|
|
|
fi
|
|
|
|
fi #parameter or option?
|
|
|
|
done
|
|
|
|
|
2006-10-02 17:52:20 +02:00
|
|
|
#echo $options;exit 0 #DEBUG for getopts
|
2006-07-26 20:22:14 +02:00
|
|
|
|
|
|
|
#get javastart args
|
|
|
|
java_args=""
|
2008-03-16 23:31:54 +01:00
|
|
|
if [ -f DATA/SETTINGS/yacy.conf ]
|
2006-07-26 20:22:14 +02:00
|
|
|
then
|
2007-01-03 00:16:18 +01:00
|
|
|
# startup memory
|
|
|
|
for i in Xmx Xms; do
|
2008-03-16 23:31:54 +01:00
|
|
|
j="`grep javastart_$i DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//'`";
|
2007-01-03 00:16:18 +01:00
|
|
|
if [ -n $j ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi;
|
2006-07-26 20:22:14 +02:00
|
|
|
done
|
2007-01-03 00:16:18 +01:00
|
|
|
|
|
|
|
# Priority
|
2008-03-16 23:31:54 +01:00
|
|
|
j="`grep javastart_priority DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//'`";
|
2007-07-27 23:56:49 +02:00
|
|
|
|
2007-01-03 21:54:14 +01:00
|
|
|
if [ ! -z "$j" ];then
|
|
|
|
if [ -n $j ]; then JAVA="nice -n $j $JAVA"; fi;
|
|
|
|
fi
|
2008-03-01 13:08:24 +01:00
|
|
|
|
2008-03-16 23:31:54 +01:00
|
|
|
PORT="`grep ^port= DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//'`";
|
2007-01-03 00:16:18 +01:00
|
|
|
|
2008-03-16 23:31:54 +01:00
|
|
|
# for i in `grep javastart DATA/SETTINGS/yacy.conf`;do
|
2007-01-03 00:16:18 +01:00
|
|
|
# i="${i#javastart_*=}";
|
|
|
|
# JAVA_ARGS="-$i $JAVA_ARGS";
|
|
|
|
# done
|
2008-02-04 23:58:40 +01:00
|
|
|
else
|
|
|
|
JAVA_ARGS="-Xmx120m -Xms120m $JAVA_ARGS";
|
2008-03-01 13:08:24 +01:00
|
|
|
PORT="8080"
|
2006-07-26 20:22:14 +02:00
|
|
|
fi
|
2008-03-16 23:31:54 +01:00
|
|
|
|
|
|
|
if [ -f DATA/SETTINGS/httpProx.conf ]
|
|
|
|
then
|
|
|
|
# startup memory
|
|
|
|
for i in Xmx Xms; do
|
|
|
|
j="`grep javastart_$i DATA/SETTINGS/httpProxy.conf | sed 's/^[^=]*=//'`";
|
|
|
|
if [ -n $j ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi;
|
|
|
|
done
|
|
|
|
|
|
|
|
# Priority
|
|
|
|
j="`grep javastart_priority DATA/SETTINGS/httpProxy.conf | sed 's/^[^=]*=//'`";
|
|
|
|
|
|
|
|
if [ ! -z "$j" ];then
|
|
|
|
if [ -n $j ]; then JAVA="nice -n $j $JAVA"; fi;
|
|
|
|
fi
|
|
|
|
|
|
|
|
PORT="`grep ^port= DATA/SETTINGS/httpProxy.conf | sed 's/^[^=]*=//'`";
|
|
|
|
fi
|
|
|
|
|
2007-01-03 21:54:14 +01:00
|
|
|
#echo "JAVA_ARGS: $JAVA_ARGS"
|
|
|
|
#echo "JAVA: $JAVA"
|
2006-07-26 20:22:14 +02:00
|
|
|
|
2007-07-29 17:29:49 +02:00
|
|
|
# generating the proper classpath
|
|
|
|
CLASSPATH=""
|
2007-07-31 22:41:54 +02:00
|
|
|
for N in lib/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
|
2007-07-29 17:29:49 +02:00
|
|
|
for N in libx/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
|
|
|
|
CLASSPATH="classes:.:htroot:$CLASSPATH"
|
|
|
|
|
2006-07-26 20:22:14 +02:00
|
|
|
cmdline="";
|
|
|
|
if [ $DEBUG -eq 1 ] #debug
|
|
|
|
then
|
2006-10-02 17:52:20 +02:00
|
|
|
cmdline="$JAVA $JAVA_ARGS -Djava.awt.headless=true -classpath $CLASSPATH yacy"
|
2006-07-26 20:22:14 +02:00
|
|
|
elif [ $LOGGING -eq 1 ];then #logging
|
2006-10-02 17:52:20 +02:00
|
|
|
cmdline="$JAVA $JAVA_ARGS -Djava.awt.headless=true -classpath $CLASSPATH yacy >> yacy.log &"
|
|
|
|
else
|
2008-01-29 22:27:06 +01:00
|
|
|
cmdline="$JAVA $JAVA_ARGS -Djava.awt.headless=true -classpath $CLASSPATH yacy >> /dev/null &"
|
2006-10-02 17:52:20 +02:00
|
|
|
fi
|
|
|
|
if [ $PRINTONLY -eq 1 ];then
|
|
|
|
echo $cmdline
|
2006-07-26 20:22:14 +02:00
|
|
|
else
|
2006-10-02 17:52:20 +02:00
|
|
|
echo "****************** YaCy Web Crawler/Indexer & Search Engine *******************"
|
|
|
|
echo "**** (C) by Michael Peter Christen, usage granted under the GPL Version 2 ****"
|
2007-09-01 13:24:23 +02:00
|
|
|
echo "**** USE AT YOUR OWN RISK! Project home and releases: http://yacy.net/ ****"
|
2006-10-02 17:52:20 +02:00
|
|
|
echo "** LOG of YaCy: DATA/LOG/yacy00.log (and yacy<xx>.log) **"
|
|
|
|
echo "** STOP YaCy: execute stopYACY.sh and wait some seconds **"
|
2007-07-19 17:32:10 +02:00
|
|
|
echo "** GET HELP for YaCy: see www.yacy-websearch.net/wiki and forum.yacy.de **"
|
2006-10-02 17:52:20 +02:00
|
|
|
echo "*******************************************************************************"
|
2008-03-01 13:08:24 +01:00
|
|
|
echo " >> YaCy started as daemon process. Administration at http://localhost:$PORT << "
|
2006-10-02 17:52:20 +02:00
|
|
|
eval $cmdline
|
2006-10-02 18:00:04 +02:00
|
|
|
if [ "$TAILLOG" -eq "1" -a ! "$DEBUG" -eq "1" ];then
|
|
|
|
tail -f DATA/LOG/yacy00.log
|
|
|
|
fi
|
2005-04-07 21:19:42 +02:00
|
|
|
fi
|