Lines 2-7
Link Here
|
2 |
# Copyright 1999-2005 Gentoo Foundation |
2 |
# Copyright 1999-2005 Gentoo Foundation |
3 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
|
4 |
|
|
|
5 |
opts="${opts} unbind restore" |
6 |
|
5 |
depend() { |
7 |
depend() { |
6 |
need net |
8 |
need net |
7 |
after openafs-server |
9 |
after openafs-server |
Lines 30-36
choose_afsdoptions() {
Link Here
|
30 |
|
32 |
|
31 |
start() { |
33 |
start() { |
32 |
ebegin "Starting OpenAFS client" |
34 |
ebegin "Starting OpenAFS client" |
33 |
failed=1 |
35 |
local failed=1 |
34 |
|
36 |
|
35 |
eindent |
37 |
eindent |
36 |
|
38 |
|
Lines 53-58
start() {
Link Here
|
53 |
else |
55 |
else |
54 |
cleanstart |
56 |
cleanstart |
55 |
failed=$? |
57 |
failed=$? |
|
|
58 |
|
59 |
if [[ ${failed} -eq 0 ]] && [[ "${RESTORE_ON_START}" == "yes" ]]; then |
60 |
restore |
61 |
fi |
62 |
|
56 |
eend $failed |
63 |
eend $failed |
57 |
fi |
64 |
fi |
58 |
|
65 |
|
Lines 85-98
cleanstart()
Link Here
|
85 |
fi |
92 |
fi |
86 |
} |
93 |
} |
87 |
|
94 |
|
|
|
95 |
unbind() { |
96 |
local binds= path= options= errors=0 |
97 |
ebegin "Saving /afs binds to ${BINDS_STORAGE}" |
98 |
|
99 |
binds=$(mount | grep '/afs on .*bind' | \ |
100 |
sed -r 's|/afs on (.+) type none \(((([[:alnum:]]+),?)+)\)$|\1 \2|;') |
101 |
|
102 |
if [[ -z "${binds}" ]]; then |
103 |
eend 0 |
104 |
return 0 |
105 |
fi |
106 |
|
107 |
if [[ -f "${BINDS_STORAGE}" ]]; then |
108 |
ewarn "Moving existing '${BINDS_STORAGE}' to '${BINDS_STORAGE}.old'" |
109 |
mv -f "${BINDS_STORAGE}" "${BINDS_STORAGE}.old" |
110 |
fi |
111 |
|
112 |
eindent |
113 |
set ${binds}; |
114 |
|
115 |
while [ $# -gt 0 ]; do |
116 |
path=$1 |
117 |
options=$2 |
118 |
shift; shift; |
119 |
|
120 |
ebegin "Unmounting and saving '${path}' (${options})" |
121 |
|
122 |
if ! umount "${path}"; then |
123 |
ewarn "Failed to umount /afs bind: ${path}" |
124 |
errors=$(( $errors + 1 )) |
125 |
eend 1 |
126 |
else |
127 |
echo "/bin/mount -o ${options} /afs \"${path}\"" \ |
128 |
>> "${BINDS_STORAGE}" |
129 |
eend $? |
130 |
fi |
131 |
done |
132 |
|
133 |
eoutdent |
134 |
|
135 |
eend ${errors} |
136 |
return ${errors} |
137 |
} |
138 |
|
139 |
restore() { |
140 |
ebegin "Restoring /afs binds from ${BINDS_STORAGE}" |
141 |
local mount_command= errors=0 |
142 |
[[ -f "${BINDS_STORAGE}" ]] || return 0 |
143 |
|
144 |
while read -r mount_command; do |
145 |
if ! eval ${mount_command}; then |
146 |
ewarn "Bind restore '${mount_command}' failed"; |
147 |
errors=$(( $errors + 1 )) |
148 |
fi |
149 |
done < ${BINDS_STORAGE} |
150 |
|
151 |
if [[ ${errors} -gt 0 ]]; then |
152 |
ewarn "${errors} binds failed to restore"; |
153 |
else |
154 |
rm -f "${BINDS_STORAGE}" |
155 |
fi |
156 |
|
157 |
eend ${errors} |
158 |
return ${errors} |
159 |
} |
160 |
|
88 |
stop() { |
161 |
stop() { |
89 |
ebegin "Stopping OpenAFS client" |
162 |
ebegin "Stopping OpenAFS client" |
90 |
failed=1 |
163 |
local failed=1 |
91 |
|
164 |
|
92 |
eindent |
165 |
eindent |
93 |
|
166 |
|
|
|
167 |
[[ "${UNBIND_ON_STOP}" == "yes" ]] && unbind |
94 |
# Three stage process: unmount / stop daemon / unload module |
168 |
# Three stage process: unmount / stop daemon / unload module |
95 |
ebegin "Unmounting /afs" |
169 |
ebegin "Unmounting /afs" |
|
|
170 |
|
96 |
if ! umount /afs; then |
171 |
if ! umount /afs; then |
97 |
eend 1 |
172 |
eend 1 |
98 |
else |
173 |
else |