#!/bin/sh
# Handling users:  Have to modify /etc/sshd_config with::
# This makes it normal for users whose home directory is in /home/.  For the
# vcsusers, this places their keys outside of the repository structure.
# authorizedKeyFile /home/%u/.ssh/authorized_keys

REPODIR=/pkgs/bzr/chroot//pkgs

if [ x$2 != "x" ]; then
	groupFlag="--groups $2"
else
	groupFlag=''
fi

useradd $1  --home $REPODIR --gid vcsuser -M -n -s /usr/sbin/scponlyc $groupFlag

if [ x$1 != 'xvcsguest' ]; then
	# Copy ssh key to /home/
	mkdir -p /home/$1/.ssh
	### FIXME: Retrieve key and copy to the directory
	chown -R $1:$1 /home/$1
	chmod -R 0500 /home/$1
	chmod 0400 /home/$1/.ssh/*
fi
