#! /bin/sh
# Create the home directory for the DJB DNS File Transfer user
# Usage: djbdns_adduser <LoginID>
#

USER="$1"

if [ "$USER"x = "x" ]; then
  echo "Usage: $0 <LoginID>"
  exit 1
fi

# -M = Don't create the user's home directory, we will do that.
useradd -M -c "$USER DJB DNS File Transfer User" "$USER"

# Create home directory.
mkdir -p /home/"$USER"
chown "$USER":"$USER" /home/"$USER"
chmod u=rx,go= /home/"$USER"

# Create .ssh directory
cd /home/"$USER"
mkdir .ssh
chown "$USER":"$USER" .ssh
chmod u=rwx,go= .ssh

# Create files in .ssh
cd .ssh
su - "$USER" -c "ssh-keygen -q" > /dev/null 2>&1 <<EOF



EOF
chmod -R a-w .

# Create JAIL directory
cd ..
mkdir JAIL
chown "$USER":"$USER" JAIL
