#!/bin/sh

set -e

case $1 in
  preinst)
    exit 0
    ;;
  postinst)
    if [ ! -f /etc/login.defs ]; then
      cp /usr/share/shadow/login.defs /etc/login.defs
    fi
    if [ ! -f /etc/login.access ]; then
      cp /usr/share/shadow/login.access /etc/login.access
    fi
    if [ ! -f /etc/limits ]; then
      cp /usr/share/shadow/limits /etc/limits
    fi
    if [ ! -f /etc/default/useradd ]; then
      cp /usr/share/shadow/useradd.default /etc/default/useradd
    fi

    if [ ! -f /etc/shadow ]; then
      echo "Converting /etc/passwd to shadow"
      pwconv
    fi

    if [ ! -f /etc/gshadow ]; then
      echo "Converting /etc/group to gshadow"
      grpconv
    fi
    ;;
  prerm)
    exit 0
    ;;
  postrm)
    exit 0
    ;;
esac
