-
Notifications
You must be signed in to change notification settings - Fork 1
/
customize
executable file
·70 lines (57 loc) · 2.3 KB
/
customize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/bash
#
# Put customizations to your image in this file.
PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
# Exit if any commands fail
set -o errexit
# Add users to groups
echo "* Add dovecot and clamav users to mail group"
usermod -G mail dovecot
usermod -G mail clamav
# Create extra user for spamd
echo "* Create spamd group and user"
groupadd spamd
useradd -d /var/spamassassin -c "spamassassin spamd user" -s /usr/bin/false -g spamd spamd
passwd -N spamd
# Change default permissions for spamd folder
echo "* Update permissions for spamassassin folders"
mkdir /var/spamassassin/.spamassassin
mkdir /var/spool/spamd
mkdir /var/run/spamd
chown -R spamd:spamd /var/spamassassin
chown spamd:spamd /var/spool/spamd
chown spamd:spamd /var/run/spamd
chown -R spamd:spamd /opt/local/etc/spamassassin
# Run sa-update so spamd can know what to do
/opt/local/bin/sa-update
# Update spamd and clamd, should speed up provision
echo "* Update spamd and clamd database"
mkdir /var/log/clamav
chown clamav /var/log/clamav
/opt/local/bin/freshclam
pyzor --homedir /opt/local/etc/spamassassin discover
echo "* Copy mailer.conf to /etc/ because of exim usage"
cp /opt/local/share/examples/exim/mailer.conf /etc/
# Install gsutil for backing up to google cloud storage
gsutil_version=4.26
# Python apparenty can't be trusted to not fuck up their URLs so use Debian's redirector service. Thanks Debian.
curl -LO http://pypi.debian.net/gsutil/gsutil-${gsutil_version}.tar.gz && tar xvzf gsutil-${gsutil_version}.tar.gz
cd gsutil-${gsutil_version}
export PATH=${PATH}:/opt/local/gcc49/bin
python setup.py install
cd ..
rm -rf gsutil-${gsutil_version} gsutil-${gsutil_version}.tar.gz
# Get acmetool for Let's Encrypt certificates
acmetool_version=v0.0.59
curl -LO https://github.com/hlandau/acme/releases/download/${acmetool_version}/acmetool-${acmetool_version}-solaris_amd64.tar.gz && tar xvzf acmetool-${acmetool_version}-solaris_amd64.tar.gz
cd acmetool-${acmetool_version}-solaris_amd64
cp bin/acmetool /opt/local/bin/acmetool.real
cd ..
rm -rf acmetool-${acmetool_version}-solaris_amd64.tar.gz acmetool-${acmetool_version}-solaris_amd64
# Clean up
echo "* Cleaning up."
rm -rf /root/*
# gcc49/binutils was only necessary to install gsutil
pkg_delete gcc49 binutils
# Prepare image for provisioning
sm-prepare-image -y