Ticket #864: zimreader

File zimreader, 783 bytes (added by elhennig, 2 years ago)

placed in /etc/init.d

Line 
1#!/bin/bash
2. /etc/default/rcS
3
4pid=`ps ax | grep ZimReader | grep -v grep | awk '{print $1}'`
5
6case "$1" in
7  start)
8    if [ "x$pid" = "x" ]; then
9        cd /usr/share/openzim
10        ./zimreader >/tmp/zim.log &
11        log=""
12        while [ "x$log" = "x" ]; do
13           sleep 2
14           log=`cat /tmp/zim.log`
15        done
16    fi
17    ;;
18  stop)
19    if [ "x$pid" != "x" ]; then
20       kill $pid
21       [ -f /tmp/zim.log ] && rm -f /tmp/zim.log
22    fi
23       ;;
24  restart)
25    $0 stop
26    $0 start
27    ;;
28  switch)
29        pid=`ps ax | grep -v grep | grep "/bin/sh ./zimreader" | awk '{print $1}'`
30        if [ -n "$pid" ]; then
31            $0 stop
32        else
33            $0 start
34        fi
35    ;;
36
37  *)
38    echo "Usage: $0 {start|stop|restart|switch}"
39    exit 1
40esac
41
42
43
44