#!/bin/bash

# This script is a modified version of the one originally used by majordomo.

# Allow this part to fail.

set +e

UNAME=listar
HOMEDIR=/usr/lib/listar
adduser --system --home $HOMEDIR --group $UNAME

if ! grep -q "^${UNAME}:.*${HOMEDIR}" /etc/passwd
then
  echo Failed to create user $UNAME
  exit 1
fi

if ! grep -q \^${UNAME}: /etc/group
then
  echo Failed to create group $UNAME
  exit 1
fi

# Restore normal error checking

set -e

# Tag everything with proper permissions.

touch /var/log/listar.log
chown -R listar.listar /usr/lib/listar /var/lib/listar /etc/listar /var/log/listar.log
chown listar.daemon /usr/lib/listar/listar
chmod 4755 /usr/lib/listar/listar

chmod o-rwx /var/lib/listar/{lists,queue}

#DEBHELPER#

cat <<EOF

Listar is now installed on your system.  However, it is not yet ready for
use.  Before using Listar, you will need to modify some listar configuration
files in /etc/listar, add things to your /etc/aliases file, and set up a
mailing list.  More details can be found in /usr/doc/listar, especially the
file README.Debian in that directory.

Press Enter to continue.

EOF

read resp

