Virtualbox 启动安装无法卸载

发布于 2024-12-27 00:56:20 字数 3952 浏览 4 评论 0原文

如果您在 VirtualBox 客户机上使用 NetBeans,我认为这里有一个非常有用的脚本。 似乎存在一个问题:

如果您查看该脚本,您会发现它会写入引导脚本,而该脚本又将 NetBeansProjects 从主机系统安装到来宾系统。这很好用。但是,会创建一个附加脚本并将其移动到用户本地 bin。事实上,创建了两个脚本:1) 允许用户挂载;2) 卸载已挂载的文件夹以实现灵活性。

我测试了这些脚本,除了“netbeans-unmount.sh”脚本之外,一切都在我的 Ubuntu 客户机上运行。

它不会卸载在启动时安装的存储库,并且我已尝试授予脚本文件“root”访问权限...

有关这是否有效以及如何工作的任何线索? :

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
export PATH

#Modify these variables as needed...
tempWork=/tmp/work
startupScript=/etc/init.d/rc.local
defaultNetBeansVersion=7.0.1

echo "Provide NetBeans version (7.0.1 is default) then hit [Enter] :"
  read NetBeansVersion

  if [ -z "$NetBeansVersion" ]
    then
    $NetBeansVersion=$defaultNetBeansVersion
  fi

mkdir -p /$tempWork;
cd /$tempWork;

