forked from ptb/mac-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep-1.command
executable file
·93 lines (72 loc) · 3.77 KB
/
step-1.command
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
sudo pmset -a sleep 0
sudo pmset -a disksleep 0
if ! grep -Fq '/usr/local/sbin' /etc/paths; then
sudo sed -i -e '/\/usr\/sbin/i\
\/usr\/local\/sbin\
' /etc/paths
fi
sudo mkdir -p '/usr/local/Caskroom'
sudo chgrp admin '/usr/local/' '/usr/local/Caskroom/' '/Library/ColorPickers/' '/Library/Screen Savers/'
sudo chmod g+w '/usr/local/' '/usr/local/Caskroom/' '/Library/ColorPickers/' '/Library/Screen Savers/'
sudo tee /etc/environment > /dev/null <<-EOF
#!/bin/sh
set -e
syslog -s -l warn "Set environment variables for \$(whoami) - start"
CASK_OPTS="--appdir=/Applications"
CASK_OPTS="\${CASK_OPTS} --caskroom=/usr/local/Caskroom"
CASK_OPTS="\${CASK_OPTS} --colorpickerdir=/Library/ColorPickers"
CASK_OPTS="\${CASK_OPTS} --fontdir=/Library/Fonts"
CASK_OPTS="\${CASK_OPTS} --prefpanedir=/Library/PreferencePanes"
CASK_OPTS="\${CASK_OPTS} --screen_saverdir='/Library/Screen Savers'"
export HOMEBREW_CASK_OPTS=\$CASK_OPTS
launchctl setenv HOMEBREW_CASK_OPTS "\$CASK_OPTS"
if [ -x /usr/libexec/path_helper ]; then
export PATH=""
eval \`/usr/libexec/path_helper -s\`
launchctl setenv PATH \$PATH
fi
osascript -e 'tell app "Dock" to quit'
syslog -s -l warn "Set environment variables for \$(whoami) - complete"
EOF
sudo chmod a+x /etc/environment
sudo defaults write '/Library/LaunchAgents/environment.user' 'Label' -string 'environment.user'
sudo defaults write '/Library/LaunchAgents/environment.user' 'ProgramArguments' -array-add '/etc/environment'
sudo defaults write '/Library/LaunchAgents/environment.user' 'RunAtLoad' -bool true
sudo defaults write '/Library/LaunchAgents/environment.user' 'WatchPaths' -array-add '/etc/environment'
sudo defaults write '/Library/LaunchAgents/environment.user' 'WatchPaths' -array-add '/etc/paths'
sudo defaults write '/Library/LaunchAgents/environment.user' 'WatchPaths' -array-add '/etc/paths.d'
sudo plutil -convert xml1 '/Library/LaunchAgents/environment.user.plist'
sudo chmod 644 /Library/LaunchAgents/environment.user.plist
sudo launchctl load -w /Library/LaunchAgents/environment.user.plist
sudo defaults write '/Library/LaunchDaemons/environment' 'Label' -string 'environment'
sudo defaults write '/Library/LaunchDaemons/environment' 'ProgramArguments' -array-add '/etc/environment'
sudo defaults write '/Library/LaunchDaemons/environment' 'RunAtLoad' -bool true
sudo defaults write '/Library/LaunchDaemons/environment' 'WatchPaths' -array-add '/etc/environment'
sudo defaults write '/Library/LaunchDaemons/environment' 'WatchPaths' -array-add '/etc/paths'
sudo defaults write '/Library/LaunchDaemons/environment' 'WatchPaths' -array-add '/etc/paths.d'
sudo plutil -convert xml1 '/Library/LaunchDaemons/environment.plist'
sudo chmod 644 /Library/LaunchDaemons/environment.plist
sudo launchctl load -w /Library/LaunchDaemons/environment.plist
/bin/echo -n "Enter full name: "
read FULLNAME
/bin/echo -n "Enter account name: "
read USERNAME
/bin/echo -n "Enter password: "
read -s PASSWORD
LASTID=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
USERID=$((LASTID+1))
sudo dscl . -create "/Users/${USERNAME}"
sudo dscl . -create "/Users/${USERNAME}" UserShell /bin/zsh
sudo dscl . -create "/Users/${USERNAME}" RealName "${FULLNAME}"
sudo dscl . -create "/Users/${USERNAME}" UniqueID "${USERID}"
sudo dscl . -create "/Users/${USERNAME}" PrimaryGroupID 20
sudo dscl . -create "/Users/${USERNAME}" NFSHomeDirectory "/Users/${USERNAME}"
sudo dscl . -passwd "/Users/${USERNAME}" "${PASSWORD}"
ADMIN_GROUPS="admin appserveradm appserverusr com.apple.sharepoint.group.1 lpadmin"
for GROUP in $ADMIN_GROUPS ; do
sudo dseditgroup -o edit -t user -a $USERNAME $GROUP
done
sudo createhomedir -c -u $USERNAME 2> /dev/null
sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool true
osascript -e 'tell app "loginwindow" to «event aevtrrst»'