From b04addda9a4346bcab0ce18e8144a9939a7d45d0 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Fri, 14 Nov 2014 13:49:01 +0000 Subject: [PATCH] move the mobileconfig into the conf directory as a plain XML file and handle substitutions and copying to /var in web.sh --- .gitignore | 1 - setup/mobileconfig.sh => conf/ios-profile.xml | 72 +++++++++---------- setup/start.sh | 1 - setup/web.sh | 13 ++++ 4 files changed, 46 insertions(+), 41 deletions(-) rename setup/mobileconfig.sh => conf/ios-profile.xml (62%) diff --git a/.gitignore b/.gitignore index f3cdb1b..e22c1d9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ management/__pycache__/ tools/__pycache__/ externals/ .env -.vagrant diff --git a/setup/mobileconfig.sh b/conf/ios-profile.xml similarity index 62% rename from setup/mobileconfig.sh rename to conf/ios-profile.xml index d246209..19460c0 100644 --- a/setup/mobileconfig.sh +++ b/conf/ios-profile.xml @@ -1,28 +1,22 @@ -#!/bin/bash -# -# iOS Configuration Profile -# ---------------------------------------------- -# -# Mobileconfig for iOS users to setup IMAP, Contacts & Calendars -# -# https://developer.apple.com/library/ios/featuredarticles/iPhoneConfigurationProfileRef/Introduction/Introduction.html - -source setup/functions.sh # load our functions -source /etc/mailinabox.conf # load global vars - -echo "Generate iOS Configuration Profile" - -echo " + + PayloadContent CalDAVAccountDescription - $PRIMARY_HOSTNAME calendar + PRIMARY_HOSTNAME calendar CalDAVHostName - $PRIMARY_HOSTNAME + PRIMARY_HOSTNAME CalDAVPort 443 CalDAVPrincipalURL @@ -30,29 +24,29 @@ echo " CalDAVUseSSL PayloadDescription - $PRIMARY_HOSTNAME (Mail-in-a-Box) + PRIMARY_HOSTNAME (Mail-in-a-Box) PayloadDisplayName - $PRIMARY_HOSTNAME calendar + PRIMARY_HOSTNAME calendar PayloadIdentifier - email.mailinabox.mobileconfig.$PRIMARY_HOSTNAME.CalDAV + email.mailinabox.mobileconfig.PRIMARY_HOSTNAME.CalDAV PayloadOrganization PayloadType com.apple.caldav.account PayloadUUID - $(cat /proc/sys/kernel/random/uuid) + UUID1 PayloadVersion 1 EmailAccountDescription - $PRIMARY_HOSTNAME mail + PRIMARY_HOSTNAME mail EmailAccountType EmailTypeIMAP IncomingMailServerAuthentication EmailAuthPassword IncomingMailServerHostName - $PRIMARY_HOSTNAME + PRIMARY_HOSTNAME IncomingMailServerPortNumber 993 IncomingMailServerUseSSL @@ -60,7 +54,7 @@ echo " OutgoingMailServerAuthentication EmailAuthPassword OutgoingMailServerHostName - $PRIMARY_HOSTNAME + PRIMARY_HOSTNAME OutgoingMailServerPortNumber 587 OutgoingMailServerUseSSL @@ -68,17 +62,17 @@ echo " OutgoingPasswordSameAsIncomingPassword PayloadDescription - $PRIMARY_HOSTNAME (Mail-in-a-Box) + PRIMARY_HOSTNAME (Mail-in-a-Box) PayloadDisplayName - $PRIMARY_HOSTNAME mail + PRIMARY_HOSTNAME mail PayloadIdentifier - email.mailinabox.mobileconfig.$PRIMARY_HOSTNAME.E-Mail + email.mailinabox.mobileconfig.PRIMARY_HOSTNAME.E-Mail PayloadOrganization PayloadType com.apple.mail.managed PayloadUUID - $(cat /proc/sys/kernel/random/uuid) + UUID2 PayloadVersion 1 PreventAppSheet @@ -90,9 +84,9 @@ echo " CardDAVAccountDescription - $PRIMARY_HOSTNAME contacts + PRIMARY_HOSTNAME contacts CardDAVHostName - $PRIMARY_HOSTNAME + PRIMARY_HOSTNAME CardDAVPort 443 CardDAVPrincipalURL @@ -100,27 +94,27 @@ echo " CardDAVUseSSL PayloadDescription - $PRIMARY_HOSTNAME (Mail-in-a-Box) + PRIMARY_HOSTNAME (Mail-in-a-Box) PayloadDisplayName - $PRIMARY_HOSTNAME contacts + PRIMARY_HOSTNAME contacts PayloadIdentifier - email.mailinabox.mobileconfig.$PRIMARY_HOSTNAME.carddav + email.mailinabox.mobileconfig.PRIMARY_HOSTNAME.carddav PayloadOrganization PayloadType com.apple.carddav.account PayloadUUID - $(cat /proc/sys/kernel/random/uuid) + UUID3 PayloadVersion 1 PayloadDescription - $PRIMARY_HOSTNAME (Mail-in-a-Box) + PRIMARY_HOSTNAME (Mail-in-a-Box) PayloadDisplayName - $PRIMARY_HOSTNAME + PRIMARY_HOSTNAME PayloadIdentifier - email.mailinabox.mobileconfig.$PRIMARY_HOSTNAME + email.mailinabox.mobileconfig.PRIMARY_HOSTNAME PayloadOrganization PayloadRemovalDisallowed @@ -128,8 +122,8 @@ echo " PayloadType Configuration PayloadUUID - $(cat /proc/sys/kernel/random/uuid) + UUID4 PayloadVersion 1 -" > "/var/lib/mailinabox/mobileconfig.xml"; + diff --git a/setup/start.sh b/setup/start.sh index c47aaee..22759c6 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -125,7 +125,6 @@ source setup/webmail.sh source setup/owncloud.sh source setup/zpush.sh source setup/management.sh -source setup/mobileconfig.sh # Write the DNS and nginx configuration files. sleep 5 # wait for the daemon to start diff --git a/setup/web.sh b/setup/web.sh index d8d4644..fd0b557 100755 --- a/setup/web.sh +++ b/setup/web.sh @@ -40,6 +40,19 @@ tools/editconf.py /etc/php5/fpm/pool.d/www.conf -c ';' \ # since it depends on what domains we're serving, which we don't know # until mail accounts have been created. +# Create the iOS Mobile Configuration file which is exposed via the +# nginx configuration at /mailinabox-mobileconfig. +mkdir -p /var/lib/mailinabox +chmod a+rx /var/lib/mailinabox +cat conf/ios-profile.xml \ + | sed "s/PRIMARY_HOSTNAME/$PRIMARY_HOSTNAME/" \ + | sed "s/UUID1/$(cat /proc/sys/kernel/random/uuid)/" \ + | sed "s/UUID2/$(cat /proc/sys/kernel/random/uuid)/" \ + | sed "s/UUID3/$(cat /proc/sys/kernel/random/uuid)/" \ + | sed "s/UUID4/$(cat /proc/sys/kernel/random/uuid)/" \ + > /var/lib/mailinabox/mobileconfig.xml +chmod a+r /var/lib/mailinabox/mobileconfig.xml + # make a default homepage if [ -d $STORAGE_ROOT/www/static ]; then mv $STORAGE_ROOT/www/static $STORAGE_ROOT/www/default; fi # migration #NODOC mkdir -p $STORAGE_ROOT/www/default