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. climbing-stairs-动态规划,爬楼梯的路径数

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  2. java json与map互相转换(二)

      java json与map互相转换(二) CreationTime--2018年7月16日15点09分 Author:Marydon 1.准备工作 所需jar包: commons-beanutil ...

  3. APache PDFbox API使用(1)----简单介绍

    因为项目的须要.近期在学习APache  PDFbox API,Apache PDFbox API是Apache Java 开源社区中个一个项目,其受Apache 版权 V2的保护,其提供了以下的功能 ...

  4. Solidworks机构运动仿真

    使用Solidworks Motion插件可以对机构进行运动学/动力学仿真.机构约束添加完成后,可以在主动部件(关节)处添加马达进行驱动.运动可以是简单的匀速运动或者复杂的表达式.数据点形式的运动. ...

  5. VTK中模型的旋转与平移

    当从外界读入STL等三维模型时,其会按照它内部的坐标位置进行显示.因此它的位置和大小是确定的.但是在实际应用中,有可能需要人为地对这个模型在空间中进行旋转.平移或缩放等操作.VTK中有许多和旋转.平移 ...

  6. Axure 图片轮播(广告通栏图片自动播放效果)

    baiduYunpan:http://pan.baidu.com/s/1eRPCy90 里面的“图片轮播”部件即可实现这个功能

  7. python模块之httplib(在py3中功能进一步强大,请详看文档)

    # -*- coding: utf-8 -*-#python 27#xiaodeng#python模块之httplib(在py3中功能进一步强大,请详看文档) import httplib#是较为底层 ...

  8. 如何实现两台Domino之间的相互访问

    一)交叉验证    1启动Administrator软件,连接到您的服务器,点击"配置"标签.    2点击右边屏幕"工具"--"验证字"--"交叉验证"    3选择您自己的cert.id,输入其口 ...

  9. Netstat命令详解(windows下)

      Netstat 用于显示与IP .TCP .UDP 和ICMP 协议相关的统计数据,一般用于检验本机各端口的网络连接情况. 如果你的计算机有时候接收到的数据报导致出错数据或故障,你不必感到奇怪,T ...

  10. 【mysql】关于ICP、MRR、BKA等特性

    一.Index Condition Pushdown(ICP) Index Condition Pushdown (ICP)是mysql使用索引从表中检索行数据的一种优化方式,从mysql5.6开始支 ...