/camera/camlib

To get this branch, use:
bzr branch http://darksoft.org/webbzr/camera/camlib

« back to all changes in this revision

Viewing changes to misc/pfcom.suse

  • Committer: Suren A. Chilingaryan
  • Date: 2011-02-13 01:33:37 UTC
  • Revision ID: csa@dside.dyndns.org-20110213013337-ibm4w4n5a3hu4k7u
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
#     Template LSB system startup script for example service/daemon FOO
 
4
#     Copyright (C) 1995--2005  Kurt Garloff, SUSE / Novell Inc.
 
5
#     Copyright (C) 2010  Silicon Software GmbH
 
6
#
 
7
#     This library is free software; you can redistribute it and/or modify it
 
8
#     under the terms of the GNU Lesser General Public License as published by
 
9
#     the Free Software Foundation; either version 2.1 of the License, or (at
 
10
#     your option) any later version.
 
11
#
 
12
#     This library is distributed in the hope that it will be useful, but
 
13
#     WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
#     Lesser General Public License for more details.
 
16
#
 
17
#     You should have received a copy of the GNU Lesser General Public
 
18
#     License along with this library; if not, write to the Free Software
 
19
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
 
20
#     USA.
 
21
#
 
22
# /etc/init.d/siso-gbe
 
23
#
 
24
# chkconfig: 345 99 00
 
25
# description: camera control proxy daemon
 
26
#
 
27
### BEGIN INIT INFO
 
28
# Provides:          pfcom
 
29
# Required-Start:    $syslog $remote_fs $time $network
 
30
# Required-Stop:     $syslog $remote_fs
 
31
# Default-Start:     3 4 5
 
32
# Default-Stop:      0 1 2 6
 
33
# Short-Description: camera control proxy daemon
 
34
# Description:       camera control proxy daemon
 
35
### END INIT INFO
 
36
 
 
37
 
 
38
# Default: Assume sysvinit binaries exist
 
39
start_daemon() { /sbin/start_daemon ${1+"$@"}; }
 
40
killproc()     { /sbin/killproc     ${1+"$@"}; }
 
41
pidofproc()    { /sbin/pidofproc    ${1+"$@"}; }
 
42
checkproc()    { /sbin/checkproc    ${1+"$@"}; }
 
43
 
 
44
if test -e /etc/rc.status; then
 
45
    # SUSE rc script library
 
46
    . /etc/rc.status
 
47
else
 
48
    export LC_ALL=POSIX
 
49
    _cmd=$1
 
50
    declare -a _SMSG
 
51
    if test "${_cmd}" = "status"; then
 
52
        _SMSG=(running dead dead unused unknown reserved)
 
53
        _RC_UNUSED=3
 
54
    else
 
55
        _SMSG=(done failed failed missed failed skipped unused failed failed reserved)
 
56
        _RC_UNUSED=6
 
57
    fi
 
58
    if test -e /lib/lsb/init-functions; then
 
59
        # LSB    
 
60
        . /lib/lsb/init-functions
 
61
        echo_rc()
 
62
        {
 
63
            if test ${_RC_RV} = 0; then
 
64
                log_success_msg "  [${_SMSG[${_RC_RV}]}] "
 
65
            else
 
66
                log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
 
67
            fi
 
68
        }
 
69
        # TODO: Add checking for lockfiles
 
70
        checkproc() { return pidofproc ${1+"$@"} >/dev/null 2>&1; }
 
71
    elif test -e /etc/init.d/functions; then
 
72
        # RHAT
 
73
        . /etc/init.d/functions
 
74
        echo_rc()
 
75
        {
 
76
            #echo -n "  [${_SMSG[${_RC_RV}]}] "
 
77
            if test ${_RC_RV} = 0; then
 
78
                success "  [${_SMSG[${_RC_RV}]}] "
 
79
            else
 
80
                failure "  [${_SMSG[${_RC_RV}]}] "
 
81
            fi
 
82
        }
 
83
        checkproc() { return status ${1+"$@"}; }
 
84
        start_daemon() { return daemon ${1+"$@"}; }
 
85
    else
 
86
        # emulate it
 
87
        echo_rc() { echo "  [${_SMSG[${_RC_RV}]}] "; }
 
88
    fi
 
89
    rc_reset() { _RC_RV=0; }
 
90
    rc_failed()
 
91
    {
 
92
        if test -z "$1"; then 
 
93
            _RC_RV=1;
 
94
        elif test "$1" != "0"; then 
 
95
            _RC_RV=$1; 
 
96
        fi
 
97
        return ${_RC_RV}
 
98
    }
 
