-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMac Lab Helper.command
More file actions
executable file
·158 lines (147 loc) · 4.95 KB
/
Copy pathMac Lab Helper.command
File metadata and controls
executable file
·158 lines (147 loc) · 4.95 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# script path, filename, directory
PROG_PATH=${BASH_SOURCE[0]} # this script's name
PROG_NAME=${PROG_PATH##*/} # basename of script (strip path)
PROG_DIR="$(cd "$(dirname "${PROG_PATH:-$PWD}")" 2>/dev/null 1>&2 && pwd)"
ERRORS=0
NAME_ADMIN="chcadmin"
NAME_GUEST="chclcguest"
echo ""
echo "Welcome to the Mac Lab Setup Helper!"
echo ""
echo "Choose an option:"
echo " 1) Run Quick Setup"
echo " 2) Edit Time Machine Prompt"
echo " 3) Edit Apple Photos as the default for SD cards"
echo " 4) Show or hide hidden files in Finder"
echo " 5) Update the resetUser script on this system"
echo " 6) Update the default background from setup_files"
echo " Enter anything else to quit"
read INPUT
if [ "$INPUT" = "1" ]
then
echo ""
echo "Run Quick Setup for:"
echo " 1) Admin"
echo " 2) Guest"
echo " 3) Both"
echo " Or type anything else to quit"
read INPUT
if [ "$INPUT" = "1" ]
then
while [ ! -e /Users/$NAME_ADMIN ]
do
echo ""
echo "Error: the $NAME_ADMIN account doesn't exist on this system."
echo "Please enter the folder name (not the username) of the user you want run as administrator:"
read NAME_ADMIN
done
echo ""
echo "Switching to a secure environment."
echo "Please enter the Admin password twice:"
#sudo sh "$PROG_DIR"/setup_files/admin_quick_setup.sh
su $NAME_ADMIN -c "sudo sh '$PROG_DIR'/setup_files/admin_quick_setup.sh"
elif [ "$INPUT" = "2" ]
then
sh "$PROG_DIR"/setup_files/guest_quick_setup.sh
elif [ "$INPUT" = "3" ]
then
echo ""
echo ""
echo "Running the Admin Quick Setup..."
echo ""
echo "Switching to a secure environment."
echo "Please enter the Admin password twice:"
su $NAME_ADMIN -c "sudo sh '$PROG_DIR'/setup_files/admin_quick_setup.sh"
echo ""
echo ""
echo "Running the Guest Quick Setup..."
sh "$PROG_DIR"/setup_files/guest_quick_setup.sh
fi
elif [ "$INPUT" = "2" ]
then
echo ""
echo "Turn off Time Machine prompt for external media? "
read INPUT
if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ] || [ "$INPUT" = "yes" ] || [ "$INPUT" = "YES" ] || [ "$INPUT" = "Yes" ] || [ "$INPUT" = "1" ]
then
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool TRUE
echo "Time Machine prompt disabled."
else
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool FALSE
echo "Time Machine prompt enabled."
fi
elif [ "$INPUT" = "3" ]
then
echo ""
echo "Turn off Apple Photos as default application for SD cards? "
read INPUT
if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ] || [ "$INPUT" = "yes" ] || [ "$INPUT" = "YES" ] || [ "$INPUT" = "Yes" ] || [ "$INPUT" = "1" ]
then
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool YES
echo "Apple Photos auto-launch disabled."
else
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool NO
echo "Apple Photos auto-launch enabled."
fi
elif [ "$INPUT" = "4" ]
then
echo ""
echo "Show hidden files and folders in Finder (will restart Finder either way)? "
read INPUT
if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ] || [ "$INPUT" = "yes" ] || [ "$INPUT" = "YES" ] || [ "$INPUT" = "Yes" ] || [ "$INPUT" = "1" ]
then
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
killall Finder
echo "Showing hidden files. Re-run and say no to hide them."
else
defaults write com.apple.finder AppleShowAllFiles -bool FALSE
killall Finder
echo "Leaving hidden files and folders hidden."
fi
elif [ "$INPUT" = "5" ]
then
echo "This Utility updates the resetUser script on the system to the current one in this program's setup files."
echo ""
echo "Type y to continue, type anything else to quit:"
read INPUT
if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ] || [ "$INPUT" = "yes" ] || [ "$INPUT" = "YES" ] || [ "$INPUT" = "Yes" ] || [ "$INPUT" = "1" ]
then
echo ""
echo ""
echo "Running the Updater, requires administrative access..."
echo ""
echo "Switching to a secure environment."
echo "Please enter the Admin password twice:"
echo " (once to switch to the Admin account, again to authorize sudo)"
su $NAME_ADMIN -c "sudo sh '$PROG_DIR'/setup_files/admin_resetGuest_updater.sh"
fi
elif [ "$INPUT" = "6" ]
then
echo "Update the default background from setup_files/Background.jpg?"
echo ""
echo "Type y to continue, type anything else to quit:"
read INPUT
if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ] || [ "$INPUT" = "yes" ] || [ "$INPUT" = "YES" ] || [ "$INPUT" = "Yes" ] || [ "$INPUT" = "1" ]
then
echo ""
echo ""
echo "Running the Updater, requires administrative access..."
echo ""
echo "Switching to a secure environment."
echo "Please enter the Admin password twice:"
echo " (once to switch to the Admin account, again to authorize sudo)"
su $NAME_ADMIN -c "sudo sh '$PROG_DIR'/setup_files/setBackground_admin.sh"
fi
#elif [ "$INPUT" = "0" ] #uninstall
#then
# launchctl unload ~/Library/LaunchAgents/com.user.loginscript.plist
else
echo "No option chosen."
fi
echo ""
echo "Program complete, exiting!"
sleep 2s
echo ""
echo ""
exit