1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-26 02:57:04 +00:00

make a bash function to use everywhere we apt-get-install (DEBIAN_FRONTEND=noninteractive apt-get -qq -y )

ensures the output is quiet
This commit is contained in:
Joshua Tauberer 2014-05-01 19:13:00 +00:00
parent 80bf60715e
commit 66269f910f
8 changed files with 43 additions and 11 deletions

View File

@ -4,8 +4,10 @@
# After this, you'll still need to run dns_update.sh to get the DKIM # After this, you'll still need to run dns_update.sh to get the DKIM
# signature in the DNS zones. # signature in the DNS zones.
source scripts/functions.sh # load our functions
# Install DKIM # Install DKIM
apt-get install -q -y opendkim opendkim-tools apt_install opendkim opendkim-tools
# Make sure configuration directories exist. # Make sure configuration directories exist.
mkdir -p /etc/opendkim; mkdir -p /etc/opendkim;

View File

@ -7,6 +7,8 @@
# #
# This script will turn on DNS for $PUBLIC_HOSTNAME. # This script will turn on DNS for $PUBLIC_HOSTNAME.
source scripts/functions.sh # load our functions
# Install nsd, our DNS server software. # Install nsd, our DNS server software.
# ...but first, we have to create the user because the # ...but first, we have to create the user because the
@ -20,7 +22,7 @@ fi
# Okay now install the package. # Okay now install the package.
apt-get -qq -y install nsd apt_install nsd
# Prepare nsd's configuration. # Prepare nsd's configuration.

21
scripts/functions.sh Normal file
View File

@ -0,0 +1,21 @@
function apt_install {
# Report any packages already installed.
PACKAGES=$@
TO_INSTALL=""
for pkg in $PACKAGES; do
if dpkg -s $pkg 2>/dev/null | grep "^Status: install ok installed" > /dev/null; then
echo $pkg is already installed \(`dpkg -s $pkg | grep ^Version: | sed -e "s/.*: //"`\)
else
TO_INSTALL="$TO_INSTALL""$pkg "
fi
done
# List the packages about to be installed.
if [[ ! -z "$TO_INSTALL" ]]; then
echo installing $TO_INSTALL...
fi
# 'DEBIAN_FRONTEND=noninteractive' is to prevent dbconfig-common from asking you questions.
DEBIAN_FRONTEND=noninteractive apt-get -qq -y install $PACKAGES > /dev/null;
}

View File

@ -12,9 +12,10 @@
# Install packages. # Install packages.
source scripts/functions.sh # load our functions
source /etc/mailinabox.conf # load global vars source /etc/mailinabox.conf # load global vars
DEBIAN_FRONTEND=noninteractive apt-get -q -y install \ apt_install \
postfix postgrey \ postfix postgrey \
dovecot-core dovecot-imapd dovecot-lmtpd dovecot-sqlite sqlite3 \ dovecot-core dovecot-imapd dovecot-lmtpd dovecot-sqlite sqlite3 \
openssl openssl

View File

@ -9,8 +9,10 @@
# plugin. The tools/mail.py tool creates the necessary sieve script for each mail # plugin. The tools/mail.py tool creates the necessary sieve script for each mail
# user when the mail user is created. # user when the mail user is created.
source scripts/functions.sh # load our functions
# Install packages. # Install packages.
apt-get -q -y install spampd razor pyzor dovecot-sieve dovecot-antispam apt_install spampd razor pyzor dovecot-sieve dovecot-antispam
# Allow spamassassin to download new rules. # Allow spamassassin to download new rules.
tools/editconf.py /etc/default/spamassassin \ tools/editconf.py /etc/default/spamassassin \

View File

