-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmacInstaller.sh
More file actions
executable file
·204 lines (183 loc) · 5.19 KB
/
macInstaller.sh
File metadata and controls
executable file
·204 lines (183 loc) · 5.19 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/bash
#macOS Installer Version 1.1
#-----------------------------------------------
##Sections:
#1.) List of Variables
#2.) User Input
#3.) Executing code
#4.) Script Complete
#-----------------------------------------------
#-----------------------------------------------
##List of all varibles
TEMPFOLDER="/tmp/lockedFirefox"
CACHE="/tmp/FirefoxCache"
DEST="/Users/$(whoami)/.firefox/"
OVERWRITEDIR=""
OVERWRITECACHE=""
DMG="firefox.dmg"
DMGPRESENT=""
BREWINSTALLED=""
WEBCONFIG=""
WEBCONFIGPATH=""
LOCALCONFIGPATH=""
RESOURCES="Firefox.app/Contents/Resources"
#-----------------------------------------------
#-----------------------------------------------
##User Input
#Set path of configuration file
read -p "Are you using a web-hosted config file? Yes/No: " WEBCONFIG
case "$WEBCONFIG" in
[yY] | [yY][eE][sS] )
#The user is using a web config
WEBCONFIG="true"
;;
[nN] | [nN][oO] )
#The user is not using web config
OVERWRITECACHE="false"
;;
*)
echo "Error 201: Must specify whether the config files are web-hosted.
Please view the README file for more info"
exit 201
;;
esac
if [[ "$WEBCONFIG" == "true" ]]; then
# echo "Using WEBCONFIG"
read -p "Please enter the URL of your .cfg file: " WEBCONFIGPATH
# echo "$WEBCONFIGPATH"
else
read -p "Please enter the local path of your .cfg file: " LOCALCONFIGPATH
# echo "$LOCALCONFIGPATH"
fi
#Testing for cached Firefox DMG
if [ -e "$CACHE"/"$DMG" ]
then
#echo "Firefox is cached"
read -p "A version of Firefox is cached. Do you want to redownload it? Yes/(N)o: " OVERWRITECACHE
case "$OVERWRITECACHE" in
[yY] | [yY][eE][sS] )
echo "A new version of Firefox will be downloaded"
OVERWRITECACHE=true
;;
[nN] | [nN][oO] )
echo "The current version will be used."
OVERWRITECACHE=false
;;
*)
echo "The current version will be used."
OVERWRITECACHE=false
;;
esac
else
echo "Firefox is not cached. A new version will be downloaded"
OVERWRITECACHE=true
fi
#Testing for all other directories
if [[ -d "$DEST" ]] || [[ -d "$TEMPFOLDER" ]]; then
read -p "One or more folders already exists. Do you want to overwrite them? (Y)es/No: " OVERWRITEDIR
case "$OVERWRITEDIR" in
[yY] | [yY][eE][sS] )
echo "The folders will be overwritten."
OVERWRITEDIR=true
;;
[nN] | [nN][oO] )
echo "Error 202: Folders not overwritten.
Please view the README file for more info"
exit 202
# echo "The current version will be used."
# OVERWRITECACHE=false
;;
*)
echo "The folders will be overwritten."
OVERWRITEDIR=true
;;
esac
else
echo "No directories present"
OVERWRITEDIR=false
fi
#Test for Homebrew
which -s brew
if [[ $? != 0 ]];
then
read -p "Homebrew is neccesarry for this script. Do you want to install it? (Y)es/No: " BREWINSTALLED
case "$BREWINSTALLED" in
[yY] | [yY][eE][sS] )
echo "Homebrew will be installed."
BREWINSTALLED=false
;;
[nN] | [nN][oO] )
echo "Error 203: Homebrew was not installed.
Please view the README file for more info"
exit 203
;;
*)
echo "Homebrew will be installed."
BREWINSTALLED=false
;;
esac
else
echo "Homebrew is installed"
BREWINSTALLED=true
fi
#-----------------------------------------------
#-----------------------------------------------
##Executing code
#Reset and make directories
if [[ "$OVERWRITEDIR" == "true" ]];
then
echo "Removing old files and folders..."
rm -Rf "$TEMPFOLDER"
rm -Rf "$DEST"
rm /Users/$(whoami)/Desktop/Firefox\ Profile.alias
fi
echo "Making new folders..."
mkdir "$CACHE"
mkdir "$TEMPFOLDER"
mkdir "$DEST"
#Install Homebrew & wget
if [[ "$BREWINSTALLED" == "false" ]] ; then
echo "Installing Homebrew..."
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget
else
brew install wget
echo "Installing wget..."
fi
#download firefox
if [[ "$OVERWRITECACHE" == "true" ]];
then
wget "https://download.mozilla.org/?product=firefox-latest-ssl&os=osx&lang=en-US" --trust-server-names -O "$CACHE"/"$DMG"
fi
#Copy firefox.dmg to tempfolder, mount the dmg, and copy dmg to temp folder
echo "Copying Firefox..."
cp -a "$CACHE"/"$DMG" "$TEMPFOLDER"
hdiutil attach "$TEMPFOLDER"/"$DMG"
cp -a /Volumes/Firefox/Firefox.app "$TEMPFOLDER"
sleep 2
hdiutil detach /Volumes/Firefox -force
#Rename & copy .cfg file and copy autostart.js
echo "Copying configuration..."
if [[ "$WEBCONFIG" == "true" ]];
then
wget "$WEBCONFIGPATH" --trust-server-names -O "$TEMPFOLDER"/"$RESOURCES"/firefox.cfg
cp autostart.js "$TEMPFOLDER"/"$RESOURCES"/defaults/pref/
else
cp "$LOCALCONFIGPATH" "$TEMPFOLDER"/"$RESOURCES"/firefox.cfg
cp autostart.js "$TEMPFOLDER"/"$RESOURCES"/defaults/pref/
fi
#Move Firefox to final destination and make alias
echo "Making desktop shortcut..."
cp -a "$TEMPFOLDER"/Firefox.app "$DEST"
ln -s "$DEST"/Firefox.app /Users/$(whoami)/Desktop/Firefox\ Profile.alias
#Clean up
echo "Cleaning up..."
rm -Rf "$TEMPFOLDER"
#-----------------------------------------------
#-----------------------------------------------
##Script Complete
echo "=============================
👍 Finished! Firefox can now be opened at:
'/Users/$(whoami)/Desktop/Firefox\ Profile.alias'
============================="