-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathuninstall.sh
executable file
·133 lines (107 loc) · 4.76 KB
/
uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
#==============================================================================
#==============================================================================
# Copyright (c) 2016 Jonathan Yantis
# yantis@yantis.net
# Released under the MIT license
#==============================================================================
#==============================================================================
###############################################################################
# Set the disk we are working on. For USB this may change later.
# The default is disk0
###############################################################################
ROOTDISK=disk0
set -u
###############################################################################
# Keep trying to unmount for up to 10 seconds. Some slow USBs can take a bit.
###############################################################################
unmount()
{
timeout=$(($(date +%s) + 10))
until sudo diskutil umount "${1}" 2>/dev/null || [[ $(date +%s) -gt $timeout ]]; do
:
done
}
###############################################################################
# Disable sudo password request time out for now.
# Editing sudoers this way on a mac really is no big deal.
# You can quickly fix any mistakes you make to it by:
# Hitting shift+⌘-+g typing /etc. Selecting sudoers and hitting ⌘-+i
# then unlock it and change your permissions to fix it.
###############################################################################
echo "Temporarily Disabling sudo password timeout"
sudo sh -c 'echo "\nDefaults timestamp_timeout=-1">>/etc/sudoers'
##############################################################################
# Uninstall Boot2Docker
###############################################################################
if hash boot2docker 2> /dev/null; then
echo "Removing boot2docker"
boot2docker stop
boot2docker delete
brew uninstall --force boot2docker
fi
###############################################################################
# Uninstall docker"
###############################################################################
if hash docker-machine 2> /dev/null; then
# echo "Remove our docker image"
# docker rmi yantis/instant-archlinux-on-mac
echo "Uninstalling docker-vm"
yes | docker-machine rm docker-vm
###############################################################################
# Uninstall docker
###############################################################################
echo "Uninstalling docker"
brew uninstall --force docker-machine
brew uninstall --force docker
brew uninstall --force boot2docker
fi
###############################################################################
# Uninstall virtualbox
###############################################################################
if hash vboxmanage 2> /dev/null; then
if [ ! -f VirtualBox-5.1.8-111374-OSX.dmg ];
then
curl -OL http://download.virtualbox.org/virtualbox/5.1.8/VirtualBox-5.1.8-111374-OSX.dmg
fi
hdiutil mount VirtualBox-5.1.8-111374-OSX.dmg
sudo sh /Volumes/VirtualBox/VirtualBox_Uninstall.tool --unattended
sleep 2
hdiutil unmount /Volumes/VirtualBox/
# Unrem this to remove the downloaded install file.
# rm VirtualBox-4.3.26-98988-OSX.dmg
fi
###############################################################################
# Remove Archlinux Volume
###############################################################################
if [ -d /Volumes/1 ]; then
echo "Removing ArchLinux Volume"
# echo "Get our ext4 volume. It should always be at disk0s4. But just in case."
EXT4VOL=$(diskutil list ${ROOTDISK} | grep "Linux Filesystem" | awk '{print $7}')
echo $EXT4VOL
# Sanity Check
if echo $EXT4VOL | grep -q "${ROOTDISK}s" ; then
echo "Our ext4 volume is $EXT4VOL"
fi
unmount $EXT4VOL
sudo rm -rf /Volumes/1
# Todo need to delete the Volume with diskutil
fi
###############################################################################
# Remove rEFInd
###############################################################################
if [ ! -d /Volumes/ESP ]; then
echo "Mounting EFI volume"
sudo mkdir -p /Volumes/ESP
sudo mount -t msdos /dev/disk0s1 /Volumes/ESP
echo "rEFInd installed uninstalling it."
sudo rm -rf /Volumes/ESP/EFI/refind
fi
###############################################################################
# Restore security
###############################################################################
sudo sed -i.bak "s/Defaults timestamp_timeout=-1/#Defaults timestamp_timeout=-1/" /etc/sudoers
###############################################################################
# All Done
###############################################################################
# vim:set ts=2 sw=2 et: