forked from tmp2000/utiliscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-components
executable file
·336 lines (268 loc) · 8.91 KB
/
install-components
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
#!/bin/bash
#
# Run this script as root; make sure Adept package manager is not running.
#
# The whole purpose of this script is to manage the package list
# to be passed to apt-get install. I typically run this with no
# parameters on any new install. Whenever I apt-get install
# something that I need, I add the package to some category in this
# script. This insures that I have every package I will need later,
# so that I do not find myself without something critical when I'm not
# connected to the internet.
#
# The other way that I commonly use this script is to run it with the
# --no-gui flag, to install everything commonly needed _except_ for
# those applications that have a user interface. There are many other
# categories and groups also provided, just in case I want to install
# just a couple of groups early in the process of configuring a new
# machine.
#
ubuntuRevision=`grep '^deb http://' /etc/apt/sources.list | head -n 1 | sed -e 's/^deb http:[^ ]* *\([^ ]*\).*/\1/'`
host=`uname -n`
echo "Install Components for Ubuntu $ubuntuRevision on $host"
#
# We're going to list all of our available packages
# in an associative array called 'packages'.
#
# The packages to install will be placed in another
# associative array called install_list. This is the
# subset of the available packages that has been selected
# for installation.
#
# Finally, there is another associative array called
# 'groups' that is essentially an alias system, where
# a group name can be used to indicate a collection of
# package groups.
#
declare -A packages
declare -A install_list
declare -A groups
groups["apps"]="reader-editor kde-utils graphics sound internet"
groups["kde"]="kde-utils"
#
# Misc useful applications that are not part of the
# standard install
#
packages[reader-editor]="nedit"
# acroread is not part of default package sources; put in w/ codecs?
packages[kde-utils]="konqueror kcalc"
#
# Graphic manipulation packages
#
# graphvis
#
packages["graphics"]="gimp inkscape imagemagick"
#
# Sound manipulation packages
#
packages["sound"]="audacity"
groups["system"]="admin intl network system-gui repository compress"
# nvidia
#
# apt-file allows searching for files in packages
# dpgk-dev is needed for certain local apt operations
# sysv-rc-conf controls which services start at boot (like Redhat's chkconfig)
#
packages["admin"]="apt-file dpkg-dev sysv-rc-conf mcrypt"
# TODO: this is only for Dell laptops
#packages["intl"]="i8kutils"
packages["intl"]=""
# packages["security"]="uif bastille"
packages["network"]="ssh rsh-client nmap davfs2 curl"
packages["system-gui"]="perl-tk k3b wmctrl wireshark"
packages["repository"]="subversion cvs git-core mercurial"
packages["compress"]="sharutils zip p7zip "
#packages["nvidia"]="nvidia-settings"
groups["database"]="postgres mysql sqlite"
# Selecting oracle-java will deselect open-java. We list both here so that --no-programming will remove both Java flavors.
groups["programming"]="compile-build dev-docs webservices debug ide repository compress oracle-java open-java python ${groups[database]}"
# Again, to allow --no-java
groups["java"]="oracle-java open-java"
packages["compile-build"]="g++ autoconf automake1.9 libtool libc6 flex bison libncurses5-dev"
# php-doc not available on lucid.
# http://tronprog.blogspot.com/2010/05/package-php-doc-missing-in-ubuntu-lucid.html
if [ "$ubuntuRevision" != "lucid" ] ; then
packages["dev-docs"]="manpages-dev php-doc"
else
packages["dev-docs"]="manpages-dev"
fi
packages["kernel"]="build-essential linux-headers-generic"
# linux-kernel-devel
packages["internet"]="chromium-browser"
packages["webservices"]="apache2 php5 libssl-dev php-pear libapache2-mod-php5 phpsysinfo php5-cli php5-pgsql php5-gd php5-xsl php5-tidy apache2-doc php5-cgi"
packages["postgres"]="postgresql libdbi-perl libdbd-pg-perl"
packages["sqlite"]="sqlite php5-sqlite"
packages["mysql"]="libdbd-mysql-perl libdbd-mysql mysql-client mysql-server php5-mysql"
# mysql-doc
# http://www.canato.org/2012/06/install-oracle-jdk-7-on-linux-mint-13-ubuntu-12-04/
packages["oracle-java"]="oracle-java7-installer ant java2html"
packages["open-java"]="openjdk-7-jdk ant java2html"
# For phpsh, we need easy_install (python-pip), Python.h (python-dev) and ncurses (libncurses5-dev).
packages["python"]="python-pip python-dev"
#
# valgrind will find memory leaks, etc.
#
packages["debug"]="valgrind php5-xdebug"
packages["ide"]="eclipse" # and netbeans
# packages["android"]="gnupg gperf libsdl-dev libesd0-dev libwxgtk2.6-dev libncurses5-dev zlib1g-dev"
groups["gui"]="system-gui ${groups[apps]} debug ide"
verbose=false
show=false
help=false
#
# Make a first pass through all of the options and
# find any one that is named after a group or package set.
# These are the items that will be installed by default.
#
for option in $* ; do
case "$option" in
-v | --verbose )
verbose=true
;;
--show | --descriptions)
show=true
;;
-h | --help )
help=true
;;
-* )
;;
*)
if [ "x${packages[$option]}" != "x" ] ; then
$verbose && echo "Select $option: ${packages[$option]}" >&2
install_list[$option]=${packages[$option]}
fi
if [ "x${groups[$option]}" != "x" ] ; then
$verbose && echo "Group $option=${groups[$option]}" >&2
for i in ${groups[$option]} ; do
if [ "x${packages[$i]}" != "x" ] ; then
$verbose && echo "Select $i: ${packages[$i]}" >&2
install_list[$i]=${packages[$i]}
fi
done
fi
;;
esac
done
#
# If no packages and no groups were selected, then
# default to everything.
#
install_sections="${!install_list[@]}"
if [ "x$install_sections" == "x" ] ; then
for i in ${!packages[@]} ; do
if [ "x${packages[$i]}" != "x" ] ; then
install_list[$i]=${packages[$i]}
fi
done
fi
if $help ; then
program=$0
echo "Usage: ${program##*/} [OPTION]... [CATAGORY]..."
echo "Installs packages from specified catagories using apt-get."
echo "If no catagories are provided, then all available packages"
echo "are installed."
echo
echo " --verbose Show extended output"
echo " --show Show descriptions of all selected packages"
echo " --no-[CATAGORY] Do not install anything from the deselected catagory"
echo " --yes-[CATAGORY] Install the selected catagory"
echo
echo "Available catagories:"
echo
for p in ${!packages[@]} ; do
echo " $p: ${packages[$p]}"
done
echo
echo "Catagories may also be selected / deselected using the following group aliases:"
echo
for g in ${!groups[@]} ; do
echo " $g=${groups[$g]}"
done
echo
echo "Note that in general, [CATAGORY] and --yes-[CATAGORY] are"
echo "roughly equivalent, except that --yes-[CATAGORY] takes"
echo "precidence over --no-[CATAGORY]. This allows you to select"
echo "packages from a deselected group; e.g.:"
echo
echo " ${program##*/} --no-programming --yes-java"
echo
echo "See also the apt-get(8), apt-cache(8) manual pages."
exit 0
fi
#
# Make a consuming pass through $options to
# handle the rest of the options
#
while [ $# -gt 0 ] ; do
option=$1
shift
# echo "Process $option"
case "$option" in
--no-* )
remove=${option:5}
no_list="$no_list $remove"
;;
--yes-* )
add=${option:6}
yes_list="$yes_list $add"
;;
esac
done
# If there is no $DISPLAY, then skip packages that depend on it.
if [ -z "$DISPLAY" ] ; then
$verbose && echo "Automatically de-select gui packages on headless system (--no-gui implied)."
no_list="$no_list gui nvidia"
fi
$verbose && echo "List of items to remove is: $no_list"
$verbose && echo "List of items to add is: $yes_list"
#
# Remove all of the --no items
#
for remove in $no_list ; do
if [ "x${install_list[$remove]}" != "x" ] ; then
$verbose && echo "Deselect $remove: ${install_list[$remove]}" >&2
unset install_list[$remove]
fi
if [ "x${groups[$remove]}" != "x" ] ; then
$verbose && echo "Deselect group $remove=${groups[$remove]}" >&2
for i in ${groups[$remove]} ; do
$verbose && echo "Deselect $i: ${install_list[$i]}"
unset install_list[$i]
done
fi
done
#
# Add the --yes items back in after all of the --no items
# have been removed.
#
for add in $yes_list ; do
if [ "x${packages[$add]}" != "x" ] ; then
$verbose && echo "Select $add: ${packages[$add]}" >&2
install_list[$add]=${packages[$add]}
fi
# If 'open-java' is explicitly added, then remove oracle-java
if [ "$add" == "open-java" ] ; then
unset install_list[oracle-java]
fi
done
# If the selected sections include 'java', then add the
# repository that contains Oracle Java. Skip this step
# if Java is already installed
selected="${!install_list[@]}"
if [ "${selected}" != "${selected/oracle-java}" ] ; then
if [ -z "$(which java)" ] ; then
add-apt-repository ppa:webupd8team/java
apt-get update
else
unset install_list[oracle-java]
fi
unset install_list[open-java]
fi
echo "Package sets selected for installation: ${!install_list[@]}"
echo ${install_list[@]}
$show && apt-cache show ${install_list[@]} | grep '^\(Package:\|Description:\| \)'
#
# Call apt-get install
#
apt-get install ${install_list[@]}