virtualbox和vagrant在macbook版本的安装文件内,都有一个卸载脚本uninstall.tool

vagrant2.1.5卸载脚本:

#!/usr/bin/env bash

#----------------------------------------------------------------------
# Functions
#----------------------------------------------------------------------
# Exits the script with the given exit code after waiting
# for a keypress.
#
# @param [Integer] $ exit code.
function key_exit() {
echo "Press any key to exit."
read
exit $
} # Appends a value to an array.
#
# @param [String] $ Name of the variable to modify
# @param [String] $ Value to append
function append() {
eval $[\${#$[*]}]=$
} #----------------------------------------------------------------------
# Script
#----------------------------------------------------------------------
# Collect the directories and files to remove
my_files=()
append my_files "/opt/vagrant"
append my_files "/usr/local/bin/vagrant" # Print the files and directories that are to be removed and verify
# with the user that that is what he/she really wants to do.
echo "The following files and directories will be removed:"
for file in "${my_files[@]}"; do
echo " $file"
done echo ""
echo "Do you wish to uninstall Vagrant (Yes/No)?"
read my_answer
if [ "$my_answer" != "Yes" ]; then
echo "Aborting install. (answer: ${my_answer})"
key_exit
fi # Initiate the actual uninstall, which requires admin privileges.
echo "The uninstallation process requires administrative privileges"
echo "because some of the installed files cannot be removed by a"
echo "normal user. You may now be prompted for a password..."
echo "" # Use AppleScript so we can use a graphical `sudo` prompt.
# This way, people can enter the username they wish to use
# for sudo, and it is more Apple-like.
osascript -e "do shell script \"/bin/rm -Rf ${my_files[*]}\" with administrator privileges" # Verify that the uninstall succeeded by checking whether every file
# we meant to remove is actually removed.
for file in "${my_files[@]}"; do
if [ -e "${file}" ]; then
echo "An error must have occurred since a file that was supposed to be"
echo "removed still exists: ${file}"
echo ""
echo "Please try again."
key_exit
fi
done echo "Successfully uninstalled Vagrant."
echo "Done."
key_exit

VirtualBox5.2.18卸载脚本:

#!/bin/bash
# $Id: VirtualBox_Uninstall.tool -- ::05Z bird $
## @file
# VirtualBox Uninstaller Script.
# #
# Copyright (C) - Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
# # Override any funny stuff from the user.
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH" #
# Display a simple welcome message first.
#
echo ""
echo "Welcome to the VirtualBox uninstaller script."
echo "" #
# Check for arguments and display
#
my_default_prompt=
if test "$#" != ""; then
if test "$#" != "" -o "$1" != "--unattended"; then
echo "Error: Unknown argument(s): $*"
echo ""
echo "Usage: uninstall.sh [--unattended]"
echo ""
echo "If the '--unattended' option is not given, you will be prompted"
echo "for a Yes/No before doing the actual uninstallation."
echo ""
exit ;
fi
my_default_prompt="Yes"
fi #
# Collect directories and files to remove.
# Note: Do NOT attempt adding directories or filenames with spaces!
#
declare -a my_directories
declare -a my_files # Users files first
test -f "${HOME}/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist" && my_files+=("${HOME}/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist") test -d /Library/StartupItems/VirtualBox/ && my_directories+=("/Library/StartupItems/VirtualBox/")
test -d /Library/Receipts/VBoxStartupItems.pkg/ && my_directories+=("/Library/Receipts/VBoxStartupItems.pkg/") test -d "/Library/Application Support/VirtualBox/LaunchDaemons/" && my_directories+=("/Library/Application Support/VirtualBox/LaunchDaemons/")
test -d "/Library/Application Support/VirtualBox/VBoxDrv.kext/" && my_directories+=("/Library/Application Support/VirtualBox/VBoxDrv.kext/")
test -d "/Library/Application Support/VirtualBox/VBoxUSB.kext/" && my_directories+=("/Library/Application Support/VirtualBox/VBoxUSB.kext/")
test -d "/Library/Application Support/VirtualBox/VBoxNetFlt.kext/" && my_directories+=("/Library/Application Support/VirtualBox/VBoxNetFlt.kext/")
test -d "/Library/Application Support/VirtualBox/VBoxNetAdp.kext/" && my_directories+=("/Library/Application Support/VirtualBox/VBoxNetAdp.kext/")
# Pre 4.3.0rc1 locations:
test -d /Library/Extensions/VBoxDrv.kext/ && my_directories+=("/Library/Extensions/VBoxDrv.kext/")
test -d /Library/Extensions/VBoxUSB.kext/ && my_directories+=("/Library/Extensions/VBoxUSB.kext/")
test -d /Library/Extensions/VBoxNetFlt.kext/ && my_directories+=("/Library/Extensions/VBoxNetFlt.kext/")
test -d /Library/Extensions/VBoxNetAdp.kext/ && my_directories+=("/Library/Extensions/VBoxNetAdp.kext/")
# Tiger support is obsolete, but we leave it here for a clean removing of older
# VirtualBox versions
test -d /Library/Extensions/VBoxDrvTiger.kext/ && my_directories+=("/Library/Extensions/VBoxDrvTiger.kext/")
test -d /Library/Extensions/VBoxUSBTiger.kext/ && my_directories+=("/Library/Extensions/VBoxUSBTiger.kext/")
test -d /Library/Receipts/VBoxKEXTs.pkg/ && my_directories+=("/Library/Receipts/VBoxKEXTs.pkg/") test -f /usr/bin/VirtualBox && my_files+=("/usr/bin/VirtualBox")
test -f /usr/bin/VBoxManage && my_files+=("/usr/bin/VBoxManage")
test -f /usr/bin/VBoxVRDP && my_files+=("/usr/bin/VBoxVRDP")
test -f /usr/bin/VBoxHeadless && my_files+=("/usr/bin/VBoxHeadless")
test -f /usr/bin/vboxwebsrv && my_files+=("/usr/bin/vboxwebsrv")
test -f /usr/bin/VBoxBugReport && my_files+=("/usr/bin/VBoxBugReport")
test -f /usr/bin/VBoxBalloonCtrl && my_files+=("/usr/bin/VBoxBalloonCtrl")
test -f /usr/bin/VBoxAutostart && my_files+=("/usr/bin/VBoxAutostart")
test -f /usr/bin/VBoxDTrace && my_files+=("/usr/bin/VBoxDTrace")
test -f /usr/bin/vbox-img && my_files+=("/usr/bin/vbox-img")
test -f /usr/local/bin/VirtualBox && my_files+=("/usr/local/bin/VirtualBox")
test -f /usr/local/bin/VBoxManage && my_files+=("/usr/local/bin/VBoxManage")
test -f /usr/local/bin/VBoxVRDP && my_files+=("/usr/local/bin/VBoxVRDP")
test -f /usr/local/bin/VBoxHeadless && my_files+=("/usr/local/bin/VBoxHeadless")
test -f /usr/local/bin/vboxwebsrv && my_files+=("/usr/local/bin/vboxwebsrv")
test -f /usr/local/bin/VBoxBugReport && my_files+=("/usr/local/bin/VBoxBugReport")
test -f /usr/local/bin/VBoxBalloonCtrl && my_files+=("/usr/local/bin/VBoxBalloonCtrl")
test -f /usr/local/bin/VBoxAutostart && my_files+=("/usr/local/bin/VBoxAutostart")
test -f /usr/local/bin/VBoxDTrace && my_files+=("/usr/local/bin/VBoxDTrace")
test -f /usr/local/bin/vbox-img && my_files+=("/usr/local/bin/vbox-img")
test -d /Library/Receipts/VirtualBoxCLI.pkg/ && my_directories+=("/Library/Receipts/VirtualBoxCLI.pkg/")
test -f /Library/LaunchDaemons/org.virtualbox.startup.plist && my_files+=("/Library/LaunchDaemons/org.virtualbox.startup.plist") test -d /Applications/VirtualBox.app/ && my_directories+=("/Applications/VirtualBox.app/")
test -d /Library/Receipts/VirtualBox.pkg/ && my_directories+=("/Library/Receipts/VirtualBox.pkg/") # legacy
test -d /Library/Receipts/VBoxDrv.pkg/ && my_directories+=("/Library/Receipts/VBoxDrv.pkg/")
test -d /Library/Receipts/VBoxUSB.pkg/ && my_directories+=("/Library/Receipts/VBoxUSB.pkg/") # python stuff
python_versions="2.3 2.5 2.6 2.7"
for p in $python_versions; do
test -f /Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.py && my_files+=("/Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.py")
test -f /Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.pyc && my_files+=("/Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.pyc")
test -f /Library/Python/$p/site-packages/vboxapi/__init__.py && my_files+=("/Library/Python/$p/site-packages/vboxapi/__init__.py")
test -f /Library/Python/$p/site-packages/vboxapi/__init__.pyc && my_files+=("/Library/Python/$p/site-packages/vboxapi/__init__.pyc")
test -f /Library/Python/$p/site-packages/vboxapi-1.0-py$p.egg-info && my_files+=("/Library/Python/$p/site-packages/vboxapi-1.0-py$p.egg-info")
test -d /Library/Python/$p/site-packages/vboxapi/ && my_directories+=("/Library/Python/$p/site-packages/vboxapi/")
done #
# Collect KEXTs to remove.
# Note that the unload order is significant.
#
declare -a my_kexts
for kext in org.virtualbox.kext.VBoxUSB org.virtualbox.kext.VBoxNetFlt org.virtualbox.kext.VBoxNetAdp org.virtualbox.kext.VBoxDrv; do
if /usr/sbin/kextstat -b $kext -l | grep -q $kext; then
my_kexts+=("$kext")
fi
done #
# Collect packages to forget
#
my_pb='org\.virtualbox\.pkg\.'
my_pkgs=`/usr/sbin/pkgutil --pkgs="${my_pb}vboxkexts|${my_pb}vboxstartupitems|${my_pb}virtualbox|${my_pb}virtualboxcli"` #
# Did we find anything to uninstall?
#
if test -z "${my_directories[*]}" -a -z "${my_files[*]}" -a -z "${my_kexts[*]}" -a -z "$my_pkgs"; then
echo "No VirtualBox files, directories, KEXTs or packages to uninstall."
echo "Done."
exit ;
fi #
# Look for running VirtualBox processes and warn the user
# if something is running. Since deleting the files of
# running processes isn't fatal as such, we will leave it
# to the user to choose whether to continue or not.
#
# Note! comm isn't supported on Tiger, so we make -c to do the stripping.
#
my_processes="`ps -axco 'pid uid command' | grep -wEe '(VirtualBox|VirtualBoxVM|VBoxManage|VBoxHeadless|vboxwebsrv|VBoxXPCOMIPCD|VBoxSVC|VBoxNetDHCP|VBoxNetNAT)' | grep -vw grep | grep -vw VirtualBox_Uninstall.tool | tr '\n' '\a'`";
if test -n "$my_processes"; then
echo 'Warning! Found the following active VirtualBox processes:'
echo "$my_processes" | tr '\a' '\n'
echo ""
echo "We recommend that you quit all VirtualBox processes before"
echo "uninstalling the product."
echo ""
if test "$my_default_prompt" != "Yes"; then
echo "Do you wish to continue none the less (Yes/No)?"
read my_answer
if test "$my_answer" != "Yes" -a "$my_answer" != "YES" -a "$my_answer" != "yes"; then
echo "Aborting uninstall. (answer: '$my_answer')".
exit ;
fi
echo ""
my_answer=""
fi
fi #
# Display the files and directories that will be removed
# and get the user's consent before continuing.
#
if test -n "${my_files[*]}" -o -n "${my_directories[*]}"; then
echo "The following files and directories (bundles) will be removed:"
for file in "${my_files[@]}"; do echo " $file"; done
for dir in "${my_directories[@]}"; do echo " $dir"; done
echo ""
fi
if test -n "${my_kexts[*]}"; then
echo "And the following KEXTs will be unloaded:"
for kext in "${my_kexts[@]}"; do echo " $kext"; done
echo ""
fi
if test -n "$my_pkgs"; then
echo "And the traces of following packages will be removed:"
for kext in $my_pkgs; do echo " $kext"; done
echo ""
fi if test "$my_default_prompt" != "Yes"; then
echo "Do you wish to uninstall VirtualBox (Yes/No)?"
read my_answer
if test "$my_answer" != "Yes" -a "$my_answer" != "YES" -a "$my_answer" != "yes"; then
echo "Aborting uninstall. (answer: '$my_answer')".
exit ;
fi
echo ""
fi #
# Unregister has to be done before the files are removed.
#
LSREGISTER=/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister
if [ -e ${LSREGISTER} ]; then
${LSREGISTER} -u /Applications/VirtualBox.app > /dev/null
${LSREGISTER} -u /Applications/VirtualBox.app/Contents/Resources/vmstarter.app > /dev/null
fi #
# Display the sudo usage instructions and execute the command.
#
echo "The uninstallation processes requires administrative privileges"
echo "because some of the installed files cannot be removed by a normal"
echo "user. You may be prompted for your password now..."
echo "" if test -n "${my_files[*]}" -o -n "${my_directories[*]}"; then
/usr/bin/sudo -p "Please enter %u's password:" /bin/rm -Rf "${my_files[@]}" "${my_directories[@]}"
my_rc=$?
if test "$my_rc" -ne ; then
echo "An error occurred durning 'sudo rm', there should be a message above. (rc=$my_rc)"
test -x /usr/bin/sudo || echo "warning: Cannot find /usr/bin/sudo or it's not an executable."
test -x /bin/rm || echo "warning: Cannot find /bin/rm or it's not an executable"
echo ""
echo "The uninstall failed. Please retry."
exit ;
fi
fi my_rc=
for kext in "${my_kexts[@]}"; do
echo unloading $kext
/usr/bin/sudo -p "Please enter %u's password (unloading $kext):" /sbin/kextunload -m $kext
my_rc2=$?
if test "$my_rc2" -ne ; then
echo "An error occurred durning 'sudo /sbin/kextunload -m $kext', there should be a message above. (rc=$my_rc2)"
test -x /usr/bin/sudo || echo "warning: Cannot find /usr/bin/sudo or it's not an executable."
test -x /sbin/kextunload || echo "warning: Cannot find /sbin/kextunload or it's not an executable"
my_rc=$my_rc2
fi
done
if test "$my_rc" -eq ; then
echo "Successfully unloaded VirtualBox kernel extensions."
else
echo "Failed to unload one or more KEXTs, please reboot the machine to complete the uninstall."
exit ;
fi # Cleaning up pkgutil database
for my_pkg in $my_pkgs; do
/usr/bin/sudo -p "Please enter %u's password (removing $my_pkg):" /usr/sbin/pkgutil --forget "$my_pkg"
done echo "Done."
exit ;

virtualbox和vagrant卸载脚本在macbook的更多相关文章

  1. 【转载】linux-查询rpm包相关安装、卸载脚本

        测试过程中,有时要测试开发自己打的rpm包,为了确认打包正确,需要查询rpm包相关安装.卸载脚本,可以使用命令:   [root@6 /]#rpm -q --scripts mysql pos ...

  2. VirtualBox 扩展包卸载或安装失败(VERR_ALREADY_EXISTS)

    最近在卸载VirtualBox出现了无法卸载的错误.提示为Failed to install the extension. The installer failed with exit code 1: ...

  3. VirtualBox 扩展包卸载或安装失败(VERR_ALREADY_EXISTS)(转)

    文章出处:http://blog.csdn.net/leshami/article/details/9232229 最近在卸载VirtualBox出现了无法卸载的错误.提示为Failed to ins ...

  4. 用VirtualBox和vagrant在win7×64上搭建ruby on rails 开发环境

    下载准备 1.vagrant 官方  WINDOWS Universal (32 and 64-bit) http://www.vagrantup.com/downloads.html 2.Virtu ...

  5. erlang mac os 10.9 卸载脚本

    #!/bin/bash if [ "$(id -u)" != "0" ]; then echo "Insufficient permissions. ...

  6. ambari 卸载脚本

    #!/bin/bash # Program: # uninstall ambari automatic PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bi ...

  7. cloudera manager 5.3完整卸载脚本

    service cloudera-scm-agent stop service cloudera-scm-agent stop umount /var/run/cloudera-scm-agent/p ...

  8. Ubuntu 软件卸载脚本(卸载软件 + 移除配置文件 + 移除依赖项)

    #!/bin/bash function z-apt-uninstall() { if [ ! $1 ] then echo "z-apt-uninstall error: software ...

  9. Laravel系列之环境搭建 — VirtualBox+Vagrant+Homestead

    一.为啥需要搭建环境 为了解决环境不统一问题,所以要搭建这么个玩意儿 二.步骤  Laravel对环境有所要求(不使用Homestead情况下),具体参考官网 使用Homestead步骤 1. Hom ...

随机推荐

  1. Eclipse项目修改没有同步到编译的问题

    有两个原因: 1:项目有错,不能正常编译:查看是否有Jar包冲突.JDK版本问题等: 2:编译输出目录配置错误: Maven项目会修改项目编译时的输出路径到target文件夹,但是我们用Myelips ...

  2. Java IO的应用之实现大文件复制

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/5827481.html  用IO进行文件复制,实质就是用FileInputStream链接要复制的文件,按一定规 ...

  3. PgSql备份pg_dump与还原手记pg_restore

    真没有想到,以前一直是PostgreSQL使用者,突然需要库移植又成了头一招了!原来它与mysql命令行操作区别还挺大.不用怕,但绝对要细心,因为数据库操作是网站的核心,一旦出现损坏或丢失,后果就非常 ...

  4. 使用SHA256WithRSA来签名和验签(.NET/C#)

    RSACryptoServiceProvider does work with SHA2-based signatures, but you have to invest some effort in ...

  5. 小贝_mysql 触发器使用

    触发器 简要 1.触发器基本概念 2.触发器语法及实战样例 3.before和after差别 一.触发器基本概念 1.一触即发 2.作用: 监视某种情况并触发某种操作 3.观察场景 一个电子商城: 商 ...

  6. excel文件批量重命名

    1.创建bat文件 2.在文件内输入以下格式的内容并保存,注意期间有空格 ren 1.txt 0011.txt     ren 2.txt 0021.txt     ren 3.txt 0031.tx ...

  7. 自制小工具含源码——SPTC上海交通卡余额查询

    说明 需求 开发 其他

  8. [转载]在VirtualBox中收缩虚拟磁盘映像文件

    原文地址:在VirtualBox中收缩虚拟磁盘映像文件作者:bobby 由于经常要测试一些软件,我在VirtualBox虚拟机中安装了一套Windows.使用过虚拟机的朋友都知道,为了节省硬盘空间,一 ...

  9. db_table--Spring Security3.1 最新配置实例

    2011-04-28 这几天学习了一下Spring Security3.1,从官网下载了Spring Security3.1版本进行练习,经过多次尝试才摸清了其中的一些原理.本人不才,希望能帮助大家. ...

  10. Python实现鸢尾花数据集分类问题——使用LogisticRegression分类器

    . 逻辑回归 逻辑回归(Logistic Regression)是用于处理因变量为分类变量的回归问题,常见的是二分类或二项分布问题,也可以处理多分类问题,它实际上是属于一种分类方法. 概率p与因变量往 ...