2014-08-25 22:47:33 +02:00
#!/usr/bin/env sh
2006-10-02 17:52:20 +02:00
JAVA = "`which java`"
2008-03-17 13:51:46 +01:00
CONFIGFILE = "DATA/SETTINGS/yacy.conf"
2006-10-02 17:52:20 +02:00
LOGFILE = "yacy.log"
2008-07-24 20:56:29 +02:00
PIDFILE = "yacy.pid"
2007-07-27 23:56:49 +02:00
OS = "`uname`"
2007-06-17 23:19:00 +02:00
2009-05-05 20:49:51 +02:00
#get javastart args
2015-07-29 23:30:05 +02:00
JAVA_ARGS = "-server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djsse.enableSNIExtension=false" ;
#rem -Djsse.enableSNIExtension=false fix a ssl problem in Java 1.7, see http://teknosrc.com/javax-net-ssl-sslprotocolexception-handshake-alert-unrecognized_name-solved/
2009-05-05 20:49:51 +02:00
#JAVA_ARGS="-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails $JAVA_ARGS";
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
2013-12-19 09:04:23 +01:00
if [ ! -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
2008-08-25 19:17:01 +02:00
usage( ) {
cat - <<USAGE
startscript for YaCy on UNIX-like systems
Options
-h, --help show this help
-t, --tail-log show the output of "tail -f DATA/LOG/yacy00.log" after starting YaCy
-l, --logging save the output of YaCy to yacy.log
-d, --debug show the output of YaCy on the console
-p, --print-out only print the command, which would be executed to start YaCy
2015-02-25 21:11:59 +01:00
-g, --gui start a gui for YaCy
2008-08-25 19:17:01 +02:00
USAGE
}
2006-07-26 20:22:14 +02:00
#startup YaCy
2006-10-02 17:52:20 +02:00
cd " `dirname $0 ` "
2006-07-26 20:22:14 +02:00
2015-02-23 22:54:49 +01:00
if [ $OS = "OpenBSD" ]
then
if [ $( echo $@ | grep -o "\-\-" | wc -l) -ne 0 ]
then
echo " WARNING: Unfortunately this script does not support long options in $OS . "
fi
2015-02-25 21:11:59 +01:00
options = " `getopt hdlptg: $* ` "
2015-02-23 22:54:49 +01:00
else
options = " `getopt -n YaCy -o h,d,l,p,t,g -l help,debug,logging,print-out,tail-log,gui -- $@ ` "
fi
2006-07-26 20:22:14 +02:00
if [ $? -ne 0 ] ; then
2015-02-23 22:54:49 +01:00
2006-07-26 20:22:14 +02:00
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
2010-08-05 12:43:03 +02:00
GUI = 0
2006-07-26 20:22:14 +02:00
for option in $options ; do
if [ $isparameter -ne 1 ] ; then #option
2008-08-25 19:17:01 +02:00
case $option in
-h| --help)
usage
exit 3
; ;
-l| --logging)
LOGGING = 1
if [ $DEBUG -eq 1 ] ; then
echo "can not combine -l and -d"
exit 1;
fi
; ;
-d| --debug)
DEBUG = 1
2009-05-05 20:49:51 +02:00
# enable asserts
2010-01-17 01:41:50 +01:00
JAVA_ARGS = " $JAVA_ARGS -ea -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
2008-08-25 19:17:01 +02:00
if [ $LOGGING -eq 1 ] ; then
echo "can not combine -l and -d"
exit 1;
fi
; ;
-p| --print-out)
PRINTONLY = 1
; ;
-t| --tail-log)
TAILLOG = 1
; ;
2015-02-23 22:54:49 +01:00
-g| --gui)
2010-08-05 12:43:03 +02:00
GUI = 1
2010-09-04 01:08:43 +02:00
isparameter = 1
2010-08-05 12:43:03 +02:00
; ;
2008-08-25 19:17:01 +02:00
esac #case option
2006-07-26 20:22:14 +02:00
else #parameter
2010-01-17 01:41:50 +01:00
if [ x$option = "--" ] ; then #option / parameter separator
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
2008-08-10 14:02:11 +02:00
#check if Linux system supports large memory pages or if OS is Solaris which
#supports large memory pages since version 9
#(according to http://java.sun.com/javase/technologies/hotspot/largememory.jsp)
ENABLEHUGEPAGES = 0;
if [ $OS = "Linux" ]
then
HUGEPAGESTOTAL = "`cat /proc/meminfo | grep HugePages_Total | sed s/[^0-9]//g`"
if [ -n " $HUGEPAGESTOTAL " ] && [ $HUGEPAGESTOTAL -ne 0 ]
then
ENABLEHUGEPAGES = 1
fi
2011-08-31 18:02:06 +02:00
# the G1 GC is on by default in Java7, so we try that here as well
# JAVA_ARGS="$JAVA_ARGS -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC"
2008-08-10 15:03:36 +02:00
elif [ $OS = "SunOS" ]
then
2008-09-14 22:35:50 +02:00
# the UseConcMarkSweepGC option caused a full CPU usage - bug on Darwin.
# It was reported that the same option causes good performance on solaris.
JAVA_ARGS = " $JAVA_ARGS -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode "
2008-08-10 15:03:36 +02:00
ENABLEHUGEPAGES = 1
2008-08-10 14:02:11 +02:00
fi
#turn on support for large memory pages if supported by OS
if [ $ENABLEHUGEPAGES -eq 1 ]
then
JAVA_ARGS = " $JAVA_ARGS -XX:+UseLargePages "
fi
2013-01-21 17:55:28 +01:00
#turn on MMap for Solr if OS is a 64bit OS
2014-01-18 12:54:14 +01:00
if [ -n "`uname -m | grep 64`" ] ; then JAVA_ARGS = " $JAVA_ARGS -Dsolr.directoryFactory=solr.MMapDirectoryFactory " ; fi
2013-01-21 17:55:28 +01:00
2008-03-17 13:51:46 +01:00
if [ ! -f $CONFIGFILE -a -f DATA/SETTINGS/httpProxy.conf ]
then
# old config if new does not exist
CONFIGFILE = "DATA/SETTINGS/httpProxy.conf"
fi
if [ -f $CONFIGFILE ]
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-17 13:51:46 +01:00
j = " `grep javastart_ $i $CONFIGFILE | 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-17 13:51:46 +01:00
j = " `grep javastart_priority $CONFIGFILE | 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-17 13:51:46 +01:00
PORT = " `grep ^port= $CONFIGFILE | sed 's/^[^=]*=//'` " ;
2007-01-03 00:16:18 +01:00
2008-03-17 13:51:46 +01:00
# for i in `grep javastart $CONFIGFILE`;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
2010-08-27 20:38:02 +02:00
JAVA_ARGS = " -Xmx600m -Xms180m $JAVA_ARGS " ;
2011-01-28 11:54:13 +01:00
PORT = "8090"
2006-07-26 20:22:14 +02:00
fi
2008-03-16 23:31:54 +01:00
2008-03-17 14:02:39 +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
2009-09-15 19:29:18 +02:00
CLASSPATH = " .:htroot: $CLASSPATH "
2007-07-29 17:29:49 +02:00
2010-09-07 19:13:47 +02:00
cmdline = " $JAVA $JAVA_ARGS -classpath $CLASSPATH net.yacy.yacy " ;
2010-08-05 12:43:03 +02:00
if [ $GUI -eq 1 ] #gui
then
2010-09-04 01:08:43 +02:00
cmdline = " $cmdline -gui $parameter "
2010-08-05 12:43:03 +02:00
fi
2015-01-23 18:34:38 +01:00
if [ $DEBUG -eq 1 ] #debug
2006-07-26 20:22:14 +02:00
then
2008-08-20 09:57:47 +02:00
cmdline = $cmdline
2006-07-26 20:22:14 +02:00
elif [ $LOGGING -eq 1 ] ; then #logging
2008-08-20 09:57:47 +02:00
cmdline = " $cmdline >> yacy.log & echo \$! > $PIDFILE "
2006-10-02 17:52:20 +02:00
else
2015-01-30 21:17:23 +01:00
cmdline = " $cmdline >/dev/null 2>/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 **"
2010-11-05 14:20:51 +01:00
echo "** GET HELP for YaCy: see http://wiki.yacy.net and http://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
2008-08-25 19:17:01 +02:00
sleep 1
2006-10-02 18:00:04 +02:00
tail -f DATA/LOG/yacy00.log
fi
2005-04-07 21:19:42 +02:00
fi