#!/bin/sh
# Install the .rc files for the sample desktop.
#
S=/usr/share/skel/examples/cfbsd/scripts
while [ 1 ]; do
  echo Enter the name of a user to install the desktop configuration files.
  echo Press \'Enter\' to stop
  echo -n "User ID: "
  read user
  if [ "$user" = "" ]; then
    exit
  fi 
  grep ^$user: /etc/passwd 2>/dev/null >/dev/null
  if [ $? -ne 0 ]; then
    echo "Can't find user " $user
  else
    dir=`grep $user /etc/passwd | head -n1 | awk -F : '{print $6}'`
    mkdir -p $dir
    group=`grep $user /etc/passwd | head -n1 | awk -F : '{print $4}'`
    echo cp -p $S/.xinitrc $S/.fvwm2rc $dir
    cp -p $S/.xinitrc $S/.fvwm2rc $dir
    echo chown $user.$group $dir/.xinitrc $dir/.fvwm2rc
    chown $user.$group $dir/.xinitrc $dir/.fvwm2rc
  fi
done
