#!/bin/bash
echo "atftpd  atftpd/use_inetd        boolean false" | debconf-set-selections
echo "atftpd  atftpd/basedir  string  /var/lib/pulse2/imaging" | debconf-set-selections
echo "atftpd  atftpd/logtofile        boolean false" | debconf-set-selections
echo "atftpd  atftpd/maxthread        string  1000" | debconf-set-selections
dpkg-reconfigure -fnoninteractive atftpd

# dpkg-reconfigure doesn't commit settings in /etc/default/atftpd
# so directly write 
# https://bugs.debian.org/510289
# https://bugs.debian.org/723201

cat << EOF > /etc/default/atftpd
USE_INETD=false
OPTIONS="--daemon --port 69 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /var/lib/pulse2/imaging"
EOF

/etc/init.d/atftpd restart
