summaryrefslogtreecommitdiff
path: root/stopYACY.sh
blob: f8baf57b106c2bc410cfd23dd8c977202aa7cbef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
cd `dirname $0`

# KILL YACY IF SCRIPT HAS BEEN STARTED WITH PARAMETER -f
if [ $# -eq 1 ]
then
    if [ $1 = "-f" ]
    then
        if [ -e "yacy.pid" ]
        then
            PID=`cat yacy.pid`
            kill -9 "$PID" 2> /dev/null
            if [ $? -ne 0 ]
            then
                echo "Unable to force closed YaCy, daemon seems to have terminated already."
            else
                echo "Force closed YaCy (process ID was $PID)."
            fi
        else
            echo "Unable to determine YaCy process ID, aborting operation."
        fi
    fi

# ELSE TRY TO STOP YACY GRACEFULLY
else

    if [ -x `which wget` ]
    then
            bin/apicall.sh "Steering.html?shutdown=true"

    echo "Please wait until the YaCy daemon process terminates [wget]"
    echo "You can monitor this with 'tail -f DATA/LOG/yacy00.log' and 'fuser log/yacy00.log'"

    elif [ -x `which curl` ]
    then
            bin/apicall.sh "Steering.html?shutdown=true"

    echo "Please wait until the YaCy daemon process terminates [curl]"
    echo "You can monitor this with 'tail -f DATA/LOG/yacy00.log' and 'fuser log/yacy00.log'"

    elif [ -x `which java` ]
    then
            # generating the proper classpath
            CLASSPATH=""
            for N in lib/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
            for N in libx/*.jar; do CLASSPATH="$CLASSPATH$N:"; done

            java -classpath classes:htroot:$CLASSPATH net.yacy.yacy -shutdown

            echo "Please wait until the YaCy daemon process terminates [java]"
            echo "You can monitor this with 'tail -f DATA/LOG/yacy00.log' and 'fuser log/yacy00.log'"

    else
            port=`cat DATA/SETTINGS/yacy.conf |grep "^port="|sed "s/.*=//"`
            echo "Neither wget nor java could be found or are not executable."
            echo "Visit http://localhost:$port/Steering.html?shutdown=true to stop YaCy or (in emergency case) use ./killYACY.sh"
    fi

fi