-
Notifications
You must be signed in to change notification settings - Fork 37
/
RenameStartupVolume.sh
66 lines (57 loc) · 2.33 KB
/
RenameStartupVolume.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
#!/bin/sh
##########################################
# Rename Startup Volume
# Josh Harvey | Jul 2017
# josh[at]macjeezy.com
# GitHub - github.com/therealmacjeezy
# JAMFnation - therealmacjeezy
##########################################
############################### Notes ##################################
# This script will find the boot volume using the bless command
# and then get the current volume name for the boot volume using
# the diskutil command. It will then find the short version of
# macOS the computer has installed.
#
# The reason for this script is so that the startup volume names
# are uniformed based off of the macOS version they have installed.
# The variable "newName" is then assigned a string based off of the
# macOS version installed. This variable is then compaired to the
# current volume name. If the names do not match, it will automatically
# rename the startup volume to the correct name.
#
########### ISSUES / USAGE #############################################
# If you have any issues or questions please feel free to contact
# using the information in the header of this script.
#
# Also, Please give me credit and let me know if you are going to use
# this script. I would love to know how it works out and if you find
# it helpful.
########################################################################
# Finds the current boot volume
bootVolume=`/usr/sbin/bless --info --getboot`
# Uses the variable above to pull the name of the boot volume
bootVolumeName=`/usr/sbin/diskutil info $bootVolume | grep "Volume Name" | sed 's/.*://g' | awk '{$1=$1};1'`
# Finds the OS version installed on the computer
osVersion=`/usr/bin/sw_vers -productVersion`
# Finds the correct Volume Name for the macOS version
if [[ "$osVersion" =~ "10.11" ]];
then
newName="macOS1011"
elif [[ "$osVersion" =~ "10.12" ]];
then
newName="macOS1012"
fi
# Compares the current volume name to the one that it's supposed to have based off the variables set above
if [[ "$bootVolumeName" == "$newName" ]];
then
validName="Yes"
else
validName="No"
fi
# If the volume name is invalid, it will be renamed to the correct name
if [[ "$validName" == "No" ]];
then
/usr/sbin/diskutil rename "$bootVolume" "$newName"
else
echo "Current Volume Name is Valid"
fi