commit | author | age
|
1bb512
|
1 |
#!/bin/bash |
W |
2 |
# Copyright (c) 2009, Scott Barr <gsbarr@gmail.com> |
|
3 |
# All rights reserved. |
|
4 |
# |
|
5 |
# Redistribution and use in source and binary forms, with or without |
|
6 |
# modification, are permitted provided that the following conditions are met: |
|
7 |
# * Redistributions of source code must retain the above copyright |
|
8 |
# notice, this list of conditions and the following disclaimer. |
|
9 |
# * Redistributions in binary form must reproduce the above copyright |
|
10 |
# notice, this list of conditions and the following disclaimer in the |
|
11 |
# documentation and/or other materials provided with the distribution. |
|
12 |
# * Neither the name of the <organization> nor the |
|
13 |
# names of its contributors may be used to endorse or promote products |
|
14 |
# derived from this software without specific prior written permission. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' |
|
17 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
19 |
# DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY |
|
20 |
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
21 |
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
22 |
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
23 |
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
24 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
25 |
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
26 |
|
|
27 |
# Global vars |
|
28 |
install_mail="no" |
|
29 |
install_web="no" |
|
30 |
install_ftp="no" |
|
31 |
install_dns="no" |
|
32 |
spinner_pid=0 |
75bde1
|
33 |
version="0.7" |
1bb512
|
34 |
|
W |
35 |
source_path=`dirname $0` |
|
36 |
source ${source_path}/utils.sh |
|
37 |
|
|
38 |
function package_has_use_flag() |
|
39 |
{ |
|
40 |
local package=$1 |
|
41 |
local useflag=$2 |
|
42 |
|
75bde1
|
43 |
res=`equery -C -N uses $package | grep -o -P "^ [-+]{1} \+ $useflag"` |
1bb512
|
44 |
[ -n "$res" ] |
W |
45 |
} |
|
46 |
|
2ee270
|
47 |
function package_is_emerged() |
W |
48 |
{ |
|
49 |
local package=$1 |
|
50 |
|
|
51 |
installed=`equery -C -N list -e -i $1 | grep $1 | grep "^\[I"` |
|
52 |
[ -n "$installed" ] |
|
53 |
} |
|
54 |
|
1bb512
|
55 |
function is_package_installed() |
W |
56 |
{ |
|
57 |
local usechange="no" |
|
58 |
local uselist="" |
|
59 |
|
2ee270
|
60 |
package_is_emerged "$1" |
W |
61 |
installed=$? |
1bb512
|
62 |
|
W |
63 |
if [ -n "$2" ] # Use flags parsed |
|
64 |
then |
|
65 |
for useflag in $2 |
|
66 |
do |
75bde1
|
67 |
uselist="$uselist +$useflag" |
1bb512
|
68 |
|
W |
69 |
# If the use flag isn't currently set or wasn't enabled when installed we'll need to re-install it. |
|
70 |
package_has_use_flag "$1" "$useflag" || usechange="yes" |
|
71 |
done |
|
72 |
|
75bde1
|
73 |
flagedit $1 $uselist --nowarn |
1bb512
|
74 |
fi |
W |
75 |
|
2ee270
|
76 |
[ $installed -eq 0 ] && [ "$usechange" == "no" ] |
1bb512
|
77 |
} |
W |
78 |
|
|
79 |
function install_progress() |
|
80 |
{ |
|
81 |
SP_STRING="/-\\|" |
|
82 |
packages=( $2 ) |
|
83 |
|
|
84 |
IP_STRING=`printf "1 of %d" "${#packages[@]}"` |
|
85 |
loop_count=0 |
|
86 |
nowf=`date +'%b %d, %Y %H:%M'` |
|
87 |
|
|
88 |
while [ -d /proc/$1 ] && [ -d /proc/$$ ] |
|
89 |
do |
|
90 |
printf "\e[1;37m\e7[ %1.1s %s ] \e8\e[0m" "$SP_STRING" "$IP_STRING" |
|
91 |
sleep 0.2 |
|
92 |
|
|
93 |
if [ $loop_count -lt 8 ] |
|
94 |
then |
|
95 |
loop_count=$(($loop_count+1)) |
|
96 |
else |
|
97 |
current=`sed -n "/Started emerge on: $nowf/,/G/p" /var/log/emerge.log | grep ">>> emerge" | tail -1 | grep -m 1 -o -P "\d+ of \d+"` |
|
98 |
if [ -n "$current" ] |
|
99 |
then |
|
100 |
IP_STRING=$current |
|
101 |
fi |
|
102 |
loop_count=0 |
|
103 |
fi |
|
104 |
|
|
105 |
SP_STRING=${SP_STRING#"${SP_STRING%?}"}${SP_STRING%?}; |
|
106 |
done |
|
107 |
|
|
108 |
printf "%-15s" " " |
|
109 |
} |
|
110 |
|
|
111 |
function install_packages() |
|
112 |
{ |
|
113 |
local package_list=$1 |
|
114 |
local title=$2 |
|
115 |
|
|
116 |
if [ -z "$title" ] |
|
117 |
then |
|
118 |
title="Installing packages" |
|
119 |
fi |
|
120 |
|
|
121 |
if [ -n "$package_list" ] |
|
122 |
then |
75bde1
|
123 |
echo -e "The following packages are going to be emerged (not including dependencies):" |
1bb512
|
124 |
echo -e "$package_list" |
W |
125 |
echo -e "" |
|
126 |
countdown "00:00:10" Continue in |
|
127 |
|
|
128 |
echo -e "" |
|
129 |
|
|
130 |
printf "%-40s" "$title" |
|
131 |
|
|
132 |
(emerge $package_list >/dev/null 2>&1) & |
|
133 |
pid=$! |
|
134 |
|
|
135 |
install_progress $pid "$package_list" |
|
136 |
wait $pid |
|
137 |
status=$? |
|
138 |
|
|
139 |
if [ $status -eq 0 ]; |
|
140 |
then |
|
141 |
echo -e "\e[1;37m[ \e[0m\e[1;32mok\e[0m\e[1;37m ] \e[0m" |
|
142 |
else |
|
143 |
echo -e "\e[1;37m[ \e[0m\e[1;31mfailed\e[0m\e[1;37m ] \e[0m" |
|
144 |
echo -e "Failed installing the following packages:" |
|
145 |
echo -e "$1" |
|
146 |
exit 1 |
|
147 |
fi |
|
148 |
else |
|
149 |
echo -e "No packages to install!" |
|
150 |
fi |
|
151 |
} |
|
152 |
|
|
153 |
function install_rcscripts() |
|
154 |
{ |
|
155 |
if [ -n "$1" ] |
|
156 |
then |
75bde1
|
157 |
|
1bb512
|
158 |
for rc in $1 |
W |
159 |
do |
75bde1
|
160 |
res=`rc-status default | grep "$1" | grep -v grep` |
W |
161 |
if [ -z "$res" ] |
|
162 |
then |
|
163 |
printf "\e[1;37m%-40s\e[0m" "Adding $rc to default runlevel" |
|
164 |
start_spinner |
|
165 |
|
|
166 |
rc-update add $rc default &> /dev/null |
|
167 |
|
|
168 |
stop_spinner |
|
169 |
echo -e "\e[1;37m[ \e[0m\e[1;32mdone\e[0m\e[1;37m ]\e[0m" |
|
170 |
fi |
1bb512
|
171 |
done |
75bde1
|
172 |
fi |
W |
173 |
} |
|
174 |
|
|
175 |
function enable_apache_module() |
|
176 |
{ |
|
177 |
local apache_conffile='/etc/conf.d/apache2' |
|
178 |
|
|
179 |
if [ -n "$1" ] |
|
180 |
then |
|
181 |
source $apache_conffile |
|
182 |
|
|
183 |
if [ $(expr "$APACHE2_OPTS" : ".*$1.*") == "0" ] |
|
184 |
then |
|
185 |
APACHE2_OPTS="${APACHE2_OPTS} -D $1" |
|
186 |
sed -i -e "s:APACHE2_OPTS=\".*\":APACHE2_OPTS=\"${APACHE2_OPTS}\":" $apache_conffile |
|
187 |
fi |
1bb512
|
188 |
fi |
W |
189 |
} |
|
190 |
|
|
191 |
function meta_mail() |
|
192 |
{ |
|
193 |
local package_list="" |
|
194 |
local add_maildrop="" |
|
195 |
local remove_ssmtp="no" |
|
196 |
local rc_scripts="" |
75bde1
|
197 |
local use_courier="no" |
W |
198 |
local use_dovecot="no" |
|
199 |
local useflags_postfix="mysql" |
|
200 |
local installed_postfix="no" |
|
201 |
local installed_amavisd="no" |
|
202 |
|
|
203 |
valid_input "Do you want to use dovecot or courier?" "dovecot/courier" |
|
204 |
|
|
205 |
if [ "$Return_Val" = "dovecot" ] |
|
206 |
then |
|
207 |
use_dovecot="yes" |
|
208 |
else |
|
209 |
use_courier="yes" |
|
210 |
fi |
1bb512
|
211 |
|
W |
212 |
echo -e "" |
|
213 |
printf "\e[1;37m%-40s\e[0m" "Building list of required mail packages" |
|
214 |
|
|
215 |
start_spinner |
|
216 |
|
75bde1
|
217 |
if [ "$use_courier" == "yes" ] |
W |
218 |
then |
|
219 |
is_package_installed "net-libs/courier-authlib" "mysql" || { package_list="$package_list net-libs/courier-authlib"; rc_scripts="$rc_scripts courier-authlib"; } |
1bb512
|
220 |
|
75bde1
|
221 |
is_package_installed "net-mail/courier-imap" "fam" || { package_list="$package_list net-mail/courier-imap"; rc_scripts="$rc_scripts courier-imapd courier-imapd-ssl courier-pop3d courier-pop3d-ssl"; } |
W |
222 |
|
|
223 |
is_package_installed "mail-filter/maildrop" || add_maildrop="yes" # Avoid file collision warnings from emerge |
|
224 |
|
|
225 |
is_package_installed "dev-libs/cyrus-sasl" "mysql" || { package_list="$package_list dev-libs/cyrus-sasl"; rc_scripts="$rc_scripts saslauthd"; } |
|
226 |
|
|
227 |
useflags_postfix="$useflags_postfix sasl" |
|
228 |
fi |
1bb512
|
229 |
|
75bde1
|
230 |
if [ "$use_dovecot" == "yes" ] |
W |
231 |
then |
|
232 |
is_package_installed "net-mail/dovecot" "sieve managesieve maildir" || { package_list="$package_list net-mail/dovecot"; rc_scripts="$rc_scripts dovecot"; } |
|
233 |
|
|
234 |
useflags_postfix="$useflags_postfix dovecot-sasl" |
|
235 |
fi |
1bb512
|
236 |
|
75bde1
|
237 |
if ! is_package_installed "mail-mta/postfix" "$useflags_postfix" |
1bb512
|
238 |
then |
W |
239 |
is_package_installed "mail-mta/ssmtp" && local remove_ssmtp="yes"; # Ssmtp blocks postfix and is installed by default. |
|
240 |
package_list="$package_list mail-mta/postfix" |
|
241 |
rc_scripts="$rc_scripts postfix" |
75bde1
|
242 |
|
W |
243 |
package_is_emerged "mail-mta/postfix" # USE flag difference will result in re-installing. If we are installing for the first time do some things later. |
|
244 |
installed=$? |
1bb512
|
245 |
|
75bde1
|
246 |
if [ $installed -eq 1 ] |
W |
247 |
then |
|
248 |
installed_postfix="yes" |
|
249 |
fi |
|
250 |
fi |
1bb512
|
251 |
|
W |
252 |
is_package_installed "net-mail/getmail" || package_list="$package_list net-mail/getmail" |
|
253 |
|
75bde1
|
254 |
if ! is_package_installed "mail-filter/amavisd-new" "mysql razor spamassassin" |
W |
255 |
then |
|
256 |
package_list="$package_list mail-filter/amavisd-new" |
|
257 |
rc_scripts="$rc_scripts amavisd" |
|
258 |
|
|
259 |
package_is_emerged "mail-filter/amavisd-new" # USE flag difference will result in re-installing. If we are installing for the first time do some things later. |
|
260 |
installed=$? |
|
261 |
|
|
262 |
if [ $installed -eq 1 ] |
|
263 |
then |
|
264 |
installed_amavisd="yes" |
|
265 |
fi |
|
266 |
fi |
1bb512
|
267 |
|
W |
268 |
is_package_installed "app-antivirus/clamav" || { package_list="$package_list app-antivirus/clamav"; rc_scripts="$rc_scripts clamd"; } |
|
269 |
|
|
270 |
is_package_installed "dev-perl/Authen-SASL" || package_list="$package_list dev-perl/Authen-SASL" |
|
271 |
|
|
272 |
is_package_installed "dev-perl/perl-ldap" || package_list="$package_list dev-perl/perl-ldap" |
|
273 |
|
|
274 |
stop_spinner |
|
275 |
echo -e "\e[1;37m[ \e[0m\e[1;32mdone\e[0m\e[1;37m ]\e[0m" |
|
276 |
|
|
277 |
if [ "$remove_ssmtp" == "yes" ] |
|
278 |
then |
|
279 |
exec_command "emerge --unmerge mail-mta/ssmtp" "Removing ssmtp to install postfix" |
|
280 |
fi |
|
281 |
|
|
282 |
install_packages "$package_list" "Installing mail packages" |
|
283 |
|
|
284 |
if [ -n "$add_maildrop" ] |
|
285 |
then |
|
286 |
exec_command "COLLISION_IGNORE=\"/usr\" emerge mail-filter/maildrop" "Installing maildrop" |
|
287 |
fi |
|
288 |
|
75bde1
|
289 |
if [ "$installed_postfix" == "yes" ] && [ ! -d '/etc/mail/aliases.db' ] |
W |
290 |
then |
|
291 |
postmap /etc/mail/aliases 2> /dev/null |
|
292 |
fi |
|
293 |
|
|
294 |
if [ "$installed_amavisd" == "yes" ] |
|
295 |
then |
|
296 |
if [ -e '/usr/share/spamassassin/sa-update-pubkey.txt' ] |
|
297 |
then |
|
298 |
sa-update --import /usr/share/spamassassin/sa-update-pubkey.txt |
|
299 |
fi |
|
300 |
|
|
301 |
sa-update |
|
302 |
fi |
|
303 |
|
1bb512
|
304 |
install_rcscripts "$rc_scripts" |
W |
305 |
} |
|
306 |
|
|
307 |
function meta_web() |
|
308 |
{ |
|
309 |
local package_list="" |
|
310 |
local fix_jailkit="no" |
|
311 |
local linguas_add="no" |
|
312 |
local webmail_add="no" |
|
313 |
local rc_scripts="" |
75bde1
|
314 |
local installed_fcgid="no" |
W |
315 |
|
|
316 |
if ! is_package_installed "dev-vcs/subversion" |
|
317 |
then |
|
318 |
flagedit dev-vcs/subversion -apache2 --nowarn |
|
319 |
fi |
|
320 |
|
|
321 |
is_package_installed "app-portage/layman" "subversion" || exec_command "emerge app-portage/layman" "Installing layman"; |
|
322 |
|
|
323 |
# Check if sunrise overlay has been enabled |
|
324 |
if [ -z "$(layman -l | grep sunrise)" ] |
|
325 |
then |
|
326 |
layman -q -S > /dev/null |
|
327 |
exec_command "layman -a sunrise" "Adding/syncing package overlay" |
|
328 |
fi |
|
329 |
|
|
330 |
if [ -z "$(grep 'var/lib/layman' /etc/make.conf)" ] |
|
331 |
then |
|
332 |
echo "source /var/lib/layman/make.conf" >> /etc/make.conf |
|
333 |
fi |
1bb512
|
334 |
|
W |
335 |
echo -e "" |
|
336 |
printf "\e[1;37m%-40s\e[0m" "Building list of required web packages" |
|
337 |
|
|
338 |
start_spinner |
|
339 |
|
75bde1
|
340 |
# Check profile and ensure the apache modules ISPConfig needs are enabled. |
W |
341 |
source /etc/make.conf |
1bb512
|
342 |
|
75bde1
|
343 |
if [ -z "${APACHE2_MODULES+xxx}" ] # Not set, fetch defaults |
W |
344 |
then |
|
345 |
source /usr/portage/profiles/base/make.defaults |
|
346 |
echo "APACHE2_MODULES=\"$APACHE2_MODULES\"" >> /etc/make.conf |
|
347 |
|
|
348 |
source /etc/make.conf |
|
349 |
fi |
|
350 |
|
|
351 |
local added_module='no' |
|
352 |
for module in rewrite dav dav_fs auth_digest |
|
353 |
do |
|
354 |
if [ $(expr "$APACHE2_MODULES" : ".*$module.*") == "0" ] |
|
355 |
then |
|
356 |
APACHE2_MODULES="${APACHE2_MODULES} $module" |
|
357 |
added_module='yes' |
|
358 |
fi |
|
359 |
done |
|
360 |
|
|
361 |
if [ "$added_module" == "yes" ] |
|
362 |
then |
|
363 |
sed -i -e "s:APACHE2_MODULES=\".*\":APACHE2_MODULES=\"${APACHE2_MODULES}\":" /etc/make.conf |
|
364 |
fi |
|
365 |
|
|
366 |
local added_worker='no' |
|
367 |
if [ -z "${APACHE2_MPMS+xxx}" ] # Not set, fetch defaults |
|
368 |
then |
|
369 |
echo 'APACHE2_MPMS="prefork"' >> /etc/make.conf |
|
370 |
added_worker='yes' |
|
371 |
else |
|
372 |
if [ $(expr "$APACHE2_MPMS" : '.*prefork.*') == "0" ] |
|
373 |
then |
|
374 |
APACHE2_MPMS="${APACHE2_MPMS} prefork" |
|
375 |
sed -i -e "s:APACHE2_MPMS=\".*\":APACHE2_MPMS=\"${APACHE2_MPMS}\":" /etc/make.conf |
|
376 |
added_worker='yes' |
|
377 |
fi |
|
378 |
fi |
|
379 |
|
|
380 |
if is_package_installed "www-servers/apache" "ssl suexec doc" || "$added_module" == "yes" || "$added_worker" == "yes" |
|
381 |
then |
|
382 |
package_list="$package_list www-servers/apache" |
|
383 |
rc_scripts="$rc_scripts apache2" |
|
384 |
fi |
|
385 |
|
|
386 |
if ! is_package_installed "www-apache/mod_fcgid" |
|
387 |
then |
|
388 |
installed_fcgid="yes" |
|
389 |
package_list="$package_list www-apache/mod_fcgid" |
|
390 |
fi |
1bb512
|
391 |
|
W |
392 |
if ! is_package_installed "app-admin/webalizer" "vhosts apache2" |
|
393 |
then |
|
394 |
|
|
395 |
is_package_installed "media-libs/gd" "jpeg png" || package_list="$package_list media-libs/gd" |
|
396 |
|
|
397 |
if package_has_use_flag "app-admin/webalizer" "nls" |
|
398 |
then |
|
399 |
source /etc/make.conf |
|
400 |
if [ -z "${LINGUAS}" ] |
|
401 |
then |
|
402 |
linguas_add="yes" |
|
403 |
fi |
|
404 |
fi |
|
405 |
|
|
406 |
package_list="$package_list app-admin/webalizer" |
|
407 |
fi |
|
408 |
|
75bde1
|
409 |
is_package_installed "www-misc/awstats" "vhosts apache2" || package_list="$package_list www-misc/awstats" |
W |
410 |
|
c7d6d9
|
411 |
if ! is_package_installed "app-admin/vlogger" "dbi" |
1bb512
|
412 |
then |
W |
413 |
# Check if package is masked |
|
414 |
if [ -n "$(equery -C -N list -I -o -e app-admin/vlogger | grep app-admin/vlogger | awk '{print $2}' | grep '^\[M')" ] |
|
415 |
then |
|
416 |
flagedit app-admin/vlogger -- +~amd64 +~x86 > /dev/null |
|
417 |
fi |
|
418 |
|
|
419 |
package_list="$package_list app-admin/vlogger" |
|
420 |
fi |
|
421 |
|
|
422 |
is_package_installed "app-crypt/mcrypt" || package_list="$package_list app-crypt/mcrypt" |
|
423 |
|
75bde1
|
424 |
is_package_installed "dev-lang/php" "apache2 gd mysql mysqli imap cli cgi pcre xml zlib crypt ctype session unicode mhash ftp soap" || package_list="$package_list dev-lang/php" |
1bb512
|
425 |
|
W |
426 |
if ! is_package_installed "www-apache/mod_suphp" |
|
427 |
then |
|
428 |
# Check if package is masked |
|
429 |
if [ -n "$(equery -C -N list -I -p -e www-apache/mod_suphp | grep www-apache/mod_suphp | awk '{print $2}' | grep '^\[M')" ] |
|
430 |
then |
|
431 |
flagedit www-apache/mod_suphp -- +~amd64 +~x86 > /dev/null |
|
432 |
fi |
|
433 |
|
|
434 |
package_list="$package_list www-apache/mod_suphp" |
|
435 |
fi |
|
436 |
|
75bde1
|
437 |
is_package_installed "www-apache/mod_ruby" || package_list="$package_list www-apache/mod_ruby" |
1bb512
|
438 |
|
W |
439 |
is_package_installed "media-gfx/imagemagick" "jpeg png tiff" || package_list="$package_list media-gfx/imagemagick" |
|
440 |
|
|
441 |
is_package_installed "dev-php/PEAR-PEAR" || package_list="$package_list dev-php/PEAR-PEAR" |
|
442 |
|
|
443 |
is_package_installed "dev-php/PEAR-Auth" || package_list="$package_list dev-php/PEAR-Auth" |
|
444 |
|
|
445 |
is_package_installed "dev-php5/pecl-imagick" || package_list="$package_list dev-php5/pecl-imagick" |
|
446 |
|
|
447 |
is_package_installed "sys-auth/pam_mysql" || package_list="$package_list sys-auth/pam_mysql" |
|
448 |
|
c7d6d9
|
449 |
is_package_installed "app-admin/sudo" || package_list="$package_list app-admin/sudo" |
W |
450 |
|
|
451 |
is_package_installed "app-arch/zip" || package_list="$package_list app-arch/zip" |
|
452 |
|
1bb512
|
453 |
if ! is_package_installed "app-admin/jailkit" |
W |
454 |
then |
|
455 |
# Check if package is masked |
|
456 |
if [ -n "$(equery -C -N list -I -o -e app-admin/jailkit | grep app-admin/jailkit | awk '{print $2}' | grep '^\[M')" ] |
|
457 |
then |
|
458 |
flagedit app-admin/jailkit -- +~amd64 +~x86 > /dev/null |
|
459 |
fi |
|
460 |
|
|
461 |
# The ebuild for jailkit 2.3 has a nasty bug that breaks the login shell. Check for version and |
|
462 |
# apply the fix if necessary. |
|
463 |
if [ "$(emerge -pv app-admin/jailkit | grep -o -P '(?<=jailkit-)[\d-.rp_]+')" == "2.3" ] |
|
464 |
then |
|
465 |
fix_jailkit="yes" |
|
466 |
cp /etc/shells /etc/shells~ |
|
467 |
fi |
|
468 |
|
|
469 |
package_list="$package_list app-admin/jailkit" |
|
470 |
fi |
|
471 |
|
75bde1
|
472 |
#if [ "$install_mail" == "yes" ] && ! is_package_installed "mail-client/squirrelmail" "vhosts" |
W |
473 |
#then |
|
474 |
# if ! is_package_installed "app-admin/webapp-config" |
|
475 |
# then |
|
476 |
# package_list="$package_list app-admin/webapp-config" |
|
477 |
# fi |
1bb512
|
478 |
|
75bde1
|
479 |
# webmail_add="yes" |
W |
480 |
# package_list="$package_list mail-client/squirrelmail" |
|
481 |
#fi |
1bb512
|
482 |
|
W |
483 |
stop_spinner |
|
484 |
echo -e "\e[1;37m[ \e[0m\e[1;32mdone\e[0m\e[1;37m ]\e[0m" |
|
485 |
|
|
486 |
if [ "$linguas_add" == "yes" ] |
|
487 |
then |
|
488 |
echo -e "" |
|
489 |
echo -e "The nls use flag is enabled for webalizer and no locale preference is set in make.conf. If " |
|
490 |
echo -e "not set webalizer will fail to install." |
|
491 |
echo -e "" |
|
492 |
|
|
493 |
accept_locales=`find /usr/share/locale/ -maxdepth 1 -type d -exec basename '{}' \; | grep -v "locale" | sort | tr "\n" "/" | sed -e 's,\(.\)/$,\1,'` |
|
494 |
valid_input "Set locale value for gettext-based programs to: " "$accept_locales" "en" |
|
495 |
|
|
496 |
echo "LINGUAS=\"$Return_Val\"" >> /etc/make.conf |
|
497 |
echo -e "" |
|
498 |
fi |
|
499 |
|
|
500 |
install_packages "$package_list" "Installing web packages" |
|
501 |
|
|
502 |
if [ $? -eq 0 ] && [ "$fix_jailkit" == "yes" ] && [ -z "$(grep 'jk_chrootsh' /etc/shells)" ] |
|
503 |
then |
|
504 |
cp /etc/shells /etc/shells.jailkit-v2.3 |
|
505 |
cp /etc/shells~ /etc/shells |
|
506 |
echo "/usr/sbin/jk_chrootsh" >> /etc/shells |
|
507 |
fi |
|
508 |
|
75bde1
|
509 |
for config_module in SUEXEC FCGID AUTH_DIGEST DAV DAV_FS RUBY |
W |
510 |
do |
|
511 |
enable_apache_module "$config_module" |
|
512 |
done |
|
513 |
|
|
514 |
#if [ "$webmail_add" == "yes" ] |
|
515 |
#then |
|
516 |
# exec_command "webapp-config -I -h localhost -u apache -d /webmail squirrelmail $(ls -r /usr/share/webapps/squirrelmail/ | awk '{print $1}')" "Adding squirrelmail to localhost" |
|
517 |
#fi |
1bb512
|
518 |
|
W |
519 |
install_rcscripts "$rc_scripts" |
|
520 |
} |
|
521 |
|
|
522 |
function meta_ftp() |
|
523 |
{ |
|
524 |
local package_list="" |
|
525 |
local rc_scripts="" |
|
526 |
|
|
527 |
echo -e "" |
|
528 |
printf "\e[1;37m%-40s\e[0m" "Building list of required ftp packages" |
|
529 |
|
|
530 |
start_spinner |
|
531 |
|
|
532 |
is_package_installed "net-ftp/pure-ftpd" "mysql" || { package_list="$package_list net-ftp/pure-ftpd"; rc_scripts="$rc_scripts pure-ftpd"; } |
|
533 |
|
|
534 |
is_package_installed "sys-fs/quota" || package_list="$package_list sys-fs/quota"; |
|
535 |
|
|
536 |
if ! is_package_installed "sys-fs/quotatool" |
|
537 |
then |
|
538 |
# Check if package is masked |
|
539 |
if [ -n "$(equery -C -N list -I -p -e sys-fs/quotatool | grep sys-fs/quotatool | awk '{print $2}' | grep '^\[M')" ] |
|
540 |
then |
|
541 |
flagedit sys-fs/quotatool -- +~amd64 +~x86 > /dev/null |
|
542 |
fi |
|
543 |
|
|
544 |
package_list="$package_list sys-fs/quotatool" |
|
545 |
fi |
|
546 |
|
|
547 |
stop_spinner |
|
548 |
echo -e "\e[1;37m[ \e[0m\e[1;32mdone\e[0m\e[1;37m ]\e[0m" |
|
549 |
|
75bde1
|
550 |
if [ $(expr "$package_list" : '.*sys-fs/quota.*') -ne 0 ] |
1bb512
|
551 |
then |
W |
552 |
echo -e "" |
|
553 |
echo -e "\e[1;33mNotice:\e[0m Don't forget to edit your fstab file and add the usrquota & grpquota options to your data partition." |
|
554 |
echo -e "" |
|
555 |
sleep 2 |
|
556 |
fi |
|
557 |
|
|
558 |
install_packages "$package_list" "Installing ftp packages" |
|
559 |
|
|
560 |
install_rcscripts "$rc_scripts" |
|
561 |
} |
|
562 |
|
|
563 |
function meta_dns() |
|
564 |
{ |
|
565 |
local package_list="" |
75bde1
|
566 |
local use_bind="no" |
W |
567 |
local use_pdns="no" |
|
568 |
|
|
569 |
valid_input "Do you want to use bind or powerdns?" "bind/powerdns" |
|
570 |
|
|
571 |
if [ "$Return_Val" = "bind" ] |
|
572 |
then |
|
573 |
use_bind="yes" |
|
574 |
else |
|
575 |
use_pdns="yes" |
|
576 |
fi |
1bb512
|
577 |
|
W |
578 |
echo -e "" |
75bde1
|
579 |
printf "\e[1;37m%-40s\e[0m" "Building list of required dns packages" |
1bb512
|
580 |
|
W |
581 |
start_spinner |
|
582 |
|
75bde1
|
583 |
if [ "$use_bind" == "yes" ] |
W |
584 |
then |
|
585 |
is_package_installed "net-dns/bind" "mysql dlz" || { package_list="$package_list net-dns/bind"; rc_scripts="$rc_scripts named"; } |
|
586 |
fi |
|
587 |
|
|
588 |
if [ "$use_pdns" == "yes" ] |
|
589 |
then |
|
590 |
is_package_installed "net-dns/pdns" "mysql" || package_list="$package_list net-dns/pdns"; |
|
591 |
fi |
1bb512
|
592 |
|
W |
593 |
stop_spinner |
|
594 |
echo -e "\e[1;37m[ \e[0m\e[1;32mdone\e[0m\e[1;37m ]\e[0m" |
|
595 |
|
|
596 |
install_packages "$package_list" "Installing dns packages" |
75bde1
|
597 |
|
W |
598 |
install_rcscripts "$rc_scripts" |
1bb512
|
599 |
} |
W |
600 |
|
|
601 |
function meta_all() |
|
602 |
{ |
|
603 |
meta_mail |
|
604 |
meta_web |
|
605 |
meta_ftp |
|
606 |
meta_dns |
|
607 |
} |
|
608 |
|
|
609 |
case $1 in |
|
610 |
"--version"|"-h"|"--help") |
|
611 |
echo -e "Gentoo Linux ISPConfig setup script" |
|
612 |
echo -e "Version $version" |
|
613 |
echo -e "" |
|
614 |
echo -e "No arguments needed, simply execute the script." |
|
615 |
exit 0 |
|
616 |
;; |
|
617 |
*) |
|
618 |
;; |
|
619 |
esac |
|
620 |
|
|
621 |
clear |
|
622 |
|
|
623 |
echo -e "\e[1;33mGentoo Linux ISPConfig setup script v$version\e[0m" |
|
624 |
echo -e "\e[1;32m========================================\e[0m" |
|
625 |
echo -e "" |
75bde1
|
626 |
|
W |
627 |
if [ -e "/etc/gentoo-release" ] |
|
628 |
then |
|
629 |
BASELAYOUT_VERSION=$(cat /etc/gentoo-release | sed "s/[^0-9.]//g") |
|
630 |
package_is_emerged "sys-apps/baselayout-$BASELAYOUT_VERSION" |
|
631 |
installed=$? |
|
632 |
|
|
633 |
if [ "$installed" != "0" ] |
|
634 |
then |
|
635 |
echo -e "" |
|
636 |
echo "This script is exclusively for use with a Gentoo Linux system." |
|
637 |
exit 10 |
|
638 |
fi |
|
639 |
else |
|
640 |
echo -e "" |
|
641 |
echo "This script is exclusively for use with a Gentoo Linux system." |
|
642 |
exit 10 |
|
643 |
fi |
1bb512
|
644 |
|
W |
645 |
sleep 0.5 |
|
646 |
|
|
647 |
valid_input "Would you like to sync portage now?" |
|
648 |
if [ "$Return_Val" = "yes" ] |
|
649 |
then |
|
650 |
exec_command "emerge --sync --quiet" "Updating portage tree" |
|
651 |
fi |
|
652 |
|
|
653 |
# Get all the programs we need to do portage queries etc. |
|
654 |
echo -en "\e[1;37mChecking for required packages\e[0m\n" |
|
655 |
|
|
656 |
# Verify if gentoolkit has been emerged and install if not |
|
657 |
which equery &> /dev/null |
|
658 |
if [ $? -ne 0 ] |
|
659 |
then |
|
660 |
exec_command "emerge app-portage/gentoolkit" "Installing gentoolkit" |
|
661 |
fi |
|
662 |
|
|
663 |
which flagedit &> /dev/null |
|
664 |
if [ $? -ne 0 ] |
|
665 |
then |
|
666 |
exec_command "emerge app-portage/flagedit" "Installing flagedit" |
|
667 |
fi |
|
668 |
|
|
669 |
if ! is_package_installed "app-admin/rsyslog" |
|
670 |
then |
|
671 |
printf "\e[1;37m%-40s\e[0m" "Checking for installed system loggers" |
|
672 |
start_spinner |
|
673 |
|
|
674 |
loggers=( syslog-ng metalog sysklogd ) |
|
675 |
clogger="" |
|
676 |
rsyslog_install="yes" |
|
677 |
|
|
678 |
for logger in $loggers |
|
679 |
do |
2ee270
|
680 |
if is_package_installed "app-admin/$logger" && [ -n "$(rc-config list default | grep $logger)" ] |
1bb512
|
681 |
then |
W |
682 |
clogger=$logger |
|
683 |
break |
|
684 |
fi |
|
685 |
done |
|
686 |
|
|
687 |
stop_spinner |
|
688 |
echo -e "\e[1;37m[ \e[0m\e[1;32mdone\e[0m\e[1;37m ]\e[0m" |
|
689 |
|
|
690 |
if [ "$clogger" != "" ] |
|
691 |
then |
|
692 |
echo -e "" |
|
693 |
echo -e "$clogger appears to be installed on your system." |
|
694 |
echo -e "To use the log monitoring features in ISPConfig" |
|
695 |
echo -e "the log facilities need to be configured to certain" |
|
696 |
echo -e "paths. Currently the default rsyslog file is used." |
|
697 |
echo -e "" |
|
698 |
|
|
699 |
valid_input "Would you like to replace $clogger with rsyslog?" |
|
700 |
if [ "$Return_Val" = "yes" ] |
|
701 |
then |
|
702 |
echo -e "" |
142fb6
|
703 |
exec_command "/etc/init.d/$clogger stop" "Stopping $clogger" |
1bb512
|
704 |
exec_command "rc-update del $clogger default" "Remove $clogger from default runlevel" |
W |
705 |
else |
|
706 |
rsyslog_install="no" |
|
707 |
fi |
|
708 |
|
|
709 |
fi |
|
710 |
|
|
711 |
if [ "$rsyslog_install" == "yes" ] |
|
712 |
then |
|
713 |
exec_command "emerge app-admin/rsyslog" "Installing rsyslog" |
|
714 |
exec_command "/etc/init.d/rsyslog start" "Starting rsyslog" |
142fb6
|
715 |
exec_command "rc-update add rsyslog default" "Add rsyslog to default runlevel" |
1bb512
|
716 |
fi |
W |
717 |
|
|
718 |
echo -e "" |
|
719 |
|
|
720 |
fi |
|
721 |
|
|
722 |
if ! is_package_installed "dev-db/mysql" "extraengine big-tables" |
|
723 |
then |
75bde1
|
724 |
package_is_emerged "dev-db/mysql" |
2ee270
|
725 |
installed=$? |
W |
726 |
|
1bb512
|
727 |
exec_command "emerge dev-db/mysql" "Installing MySql" |
2ee270
|
728 |
|
W |
729 |
if [ $installed -eq 1 ] |
|
730 |
then |
75bde1
|
731 |
echo -e "" |
W |
732 |
echo -e "\e[1;33mNotice:\e[0m Don't forget to set the mysql root password with: /usr/bin/mysqladmin -u root password 'new-password'." |
|
733 |
echo -e "" |
2ee270
|
734 |
fi |
75bde1
|
735 |
fi |
W |
736 |
|
|
737 |
if [ ! -d '/var/lib/mysql/mysql' ] |
|
738 |
then |
|
739 |
exec_command "mysql_install_db" "Set-up mysql grant tables" |
|
740 |
fi |
|
741 |
|
|
742 |
install_rcscripts "mysql" |
|
743 |
|
|
744 |
mysql_started=`eselect rc show | grep mysql | grep started | grep -v grep` |
|
745 |
if [ -z "$mysql_started" ] |
|
746 |
then |
|
747 |
exec_command "/etc/init.d/mysql start" "Starting MySQL service" |
1bb512
|
748 |
fi |
W |
749 |
|
|
750 |
which vim &> /dev/null |
|
751 |
if [ $? -ne 0 ] |
|
752 |
then |
|
753 |
exec_command "emerge app-editors/vim" "Installing vim" |
|
754 |
fi |
|
755 |
|
|
756 |
is_package_installed "sys-devel/binutils" || exec_command "emerge sys-devel/binutils" "Installing binutils"; |
|
757 |
is_package_installed "app-forensics/rkhunter" || exec_command "emerge app-forensics/rkhunter" "Installing rkhunter"; |
|
758 |
is_package_installed "net-analyzer/fail2ban" || exec_command "emerge net-analyzer/fail2ban" "Installing fail2ban"; |
|
759 |
|
|
760 |
echo -e "" |
|
761 |
|
|
762 |
# Service based packages |
|
763 |
echo -en "\e[1;37mService based packages\e[0m\n" |
|
764 |
|
|
765 |
valid_input "Install all packages or select targeted services?" "all/targeted" |
|
766 |
|
|
767 |
if [ "$Return_Val" = "all" ] |
|
768 |
then |
|
769 |
install_mail="yes" |
|
770 |
install_web="yes" |
|
771 |
install_ftp="yes" |
|
772 |
install_dns="yes" |
|
773 |
meta_all |
|
774 |
else |
|
775 |
valid_input "Install mail related packages?" |
|
776 |
install_mail=$Return_Val |
|
777 |
if [ "$install_mail" = "yes" ] |
|
778 |
then |
|
779 |
meta_mail |
|
780 |
fi |
|
781 |
|
|
782 |
echo -e "" |
75bde1
|
783 |
echo -e "\e[1;33mNotice:\e[0m If this server is going to run the ISPConfig interface, say 'yes' to web related packages." |
W |
784 |
echo -e "" |
|
785 |
|
1bb512
|
786 |
valid_input "Install web related packages?" |
W |
787 |
install_web=$Return_Val |
|
788 |
if [ "$install_web" = "yes" ] |
|
789 |
then |
|
790 |
meta_web |
|
791 |
fi |
|
792 |
|
|
793 |
echo -e "" |
|
794 |
valid_input "Install ftp related packages?" |
|
795 |
install_ftp=$Return_Val |
|
796 |
if [ "$install_ftp" = "yes" ] |
|
797 |
then |
|
798 |
meta_ftp |
|
799 |
fi |
|
800 |
|
|
801 |
echo -e "" |
|
802 |
valid_input "Install dns related packages?" |
|
803 |
install_dns=$Return_Val |
|
804 |
if [ "$install_dns" = "yes" ] |
|
805 |
then |
|
806 |
meta_dns |
|
807 |
fi |
|
808 |
fi |
|
809 |
|
2ee270
|
810 |
if [ "$install_web" = "no" ] && ! is_package_installed "dev-lang/php" "-apache2 gd mysql mysqli imap cli cgi pcre xml zlib crypt ctype session unicode mhash ftp" |
W |
811 |
then |
|
812 |
exec_command "emerge dev-lang/php" "Installing PHP" |
|
813 |
fi |
|
814 |
|
1bb512
|
815 |
echo -e "" |
W |
816 |
echo -e "\e[1;33mSetup script completed\e[0m" |
|
817 |
echo -e "\e[1;32m========================================\e[0m" |
|
818 |
echo -e "" |
|
819 |
|
|
820 |
valid_input "Do you want to start the ISPConfig installer?" |
|
821 |
if [ "$Return_Val" = "yes" ] |
|
822 |
then |
|
823 |
clear |
|
824 |
php -q ../install/install.php |
|
825 |
fi |
|
826 |
|
|
827 |
exit $? |