~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/udftools

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
#
3
 
# udftools
4
 
#     Call pktsetup to set up packet device associations
5
 
#
6
 
# Written and Copyright 2003 Richard Atterer <atterer<at>debian.org>, GPLv2.
7
 
# * Thanks to Aleksandar Topuzovic <aleksandar.topuzovic<at>fer.hr> for an
8
 
#   initial version of the script.
9
 
# * Thanks to Cyrille Ch�p�lov <cyrille<at>chepelov.org> for additional
10
 
#   help with the specifics of 2.6 packet writing.
11
 
# * Thanks to Christopher Martin <christopher.martin<at>utoronto.ca>
12
 
#   for fixes to make things work on systems that have "no udev + new
13
 
#   interface" or "udev + old interface"
14
 
 
15
 
### BEGIN INIT INFO
16
 
# Provides:          udftools
17
 
# Required-Start:    $remote_fs 
18
 
# Required-Stop:     $remote_fs
19
 
# Default-Start:     2 3 4 5
20
 
# Default-Stop:      0 1 6
21
 
# Short-Description: Set up packet writing devices
22
 
# Description:       Set up packet writing devices, i.e. tell the kernel that
23
 
#                    e.g. device /dev/hdc is to be made available as packet
24
 
#                    writing device /dev/pktcdvd/0.
25
 
### END INIT INFO
26
 
 
27
 
set -e
28
 
 
29
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
30
 
DESC="udftools packet writing"
31
 
PKTSETUP=/usr/bin/pktsetup
32
 
DEFAULTFILE=/etc/default/udftools
33
 
DEVICES=""
34
 
NEWINTNAMES="0 1 2 3"
35
 
UDEVNAMES="/dev/pktcdvd/0 /dev/pktcdvd/1 /dev/pktcdvd/2 /dev/pktcdvd/3"
36
 
UDEV=""
37
 
NEWINT=""
38
 
 
39
 
if test -e /dev/.devfsd; then
40
 
    OLDINTNAMES="/dev/pktcdvd/0 /dev/pktcdvd/1 /dev/pktcdvd/2 /dev/pktcdvd/3"
41
 
else
42
 
    OLDINTNAMES="/dev/pktcdvd0 /dev/pktcdvd1 /dev/pktcdvd2 /dev/pktcdvd3"
43
 
fi
44
 
 
45
 
if test -f "$DEFAULTFILE"; then
46
 
    # Read user settings
47
 
    . "$DEFAULTFILE"
48
 
fi
49
 
test -x "$PKTSETUP" || exit 0
50
 
 
51
 
# Only execute modprobe if DEVICES set - avoid possible problems with
52
 
# the module for people who don't use packet writing.
53
 
if test -n "$DEVICES"; then
54
 
    modprobe --quiet pktcdvd || true
55
 
    if test -z "$NEWINT"; then # User did not set NEWINT, try auto-detection
56
 
        if dpkg --compare-versions `uname -r` ge 2.6.8; then
57
 
            NEWINT=true
58
 
        else
59
 
            NEWINT=false
60
 
        fi
61
 
    fi
62
 
    if test -z "$UDEV"; then # User did not set UDEV, try auto-detection
63
 
        if test -e /dev/.udev; then
64
 
            UDEV=true
65
 
        else
66
 
            UDEV=false
67
 
        fi
68
 
    fi
69
 
fi
70
 
 
71
 
dostart() {
72
 
    if test -z "$DEVICES"; then
73
 
        echo "Not starting $DESC: No devices listed in $DEFAULTFILE"
74
 
    else
75
 
        echo "Starting $DESC:"
76
 
        if $NEWINT; then
77
 
            set $NEWINTNAMES
78
 
            for DEVICE in $DEVICES; do
79
 
                echo -n "/dev/pktcdvd/$1=$DEVICE " || true
80
 
                $PKTSETUP "$1" "$DEVICE"
81
 
                shift
82
 
            done
83
 
        else
84
 
            if $UDEV; then
85
 
                set $UDEVNAMES
86
 
            else
87
 
                set $OLDINTNAMES
88
 
            fi
89
 
            for DEVICE in $DEVICES; do
90
 
                echo -n "$1=$DEVICE " || true
91
 
                $PKTSETUP "$1" "$DEVICE"
92
 
                shift
93
 
            done
94
 
        fi
95
 
        echo ""
96
 
    fi
97
 
}
98
 
 
99
 
dostop() {
100
 
    if test -z "$DEVICES"; then
101
 
        echo "Not stopping $DESC: No devices listed in $DEFAULTFILE"
102
 
    else
103
 
        echo "Stopping $DESC:"
104
 
        if $NEWINT; then
105
 
            set $NEWINTNAMES
106
 
            for DEVICE in $DEVICES; do
107
 
                echo -n "/dev/pktcdvd/$1=$DEVICE " || true
108
 
                $PKTSETUP -d "$1" || true
109
 
                shift
110
 
            done
111
 
        else
112
 
            if $UDEV; then
113
 
                set $UDEVNAMES
114
 
            else
115
 
                set $OLDINTNAMES
116
 
            fi
117
 
            for DEVICE in $DEVICES; do
118
 
                echo -n "$1=$DEVICE " || true
119
 
                $PKTSETUP -d "$1" || true
120
 
                shift
121
 
            done
122
 
        fi
123
 
        echo ""
124
 
    fi
125
 
}
126
 
 
127
 
case "$1" in
128
 
    start) dostart;;
129
 
    stop)  dostop;;
130
 
    restart|force-reload) dostop; dostart;;
131
 
    status)
132
 
        nmappings=`$PKTSETUP -s | wc -l`
133
 
        echo "Status of $DESC: $nmappings device mappings"
134
 
        if test $nmappings -eq 0; then exit 1; fi
135
 
        ;;
136
 
    *)
137
 
        echo "Usage: /etc/init.d/udftools {start|stop|restart|force-reload}" >&2
138
 
        exit 1
139
 
        ;;
140
 
esac
141
 
 
142
 
exit 0