2014-06-03 13:24:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source setup/functions.sh
|
|
|
|
|
2014-08-21 11:25:06 +00:00
|
|
|
apt_install python3-flask links duplicity libyaml-dev python3-dnspython unattended-upgrades
|
2014-07-16 13:06:45 +00:00
|
|
|
hide_output pip3 install rtyaml
|
2014-06-03 20:21:17 +00:00
|
|
|
|
|
|
|
# Create a backup directory and a random key for encrypting backups.
|
|
|
|
mkdir -p $STORAGE_ROOT/backup
|
|
|
|
if [ ! -f $STORAGE_ROOT/backup/secret_key.txt ]; then
|
2014-08-22 21:23:56 +00:00
|
|
|
$(umask 077; openssl rand -base64 2048 > $STORAGE_ROOT/backup/secret_key.txt)
|
2014-06-03 20:21:17 +00:00
|
|
|
fi
|
2014-06-03 13:24:48 +00:00
|
|
|
|
|
|
|
# Link the management server daemon into a well known location.
|
2014-06-21 16:35:00 +00:00
|
|
|
rm -f /usr/local/bin/mailinabox-daemon
|
|
|
|
ln -s `pwd`/management/daemon.py /usr/local/bin/mailinabox-daemon
|
2014-06-03 13:24:48 +00:00
|
|
|
|
|
|
|
# Create an init script to start the management daemon and keep it
|
|
|
|
# running after a reboot.
|
|
|
|
rm -f /etc/init.d/mailinabox
|
|
|
|
ln -s $(pwd)/conf/management-initscript /etc/init.d/mailinabox
|
2014-07-16 13:06:45 +00:00
|
|
|
hide_output update-rc.d mailinabox defaults
|
2014-06-03 13:24:48 +00:00
|
|
|
|
2014-08-21 11:25:06 +00:00
|
|
|
# Allow apt to install system updates automatically every day.
|
|
|
|
cat > /etc/apt/apt.conf.d/02periodic <<EOF;
|
|
|
|
APT::Periodic::MaxAge "7";
|
|
|
|
APT::Periodic::Update-Package-Lists "1";
|
|
|
|
APT::Periodic::Unattended-Upgrade "1";
|
|
|
|
APT::Periodic::Verbose "1";
|
|
|
|
EOF
|
|
|
|
|
2014-06-26 10:46:22 +00:00
|
|
|
# Perform a daily backup.
|
|
|
|
cat > /etc/cron.daily/mailinabox-backup << EOF;
|
|
|
|
#!/bin/bash
|
|
|
|
# Mail-in-a-Box --- Do not edit / will be overwritten on update.
|
|
|
|
# Perform a backup.
|
|
|
|
$(pwd)/management/backup.py
|
|
|
|
EOF
|
|
|
|
chmod +x /etc/cron.daily/mailinabox-backup
|
|
|
|
|
2014-06-03 13:24:48 +00:00
|
|
|
# Start it.
|
2014-07-16 13:06:45 +00:00
|
|
|
restart_service mailinabox
|