Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
9cd5fc34
Commit
9cd5fc34
authored
Sep 08, 2013
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring dns_update: use global vars stored in /etc/mailinabox.conf
parent
548cc8a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
31 deletions
+10
-31
dns.sh
scripts/dns.sh
+0
-19
dns_update.sh
scripts/dns_update.sh
+9
-12
start.sh
scripts/start.sh
+1
-0
No files found.
scripts/dns.sh
View file @
9cd5fc34
...
...
@@ -11,30 +11,11 @@
apt-get
-qq
-y
install
nsd3
# Get configuraton information.
if
[
-z
"
$PUBLIC_HOSTNAME
"
]
;
then
PUBLIC_HOSTNAME
=
example.org
fi
if
[
-z
"
$PUBLIC_IP
"
]
;
then
# works on EC2 only...
PUBLIC_IP
=
`
wget
-q
-O-
http://instance-data/latest/meta-data/public-ipv4
`
fi
# Prepare nsd3's configuration.
sudo mkdir
-p
/var/run/nsd3
mkdir
-p
"
$STORAGE_ROOT
/dns"
;
# Store our desired IP address (to put in the zone files) for later.
# Also store our primary hostname, which we'll use for all DKIM signatures
# in case the user is only delegating MX and we aren't setting DKIM on
# the main DNS.
echo
$PUBLIC_IP
>
$STORAGE_ROOT
/dns/our_ip
echo
$PUBLIC_HOSTNAME
>
$STORAGE_ROOT
/dns/primary_hostname
# Create the default zone if it doesn't exist.
if
[
!
-f
"
$STORAGE_ROOT
/dns/
$PUBLIC_HOSTNAME
.txt"
]
;
then
...
...
scripts/dns_update.sh
View file @
9cd5fc34
...
...
@@ -8,10 +8,7 @@
# This script is safe to run on its own.
# Load $STORAGE_ROOT, $PUBLIC_IP, and $PRIMARY_HOSTNAME.
source
/etc/mailinabox.conf
PUBLIC_IP
=
`
cat
$STORAGE_ROOT
/dns/our_ip
`
PRIMARY_HOSTNAME
=
`
cat
$STORAGE_ROOT
/dns/primary_hostname
`
source
/etc/mailinabox.conf
# load global vars
# Ensure a zone file exists for every domain name in use by a mail user.
for
mail_user
in
`
tools/mail.py user
`
;
do
...
...
@@ -69,7 +66,7 @@ for fn in $STORAGE_ROOT/dns/*.txt; do
\$
ORIGIN
$zone
. ; default zone domain
\$
TTL 86400 ; default time to live
@ IN SOA ns1.
$P
RIMARY_HOSTNAME
. hostmaster.
$PRIMARY
_HOSTNAME
. (
@ IN SOA ns1.
$P
UBLIC_HOSTNAME
. hostmaster.
$PUBLIC
_HOSTNAME
. (
$serial
; serial number
28800 ; Refresh
7200 ; Retry
...
...
@@ -77,18 +74,18 @@ for fn in $STORAGE_ROOT/dns/*.txt; do
86400 ; Min TTL
)
NS ns1.
$P
RIMARY
_HOSTNAME
.
NS ns2.
$P
RIMARY
_HOSTNAME
.
NS ns1.
$P
UBLIC
_HOSTNAME
.
NS ns2.
$P
UBLIC
_HOSTNAME
.
IN A
$PUBLIC_IP
MX 10
$P
RIMARY
_HOSTNAME
.
MX 10
$P
UBLIC
_HOSTNAME
.
300 TXT "v=spf1 mx -all"
www IN A
$PUBLIC_IP
EOF
# In P
RIMARY
_HOSTNAME, also define ns1 and ns2.
if
[
"
$zone
"
=
$P
RIMARY
_HOSTNAME
]
;
then
# In P
UBLIC
_HOSTNAME, also define ns1 and ns2.
if
[
"
$zone
"
=
$P
UBLIC
_HOSTNAME
]
;
then
cat
>>
/etc/nsd3/zones/
$fn2
<<
EOF
;
ns1 IN A
$PUBLIC_IP
ns2 IN A
$PUBLIC_IP
...
...
@@ -112,12 +109,12 @@ EOF
# the selector, and the path to the private key.
#
# Just in case we don't actually host the DNS for all domains of our mail users,
# we assume that DKIM is at least configured in the DNS of $P
RIMARY
_HOSTNAME and
# we assume that DKIM is at least configured in the DNS of $P
UBLIC
_HOSTNAME and
# we use that host for all DKIM signatures.
#
# In SigningTable, we map every email address to a key record called $zone.
# Then we specify for the key record named $zone its domain, selector, and key.
echo
"
$zone
$P
RIMARY
_HOSTNAME
:mail:
$STORAGE_ROOT
/mail/dkim/mail.private"
>>
/etc/opendkim/KeyTable
echo
"
$zone
$P
UBLIC
_HOSTNAME
:mail:
$STORAGE_ROOT
/mail/dkim/mail.private"
>>
/etc/opendkim/KeyTable
echo
"*@
$zone
$zone
"
>>
/etc/opendkim/SigningTable
done
...
...
scripts/start.sh
View file @
9cd5fc34
...
...
@@ -50,6 +50,7 @@ fi
cat
>
/etc/mailinabox.conf
<<
EOF
;
STORAGE_ROOT=
$STORAGE_ROOT
PUBLIC_HOSTNAME=
$PUBLIC_HOSTNAME
PUBLIC_IP=
$PUBLIC_IP
EOF
# Start service configuration.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment