I want to mount another root partition, edit the grub.cfg file with a python script and afterwards umount the partition again. How can I wait for the python script to finish and check if the partition is ready to be umounted? Currently I have tried to use wait but this doesn't do the trick.
if mountpoint $MPOINT; then
echo "Already mounted. To prevent potential file loss aborting."
else
echo "OK, will now mount the needed device."
mkdir $MPOINT
mount $DEVICE $MPOINT
if [ $? -eq 0 ]; then
# Edit config file
python /usr/bin/grubcfgmgr.py "$MPOINT" &
pid=$!
else
echo "Failed, could not mount. Aborting."
rm -rf $MPOINT
exit n
fi
# Umount
wait $pid
umount $MPOINT
if [ $? -eq 0 ]; then
echo "OK, umount was succesfull. Will delete empty mount point."
rm -rf $MPOINT
else
echo "Failed, could not umount. Aborting."
fi
fi
if [ $? -eq 0 ]
is unnecessay. Doif mount "$DEVICE" "$MPOINT" ; then
– Sergiy Kolodyazhnyy Jan 13 '19 at 14:00mountpoint: /run/media/con/773a2bb3-546b-4483-a777-275ac1a57427: No such file or directory OK, will now mount the needed device. umount: /run/media/con/773a2bb3-546b-4483-a777-275ac1a57427: device is busy. Failed, could not umount. Aborting.
– conste Jan 19 '19 at 14:15