Skip to content

Commit 91f233e

Browse files
committed
Prelimenary fix for Issue #3, ramdisk unmounting before it's unloaded
1 parent 9117747 commit 91f233e

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

Diff for: minecraft

+33-14
Original file line numberDiff line numberDiff line change
@@ -428,22 +428,36 @@ mcrd_mount() {
428428
#----------------------+
429429
430430
mcrd_unmount() {
431-
if mount -l -t $RD_TYPE | grep $ROOT_PATH/$RD_DIR > /dev/null
432-
then echo "Ramdisk mounted at $ROOT_PATH/$RD_DIR.... unmounting"
433431
434-
while mount -l -t $RD_TYPE | grep $ROOT_PATH/$RD_DIR > /dev/null
435-
do
436-
sleep 2
437-
umount $ROOT_PATH/$RD_DIR
438-
sleep 1
439-
done
440-
441-
if [ ! "$(ls -A $ROOT_PATH/$RD_DIR)" ] # If $ROOT_PATH/$RD_DIR is empty remove it.
442-
then as_user "rmdir $ROOT_PATH/$RD_DIR"
443-
fi
444-
echo "Ramdisk unmounted"
432+
if ps -U $USERNAME x | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null # Is service running?
433+
then echo "Can't unmount ramdisk, $SERVICE is still running!"
434+
435+
elif [ $mcrd_status == 1 ]
436+
then echo "Can't unmount ramdisk, ramdisk not unloaded!"
437+
438+
elif [ $mcrd_status == 0 ]
439+
then
440+
441+
if mount -l -t $RD_TYPE | grep $ROOT_PATH/$RD_DIR > /dev/null
442+
then echo "Ramdisk mounted at $ROOT_PATH/$RD_DIR.... unmounting"
445443
446-
else echo "Ramdisk was not mounted at $ROOT_PATH/$RD_DIR"
444+
while mount -l -t $RD_TYPE | grep $ROOT_PATH/$RD_DIR > /dev/null
445+
do
446+
sleep 2
447+
umount $ROOT_PATH/$RD_DIR
448+
sleep 1
449+
done
450+
451+
if [ ! "$(ls -A $ROOT_PATH/$RD_DIR)" ] # If $ROOT_PATH/$RD_DIR is empty remove it.
452+
then as_user "rmdir $ROOT_PATH/$RD_DIR"
453+
fi
454+
echo "Ramdisk unmounted"
455+
456+
else echo "Ramdisk was not mounted at $ROOT_PATH/$RD_DIR"
457+
fi
458+
459+
else echo "Could not unmount ramdisk"
460+
447461
fi
448462
}
449463
@@ -507,6 +521,9 @@ mcrd_unload() {
507521
508522
if ps -U $USERNAME x | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null # Is service running?
509523
then echo "Can't unload ramdisk, $SERVICE is still running!"
524+
525+
mcrd_status=1 # Could not unload ramdisk, notify other functions of failure
526+
510527
else
511528
512529
if [ ! -d "$ROOT_PATH/$RD_DIR/worlds/$WORLD_NAME" ] # Check if $WORLD_NAME (whatevere it was named in server.properties) exists in $ROOT_PATH/$RD_DIR
@@ -548,6 +565,8 @@ mcrd_unload() {
548565
fi
549566
done
550567
568+
mcrd_status=0 # Ramdisk successfully unloaded, notify other functions of success
569+
551570
fi
552571
553572
else echo "Nothing to save, ramdisk not mounted at $ROOT_PATH/$RD_DIR" # Service not running, nothing to save

0 commit comments

Comments
 (0)