- add inotify-tools to avoid `sleep` and check expected files directly. - add mailutils to generate mime structured emails
71 lines
1.7 KiB
Bash
Executable File
71 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
BRANCH=$1
|
|
|
|
## create domain
|
|
echo "127.0.0.1 " $(hostname) >> /etc/hosts
|
|
echo "127.0.0.2 example.com" >> /etc/hosts
|
|
echo "127.0.0.3 example.org" >> /etc/hosts
|
|
|
|
## build milter
|
|
if [ -f /opt/husk/mapped/Cargo.toml ] ; then
|
|
HUSK_BIN=/opt/husk/mapped/target/debug/husk
|
|
HUSK_DIR=/opt/husk/mapped/
|
|
else
|
|
cd /opt/husk
|
|
git clone https://gitlab.com/husk-project/husk-milter.git
|
|
cd husk-milter
|
|
if [ "$BRANCH" != "" ] ; then
|
|
git checkout $BRANCH
|
|
fi
|
|
ASSET_DIR=/tmp cargo build
|
|
|
|
HUSK_BIN=/opt/husk/husk-milter/target/debug/husk
|
|
HUSK_DIR=/opt/husk/husk-milter/
|
|
|
|
cp /tmp/shell_completions/husk.bash /etc/bash_completion.d/
|
|
fi
|
|
|
|
## start rsyslogd
|
|
/usr/sbin/rsyslogd -n -iNONE &
|
|
|
|
## start postfix
|
|
sudo postfix start > /dev/null
|
|
|
|
## start and prepare postgres
|
|
DOMAINS="example.com"
|
|
sudo /etc/init.d/postgresql start
|
|
echo "create user hockeypuck;" | sudo -u postgres psql -d template1 -U postgres
|
|
for domain in $DOMAINS ; do
|
|
DB_NAME=$(echo $domain | tr -d '.-')
|
|
echo "
|
|
create database hkp_$DB_NAME with owner 'hockeypuck';
|
|
GRANT ALL PRIVILEGES ON DATABASE hkp_$DB_NAME to hockeypuck;
|
|
" | sudo -u postgres psql -d template1 -U postgres
|
|
done
|
|
|
|
#
|
|
# start hockeypuck
|
|
#
|
|
echo "start hockeypuck"
|
|
for domain in $DOMAINS ; do
|
|
echo " $domain..."
|
|
sudo -u hockeypuck hockeypuck --config /etc/hockeypuck.d/hockeypuck_$domain.conf 2>&1 > /tmp/hockeypuck_$domain.out &
|
|
done
|
|
|
|
## create sequoia_home
|
|
bash /usr/bin/gen_sq_home.sh
|
|
|
|
## start milter
|
|
cd $HUSK_DIR/config
|
|
$HUSK_BIN daemon start --config config.toml &
|
|
|
|
## extract SEQUOIA_HOME from the configuration
|
|
SEQUOIA_HOME=$(grep "sequoia_home" config.toml | cut -d '=' -f 2 | tr -d ' ')
|
|
|
|
cat << EO_ENV > /tmp/env.sh
|
|
export HUSK_BIN=$HUSK_BIN
|
|
export HUSK_DIR=$HUSK_DIR
|
|
export SEQUOIA_HOME=$SEQUOIA_HOME
|
|
EO_ENV
|