blob: a574c62c2fae0701ee27cef433ca0133bc08ff80 (
plain)
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
|
#! /bin/sh
# chkconfig: 12345 13 87
# description: Starts and stops the ZFS file systems
# author: Manuel Amador (Rudd-O)
PIDFILE=/var/run/zfs-fuse.pid
LOCKFILE=/var/lock/zfs/zfs_lock
# Source function library.
. /etc/init.d/functions
# Source cmdline opts
OPTIONS=
[ -f /etc/sysconfig/zfs-fuse ] && . /etc/sysconfig/zfs-fuse
export PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin
unset LANG
ulimit -v unlimited
ulimit -c unlimited
ulimit -l unlimited
do_start() {
PID=$(cat "$PIDFILE" 2> /dev/null)
if [ "$PID" != "" ]
then
if kill -0 $PID 2> /dev/null
then
echo -n "ZFS-FUSE is already running"
failure
exit 3
else
# pid file is stale, we clean up shit
action "Cleaning up stale ZFS-FUSE PID files" rm -f "$PIDFILE"
fi
fi
export DAEMON_COREFILE_LIMIT=unlimited
action "Starting ZFS-FUSE process" daemon --pidfile $PIDFILE zfs-fuse -p "$PIDFILE" $OPTIONS
ES_TO_REPORT=$?
if [ 0 != $ES_TO_REPORT ] ; then
exit $ES_TO_REPORT
fi
for a in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
PID=$(cat "$PIDFILE" 2> /dev/null)
[ "$PID" != "" ] && break
sleep 1
done
if [ "$PID" = "" ]
then
echo -n "ZFS-FUSE did not start or create $PIDFILE"
failure
exit 3
fi
action "Immunizing ZFS-FUSE against OOM kills and sendsigs signals" true
echo -17 > "/proc/$PID/oom_adj"
ES_TO_REPORT=$?
if [ 0 != $ES_TO_REPORT ] ; then
exit $ES_TO_REPORT
fi
sleep 1
action "Mounting ZFS filesystems" zfs mount -a
ES_TO_REPORT=$?
if [ 0 != $ES_TO_REPORT ] ; then
exit $ES_TO_REPORT
fi
}
do_stop () {
PID=$(cat "$PIDFILE" 2> /dev/null)
if [ "$PID" = "" ] ; then
# no pid file, we exit
exit 0
elif kill -0 $PID 2> /dev/null; then
# pid file and killable, we continue
true
else
# pid file is stale, we clean up shit
action "Cleaning up stale ZFS-FUSE PID files" rm -f "$PIDFILE"
exit 0
fi
action "Syncing disks" sync
action "Unmounting ZFS filesystems" zfs unmount -a
ES_TO_REPORT=$?
if [ 0 != $ES_TO_REPORT ] ; then
exit $ES_TO_REPORT
fi
action "Terminating ZFS-FUSE process gracefully" kill -TERM $PID
for a in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
kill -0 $PID 2> /dev/null
[ "$?" != "0" ] && break
sleep 1
done
if kill -0 $PID 2> /dev/null
then
echo -n "ZFS-FUSE refused to die after 15 seconds"
failure
exit 3
else
rm -f "$PIDFILE"
fi
action "Syncing disks again" sync
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
status)
PID=$(cat "$PIDFILE" 2> /dev/null)
if [ "$PID" = "" ] ; then
echo "ZFS-FUSE is not running"
exit 3
else
if kill -0 $PID
then
echo "ZFS-FUSE is running, pid $PID"
zpool status
exit 0
else
echo "ZFS-FUSE died, PID files stale"
exit 3
fi
fi
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
*)
echo "Usage: $0 start|stop|status" >&2
exit 3
;;
esac
:
|