File: ocfs2.init

package info (click to toggle)
ocfs2-tools 1.8.4-4+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,312 kB
  • sloc: ansic: 85,325; sh: 5,702; python: 2,380; makefile: 1,265
file content (188 lines) | stat: -rwxr-xr-x 3,532 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#! /bin/bash
# Copyright (c) 2005 Oracle
# All rights reserved.
#
# chkconfig: 2345 25 18
# description: Mount OCFS2 volumes at boot.
#
### BEGIN INIT INFO
# Provides: ocfs2
# Required-Start: $local_fs $network o2cb
# Required-Stop: $local_fs $network o2cb
# Should-Start: drbd iscsi multipath-tools
# Should-Stop: drbd iscsi multipath-tools
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mount OCFS2 volumes at boot.
# Description:  Mount OCFS2 volumes at boot.
### END INIT INFO

# Let's try to use the LSB functions
. /lib/lsb/init-functions
if [ $? != 0 ]
then
    echo "Unable to load LSB init functions" >&2
    exit 1
fi

if [ -f /etc/redhat-release ]
then
. /etc/init.d/functions

init_status()
{
    return 0
}

success_status()
{
    success
    echo
}

failure_status()
{
    failure $1
    echo
}

exit_status()
{
    exit $?
}
elif [ -f /etc/SuSE-release -o -f /etc/UnitedLinux-release ]
then
. /etc/rc.status

init_status()
{
    rc_reset
}

success_status()
{
    /bin/true
    rc_status -v
}

failure_status()
{
    /bin/false
    rc_status -v
}

exit_status()
{
    rc_exit
}
else
init_status()
{
    return 0
}

success_status()
{
    echo "OK"
    return 0
}

failure_status()
{
    echo "Failed"
    return 0
}

exit_status()
{
    exit $?
}
fi

ocfs2mounts()
{
    LC_ALL=C awk '$3 == "ocfs2"  { print $2 }' /proc/mounts
}

ocfs2fstab()
{
    LC_ALL=C awk '!/^#/ && $3 == "ocfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab
}

init_status

FUSER=`which fuser`

case "$1" in
    start|reload)
        if [ -d /var/lock/subsys ] ; then
            touch /var/lock/subsys/ocfs2
        fi
        if [ -n "`ocfs2fstab`" ] ; then
            echo -n "Starting Oracle Cluster File System (OCFS2) "
            mount -at ocfs2
            if [ $? = 0 ]
            then
                success_status
            else
                failure_status "Unable to mount OCFS2 filesystems"
            fi
        fi
        ;;
    stop)
        echo -n "Stopping Oracle Cluster File System (OCFS2) "
        remaining="`ocfs2mounts`"
        sig=
        retry=3
        while [ -n "$remaining" -a "$retry" -gt 0 ]
        do
            if [ "$retry" -lt 3 ]; then
                echo -n "Retry stopping Oracle Cluster File System (OCFS2) "
            fi
            umount -a -t ocfs2 2>/dev/null
            sleep 1

            remaining="`ocfs2mounts`"
            [ -z "$remaining" ] && break
            failure_status "Unable to unmount OCFS2 filesystems"

            $FUSER -km $sig $remaining >/dev/null
            sleep 5
            retry=$(($retry - 1))
            sig=-9
        done
        if [ -z "$remaining" ] && [ -e /var/lock/subsys/ocfs2 ] ; then
                rm /var/lock/subsys/ocfs2
        fi
        [ -z "$remaining" ] && success_status
        ;;
    restart|force-reload)
        $0 stop
        $0 start
        ;;
    status)
        if [ -f /proc/mounts ] ; then
            [ -n "`ocfs2fstab`" ] && {
                echo "Configured OCFS2 mountpoints: " `ocfs2fstab`
            }

            [ -n "`ocfs2mounts`" ] && {
                echo "Active OCFS2 mountpoints: " `ocfs2mounts`
            }
        else
            echo -n "Checking OCFS2 mountpoints: "
            failure_status
        fi
        ;;
    try-restart|condrestart)
        $0 status
        if test $? = 0; then
            $0 restart
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status|reload|force-reload|restart|try-restart}"
        exit 1
esac

exit_status