CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Difference between
modified post 1022 by johnraff on Mon 25th Apr 17:55 and
original post 1018 by johnraff on Fri 22nd Apr 18:56
Show old version | new version | both versions

    
11
# /lib/lsb/init-functions for Debian -*- shell-script -*-
22
#
33
#Copyright (c) 2002-08 Chris Lawrence
44
#All rights reserved.
55
#
66
#Redistribution and use in source and binary forms, with or without
77
#modification, are permitted provided that the following conditions
88
#are met:
99
#1. Redistributions of source code must retain the above copyright
1010
#   notice, this list of conditions and the following disclaimer.
1111
#2. Redistributions in binary form must reproduce the above copyright
1212
#   notice, this list of conditions and the following disclaimer in the
1313
#   documentation and/or other materials provided with the distribution.
1414
#3. Neither the name of the author nor the names of other contributors
1515
#   may be used to endorse or promote products derived from this software
1616
#   without specific prior written permission.
1717
#
1818
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1919
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2121
#ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
2222
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2323
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2424
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
2525
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2626
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2727
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2828
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
start_daemon () {
3131
    local force nice pidfile exec i args
3232
    force=0
3333
    nice=0
3434
    pidfile=/dev/null
3636
    OPTIND=1
3737
    while getopts fn:p: opt ; do
3838
        case "$opt" in
3939
            f)  force=1;;
4040
            n)  nice="$OPTARG";;
4141
            p)  pidfile="$OPTARG";;
4242
        esac
4343
    done
4545
    shift $(($OPTIND - 1))
4646
    if [ "$1" = '--' ]; then
4747
        shift
4848
    fi
5050
    exec="$1"; shift
5252
    args="--start --nicelevel $nice --quiet --oknodo"
5353
    if [ $force = 1 ]; then
5454
        /sbin/start-stop-daemon $args --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
5555
    elif [ $pidfile ]; then
5656
        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
5757
    else
5858
        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
5959
    fi
6060
}
6262
pidofproc () {
6363
    local pidfile line i pids= status specified pid
6464
    pidfile=
6565
    specified=
6767
    OPTIND=1
6868
    while getopts p: opt ; do
6969
        case "$opt" in
7070
            p)  pidfile="$OPTARG"; specified=1;;
7171
        esac
7272
    done
7373
    shift $(($OPTIND - 1))
7575
    base=${1##*/}
7676
    if [ ! "$specified" ]; then
7777
        pidfile="/var/run/$base.pid"
7878
    fi
8080
    if [ -n "${pidfile:-}" -a -r "$pidfile" ]; then
8181
        read pid < "$pidfile"
8282
        if [ -n "${pid:-}" ]; then
8383
            if $(kill -0 "${pid:-}" 2> /dev/null); then
8484
                echo "$pid"
8585
                return 0
8686
            elif ps "${pid:-}" >/dev/null 2>&1; then
8787
                echo "$pid"
8888
                return 0 # program is running, but not owned by this user
8989
            else
9090
                return 1 # program is dead and /var/run pid file exists
9191
            fi
9292
        fi
9393
    fi
9494
    if [ -x /bin/pidof -a ! "$specified" ]; then
9595
        status="0"
9696
        /bin/pidof -o %PPID -x $1 || status="$?"
9797
        if [ "$status" = 1 ]; then
9898
            return 3 # program is not running
9999
        fi
100100
        return 0
101101
    fi
102102
    return 4 # Unable to determine status
103103
}
105105
# start-stop-daemon uses the same algorithm as "pidofproc" above.
106106
killproc () {
107107
    local pidfile sig status base i name_param is_term_sig
108108
    pidfile=
109109
    name_param=
110110
    is_term_sig=no
112112
    OPTIND=1
113113
    while getopts p: opt ; do
114114
        case "$opt" in
115115
            p)  pidfile="$OPTARG";;
116116
        esac
117117
    done
