-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzfs-fuse.init
executable file
·233 lines (206 loc) · 4.9 KB
/
zfs-fuse.init
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#! /bin/bash
#
# zfs-fuse - startup script for zfs-fuse daemon
#
# chkconfig: - 26 74
# description: zfs-fuse daemon
#
### BEGIN INIT INFO
# Provides: zfs-fuse
# Required-Start: fuse
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Start the zfs-fuse daemon
# Description: zfs-fuse daemon
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
prog="zfs-fuse"
exec="/sbin/$prog"
config=/etc/sysconfig/$prog
[ -e $config ] && . $config
PIDFILE=/var/run/$prog.pid
unset LANG
ulimit -v unlimited
ulimit -c 512000
ulimit -l unlimited
ulimit -s unlimited
start() {
[ -x $exec ] || (echo "$prog binary not present or executable" && exit 5)
PID=`pidofproc $prog`
start_status=$?
case "$start_status" in
0)
echo "ZFS-FUSE is already running with pid $pid"
exit 3
;;
1)
echo "Cleaning up stale $prog PID file in $PIDFILE"
rm -f "$PIDFILE"
;;
3)
# not running
;;
*)
echo "Huh?"
exit 99
esac
if [ "$ZFS_KILL_ORPHANS" == "yes_really" ] ; then
echo -n Killing processes with unknown working directory:
for a in 1 2 3 4 5 ; do
orphans=`lsof -w -n | awk '$4 == "cwd" && $5 == "unknown" {print $2}'`
echo -n $orphans
[ "$orphans" == "" ] && break
echo -n .
kill $orphans
sleep 1
done
orphans=`lsof -w -n | awk '$4 == "cwd" && $5 == "unknown" {print $2}'`
if [ "$orphans" != "" ] ; then
echo_failure ; echo
echo -n Some orphans still live: $orphans Killing with signal 9
kill -9 $orphans
fi
orphans=`lsof -w -n | awk '$4 == "cwd" && $5 == "unknown" {print $2}'`
if [ "$orphans" != "" ] ; then
echo_failure ; echo
echo -n Some orphans still live: $orphans
echo_failure ; echo
exit 8
fi
echo_success ; echo
fi
echo -n $"Starting $prog: "
daemon $exec -p "$PIDFILE"
exec_retval=$?
echo
[ $exec_retval -ne 0 ] && return $exec_retval
for a in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
PID=`pidofproc $prog`
[ "$PID" != "" ] && break
echo -n "."
sleep 1
done
if [ "$PID" = "" ] ; then
echo "ZFS-FUSE did not start or create $PIDFILE"
exit 3
fi
echo -n "Immunizing $prog against OOM kills"
echo -17 > "/proc/$PID/oom_adj"
ES_TO_REPORT=$?
if [ "$ES_TO_REPORT" -ne 0 ] ; then
echo_warning
echo "code $ES_TO_REPORT"
exit 3
fi
echo_success
echo
if [ "$ZFS_AUTOMOUNT" == "1" ] ; then
echo "Deprecated use of ZFS_AUTOMOUNT option. Use ZFS_AUTOMOUNT=yes instead."
ZFS_AUTOMOUNT=yes
fi
if [ "$ZFS_AUTOMOUNT" == "yes" ] ; then
echo -n $"Mounting zfs partitions: "
sleep 1
rm -f /var/lib/random-seed
zfs mount -a
zfs_mount_retval=$?
if [ $zfs_mount_retval = 0 ]; then
echo_success
else
echo_warning
echo zfs mount failed with code $zfs_mount_retval
fi
echo
fi
# if [ -x /nonexistent -a -x /usr/bin/renice ] ; then # DISABLED
# log_action_begin_msg "Increasing ZFS-FUSE priority"
# /usr/bin/renice -15 -g $PID > /dev/null
# ES_TO_REPORT=$?
# if [ 0 = "$ES_TO_REPORT" ] ; then
# log_action_end_msg 0
# else
# log_action_end_msg 1 "code $ES_TO_REPORT"
# exit 3
# fi
# true
# fi
return $exec_retval
}
stop() {
status_quiet || return 0
[ -x $exec ] || (echo "$prog binary not present or executable" && exit 5)
PID=`pidofproc $prog`
if [ "$PID" != "" ] ; then
echo -n "Syncing disks"
sync
echo_success
echo
echo -n "Unmounting ZFS filesystems"
zfs unmount -a
ES_TO_REPORT=$?
if [ 0 = "$ES_TO_REPORT" ] ; then
echo_success
else
echo_warning
fi
echo
fi
echo -n $"Stopping $prog: "
killproc $prog
kill_retval=$?
echo
if [ "$PID" != "" ] ; then
echo -n "Syncing disks again"
sync
echo_success
echo
fi
return $kill_retval
}
restart() {
stop
start
}
pool_status() {
# run checks to determine if the service is running or use generic status
status $prog && /sbin/zpool status
}
pool_status_quiet() {
pool_status >/dev/null 2>&1
}
status_quiet() {
status $prog >/dev/null 2>&1
}
case "$1" in
start)
status_quiet && exit 0
$1
;;
stop)
$1
;;
restart)
restart
;;
reload)
restart
;;
force-reload)
restart
;;
status)
pool_status
;;
condrestart|try-restart)
pool_status_quiet || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?