summaryrefslogtreecommitdiff
path: root/addon/yacyInit.sh
diff options
context:
space:
mode:
Diffstat (limited to 'addon/yacyInit.sh')
-rwxr-xr-xaddon/yacyInit.sh78
1 files changed, 78 insertions, 0 deletions
diff --git a/addon/yacyInit.sh b/addon/yacyInit.sh
new file mode 100755
index 000000000..189757239
--- /dev/null
+++ b/addon/yacyInit.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+#
+# init script for the HTTP Proxy: yacy
+#
+# Provided by Matthias Kempka, 26.12.2004
+
+PATH=/sbin:/bin:/usr/sbin:/usr/local/bin:/usr/bin #ensure java is in the path
+DAEMON_DIR=/opt/yacy #installation directory
+USER=yacy #set to the user whose rights the proxy will gain
+
+
+CLASSPATH=$DAEMON_DIR/classes
+DAEMON=$DAEMON_DIR/startYACY.sh
+NAME="yacy"
+DESC="Yacy HTTP Proxy"
+PID_FILE=/var/run/$NAME.pid
+
+# Don't run if not installed
+test -f $DAEMON || exit 0
+
+JAVA=$(which java)
+
+if [ -f $PID_FILE ]; then
+ pid=$(cat "$PID_FILE")
+ pidno=$( ps ax | grep "$pid" | awk '{ print $1 }' | grep "$pid" )
+fi
+
+case "$1" in
+ start)
+ if [ -n "$pidno" ]; then
+ echo "already running"
+ exit 0
+ fi
+ echo -n "Starting $DESC: "
+ start-stop-daemon --start --background --make-pidfile --chuid $USER\
+ --pidfile $PID_FILE --startas $JAVA\
+ -- -classpath $CLASSPATH yacy $DAEMON_DIR
+ echo "$NAME."
+ ;;
+
+ stop)
+ if [ -n "$pidno" ]; then
+ echo -n "Stopping $DESC: "
+ cd $DAEMON_DIR
+ ./stopYACY.sh
+ timeout=20
+ while [ -n "$pidno" ]
+ do
+ let timeout=$timeout-1
+ if [ $timeout -eq 0 ]; then
+ start-stop-daemon --stop --pidfile $PID_FILE --oknodo
+ break
+ fi
+ echo -n "."
+ sleep 1
+ pidno=$( ps ax | grep $pid | awk '{ print $1 }' | grep $pid )
+ done
+ echo "$NAME."
+ cd -
+ exit 0
+ fi
+ echo "not running."
+ ;;
+
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ N=/etc/init.d/yacyInit.sh
+ # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $N {start|stop|restart}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0