99
    rc_check()
 
100
    {
 
101
        return rc_failed $?
 
102
    }   
 
103
    rc_status()
 
104
    {
 
105
        rc_failed $?
 
106
        if test "$1" = "-r"; then _RC_RV=0; shift; fi
 
107
        if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi
 
108
        if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi
 
109
        if test "$1" = "-v"; then echo_rc; shift; fi
 
110
        if test "$1" = "-r"; then _RC_RV=0; shift; fi
 
111
        return ${_RC_RV}
 
112
    }
 
113
    rc_exit() { exit ${_RC_RV}; }
 
114
    rc_active() 
 
115
    {
 
116
        if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi
 
117
        if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi
 
118
        return 1
 
119
    }
 
120
fi
 
121
 
 
122
# Reset status of this service
 
123
rc_reset
 
124
 
 
125
# Return values acc. to LSB for all commands but status:
 
126
# 0       - success
 
127
# 1       - generic or unspecified error
 
128
# 2       - invalid or excess argument(s)
 
129
# 3       - unimplemented feature (e.g. "reload")
 
130
# 4       - user had insufficient privileges
 
131
# 5       - program is not installed
 
132
# 6       - program is not configured
 
133
# 7       - program is not running
 
134
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
 
135
 
136
# Note that starting an already running service, stopping
 
137
# or restarting a not-running service as well as the restart
 
138
# with force-reload (in case signaling is not supported) are
 
139
# considered a success.
 
140
 
 
141
case "$1" in
 
142
    start)
 
143
        echo -n "Starting pfserver "
 
144
        ## Start daemon with startproc(8). If this fails
 
145
        ## the return value is set appropriately by startproc.
 
146
        start_daemon -p /var/run/pfcomserver.pid -l /var/log/pfcomserver.log /opt/camera/bin/pfserver
 
147
 
 
148
        # Remember status and be verbose
 
149
        rc_status -v
 
150
        ;;
 
151
    stop)
 
152
        echo -n "Shutting down pfserver "
 
153
        ## Stop daemon with killproc(8) and if this fails
 
154
        ## killproc sets the return value according to LSB.
 
155
        killproc -TERM /opt/camera/bin/pfserver -p /var/run/pfcomserver.pid
 
156
 
 
157
        # Remember status and be verbose
 
158
        rc_status -v
 
159
        ;;
 
160
    try-restart|condrestart)
 
161
        ## Do a restart only if the service was active before.
 
162
        ## Note: try-restart is now part of LSB (as of 1.9).
 
163
        ## RH has a similar command named condrestart.
 
164
        if test "$1" = "condrestart"; then
 
165
                echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
 
166
        fi
 
167
        $0 status
 
168
        if test $? = 0; then
 
169
                $0 restart
 
170
        else
 
171
                rc_reset        # Not running is not a failure.
 
172
        fi
 
173
        # Remember status and be quiet
 
174
        rc_status
 
175
        ;;
 
176
    restart)
 
177
        ## Stop the service and regardless of whether it was
 
178
        ## running or not, start it again.
 
179
        $0 stop
 
180
        $0 start
 
181
 
 
182
        # Remember status and be quiet
 
183
        rc_status
 
184
        ;;
 
185
    force-reload)
 
186
        $0 try-restart
 
187
        rc_status
 
188
        ;;
 
189
    reload)
 
190
        rc_failed 3
 
191
        rc_status -v
 
192
        ;;
 
193
    status)
 
194
        echo -n "Checking for pfserver "
 
195
        ## Check status with checkproc(8), if process is running
 
196
        ## checkproc will return with exit status 0.
 
197
 
 
198
        # Return value is slightly different for the status command:
 
199
        # 0 - service up and running
 
200
        # 1 - service dead, but /var/run/  pid  file exists
 
201
        # 2 - service dead, but /var/lock/ lock file exists
 
202
        # 3 - service not running (unused)
 
203
        # 4 - service status unknown :-(
 
204
        # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
 
205
        
 
206
        # NOTE: checkproc returns LSB compliant status values.
 
207
        checkproc /opt/camera/bin/pfserver
 
208
        # NOTE: rc_status knows that we called this init script with
 
209
        # "status" option and adapts its messages accordingly.
 
210
        rc_status -v
 
211
        ;;
 
212
    *)
 
213
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
 
214
        exit 1
 
215
        ;;
 
216
esac
 
217
rc_exit