2014-06-20 01:16:38 +00:00
|
|
|
#!/bin/bash
|
2013-09-01 14:24:49 +00:00
|
|
|
# HTTP: Turn on a web server serving static files
|
|
|
|
#################################################
|
|
|
|
|
2014-06-03 11:12:38 +00:00
|
|
|
source setup/functions.sh # load our functions
|
2014-06-20 01:16:38 +00:00
|
|
|
source /etc/mailinabox.conf # load global vars
|
2014-05-01 19:13:00 +00:00
|
|
|
|
2014-08-12 13:39:45 +00:00
|
|
|
apt_install nginx php5-fpm
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2013-09-07 20:53:25 +00:00
|
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
|
|
|
2014-06-20 01:16:38 +00:00
|
|
|
# copy in a nginx configuration file for common and best-practices
|
|
|
|
# SSL settings from @konklone
|
2014-04-18 00:27:52 +00:00
|
|
|
cp conf/nginx-ssl.conf /etc/nginx/nginx-ssl.conf
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2014-07-07 11:23:31 +00:00
|
|
|
# Fix some nginx defaults.
|
|
|
|
# The server_names_hash_bucket_size seems to prevent long domain names?
|
|
|
|
tools/editconf.py /etc/nginx/nginx.conf -s \
|
|
|
|
server_names_hash_bucket_size="64;"
|
|
|
|
|
2014-06-20 01:16:38 +00:00
|
|
|
# Other nginx settings will be configured by the management service
|
|
|
|
# since it depends on what domains we're serving, which we don't know
|
|
|
|
# until mail accounts have been created.
|
|
|
|
|
2013-09-08 09:55:58 +00:00
|
|
|
# make a default homepage
|
2014-06-20 01:16:38 +00:00
|
|
|
if [ -d $STORAGE_ROOT/www/static ]; then mv $STORAGE_ROOT/www/static $STORAGE_ROOT/www/default; fi # migration
|
|
|
|
mkdir -p $STORAGE_ROOT/www/default
|
2014-06-23 19:43:19 +00:00
|
|
|
if [ ! -f $STORAGE_ROOT/www/default/index.html ]; then
|
2014-06-20 01:16:38 +00:00
|
|
|
cp conf/www_default.html $STORAGE_ROOT/www/default/index.html
|
|
|
|
fi
|
2014-06-23 10:53:09 +00:00
|
|
|
chown -R $STORAGE_USER $STORAGE_ROOT/www
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2014-03-17 01:46:47 +00:00
|
|
|
# Create an init script to start the PHP FastCGI daemon and keep it
|
|
|
|
# running after a reboot. Allows us to serve Roundcube for webmail.
|
|
|
|
rm -f /etc/init.d/php-fastcgi
|
|
|
|
ln -s $(pwd)/conf/phpfcgi-initscript /etc/init.d/php-fastcgi
|
2014-07-16 13:06:45 +00:00
|
|
|
hide_output update-rc.d php-fastcgi defaults
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2014-07-12 00:02:32 +00:00
|
|
|
# Put our webfinger and Exchange autodiscover.xml server scripts
|
|
|
|
# into a well-known location.
|
|
|
|
for f in webfinger exchange-autodiscover; do
|
|
|
|
cp tools/$f.php /usr/local/bin/mailinabox-$f.php
|
|
|
|
chown www-data.www-data /usr/local/bin/mailinabox-$f.php
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make some space for users to customize their webfinger responses.
|
2014-06-21 17:08:18 +00:00
|
|
|
mkdir -p $STORAGE_ROOT/webfinger/acct;
|
|
|
|
chown -R $STORAGE_USER $STORAGE_ROOT/webfinger
|
2014-06-20 01:54:59 +00:00
|
|
|
|
2014-03-17 01:46:47 +00:00
|
|
|
# Start services.
|
2014-07-16 13:06:45 +00:00
|
|
|
restart_service nginx
|
2014-08-11 23:26:51 +00:00
|
|
|
restart_service php5-fpm
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2014-03-17 01:46:47 +00:00
|
|
|
# Open ports.
|
2014-05-01 19:35:18 +00:00
|
|
|
ufw_allow http
|
|
|
|
ufw_allow https
|
2013-09-01 14:24:49 +00:00
|
|
|
|