#!/bin/sh
# Setup script for chroot ftpaccess 
# works with wuftp ver wu-2.6.2(2)
# System: MAC OSX 10.1.4
# 
# I had big troubles getting ls to work with chrooted guest access 
# on our servers (macosx/Darwin). Finally I figured it out and wrote
# a shell script to do the job.  
#
# Christian Albinsson 2001-2002 
# Korridor AB
# christian@korridor.se
#
# $Id: ftp_guest,v 1.3 2002/05/15 12:34:13 chrisalb Exp $

case $# in
0)
echo "Usage: $0 username"
        exit 1
;;

1)
if cd /Users/$1
 then
mkdir -p usr/lib
cp /usr/lib/dyld usr/lib
cp /usr/lib/libSystem.B.dylib usr/lib

mkdir bin
cp /bin/ls bin/ls
cp /usr/bin/gzip bin/gzip
cp /usr/bin/tar bin/tar

chown -R root.wheel usr bin
chmod -R 755 usr bin
chown root.wheel .*

echo guestuser $1 >> /etc/ftpaccess
echo $1 >> /etc/ftpchroot

niutil -createprop / /users/$1 shell /bin/sh

echo 1>&2 Ftp setup sucessfully completed for user $1
        exit 0
else
echo "No such user: $1"
        exit 1
fi
;;

*)
echo  "Usage: $0 username"
        exit 1
;;

esac


