forked from cdelorme/system-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·370 lines (310 loc) · 10.1 KB
/
setup
File metadata and controls
executable file
·370 lines (310 loc) · 10.1 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#!/bin/bash
# query for options
if [ $(uname) = "Linux" ]
then
##
# fail if not running as root
##
[ $(id -u) -ne 0 ] && echo "must be executed with root permissions..." && exit 1
##
# ask platform specific questions
##
# verify service to install
while [ "$service" != "template" ] && [ "$service" != "web" ] && [ "$service" != "dev" ]
do
echo -n "what type of system is this (template|web|dev)? "
read service
done
# new user credentials
while [ -z "$username" ]
do
echo -n "enter a username for your (new) system user: "
read username
done
while [ -z "$password" ]
do
echo -n "enter a password for your (new) system user: "
read password
done
# ask if they want to install dot files
while [ "$dot_files" != "n" ] && [ "$dot_files" != "y" ]
do
echo -n "install dot-files (y|n)? "
read dot_files
done
echo -n "enter a github username for the configuration (optional): "
read github_username
echo -n "enter a github password for the configuration (optional): "
read github_password
# ask if they want to create a new id_rsa
while [ "$create_ssh" != "n" ] && [ "$create_ssh" != "y" ]
do
[ -f "/home/$username/.ssh/id_rsa" ] && echo -n "would you like to create a replacement ssh key (replaces ~/.ssh/id_rsa, y|n)? " || echo -n "would you like to generate an ssh key (y|n)? "
read create_ssh
done
# verify whether they wish to upload their new key to github
if [ "$create_ssh" = "y" ] && [ -n "$github_password" ]
then
while [ "$send_ssh_to_github" != "n" ] && [ "$send_ssh_to_github" != "y" ]
do
echo -n "do you want your new ssh key to be sent to github (y|n)? "
read send_ssh_to_github
done
fi
# verify whether default port is "ok"
echo -n "enter an ssh port (default: 22): "
read ssh_port
# ask for a host & domain name
echo -n "enter a hostname (default: $service): "
read system_hostname
echo -n "enter a domain name (optional): "
read domainname
# verify timezone
echo -n "enter a timezone path (default: US/Eastern): "
read timezone
# as if they want to enable jis locale
while [ "$jis" != "n" ] && [ "$jis" != "y" ]
do
echo -n "enable jis locale (y|n)? "
read jis
done
##
# request service specific settings
##
if [ "$service" = "dev" ]
then
# ask if they want to install mdadm raid software
while [ "$install_mdadm" != "n" ] && [ "$install_mdadm" != "y" ]
do
echo -n "would you like to install the mdadm software raid package (y|n)? "
read install_mdadm
done
# ask if they want to install samba
while [ "$install_samba" != "n" ] && [ "$install_samba" != "y" ]
do
echo -n "would you like to install samba file sharing (y|n)? "
read install_samba
done
# ask if they want weechat
while [ "$install_weechat" != "n" ] && [ "$install_weechat" != "y" ]
do
echo -n "would you like to install the weechat irc client (y|n)? "
read install_weechat
done
# ask if they want to install wireless utilities
while [ "$install_wireless" != "n" ] && [ "$install_wireless" != "y" ]
do
echo -n "would you like to install wireless & bluetooth utilities (y|n)? "
read install_wireless
done
# ask if they want to install transmission
while [ "$install_transmission" != "n" ] && [ "$install_transmission" != "y" ]
do
echo -n "would you like to install the transmission bittorrent client (y|n)? "
read install_transmission
done
# ask if they want openbox
while [ "$install_openbox" != "n" ] && [ "$install_openbox" != "y" ]
do
echo -n "would you like to install the openbox graphical environment (y|n)? "
read install_openbox
done
# add questions for openbox options
if [ "$install_openbox" = "y" ]
then
# ask if they want to install compton
while [ "$install_compton" != "n" ] && [ "$install_compton" != "y" ]
do
echo -n "would you like to install the compton transparency compsitor (y|n)? "
read install_compton
done
fi
# ask if they want to install web services
while [ "$install_web" != "n" ] && [ "$install_web" != "y" ]
do
echo -n "would you like to install web services (y|n)? "
read install_web
done
# assume processing tools (may include duplicates of some packages...)
[ "$install_web" = "y" ] && install_processing_tools="y"
fi
# for web/dev ask server-service installation questions
if [ "$service" = "web" ] || [[ "$service" = "dev" && "$install_web" = "y" ]]
then
# ask about processing tools
while [ "$install_processing_tools" != "n" ] && [ "$install_processing_tools" != "y" ]
do
echo -n "would you like to install video, audio, and graphics processing utilities (y|n)? "
read install_processing_tools
done
# mongodb questions
while [ "$install_mongodb" != "n" ] && [ "$install_mongodb" != "y" ]
do
echo -n "would you like to install mongodb (y|n)? "
read install_mongodb
done
if [ "$install_mongodb" = "y" ]
then
while [ "$public_mongodb" != "n" ] && [ "$public_mongodb" != "y" ]
do
echo -n "would you like to make mongodb publicly accessible (y|n)? "
read public_mongodb
done
fi
# mariadb questions
while [ "$install_mariadb" != "n" ] && [ "$install_mariadb" != "y" ]
do
echo -n "would you like to install mariadb (y|n)? "
read install_mariadb
done
if [ "$install_mariadb" = "y" ]
then
while [ "$public_mariadb" != "n" ] && [ "$public_mariadb" != "y" ]
do
echo -n "would you like to make mariadb publicly accessible (y|n)? "
read public_mariadb
done
fi
# php-fpm questions
while [ "$install_phpfpm" != "n" ] && [ "$install_phpfpm" != "y" ]
do
echo -n "would you like to install php-fpm (y|n)? "
read install_phpfpm
done
if [ "$install_phpfpm" = "y" ]
then
while [ "$public_phpfpm" != "n" ] && [ "$public_phpfpm" != "y" ]
do
echo -n "would you like to make php-fpm publicly accessible (y|n)? "
read public_phpfpm
done
fi
# mail server questions
while [ "$install_msmtp" != "n" ] && [ "$install_msmtp" != "y" ]
do
echo -n "would you like to install the msmtp mail server (y|n)? "
read install_msmtp
done
if [ "$install_msmtp" = "y" ]
then
while [ -z "$msmtp_username" ]
do
echo -n "please enter a valid gmail username for msmtp: "
read msmtp_username
done
while [ -z "$msmtp_password" ]
do
echo -n "please enter the password for that gmail: "
read msmtp_password
done
fi
fi
##
# set platform defaults
##
[ -z "$ssh_port" ] && ssh_port=22
[ -z "$timezone" ] && timezone="US/Eastern"
[ -z "$system_hostname" ] && system_hostname=$service
cronfile="/var/spool/cron/crontabs/${username}"
elif [ $(uname) = "Darwin" ]
then
# set (assume) service
service="osx"
##
# ask platform specific questions
##
while [ "$jis" != "n" ] && [ "$jis" != "y" ]
do
echo -n "enable jis (y|n): "
read jis
done
while [ "$create_ssh" != "n" ] && [ "$create_ssh" != "y" ]
do
echo "would you like to generate an ssh key (y|n)?"
read create_ssh
done
while [ "$create_homebrew_token" != "n" ] && [ "$create_homebrew_token" != "y" ]
do
echo -n "generate github homebrew token (y|n): "
read create_homebrew_token
done
##
# set platform specific settings
##
cronfile="$HOME/.crontab"
elif [[ $(name) = MINGW* ]]
then
# set (assume) service
service="windows"
##
# ask platform specific questions
##
while [ "$create_ssh" != "n" ] && [ "$create_ssh" != "y" ]
do
echo "would you like to generate an ssh key (y|n)?"
read create_ssh
done
##
# set platform specific settings
##
cron_file=~/.crontab
else
echo "no scripts for this platform..."
exit 1
fi
##
# set default values for scripted execution
##
remote_source="https://raw.githubusercontent.com/cdelorme/system-setup/master/"
[ "$dot_files" = "y" ] && dot_files="https://raw.githubusercontent.com/cdelorme/dot-files/master/install"
##
# verify available remote commands
##
if which curl &> /dev/null
then
dl_cmd="curl -Lo"
source_cmd="curl -s"
elif which wget &> /dev/null
then
dl_cmd="wget --no-check-certificate -O"
source_cmd="wget --no-check-certificate -qO-"
fi
# export & printenv
export username
export password
export dot_files
export github_username
export create_ssh
export ssh_port
export system_hostname
export timezone
export jis
export cronfile
export remote_source
export install_processing_tools
export install_mongodb
export public_mongodb
export install_mariadb
export public_mariadb
export install_phpfpm
export public_phpfpm
export install_msmtp
export msmtp_username
export msmtp_password
export install_mdadm
export install_samba
export install_weechat
export install_wireless
export install_transmission
export install_openbox
export install_compton
export install_web
export dl_cmd
export source_cmd
env
##
# load service script
##
echo "loading $service script..."
[ -f "scripts/${service}.sh" ] && . "scripts/${service}.sh" || eval "$($source_cmd ${remote_source}scripts/${service}.sh)"
echo "finished setup..."