@ -1,10 +1,12 @@
source scripts/functions.sh # load our functions
# Base system configuration. # Base system configuration.
apt-get -q -q update apt-get -q -q update
apt-get -q -y upgrade apt-get -q -y upgrade
# Install openssh-server to ensure that the end result is consistent across all Mail-in-a-Boxes. # Install openssh-server to ensure that the end result is consistent across all Mail-in-a-Boxes.
apt-get -q -y install openssh-server apt_install openssh-server
# Check that SSH login with password is disabled. Stop if it's enabled. # Check that SSH login with password is disabled. Stop if it's enabled.
if grep -q "^PasswordAuthentication yes" /etc/ssh/sshd_config \ if grep -q "^PasswordAuthentication yes" /etc/ssh/sshd_config \
@ -18,7 +20,7 @@ if grep -q "^PasswordAuthentication yes" /etc/ssh/sshd_config \
exit exit
fi fi
apt-get -q -y install python3 apt_install python3
# Turn on basic services: # Turn on basic services:
# #
@ -28,11 +30,11 @@ apt-get -q -y install python3
# #
# These services don't need further configuration and are started immediately after installation. # These services don't need further configuration and are started immediately after installation.
apt-get -q -y install ntp fail2ban apt_install ntp fail2ban
# Turn on the firewall. First allow incoming SSH, then turn on the firewall. # Turn on the firewall. First allow incoming SSH, then turn on the firewall.
# Other ports will be opened at the point where we set up those services. # Other ports will be opened at the point where we set up those services.
apt-get -q -y install ufw; apt_install ufw
ufw allow ssh; ufw allow ssh;
ufw --force enable; ufw --force enable;

View File

@ -1,12 +1,14 @@
# HTTP: Turn on a web server serving static files # HTTP: Turn on a web server serving static files
################################################# #################################################
source scripts/functions.sh # load our functions
# Remove Apache before installing Nginx. Apache may leave # Remove Apache before installing Nginx. Apache may leave
# some unwanted configuration files around (e.g. a ufw # some unwanted configuration files around (e.g. a ufw
# application config), so purge the packages. # application config), so purge the packages.
apt-get purge -q -y apache2 apache2.2-common apt-get purge -q -y apache2 apache2.2-common
apt-get install -q -y nginx php5-cgi apt_install nginx php5-cgi
rm -f /etc/nginx/sites-enabled/default rm -f /etc/nginx/sites-enabled/default

View File

@ -1,6 +1,7 @@
# Webmail: Using roundcube # Webmail: Using roundcube
########################## ##########################
source scripts/functions.sh # load our functions
source /etc/mailinabox.conf # load global vars source /etc/mailinabox.conf # load global vars
# Ubuntu's roundcube-core has a dependency on Apache & MySQL, which we don't want, so we can't # Ubuntu's roundcube-core has a dependency on Apache & MySQL, which we don't want, so we can't
@ -8,10 +9,9 @@ source /etc/mailinabox.conf # load global vars
# dependencies of roundcube that we know we need, and then we'll manually install debs for the # dependencies of roundcube that we know we need, and then we'll manually install debs for the
# roundcube version we want from Debian. # roundcube version we want from Debian.
# #
# 'DEBIAN_FRONTEND=noninteractive' is to prevent dbconfig-common from asking you questions.
# The dependencies are from 'apt-cache showpkg roundcube-core'. # The dependencies are from 'apt-cache showpkg roundcube-core'.
DEBIAN_FRONTEND=noninteractive apt-get -q -q -y install \ apt_install \
dbconfig-common \ dbconfig-common \
php5 php5-sqlite php5-mcrypt php5-intl php5-json php5-common php-auth php-net-smtp php-net-socket php-net-sieve php-mail-mime php-crypt-gpg php5-gd php5-pspell \ php5 php5-sqlite php5-mcrypt php5-intl php5-json php5-common php-auth php-net-smtp php-net-socket php-net-sieve php-mail-mime php-crypt-gpg php5-gd php5-pspell \
tinymce libjs-jquery libjs-jquery-mousewheel libmagic1 tinymce libjs-jquery libjs-jquery-mousewheel libmagic1