#! /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="/usr/bin/$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 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 -eq 1 ] ; 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 exit 3 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 && /usr/bin/zpool status } status_quiet() { pool_status >/dev/null 2>&1 } case "$1" in start) status_quiet && exit 0 $1 ;; stop) $1 ;; restart) restart ;; reload) status_quiet || exit 7 restart ;; force-reload) restart ;; status) pool_status ;; condrestart|try-restart) status_quiet || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $?