-
Notifications
You must be signed in to change notification settings - Fork 1
/
LAB_User_Template_Finder.sh
executable file
·94 lines (70 loc) · 3.42 KB
/
LAB_User_Template_Finder.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
#!/bin/sh
# Jason Filice
# Technology Support Services in IT
# California State University, Monterey Bay
# https://csumb.edu/it
# Commands must run as root.
#
# History
# 2021/08/31: Creation.
#
SCRIPTNAME=`/usr/bin/basename "$0"`
SCRIPTPATH=`/usr/bin/dirname "$0"`
echo "***Begin $SCRIPTNAME script***"
/bin/date
# set alias for PlistBuddy and several others so I don't have to specify full path.
# Prefix sudo path because I'm using it here for all commands.
# If I want to run a command without the alias, then specify the full path.
alias PlistBuddy="/usr/libexec/PlistBuddy"
alias chown="/usr/sbin/chown"
alias chmod="/bin/chmod"
alias ditto="/usr/bin/ditto"
alias defaults="defaults"
alias rm="/bin/rm"
alias cp="/bin/cp"
alias mkdir="/bin/mkdir"
alias mv="/bin/mv"
alias sudo=/usr/bin/sudo
# set -x # For debugging, show commands.
osXversion=$(sw_vers -productVersion)
echo "osXversion=$osXversion"
# Just get the second version value after 10.
macOSversionMajor=$(echo $osXversion | awk -F. '{print $1}')
macOSversionMinor=$(echo $osXversion | awk -F. '{print $2}')
echo "macOSversionMajor=$macOSversionMajor"
echo "macOSversionMinor=$macOSversionMinor"
# if
# macOS 11.x or newer
# or
# macOS 10.15.x or newer
if [ $macOSversionMajor -ge 11 ] || [ $macOSversionMajor -ge 10 -a $macOSversionMinor -ge 15 ]; then
echo "10.15 and newer"
USER_TEMPL='/Library/User Template'
else
echo "older than 10.15"
USER_TEMPL='/System/Library/User Template'
fi
echo "USER_TEMPL=$USER_TEMPL"
########## FINDER ##########
mkdir -pv -m 755 "${USER_TEMPL}/Non_localized/Library/Preferences"
touch "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist"
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowPathBar -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowPathbar -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowStatusBar -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowMountedServersOnDesktop -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowHardDrivesOnDesktop -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" BrowserWindowRestoreAttempted -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" FinderSpawnWindow -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowExternalHardDrivesOnDesktop -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowRemovableMediaOnDesktop -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" SidebarDevicesSectionDisclosedState -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" SidebarPlacesSectionDisclosedState -bool TRUE
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" FXPreferredViewStyle -string "Nlsv"
defaults write "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist" ShowSidebar -bool TRUE
chmod 644 "${USER_TEMPL}/Non_localized/Library/Preferences/com.apple.finder.plist"
chown -fR 0:0 "${USER_TEMPL}"
########## ##########
echo "***End $SCRIPTNAME script***"
/bin/date
exit 0