helpers/sonews
author František Kučera <franta-hg@frantovo.cz>
Wed, 12 Oct 2011 00:25:14 +0200
changeset 73 1feed5fbf147
parent 3 2fdc9cc89502
permissions -rwxr-xr-x
Drupal: vyhození zbytečností.
     1 #!/bin/bash
     2 
     3 CLASSPATH=/usr/share/java/sonews.jar:\
     4 /usr/share/java/sonews-helpers.jar:\
     5 /usr/share/java/mysql-connector-java.jar:\
     6 /usr/share/java/glassfish-mail.jar:\
     7 /usr/share/java/postgresql.jar
     8 
     9 LOGFILE=/var/log/sonews.log
    10 PIDFILE=/var/run/sonews.pid
    11 ARGS="-mlgw -c /etc/sonews/sonews.conf -feed"
    12 
    13 MAINCLASS=org.sonews.Main
    14 JAVA=java
    15 
    16 case "$1" in
    17   start)
    18     echo "Starting sonews Newsserver..."
    19     $JAVA -classpath $CLASSPATH $MAINCLASS $ARGS &> $LOGFILE &
    20     PID=$!
    21     echo $PID > $PIDFILE
    22     ;;
    23   stop)
    24     echo "Stopping sonews Newsserver..."
    25     PID=`cat $PIDFILE`
    26     STOPRES=0
    27     while [ $STOPRES -le 0 ]
    28     do
    29       kill -15 $PID &> /dev/null
    30       STOPRES=$?
    31       sleep 1
    32     done
    33     echo "done."
    34     ;;
    35   restart)
    36     $0 stop && $0 start
    37     ;;
    38   setup)
    39     $JAVA -classpath $CLASSPATH org.sonews.util.DatabaseSetup
    40     ;;
    41   purge)
    42     $JAVA -classpath $CLASSPATH org.sonews.util.Purger
    43     ;;
    44   version)
    45     $JAVA -classpath $CLASSPATH $MAINCLASS -version
    46     ;;
    47   *)
    48     echo "Usage: sonews [start|stop|restart|setup|purge]"
    49 esac