-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#! /usr/bin/env bash | ||
# | ||
# chkconfig: - 99 99 | ||
# | ||
# description: Correctly unmount yas3fs mounts before going reboot or halt (a workaround for https://github.com/libfuse/libfuse/issues/1) | ||
# | ||
|
||
# how many seconds to wait for yas3fs queues flushing | ||
TIMER=60 | ||
|
||
lockfile=/var/lock/subsys/unmount-yas3fs | ||
|
||
start() { | ||
/bin/touch $lockfile | ||
} | ||
|
||
stop() { | ||
logger -t "unmount-yas3fs" "Unmounting yas3fs volumes..." | ||
echo "unmount-yas3fs: Unmounting yas3fs volumes..." | ||
awk '$1 ~ /^yas3fs$/ { print $2 }' \ | ||
/proc/mounts | sort -r | \ | ||
while read line; do | ||
fstab-decode /bin/umount -f $line | ||
done | ||
|
||
logger -t "unmount-yas3fs" "Waiting for yas3fs queues get flushed..." | ||
echo -n "unmount-yas3fs: Waiting for yas3fs queues get flushed" | ||
c=0 | ||
while $(pgrep -x yas3fs &>/dev/null); do | ||
if [ "$c" -gt "$TIMER" ]; then | ||
logger -t "unmount-yas3fs" "Wasn't able to complete in $TIMER seconds, exiting forcefully..." | ||
echo | ||
echo "unmount-yas3fs: Wasn't able to complete in $TIMER seconds, exiting forcefully..." | ||
/bin/rm -f $lockfile | ||
exit 0 | ||
fi | ||
echo -n "." | ||
sleep 1 | ||
c=$((c+1)) | ||
done | ||
logger -t "unmount-yas3fs" "done" | ||
echo -n "done" | ||
echo | ||
/bin/rm -f $lockfile | ||
} | ||
|
||
case "$1" in | ||
start) start;; | ||
stop) stop;; | ||
*) | ||
echo $"Usage: $0 {start|stop}" | ||
exit 1 | ||
esac | ||
|
||
exit 0 |