wget http://dlc.sun.com.edgesuite.net/netbeans/7.0.1/final/bundles/netbeans-$NetBeansVersion-ml-javase-linux.sh;
sh $tempWork/*sh;


#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal
#This line will need to be changed if you changed the default install location (IOW Netbeans is not in ~/)
sudo ln -f -s ~/netbeans-$NetBeansVersion/bin/netbeans /usr/bin/;

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match 'NetBeansProjects'
mkdir -p $HOME/NetBeansProjects

if [ -f /sbin/mount.vboxsf ]
then
    sudo /sbin/umount /home/$HOME/NetBeansProjects
    sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects
fi

if mountpoint -q ~/NetBeansProjects
then
#Add it to the universal start script to automate process...
    sudo sed -ie '$d' $startupScript
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects"| sudo tee -a $startupScript
    echo "exit 0"| sudo tee -a $startupScript
    sudo chmod +x $startupScript

#Create a mount and unmount script file and add it to users local bin
    rm -rf $tempWork/*
    echo '#!/bin/bash' > $tempWork/netbeans-mount.sh
    echo '#!/bin/bash' > $tempWork/netbeans-umount.sh
    echo '#!/bin/bash' > $tempWork/mount-from-host.sh
    echo '#!/bin/bash' > $tempWork/unmount-from-host.sh
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" >> $tempWork/netbeans-mount.sh
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" >> $tempWork/mount-from-host.sh
    echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/netbeans-umount.sh
    echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/unmount-from-host.sh
    echo "exit 0" >> $tempWork/unmount-from-host.sh
    echo "exit 0" >> $tempWork/mount-from-host.sh
    echo "exit 0" >> $tempWork/netbeans-mount.sh
    echo "exit 0" >> $tempWork/netbeans-umount.sh

    sudo chmod +x $tempWork/*
    sudo mv -f $tempWork/*.sh /usr/local/bin
    rm -rf $tempWork
fi

#This function is used to cleanly exit with an error code.
function error_exit {
    sleep 7
    exit 1
}
#restart
sudo reboot
exit 0

更新:在终端中手动编码卸载也无法卸载 NetBeans 项目文件夹。所以我想我需要问如果系统初始化安装了该文件夹是否可以卸载该文件夹?

更新2:仍然卡住,但在查看 etc/mtab 后我得到了一些新信息。 这是我所看到的:

...
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
...

很明显,我必须多次运行 sudo unmount ~/NetBeansProjects!

像“平”这样的附加安装选项也不起作用,因为它会卸载所有内容,而我只想卸载我的目标目录。

I have what I think is a very useful script here if you use NetBeans on VirtualBox guest.
There seems to be one problem:

If you look at the script, it writes to a boot scripts that in turn, mounts NetBeansProjects from the Host system to Guest. This works fine. However an additional script is created and moved to the users local bin. In fact, two scripts are created: 1)To allow user to mount and 2)Unmount the mounted folder to allow flexibility.

I test the scripts and everything works on my Ubuntu guest, except the 'netbeans-unmount.sh' script.

It will not unmount the sirectory that was mounted at boot and I have tried giving the scripts file 'root' access...

Any clues as to if this will work and how? :

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
export PATH

#Modify these variables as needed...
tempWork=/tmp/work
startupScript=/etc/init.d/rc.local
defaultNetBeansVersion=7.0.1

echo "Provide NetBeans version (7.0.1 is default) then hit [Enter] :"
  read NetBeansVersion

  if [ -z "$NetBeansVersion" ]
    then
    $NetBeansVersion=$defaultNetBeansVersion
  fi

mkdir -p /$tempWork;
cd /$tempWork;

wget http://dlc.sun.com.edgesuite.net/netbeans/7.0.1/final/bundles/netbeans-$NetBeansVersion-ml-javase-linux.sh;
sh $tempWork/*sh;


#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal
#This line will need to be changed if you changed the default install location (IOW Netbeans is not in ~/)
sudo ln -f -s ~/netbeans-$NetBeansVersion/bin/netbeans /usr/bin/;

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match 'NetBeansProjects'
mkdir -p $HOME/NetBeansProjects

if [ -f /sbin/mount.vboxsf ]
then
    sudo /sbin/umount /home/$HOME/NetBeansProjects
    sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects
fi

if mountpoint -q ~/NetBeansProjects
then
#Add it to the universal start script to automate process...
    sudo sed -ie '$d' $startupScript
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects"| sudo tee -a $startupScript
    echo "exit 0"| sudo tee -a $startupScript
    sudo chmod +x $startupScript

#Create a mount and unmount script file and add it to users local bin
    rm -rf $tempWork/*
    echo '#!/bin/bash' > $tempWork/netbeans-mount.sh
    echo '#!/bin/bash' > $tempWork/netbeans-umount.sh
    echo '#!/bin/bash' > $tempWork/mount-from-host.sh
    echo '#!/bin/bash' > $tempWork/unmount-from-host.sh
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" >> $tempWork/netbeans-mount.sh
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" >> $tempWork/mount-from-host.sh
    echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/netbeans-umount.sh
    echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/unmount-from-host.sh
    echo "exit 0" >> $tempWork/unmount-from-host.sh
    echo "exit 0" >> $tempWork/mount-from-host.sh
    echo "exit 0" >> $tempWork/netbeans-mount.sh
    echo "exit 0" >> $tempWork/netbeans-umount.sh

    sudo chmod +x $tempWork/*
    sudo mv -f $tempWork/*.sh /usr/local/bin
    rm -rf $tempWork
fi

#This function is used to cleanly exit with an error code.
function error_exit {
    sleep 7
    exit 1
}
#restart
sudo reboot
exit 0

Update: Hand coded unmounting in terminal also fails to unmount the NetBeans Projects folder. So I guess I need to ask if it's even possible to unmount this folder if the system initialization mounted the folder?

Update2:Still Stuck, but I have some new info after looking in etc/mtab.
Here is what I see:

...
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
...

It is clear that I have to run sudo unmount ~/NetBeansProjects many times!!

Additional mount options like 'f-l-a-t' won't work either as it unmounts everything and I only want my targeted directory unmounted.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你好,陌生人 2025-01-03 00:56:20

您可以使用以下命令卸载所有共享:

sudo umount -a -t vboxsf 

或使用fusermount -u

sudo fusermount -u /mnt

you may unmount all shares with:

sudo umount -a -t vboxsf 

or use fusermount -u

sudo fusermount -u /mnt
七月上 2025-01-03 00:56:20

我重新检查了所有初始化文件,发现有一些额外的安装添加到 /etc/init.d/rc.local 我现在在像这样编写之前测试现有字符串(作为示例):

if ! grep "JAVA_HOME=${javaUsrLib}/jdk1.7.0_01" /etc/environment

然后
回声“JAVA_HOME=${javaUsrLib}/jdk1.7.0_01”| sudo tee -a /etc/环境

I rechecked all my init files and found there were some additional mounts added to /etc/init.d/rc.local I now test for existing string before writing like this (as an example):

if ! grep "JAVA_HOME=${javaUsrLib}/jdk1.7.0_01" /etc/environment

then
echo "JAVA_HOME=${javaUsrLib}/jdk1.7.0_01" | sudo tee -a /etc/environment
fi

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文