118118
    shift $(($OPTIND - 1))
120120
    base=${1##*/}
121121
    if [ ! $pidfile ]; then
122122
        name_param="--name $base --pidfile /var/run/$base.pid"
123123
    else
124124
        name_param="--pidfile $pidfile"
125125
    fi
127127
    sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
128128
    sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
129129
    if [ -z "$sig" -o "$sig" = 15 -o "$sig" = TERM ]; then
130130
        is_term_sig=yes
131131
    fi
132132
    status=0
133133
    if [ ! "$is_term_sig" = yes ]; then
134134
        if [ -n "$sig" ]; then
135135
            /sbin/start-stop-daemon --stop --signal "$sig" --quiet $name_param || status="$?"
136136
        else
137137
            /sbin/start-stop-daemon --stop --quiet $name_param || status="$?"
138138
        fi
139139
    else
140140
        /sbin/start-stop-daemon --stop --quiet --oknodo $name_param || status="$?"
141141
    fi
142142
    if [ "$status" = 1 ]; then
143143
        if [ -n "$sig" ]; then
144144
            return 0
145145
        fi
146146
        return 3 # program is not running
147147
    fi
149149
    if [ "$status" = 0 -a "$is_term_sig" = yes -a "$pidfile" ]; then
150150
        pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
151151
    fi
152152
    return 0
153153
}
155155
# Return LSB status
156156
status_of_proc () {
157157
    local pidfile daemon name status
159159
    pidfile=
160160
    OPTIND=1
161161
    while getopts p: opt ; do
162162
        case "$opt" in
163163
            p)  pidfile="$OPTARG";;
164164
        esac
165165
    done
166166
    shift $(($OPTIND - 1))
168168
    if [ -n "$pidfile" ]; then
169169
        pidfile="-p $pidfile"
170170
    fi
171171
    daemon="$1"
172172
    name="$2"
174174
    status="0"
175175
    pidofproc $pidfile $daemon >/dev/null || status="$?"
176176
    if [ "$status" = 0 ]; then
177177
        log_success_msg "$name is running"
178178
        return 0
179179
    elif [ "$status" = 4 ]; then
180180
        log_failure_msg "could not access PID file for $name"
181181
        return $status
182182
    else
183183
        log_failure_msg "$name is not running"
184184
        return $status
185185
    fi
186186
}
188188
log_use_fancy_output () {
189189
    TPUT=/usr/bin/tput
190190
    EXPR=/usr/bin/expr
191191
    if [ -t 1 ] && [ "x${TERM:-}" != "x" ] && [ "x${TERM:-}" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then
192192
        [ -z $FANCYTTY ] && FANCYTTY=1 || true
193193
    else
194194
        FANCYTTY=0
195195
    fi
196196
    case "$FANCYTTY" in
197197
        1|Y|yes|true)   true;;
198198
        *)              false;;
199199
    esac
200200
}
202202
log_success_msg () {
203203
    if [ -n "${1:-}" ]; then
204204
        log_begin_msg $@
205205
    fi
206206
    log_end_msg 0
207207
}
209209
log_failure_msg () {
210210
    if [ -n "${1:-}" ]; then
211211
        log_begin_msg $@ "..."
212212
    fi
213213
    log_end_msg 1 || true
214214
}
216216
log_warning_msg () {
217217
    if [ -n "${1:-}" ]; then
218218
        log_begin_msg $@ "..."
219219
    fi
220220
    log_end_msg 255 || true
221221
}
223223
#
224224
# NON-LSB HELPER FUNCTIONS
225225
#
226226
# int get_lsb_header_val (char *scriptpathname, char *key)
227227
get_lsb_header_val () {
228228
        if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
229229
                return 1
230230
        fi
231231
        LSB_S="### BEGIN INIT INFO"
232232
        LSB_E="### END INIT INFO"
233233
        sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
234234
}
236+
# SEND MESSAGES TO PLYMOUTH

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me