#!/bin/csh
#
#	GNU-Darwin net install
#	0.0.1a3 (untested)
#	proclus (GPL)
#	Mon Oct  8 19:34:41 EDT 2001
#

# For OSX, you should be able to go directly to essential_binaries 
# after installing wget.  Just uncomment the line below and run 
# the network installer with "source gdNet-install"
# For now, you will have to download wget to a second computer,
# then scp it to your Darwin machine
# wget http://gnu-darwin.sourceforge.net/packages/wget
# chmod 755 wget
# cp wget /usr/bin
#

setenv user_name $1          # one word
goto make_user
#goto essential_binaries

# Darwin network and user setup

setenv IPnumber  ?.?.?.?
setenv Router    ?.?.?.?
setenv NameServer    ?.?.?.?
setenv your_hostname ????
setenv user_name ?????          # one word

# For Darwin, Set the variables above, and run this script.
# Install wget, then uncomment "goto essential_binaries" above

goto network

network:
ifconfig en0 $IPnumber up
route add default $Router
sshd
hostname $your_hostname
niutil -create . /locations/resolver
niutil -createprop . /locations/resolver nameserver $NameServer

make_user:
mkdir /Users/$user_name
niutil -create . /users/$user_name
niutil -createprop . /users/$user_name uid 1001
niutil -createprop . /users/$user_name gid 0
niutil -createprop . /users/$user_name shell /bin/tcsh
niutil -createprop . /users/$user_name home /Users/$user_name
echo enter password for $user_name
passwd $user_name
chown -R $user_name /Users/$user_name
chown -R .wheel /Users/$user_name
exit


#  Everything below depends on wget.

essential_binaries:
#scp love@moerbeke:/usr/bin/wget /usr/bin/
cd /usr/bin
mv tar ~
wget http://gnu-darwin.sourceforge.net/packages/tar
chmod 755 /usr/bin/tar
cd /usr/sbin/
wget http://gnu-darwin.sourceforge.net/packages/pkg_add
chmod 755 pkg_add
rehash
cd /usr/lib
# sorry for this kludge ;(
wget http://gnu-darwin.sourceforge.net/libtcl8.3.dylib


more_binaries:
cd ~;mkdir basefiles
cd basefiles/
wget http://prdownloads.sourceforge.net/gnu-darwin/pkg_install.tgz
tar -zxf pkg_install.tgz
cp pkg_install/info/pkg_info /usr/sbin/
cp pkg_install/create/pkg_create /usr/sbin/
cp pkg_install/delete/pkg_delete /usr/sbin/
cp pkg_install/info/pkg_info /usr/sbin/
cp pkg_install/*/*.1 /usr/share/man/man1/
wget http://prdownloads.sourceforge.net/gnu-darwin/md5.tgz
tar -zxf md5.tgz
cp md5/md5 /usr/local/bin/
wget http://prdownloads.sourceforge.net/gnu-darwin/libmd-0.3b.tgz
tar -zxf libmd-0.3b.tgz
cp libmd-0.3b/*.h /usr/local/include/
wget http://proclus.tripod.com/darwin/ls
chmod 755 ls
mv ls /usr/bin/

add_packages:
wget http://gnu-darwin.sourceforge.net/getPackages
mkdir packages
cd packages
source ../getPackages

make_links:
cd /usr/local/
cd share/
ln -s misc/terminfo .
cd /usr/local/
cp -rf share/* /usr/X11R6/share/
rm -rf share
ln -s /usr/X11R6/share .
cd share/
ln -s gnome ./

misc:
/usr/libexec/locate.updatedb &
exit

# Some of these edits are required to make the network settings permanent.
# See Darwinfo FAQ for more info.  http://darwinfo.org/faq.shtml#resolv
# Everything below requires some manual entry 
# Just use this as a guide

various_edits:
vi /etc/hostconfig
cd /etc/
vi hosts
vi iftab
scp $Router:/etc/hosts .
cat hosts >> /etc/hosts
vi /etc/hosts
niload hosts / < /etc/hosts
nidump hosts /

restart_nameserver:
# kill netinfod and lookupd with -HUP or just reboot
kill -HUP ? ?
nslookup
ping apple.com