-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmac-install-internal
More file actions
executable file
·129 lines (101 loc) · 6.61 KB
/
mac-install-internal
File metadata and controls
executable file
·129 lines (101 loc) · 6.61 KB
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
#!/bin/bash
# TODO:
# - Autopopulate dock. I tried using dockutil, but it had silent failures.
# - Cauxpublic mounting alias. I've still not found a way to create this programatically so that it auto-mounts.
# - Automatically install internet cafe printers on internet cafe machines.
shopt -s nullglob
die() {
printf '%s\n' "$@"
exit 1
}
username="iofc"
#read -rp "Login: " username
realName="$username"
password="$username" # As weird as this looks, we only need this for autologin, otherwise we wouldn't need one.
(( EUID )) && die "This script must be run as root."
curl -s -o /tmp/kcpassword.pl 'https://raw.githubusercontent.com/caux-iofc/kcpassword/master/kcpassword.pl' || die "Couldn't download kcpassword."
chmod a+x /tmp/kcpassword.pl
id -u "$username" >/dev/null 2>&1 && die "User $username already exists on system."
read -rp "Computer ID: " computerID
username+=$computerID
realName+=$computerID
dscl . -create "/Users/$username" || die "Failed to create user."
dscl . -create "/Users/$username" UserShell /bin/bash || die "Failed to set user shell."
dscl . -create "/Users/$username" RealName "$realName" || die "Failed to set user real name."
dscl . -create "/Users/$username" UniqueID "$(dscl . -list /Users UniqueID | awk 'BEGIN{i=0}{if($2>i)i=$2}END{print i+1}')" || die "Failed to set UID."
dscl . -create "/Users/$username" PrimaryGroupID 20 || die "Failed to set primary GID as staff."
dscl . -create "/Users/$username" NFSHomeDirectory "/Users/$username" || die "Failed to set NFS directory."
dscl . -passwd "/Users/$username" "$password" || die "Failed to set password."
cp -a "/System/Library/User Template/English.lproj" "/Users/$username" || die "Failed to copy lproj."
chown -R "$username:staff" "/Users/$username" || die "Failed to change homedir ownership."
for group in localaccounts everyone; do
dseditgroup -o edit -t user -a "$username" "$group" || die "Failed to add secondary group $group."
done
defaults write /Library/Preferences/.GlobalPreferences MultipleSessionEnabled -bool yes || die "Failed to enable fast user switching."
defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser $username
# stop reopening windows after a reboot
defaults write com.apple.loginwindow TALLogoutSavesState -bool false
defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false
for file in /etc/cups/ppd/*.ppd; do
printer="${file##*/}"
printer="${printer%.*}"
read -rp "Delete printer $printer? "
[[ $REPLY == [yY]* ]] && lpadmin -x "$printer"
done
/tmp/kcpassword.pl "$username" "$password"
read -rp "Enable parental controls? "
if [[ $REPLY == [yY]* ]]; then
curl -s -o /tmp/mac-parental-controls 'https://raw.githubusercontent.com/caux-iofc/scripts/master/mac-parental-controls' || die "Couldn't download mac-parental-controls"
chmod a+x /tmp/mac-parental-controls
bash /tmp/mac-parental-controls $username
fi
# ==============================================
# Set keyboard preferences
# ==============================================
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.SwissFrench"
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleDefaultAsciiInputSource -dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 18 "KeyboardLayout Name" "Swiss French"
# Enable US layout
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }'
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleInputSourceHistory -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }'
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleSelectedInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }'
# Enable British layout
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 2; "KeyboardLayout Name" = "British"; }'
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleInputSourceHistory -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 2; "KeyboardLayout Name" = "British"; }'
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleSelectedInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 2; "KeyboardLayout Name" = "British"; }'
# Enable key repeat
sudo defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool FALSE
# Set keyboard repeat rate
sudo defaults write NSGlobalDomain KeyRepeat -int 2
# Add keyboard switcher to the top right menu, install a few extra keyboard layouts
# defaults read /Users/$username/Library/Preferences/com.apple.systemuiserver menuExtras
# (
# "/System/Library/CoreServices/Menu Extras/TimeMachine.menu",
# "/System/Library/CoreServices/Menu Extras/Bluetooth.menu",
# "/System/Library/CoreServices/Menu Extras/AirPort.menu",
# "/System/Library/CoreServices/Menu Extras/Volume.menu",
# "/System/Library/CoreServices/Menu Extras/TextInput.menu",
# "/System/Library/CoreServices/Menu Extras/Clock.menu",
# "/System/Library/CoreServices/Menu Extras/User.menu"
# )
sudo defaults write /Users/$username/Library/Preferences/com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Bluetooth.menu" "/System/Library/CoreServices/Menu Extras/AirPort.menu" "/System/Library/CoreServices/Menu Extras/Volume.menu" "/System/Library/CoreServices/Menu Extras/TextInput.menu" "/System/Library/CoreServices/Menu Extras/Clock.menu" "/System/Library/CoreServices/Menu Extras/User.menu"
# Refresh dashboard
sudo killall SystemUIServer
# Check results with this command
#sudo defaults read /Users/$username/Library/Preferences/com.apple.systemuiserver menuExtras
# Finally, ask the user if they want to switch to IOFC-secure
read -rp "If you want to set this computer up with IOFC-secure wifi for cauxpublic access, enter the password here, otherwise press enter: "
if [[ $REPLY != '' ]]; then
echo "Switching to IOFC-secure"
sudo networksetup -setairportpower en1 on
sudo networksetup -removepreferredwirelessnetwork en1 IOFC
sudo networksetup -addpreferredwirelessnetworkatindex en1 IOFC-secure 0 WPA2 $REPLY
echo "Please add the MAC address of this computer to the radius server. Here is the relevant information:"
echo
echo "Name: $username"
echo "MAC: " `ifconfig en1 |grep ether|sed -e 's/^.*ether//'`
echo "Device: Mac $username"
echo
fi
# Log out
read -s -n1 -p "Press any key to log out."
killall loginwindow