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. React-Native视频组件react-native-video使用(安卓版)

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/7366019.html 一:安装 在IDE中打开你的项目,然后在IDE的terminal,输入: npm i - ...

  2. EF Code First导航属性一对一关系中注意点及配置方法

    //学生 public class Student { [key] public int StId { get; set; } public int SocialSecurityNumber { ge ...

  3. nginx 和php设置上传大小及可以提交的内容限制

    1. 以下代码加入 /etc/nginx/nginx.conf 文件中的 http{ ... } 块中 client_max_body_size 8M; 2. PHP 设置上传大小 打开 /etc/p ...

  4. Software development --daily scrum team

    History[edit] Scrum was first defined as "a flexible, holistic product development strategy whe ...

  5. python之docstrinigs

    # -*- coding: cp936 -*- #python 27 #xiaodeng #docstrinigs #文档字符串惯例 ''' 1.多行字符串 2.首行以大写字母开始,以句号结束 3.第 ...

  6. 转 CentOS下php安装mcrypt扩展

    (以下步骤均为本人实际操作,可能与你的安装方法有所区别,但我会尽量排除疑惑) 大致步骤(1)安装mcrypt,(2)安装php对mcrypt的扩展,(3)重启apache (1).确认你的linux没 ...

  7. Javascript 思维导图 绘制基础内容(值得一看)

    来源于:http://www.cnblogs.com/coco1s/p/3953653.html javascript变量 javascript运算符 javascript数组 javascript流 ...

  8. Easyui入门视频教程 第10集---Messager的使用

    Easyui入门视频教程 第10集---Messager的使用 <script type="text/javascript"> function show(){ $.m ...

  9. 设置树莓派SSH连接因超时闲置断开(转)

    设置树莓派SSH连接因超时闲置断开 转自:http://shumeipai.nxez.com/2013/12/06/set-ssh-connection-is-disconnected-due-to- ...

  10. java 结束程序进程 代码

    结束firefox的进程,一句代码就够了,如下: Runtime.getRuntime().exec("taskkill /F /IM firefox.exe"); 结束qq: R ...