~ubuntu-branches/ubuntu/precise/autofs5/precise

« back to all changes in this revision

Viewing changes to .pc/autofs-5.0.5-fix-status-privilege-error.patch/redhat/autofs.init.in

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-03 14:35:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110703143546-nej26krjij0rf792
Tags: 5.0.6-0ubuntu1
* New upstream release:
  - Dropped upstream patches 
  - Refreshed debian/patches/17ld.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
#
3
 
# rc file for automount using a Sun-style "master map".
4
 
#
5
 
# chkconfig: 345 28 72
6
 
# processname: /usr/sbin/automount
7
 
# config: /etc/auto.master
8
 
# description: Automounts filesystems on demand
9
 
#
10
 
### BEGIN INIT INFO
11
 
# Provides: $autofs
12
 
# Required-Start: $network $ypbind
13
 
# Required-Stop: $network $ypbind
14
 
# Default-Start: 3 4 5
15
 
# Default-Stop: 0 1 2 6
16
 
# Short-Description: Automounts filesystems on demand
17
 
# Description: Automounts filesystems on demand
18
 
### END INIT INFO
19
 
#
20
 
# Location of the automount daemon and the init directory
21
 
#
22
 
DAEMON=@@sbindir@@/automount
23
 
prog=`basename $DAEMON`
24
 
MODULE="autofs4"
25
 
DEVICE="autofs"
26
 
initdir=@@initdir@@
27
 
confdir=@@autofsconfdir@@
28
 
 
29
 
test -e $DAEMON || exit 0
30
 
 
31
 
if [ -r $initdir/functions ]; then
32
 
        . $initdir/functions
33
 
fi
34
 
 
35
 
PATH=/sbin:/usr/sbin:/bin:/usr/bin
36
 
export PATH
37
 
 
38
 
#
39
 
# load customized configuation settings
40
 
#
41
 
if [ -r $confdir/autofs ]; then
42
 
        . $confdir/autofs
43
 
fi
44
 
 
45
 
function start() {
46
 
        # Make sure autofs4 module is loaded
47
 
        if ! grep -q autofs /proc/filesystems
48
 
        then
49
 
                echo -n "Loading $MODULE: "
50
 
                # Try load the autofs4 module fail if we can't
51
 
                modprobe $MODULE >/dev/null 2>&1
52
 
                RETVAL=$?
53
 
                if [ $RETVAL -eq 1 ]
54
 
                then
55
 
                        failure "Load $MODULE"
56
 
                        echo
57
 
                        return $RETVAL
58
 
                else
59
 
                        success "Load $MODULE"
60
 
                        echo
61
 
                fi
62
 
        elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]
63
 
        then
64
 
                RETVAL=1
65
 
                failure "Load $MODULE"
66
 
                echo
67
 
                return $RETVAL
68
 
        fi
69
 
 
70
 
        # Check misc device
71
 
        if [ -n "$USE_MISC_DEVICE" -a "x$USE_MISC_DEVICE" = "xyes" ]; then
72
 
                sleep 1
73
 
                if [ -e "/proc/misc" ]; then
74
 
                        MINOR=`awk "/$DEVICE/ {print \\$1}" /proc/misc`
75
 
                        if [ -n "$MINOR" -a ! -c "/dev/$DEVICE" ]; then
76
 
                                mknod -m 0600 /dev/$DEVICE c 10 $MINOR
77
 
                        fi
78
 
                fi
79
 
                if [ -x /sbin/restorecon -a -c /dev/$DEVICE ]; then
80
 
                        /sbin/restorecon /dev/$DEVICE
81
 
                fi
82
 
        else
83
 
                if [ -c /dev/$DEVICE ]; then
84
 
                        rm /dev/$DEVICE
85
 
                fi
86
 
        fi
87
 
 
88
 
        echo -n $"Starting $prog: "
89
 
        $prog $OPTIONS --pid-file /var/run/autofs.pid
90
 
        RETVAL=$?
91
 
        if [ $RETVAL -eq 0 ] ; then
92
 
                success "$prog startup"
93
 
        else
94
 
                failure "$prog startup"
95
 
        fi
96
 
        if [ $RETVAL -eq 0 ]; then
97
 
                touch /var/lock/subsys/autofs
98
 
        else
99
 
                RETVAL=1
100
 
        fi
101
 
        echo
102
 
        return $RETVAL
103
 
}
104
 
 
105
 
function stop() {
106
 
        echo -n $"Stopping $prog: "
107
 
        count=0
108
 
        while [ -n "`pidof $prog`" -a $count -lt 15 ] ; do
109
 
                killproc $prog -TERM >& /dev/null
110
 
                RETVAL=$?
111
 
                [ $RETVAL = 0 -a -z "`pidof $prog`" ] || sleep 3
112
 
                count=`expr $count + 1`
113
 
        done
114
 
        if [ $RETVAL -eq 0 ]; then
115
 
                rm -f /var/lock/subsys/autofs
116
 
        else
117
 
                RETVAL=1
118
 
        fi
119
 
        if [ -n "`pidof $prog`" ] ; then
120
 
                failure "$prog shutdown"
121
 
        else
122
 
                success "$prog shutdown"
123
 
        fi
124
 
        echo
125
 
        return $RETVAL
126
 
}
127
 
 
128
 
function restart() {
129
 
        status autofs > /dev/null 2>&1
130
 
        if [ $? -eq 0 ]; then
131
 
                stop
132
 
        fi
133
 
        start
134
 
}
135
 
 
136
 
function reload() {
137
 
        if [ ! -f /var/lock/subsys/autofs ]; then
138
 
                echo $"$prog not running"
139
 
                RETVAL=1
140
 
                return $RETVAL
141
 
        fi
142
 
        pid=`pidof $prog`
143
 
        if [ -z $pid ]; then
144
 
                echo $"$prog not running"
145
 
                RETVAL=1
146
 
        else
147
 
                kill -HUP $pid 2> /dev/null
148
 
                echo $"Reloading maps"
149
 
                RETVAL=0
150
 
        fi
151
 
        return $RETVAL
152
 
}
153
 
 
154
 
RETVAL=0
155
 
 
156
 
# Only the root user may change the service status
157
 
if [ `id -u` -ne 0 ]; then
158
 
        echo "insufficient privilege to change service status"
159
 
        exit 4
160
 
fi
161
 
 
162
 
case "$1" in
163
 
        start)
164
 
                start
165
 
                ;;
166
 
        forcestart)
167
 
                OPTIONS="$OPTIONS --force"
168
 
                start
169
 
                ;;
170
 
        stop)
171
 
                stop
172
 
                ;;
173
 
        status)
174
 
                status -p /var/run/autofs.pid -l autofs $prog
175
 
                ;;
176
 
        restart)
177
 
                restart
178
 
                ;;
179
 
        forcerestart)
180
 
                OPTIONS="$OPTIONS --force"
181
 
                restart
182
 
                ;;
183
 
        reload)
184
 
                reload
185
 
                ;;
186
 
        condrestart)
187
 
                if [ -f /var/lock/subsys/autofs ]; then
188
 
                        restart
189
 
                fi
190
 
                ;;
191
 
        usage)
192
 
                echo $"Usage: $0 {start|forcestart|stop|status|restart|forcerestart|reload|condrestart}"
193
 
                exit 0
194
 
                ;;
195
 
        try-restart|force-reload)
196
 
                echo "$1 service action not supported"
197
 
                exit 3
198
 
                ;;
199
 
        *)
200
 
                echo "unknown, invalid or excess argument(s)"
201
 
                exit 2
202
 
                ;;
203
 
esac
204
 
 
205
 
exit $?
206