#!/bin/sh -e
#
# Michael Pozhidaev <msp@altlinux.org>

[ -z "$HOMEROS_INSTALL_USER" ] && exit 0

DEFUSER=altlinux
NEWUSER="$HOMEROS_INSTALL_USER"

/bin/rm -rf /home/"$DEFUSER" /var/spool/mail/"$DEFUSER"
find /etc/sudo.d/ -type f -exec /bin/rm -f '{}' \;
useradd-homeros "$NEWUSER"
usermod -G wheel,proc,cdrom,cdwriter,audio,users,scanner,fuse "$NEWUSER"
subst s/"$DEFUSER"/"$NEWUSER"/  /etc/inittab
echo "$NEWUSER ALL=NOPASSWD:ALL" > /etc/sudo.d/"$NEWUSER"
chmod 400 /etc/sudo.d/"$NEWUSER"
