]>
Commit | Line | Data |
---|---|---|
320694f6 JB |
1 | #!/bin/sh |
2 | # | |
3 | # cWnn This shell script takes care of starting and stopping | |
4 | # cserver (Chinese Conversion Engine). | |
5 | # | |
6 | # chkconfig: 345 90 12 | |
7 | # description: cWnn - Chinese(zh_CN) Conversion Engine | |
8 | # processname: cserver | |
9 | ||
10 | # Source function library. | |
11 | . /etc/init.d/functions | |
12 | ||
13 | # Source networking configuration. | |
14 | . /etc/sysconfig/network | |
15 | ||
16 | # Get service config | |
17 | [ -f /etc/sysconfig/cWnn ] && . /etc/sysconfig/cWnn | |
18 | ||
19 | # Check that networking is up. | |
869cff65 | 20 | if is_yes "${NETWORKING}"; then |
af825fad | 21 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
869cff65 | 22 | msg_network_down cWnn |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
320694f6 JB |
27 | fi |
28 | ||
c4fa925d | 29 | if [ -f /etc/FreeWnn/zh_CN/cserverrc ]; then |
30 | nls "%s config %s does not exist." cWnn /etc/FreeWnn/zh_CN/cserverrc | |
31 | exit 6 | |
32 | fi | |
320694f6 | 33 | |
1395a66d | 34 | start() { |
320694f6 JB |
35 | if [ ! -f /var/lock/subsys/cWnn ]; then |
36 | msg_starting cWnn | |
37 | rm -f /tmp/jd_sockV4 | |
38 | ( su - wnn -s /bin/sh -c '/usr/bin/cserver' | grep "Finished" > /dev/null ) \ | |
39 | && ok || fail | |
40 | RETVAL=$? | |
149096ad | 41 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cWnn || RETVAL=1 |
320694f6 JB |
42 | else |
43 | msg_already_running cWnn | |
320694f6 | 44 | fi |
1395a66d JB |
45 | } |
46 | ||
47 | stop() { | |
320694f6 JB |
48 | if [ -f /var/lock/subsys/cWnn ]; then |
49 | msg_stopping cWnn | |
50 | killproc cserver | |
320694f6 | 51 | rm -f /var/lock/subsys/cWnn /tmp/jd_sockV4 |
320694f6 JB |
52 | else |
53 | msg_not_running cWnn | |
320694f6 | 54 | fi |
1395a66d JB |
55 | } |
56 | ||
57 | condrestart() { | |
58 | if [ ! -f /var/lock/subsys/cWnn ]; then | |
59 | msg_not_running cWnn | |
60 | RETVAL=$1 | |
61 | return | |
62 | fi | |
63 | stop | |
64 | start | |
65 | } | |
66 | ||
67 | RETVAL=0 | |
68 | # See how we were called. | |
69 | case "$1" in | |
70 | start) | |
71 | start | |
72 | ;; | |
73 | stop) | |
74 | stop | |
320694f6 | 75 | ;; |
149096ad | 76 | status) |
320694f6 | 77 | status cserver |
1395a66d JB |
78 | RETVAL=$? |
79 | ;; | |
80 | restart) | |
81 | stop | |
82 | start | |
83 | ;; | |
84 | try-restart) | |
85 | condrestart 0 | |
320694f6 | 86 | ;; |
1395a66d JB |
87 | force-reload) |
88 | condrestart 7 | |
320694f6 | 89 | ;; |
149096ad | 90 | *) |
1395a66d | 91 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
149096ad | 92 | exit 3 |
320694f6 JB |
93 | ;; |
94 | esac | |
95 | ||
149096ad | 96 | exit $RETVAL |