我想挂载另一个根分区,使用 python 脚本编辑 grub.cfg 文件,然后再次卸载该分区。如何等待 python 脚本完成并检查分区是否准备好卸载?目前我尝试使用等待,但这并不能解决问题。
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