#!/bin/bash #Copyright 1999-2004 Jeff Dike and William #Stearns . GPL'd; see the GPL for more info. #FIXME - public key name uses (host hostname) for ssh. #FIXME - need ifconfig eth0 arp/ifconfig eth0 hw ether anymore? export OrigDir=`pwd` CleanUp () { showstate 'Cleaning up' cd $OrigDir echo In `pwd` if [ -n "$UnmountDirs" ]; then for OneDir in $UnmountDirs ; do echo Unmounting $OneDir $SUDO umount $OneDir done fi showstate '' } trap CleanUp EXIT DIST=${1:-rh-6.2} # This is the file containing the filesystem. You probably shouldn't change # it since the kernel has this name hard-wired. FSFILE=${FSFILE:-root_fs} # This is a temporary mount point which will be used to mount the new # filesystem while it's being built. MNTDIR=${MNTDIR:-mnt} # Change this if your distribution is located someplace else if [ -z "$RPMDIR" ]; then RPMDIR=/usr/src/${DIST}-source fi #This needs to be a (dist-specific) file in a writable directory. It will #be created automatically if it doesn't exit. if [ -z "$RPMPROVIDES" ]; then RPMPROVIDES=`pwd`/${DIST}-provides fi #You have three ways to specify the size of the root filesystem. The #actual size will be the largest of any you specify, or 100M if you #don't specify any. #FSMEGS: an actual size in Megs of the filesystem. #FSFREEPCT: In addition to the amount of space used, this percentage over #the used space must be free. If 100M is used by the dist and FSFREEPCT #is 15, you'll have a root filesystem of at least 115M. #FSFREEMEGS: In addition to the amount of space used, this absolute number #of megabytes must be free. Again, if 100M used by dist and FSFREEMEGS #is 30, the root filesystem will be at least 130M. #I'd suggest setting FSFREEPCT to 20 (or something between 30 and 100 if you #know you'll be adding a lot of stuff) and leaving the rest unset. #FSMEGS="100" #FSFREEPCT="15" #FSFREEMEGS="30" FSMEGS=${FSMEGS:-1000} FSFREEPCT=${FSFREEPCT:-35} #FSFREEMEGS=${FSFREEMEGS:-750} if [ -z "$RPMS" ]; then #If calling program failed to request any rpms, provide a few. RPMS=" $RPMS bdflush- dev- mount- SysVinit- net-tools- quota- findutils- tcp_wrappers- \ bind-utils- devfsd- iptables- sysklogd- vixie-cron- binutils- \ util-linux- gzip- iputils- passwd- sh-utils- fileutils- " #Base, uml-net-tools- not needed any more. RPMS=" $RPMS lynx- mc- tcpdump- strace- traceroute- less- man- info- passwd- \ diffutils- console-tools- rpm- vim-minimal- vim- vim-enhanced- telnet- netkit-ftp- \ ftp- openssh-clients- ssh- ircii- " #Client fi case $DIST in ca-2.4|ca-3.1.1|co-5.1|co-6.0|co-7.0|fc-2|im-6.2|md-7.1|md-8.0|md-8.1|md-8.2|rh-6.2|rh-7.0|rh-7.1|rh-7.2|rh-7.3|rh-skipjack|rh-9|su-7.0|tu-7) : ;; *) echo Unknown distribution $DIST . Continuing, but be advised that you echo may need to customize these scripts for your distribution. sleep 10 ;; esac #I think we have to pass on lpr. Skipping cvs/rcs, postgresql, rsh, #rsync, rwall, rwho, talks, tftp, times, uucp, yp, syslog port if [ ! -f ./functions ]; then echo Missing ./functions, exiting. >>/dev/stderr exit 1 fi . ./functions #addline() #Params: $1 File that needs the additional line, $2 line to add. #bitstomask() #broadcastof() #delline() #Params: $1 File that needs the line removed, $2 line to remove (may be a partial line). #networkof() #rpm_params() #rpm_file() #substline() #Params: $1 File that needs the additional line, $2 string to look for, $3 string with which it should be replaced. #and others... if [ `whoami` = root ]; then SUDO="" else SUDO=`which sudo` [ $? -ne 0 ] && echo \ You need to have sudo installed or you need to run this script as root && \ SUDO=`get_data "Your local copy of sudo (hit return to exit)" "" \ verify_sudo` [ "$SUDO" = "" ] && exit 1 fi RPMS=" $RPMS " if ! echo "$RPMS" | grep -q "[# /]bash-[# 1-9]" ; then echo Adding missing bash to the list. RPMS=" bash- $RPMS " fi if ! echo "$RPMS" | grep -q "[# /]glibc-[# 1-9]" ; then #Yes, I know there are distributions w/o glibc. Case later. echo Adding missing glibc to the list. RPMS=" glibc- $RPMS " fi #If an rpm is in the list twice, only keep the first. #FIXME - this strips hardcoded #'s echo RPMS before deldups: $RPMS UNIQRPMS=" " for OneRpm in $RPMS ; do if ! echo "$UNIQRPMS" | grep -q "[# ]$OneRpm[# ]" ; then UNIQRPMS=" $UNIQRPMS $OneRpm " else if [ -n "$Verbose" ]; then echo Removing duplicate $OneRpm fi fi done RPMS=" $UNIQRPMS " echo RPMS after deldups: $RPMS echo Add rpm dependencies. if [ -d rpmdeptree ]; then $SUDO rm -rf ./rpmdeptree elif [ -e rpmdeptree ]; then echo rpmdeptree exists, ugh, exiting. exit 1 fi $SUDO mkdir rpmdeptree #Warn that a kernel param/modload param needed for >4M ramdisks. #append ramdisk_size=13288 #options rd rd_size=13288 #or set in kernel configuration. #to /etc/conf.modules (yes, at boot uses "ramdisk_size" and module #uses "rd_size" -- sigh) But it does indeed work -- e.g: $SUDO umount -f rpmdeptree 2>/dev/null #$SUDO mke2fs -m0 /dev/ram0 #$SUDO mount -t ext2 /dev/ram0 rpmdeptree #Use tmpfs instead to avoid size problems entirely $SUDO mount -t tmpfs tmpfs rpmdeptree/ UnmountDirs="`pwd`/rpmdeptree $UnmountDirs" if [ "`df rpmdeptree | grep rpmdeptree | awk '{print $4}'`" -lt 13000 ]; then echo Your ramdisks are too small. Please make them larger by adding echo append = \"ramdisk_size=16384\" echo at the top of /etc/lilo.conf , rerunning \"lilo\", adding echo options rd rd_size=16384 echo to /etc/modules.conf or /etc/conf.modules, and rebooting. echo The build will continue, but it will be slower because the echo dependencies need to be checked on your physical drive. echo Press enter to continue. read JUNK $SUDO umount rpmdeptree fi cd rpmdeptree CURRENTDIR=`pwd` RPMS="`rpm_add_deps $RPMS`" cd .. if [ -d rpmdeptree ]; then $SUDO rm -rf ./rpmdeptree/* else echo rpmdeptree isn\'t a directory, ugh. exiting. exit 1 fi $SUDO umount rpmdeptree 2>/dev/null echo Finished adding dependencies NUMRPMS=0 TOTALSPACE=0 for ONERPM in `echo $RPMS | sed -e 's/#/ /g'` ; do NUMRPMS=$[ $NUMRPMS + 1 ] TOTALSPACE=$[ $TOTALSPACE + `rpm --queryformat '%{SIZE}' -qp $ONERPM` ] done echo -n There are $TOTALSPACE bytes \( TOTALSPACE=$[ $TOTALSPACE / 1024 / 1024 ] #Convert TOTALSPACE to Megabytes echo $TOTALSPACE M\) of space used by $NUMRPMS rpms. SIZES="100" if [ -n "$FSMEGS" ]; then echo FS needs to be at least $FSMEGS. SIZES="$SIZES $FSMEGS" fi if [ -n "$FSFREEPCT" ]; then echo FS needs to have at least $FSFREEPCT percent free additional free space= $[ ( $TOTALSPACE * (100 + $FSFREEPCT + 5)) / 100 ] M. SIZES="$SIZES $[ ( $TOTALSPACE * (100 + $FSFREEPCT + 5)) / 100 ]" #5% here and below accounts for root-owned space. fi if [ -n "$FSFREEMEGS" ]; then echo FS needs to have at least $FSFREEMEGS free additional free space. SIZES="$SIZES $[ ( $FSFREEMEGS * 105 ) / 100 ]" fi ACTUALFSSIZE=`max $SIZES` echo Using $ACTUALFSSIZE for the root filesystem. if [ -d $FSFILE ]; then MNTDIR=$FSFILE else MNTDIR=mnt if [ ! -b $FSFILE ]; then if [ -f $FSFILE ] || [ -f $FSFILE.old ]; then echo Moving old root filesystem out of the way... if [ -f $FSFILE.old ]; then rm -f $FSFILE.old ; fi if [ -f $FSFILE ]; then mv -f $FSFILE $FSFILE.old ; fi fi echo Creating \"$FSFILE\" as an empty file... dd if=/dev/zero of=$FSFILE bs=$((1024 * 1024)) count=0 seek=$ACTUALFSSIZE || exit 1 #Make a completely sparse file to start with; use "count=$ACTUALFSSIZE", no seek if you'd rather not. fi [ "$SUDO" != "" ] && \ echo Privileged operation - you may need to type your root password at sudo echo Making a file system in it... $SUDO mke2fs -F $FSFILE || exit 1 echo Mounting it on $MNTDIR [ ! -d $MNTDIR ] && mkdir $MNTDIR [ ! -b $FSFILE ] && LOOP="-o loop" $SUDO umount $MNTDIR >/dev/null 2>&1 || /bin/true $SUDO mount $LOOP $FSFILE $MNTDIR || exit 1 UnmountDirs="`pwd`/$MNTDIR $UnmountDirs" fi cd $MNTDIR if [ `ls -A1 $RPMDIR/*.cgz 2>/dev/null | wc -l` -gt 0 ]; then echo Opening up Base files. #Caldera's fsstnd.cgz and skeleton.cgz for ONEBASE in $RPMDIR/*.cgz ; do cat $ONEBASE | gunzip - | $SUDO cpio -idm --no-absolute-filenames done fi $SUDO mkdir -p --mode=755 dev/ || exit 1 $SUDO mkdir -p --mode=755 etc/ || exit 1 $SUDO mkdir -p --mode=555 proc/ || exit 1 $SUDO mkdir -p --mode=755 lib/ || exit 1 $SUDO mkdir -p --mode=755 usr/lib/ || exit 1 $SUDO mkdir -p --mode=700 root/ || exit 1 $SUDO mkdir -p --mode=755 sbin/ || exit 1 $SUDO mkdir -p --mode=1777 tmp/ || exit 1 $SUDO mkdir -p --mode=775 var/lib/rpm/ || exit 1 $SUDO mkdir -p --mode=755 var/log/ || exit 1 $SUDO mkdir -p --mode=755 var/lock/ || exit 1 $SUDO mkdir -p --mode=755 var/lock/subsys || exit 1 $SUDO mkdir -p --mode=755 var/run/ || exit 1 $SUDO mkdir -p --mode=1777 var/tmp/ || exit 1 $SUDO mount -t proc none proc/ UnmountDirs="`pwd`/proc $UnmountDirs" $SUDO mknod -m 666 dev/null c 1 3 #What nitwit redirects to /dev/null in the _preinstall_ script for dev-? ;-) $SUDO touch etc/fstab $SUDO chown root.root etc/fstab $SUDO chmod 644 etc/fstab case "$DIST" in ca*) addline etc/passwd "root:x:0:0:root:/root:/bin/bash" addline etc/passwd "bin:x:1:1:bin:/bin:" addline etc/passwd "daemon:x:2:2:daemon:/sbin:" addline etc/passwd "adm:x:3:4:adm:/var/adm:" addline etc/passwd "lp:x:4:7:lp:/var/spool/lpd:" addline etc/passwd "sync:x:5:0:sync:/sbin:/bin/sync" addline etc/passwd "shutdown:x:6:11:shutdown::/sbin/shutdown" addline etc/passwd "halt:x:7:0:halt:/sbin:/sbin/halt" addline etc/passwd "mail:x:8:12:mail:/var/spool/mail:" addline etc/passwd "news:x:9:13:news:/var/spool/news:" addline etc/passwd "uucp:x:10:14:uucp:/var/spool/uucp:" addline etc/passwd "operator:x:11:0:operator:/root:" addline etc/passwd "games:x:12:100:games:/usr/games:" addline etc/passwd "gopher:x:13:30:man:/usr/lib/gopher-data:" addline etc/passwd "ftp:x:14:50:FTP user:/home/ftp:" addline etc/passwd "man:x:15:15:Manuals Owner:/:" addline etc/passwd "majordom:x:16:16:Majordomo:/:/bin/false" addline etc/passwd "postgres:x:17:17:Postgres User:/home/postgres:/bin/bash" addline etc/passwd "mysql:x:18:18:MySQL User:/var/lib/mysql:/bin/false" addline etc/passwd "bind:x:19:19:BIND Server Pseudo User:/:/bin/false" addline etc/passwd "httpd:x:55:55:HTTP User:/:/bin/false" addline etc/passwd "nobody:x:65534:65534:Nobody:/:/bin/false" addline etc/passwd "col:x:100:100:Caldera OpenLinux User:/home/col:/bin/bash" addline etc/group "root::0:root" addline etc/group "bin::1:root,bin,daemon" addline etc/group "daemon::2:root,bin,daemon" addline etc/group "sys::3:root,bin,adm" addline etc/group "adm::4:root,adm,daemon" addline etc/group "tty::5:" addline etc/group "disk::6:root" addline etc/group "lp::7:daemon,lp" addline etc/group "mem::8:" addline etc/group "kmem::9:" addline etc/group "wheel::10:root" addline etc/group "operator::11:" addline etc/group "mail::12:mail" addline etc/group "news::13:news" addline etc/group "uucp::14:uucp" addline etc/group "man::15:" addline etc/group "majordom::16:" addline etc/group "database::17:" addline etc/group "mysql::18:" addline etc/group "bind::19:" addline etc/group "games::20:" addline etc/group "gopher::30:" addline etc/group "dip::40:" addline etc/group "utmp::45:" addline etc/group "ftp::50:" addline etc/group "http::55:" addline etc/group "users::100:" addline etc/group "nobody::65534:" addline etc/group "gdm::87:" addline etc/ld.so.conf "/usr/lib" addline sbin/rdev "#!/bin/sh" chmod 755 sbin/rdev #FIXME del this later ;; co-6.0|co-7.0) #Just enough to do the install. addline etc/group "daemon::2:root,bin,daemon" addline etc/group "sys::3:root,bin,adm" addline etc/group "tty::5:" addline etc/group "disk::6:root" addline etc/group "lp::7:daemon,lp" addline etc/group "kmem::9:" addline etc/group "mail::12:mail" addline etc/group "news::13:news" addline etc/group "uucp::14:uucp" addline etc/group "man::15:" addline etc/group "floppy::19:" addline etc/group "utmp:x:22:" addline etc/group "cdrom::24:" addline etc/group "audio::29:" addline etc/group "nobody::65534:" addline etc/passwd "root::0:0:root:/root:/bin/bash" addline etc/passwd "lp:*:4:7:lp:/var/spool/lpd:" ;; fc-2) addline etc/group "utmp:x:16:" addline etc/group "floppy:x:19:" addline etc/passwd "vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin" touch etc/modules.conf ;; md-8.0|md-8.1|md-8.2) addline etc/group "daemon:x:2:root,bin,daemon" addline etc/group "sys:x:3:root,bin,adm" addline etc/group "tty:x:5:" addline etc/group "disk:x:6:root" addline etc/group "lp:x:7:daemon,lp" addline etc/group "kmem:x:9:" addline etc/group "uucp:x:14:uucp" addline etc/group "cdwriter:x:80:" addline etc/group "audio:x:81:" addline etc/group "x10:x:82:" addline etc/group "utmp:x:406:" : ;; rh-7.3) addline etc/group "utmp:x:16:" touch etc/modules.conf ;; rh-9) #addline etc/group "utmp:x:16:" touch etc/modules.conf ;; esac echo Install the rpms... CURRENTDIR=`pwd` if [ -n "$Verbose" ]; then echo RPMS are: echo $RPMS echo done. fi for rpm in $RPMS ; do ShortRpm=${rpm%-*} #Drop from last dash on, i.e. the rpm build num and later ShortRpm=${ShortRpm##*/} #Drop path info echo -n $ShortRpm... #package (and distribution) specific changes before package installed case $DIST/$ShortRpm in rh-7.0/dev-*) echo addline etc/group 'floppy:x:19:' #$SUDO /usr/sbin/groupadd -g 19 -r -f floppy > /dev/null #Use this instead? ;; co-6.0/setup-*|co-7.0/setup-*|fc-2/setup-*|md-8.0/setup-*|md-8.1/setup-*|md-8.2/setup-*) $SUDO rm -f etc/group #the setup package will add the complete etc/group... $SUDO rm -f etc/passwd #...and passwd ;; esac case $ShortRpm in openssh-server-*|ssh-*|openssl-*) #Set hostname to the hostname of the uml system just long enough to set the host key comment. HostHostname=`hostname` $SUDO hostname uml #Perhaps the distribution hostname later. ;; esac #Actually install the package(s) if echo "$rpm" | grep -q '#' 2>/dev/null ; then echo -n \(2+\) $SUDO rpm -i --root $CURRENTDIR --noscripts --notriggers `rpm_file $rpm` `rpm_params $DIST $rpm` #--nodeps is set where needed by rpm_params $SUDO rpm -i --root $CURRENTDIR --replacepkgs `rpm_file $rpm` `rpm_params $DIST $rpm` #--nodeps is set where needed by rpm_params else $SUDO rpm -i --root $CURRENTDIR `rpm_file $rpm` `rpm_params $DIST $rpm` #--nodeps is set where needed by rpm_params fi #package (and distribution) specific changes after package installed case $DIST/$ShortRpm in md-7.1/msec-*|md-8.0/msec-*|md-8.1/msec-*|md-8.2/msec-*) export SECURE_LEVEL=1 #Mandrake: lie that it has been set. #$SUDO chroot . usr/sbin/msec 1 #Mandrake: 'Couldn't find used secure level, You should correct this problem by running /usr/sbin/msec' in other post scripts. ;; esac case $ShortRpm in openssh-server-*|ssh-*|openssl-*) #Reset hostname to the host hostname. $SUDO hostname $HostHostname ;; esac done echo Done! echo Copying bin/true over sbin/hwclock... $SUDO cp bin/true sbin/hwclock $SUDO cp bin/true sbin/ktzset #Caldera's timezone only setter. #Ummm, is this really necessary? Yup, until I figure out how the pam stuff works. if [ -f etc/pam.d/gdm ]; then $SUDO mv etc/pam.d/gdm tmp/gdm #Need to keep pam/gdm $SUDO rm etc/pam.d/* $SUDO mv tmp/gdm etc/pam.d/gdm else $SUDO rm etc/pam.d/* fi if [ -e lib/tls ]; then #Remove this once the UML kernel can handle the thread system call echo Disabling glibc threading support by moving lib/tls to /root/lib.tls.disabled $SUDO mv lib/tls root/lib.tls.disabled fi echo Making one line changes to configuration files.. addline etc/fstab "/dev/ubd/0 / ext2 defaults 1 1" addline etc/fstab "/proc /proc proc defaults" addline etc/fstab "devpts /dev/pts devpts mode=0622 0 0" addline etc/fstab "/dev/ubd/1 none swap sw" addline etc/hosts "127.0.0.1 localhost" case $DIST in ca*) substline etc/inittab "1:12345:respawn:/sbin/getty tty1 VC linux" "0:12345:respawn:/sbin/getty ttys/0 VC linux" substline etc/inittab "2:2345:respawn:/sbin/getty tty2 VC linux" "1:2345:respawn:/sbin/getty ttys/1 VC linux" substline etc/inittab "3:2345:respawn:/sbin/getty tty3 VC linux" "2:2345:respawn:/sbin/getty ttys/2 VC linux" substline etc/inittab "4:2345:respawn:/sbin/getty tty4 VC linux" "c:2345:respawn:/sbin/getty serial/0 VC linux" delline etc/inittab "5:2345:respawn:/sbin/getty tty5 VC linux" delline etc/inittab "6:2345:respawn:/sbin/getty tty6 VC linux" ;; *) substline etc/inittab "1:2345:respawn:/sbin/mingetty tty1" "0:2345:respawn:/sbin/mingetty ttys/0" substline etc/inittab "2:2345:respawn:/sbin/mingetty tty2" "1:2345:respawn:/sbin/mingetty ttys/1" substline etc/inittab "3:2345:respawn:/sbin/mingetty tty3" "2:2345:respawn:/sbin/mingetty ttys/2" substline etc/inittab "4:2345:respawn:/sbin/mingetty tty4" "c:2345:respawn:/sbin/mingetty serial/0" delline etc/inittab "5:2345:respawn:/sbin/mingetty tty5" delline etc/inittab "6:2345:respawn:/sbin/mingetty tty6" ;; esac #addline etc/issue "Welcome to the user-mode kernel." addline etc/issue "Unauthorized access to this system is strictly prohibited." addline etc/issue.net "Unauthorized access to this system is strictly prohibited." if [ -f etc/pam.d/ftp ]; then delline etc/pam.d/ftp "auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed" delline etc/pam.d/ftp "auth required /lib/security/pam_pwdb.so shadow nullok" delline etc/pam.d/ftp "auth required /lib/security/pam_shells.so" delline etc/pam.d/ftp "account required /lib/security/pam_pwdb.so" delline etc/pam.d/ftp "session required /lib/security/pam_pwdb.so" fi addline etc/pam.d/ftp "#%PAM-1.0" addline etc/pam.d/ftp "auth required pam_unix_auth.so" addline etc/pam.d/ftp "account required pam_unix_acct.so" addline etc/pam.d/ftp "password required pam_unix_passwd.so" addline etc/pam.d/ftp "session required pam_unix_session.so" if [ -f etc/pam.d/other ]; then delline etc/pam.d/other "auth required /lib/security/pam_deny.so" delline etc/pam.d/other "account required /lib/security/pam_deny.so" delline etc/pam.d/other "password required /lib/security/pam_deny.so" delline etc/pam.d/other "session required /lib/security/pam_deny.so" fi addline etc/pam.d/other "#%PAM-1.0" addline etc/pam.d/other "auth required pam_unix_auth.so" addline etc/pam.d/other "account required pam_unix_acct.so" addline etc/pam.d/other "password required pam_unix_passwd.so" addline etc/pam.d/other "session required pam_unix_session.so" substline etc/rc.d/rc "LOG=/dev/tty12" "LOG=/var/log/bootmessage.log" #Caldera substline etc/rc.d/rc.local "\(^[^#].*\)" "#\1" #Translation: add a # in front of all lines that don't have one. #The following two lines are not needed with the new (6/2001) networking, at least the ethertap version. #addline etc/rc.d/rc.sysinit "/sbin/ifconfig eth0 arp" #addline etc/rc.d/rc.sysinit "/sbin/um_eth_net_set eth0 100" #default addline etc/securetty "cua0" addline etc/securetty "tty0" addline etc/securetty "ttys/0" addline etc/securetty "ttys/1" addline etc/securetty "ttys/2" #The following would have been a functional fallback if the gdm.conf changes hadn't worked. #substline etc/sysconfig/desktop 'DISPLAYMANAGER=gdm' 'DISPLAYMANAGER=xdm' addline etc/sysconfig/keyboard "KEYTABLE=" addline etc/sysconfig/network "NETWORKING=yes" addline etc/sysconfig/network "FORWARD_IPV4=false" addline etc/sysconfig/network-scripts/ifcfg-eth0 "DEVICE=eth0" case $DIST in ca*) addline etc/sysconfig/network-scripts/ifcfg-eth0 "ONBOOT=yes" #Caldera requires this lowercase. ;; *) addline etc/sysconfig/network-scripts/ifcfg-eth0 "ONBOOT=YES" #FIXME - move all to lowercase when you're sure they'll take it lowercase in /sbin/ifup ;; esac for OneFile in var/log/utmp var/log/wtmp ; do if [ ! -f $OneFile ]; then touch $OneFile fi done $SUDO mkdir --parents home/httpd/html $SUDO mkdir --parents dev/ubd echo -n Making /dev/ubd/ for MINOR in `seq 0 7` ; do echo -n $MINOR... $SUDO mknod --mode=660 dev/ubd/$MINOR b 98 $MINOR $SUDO chown root.disk dev/ubd/$MINOR done echo Done! echo Adding accounts and passwords. for ONEUSER in root user guest ; do if [ "$ONEUSER" = "root" ]; then HOMEDIR="root" else HOMEDIR="home/$ONEUSER" $SUDO chroot . adduser $ONEUSER fi $SUDO mkdir $HOMEDIR/.ssh $SUDO chmod 700 $HOMEDIR/.ssh $SUDO touch $HOMEDIR/.ssh/authorized_keys $SUDO chmod 600 $HOMEDIR/.ssh/authorized_keys $SUDO touch $HOMEDIR/.Xclients $SUDO chmod 755 $HOMEDIR/.Xclients addline $HOMEDIR/.Xclients '#!/bin/bash' addline $HOMEDIR/.Xclients 'xterm &' if [ -f usr/bin/panel ]; then addline $HOMEDIR/.Xclients 'panel &' fi if [ -f usr/bin/enlightenment ]; then addline $HOMEDIR/.Xclients 'exec enlightenment' elif [ -f usr/X11R6/bin/fvwm2 ]; then addline $HOMEDIR/.Xclients 'exec fvwm' elif [ -f usr/X11R6/bin/twm ]; then addline $HOMEDIR/.Xclients 'exec twm' fi $SUDO chroot . chown $ONEUSER.$ONEUSER $HOMEDIR/.ssh $HOMEDIR/.ssh/authorized_keys $HOMEDIR/.Xclients done #How to set them manually (non-caldera; see below for caldera). #echo spleenmaster | $SUDO chroot . usr/bin/passwd --stdin root #echo corbathegreek | $SUDO chroot . usr/bin/passwd --stdin user #echo chompinatthesavoy | $SUDO chroot . usr/bin/passwd --stdin guest for ONEUSER in root user guest ; do #Tough passwords ;-), but... case $DIST in ca*) echo $ONEUSER:$ONEUSER | $SUDO chroot . usr/sbin/chpasswd ;; *) echo $ONEUSER | $SUDO chroot . usr/bin/passwd --stdin $ONEUSER ;; esac done $SUDO chroot . pwconv for ONEUSER in root user guest ; do #... make them set new ones on login. $SUDO chroot . chage -d 1 $ONEUSER ; $SUDO chroot . chage -M 180 $ONEUSER done #Make the /lib/modules/2.9.77/ directory before the depmod section so it's there when depmod needs it. #Do not make into one line; the backslash-newline at the end of the first line is needed to separate the two lines in rc.sysinit. substline etc/rc.d/rc.sysinit '\(.*\-x /sbin/depmod.*\)' 'if [ ! -d /lib/modules/`/bin/uname -r` ]; then /bin/mkdir /lib/modules/`/bin/uname -r` ; fi\ \1' if [ -f etc/rc.d/init.d/httpd ]; then addline home/httpd/html/index.html "WelcomeI thought I'd put something here!" fi if [ -f etc/rc.d/init.d/innd ]; then if [ ! -d usr/lib/news ]; then $SUDO mkdir usr/lib/news fi #$SUDO chown news.news usr/lib/news #? addline etc/services "actived 1119/udp" fi if [ -f usr/X11R6/bin/Xnest ]; then cd etc/X11 $SUDO ln -sf ../../usr/X11R6/bin/Xnest X cd ../.. fi if [ -f etc/X11/xdm ]; then substline etc/X11/xdm/Xservers ':0 local /bin/nice -n -10 /usr/X11R6/bin/X -deferglyphs 16' ':0 local /bin/nice -n -10 /usr/X11R6/bin/Xnest -display xdisplay:0 -deferglyphs 16' fi if [ -f etc/X11/gdm/gdm.conf ]; then substline etc/X11/gdm/gdm.conf '0=/usr/bin/X11/X' '0=/usr/bin/X11/Xnest -display xdisplay:0' substline etc/X11/gdm/gdm.conf 'command=/usr/bin/X11/X -deferglyphs 16' 'command=/usr/bin/X11/Xnest -display xdisplay:0 -deferglyphs 16' fi if [ -f etc/X11/prefdm ]; then substline etc/X11/prefdm 'fexit 1' 'exit 1' fi echo Set some basic networking information. The SysV init script will replace these values if called with a \"reload\" parameter. #FIXME - Macaddr no longer used case $DIST in ca-2.4) UMLIP="192.168.0.101" HOSTNAME="caldera24.goober.org" MACADDR="FE:FD:C0:A8:0:65" ;; ca-3.1.1) UMLIP="192.168.0.102" HOSTNAME="caldera311.goober.org" MACADDR="FE:FD:C0:A8:0:66" ;; co-5.1) UMLIP="192.168.0.111" HOSTNAME="connectiva51.goober.org" MACADDR="FE:FD:C0:A8:0:6F" ;; co-6.0) UMLIP="192.168.0.112" HOSTNAME="connectiva60.goober.org" MACADDR="FE:FD:C0:A8:0:70" ;; co-7.0) UMLIP="192.168.0.113" HOSTNAME="connectiva70.goober.org" MACADDR="FE:FD:C0:A8:0:71" ;; fc-2) UMLIP="192.168.0.161" HOSTNAME="fedora2.goober.org" MACADDR="FE:FD:C0:A8:0:A1" ;; im-6.2) UMLIP="192.168.0.121" HOSTNAME="immunix62.goober.org" MACADDR="FE:FD:C0:A8:0:79" ;; md-7.1) UMLIP="192.168.0.131" HOSTNAME="mandrake71.goober.org" MACADDR="FE:FD:C0:A8:0:83" ;; md-8.0) UMLIP="192.168.0.132" HOSTNAME="mandrake80.goober.org" MACADDR="FE:FD:C0:A8:0:84" ;; md-8.1) UMLIP="192.168.0.133" HOSTNAME="mandrake81.goober.org" MACADDR="FE:FD:C0:A8:0:85" ;; md-8.2) UMLIP="192.168.0.134" HOSTNAME="mandrake82.goober.org" MACADDR="FE:FD:C0:A8:0:86" ;; rh-6.2) UMLIP="192.168.0.141" HOSTNAME="redhat62.goober.org" MACADDR="FE:FD:C0:A8:0:8D" ;; rh-7.0) UMLIP="192.168.0.142" HOSTNAME="redhat70.goober.org" MACADDR="FE:FD:C0:A8:0:8E" ;; rh-7.1) UMLIP="192.168.0.143" HOSTNAME="redhat71.goober.org" MACADDR="FE:FD:C0:A8:0:8F" ;; rh-7.2) UMLIP="192.168.0.144" HOSTNAME="redhat72.goober.org" MACADDR="FE:FD:C0:A8:0:90" ;; rh-skipjack) UMLIP="192.168.0.145" HOSTNAME="redhatskipjack.goober.org" MACADDR="FE:FD:C0:A8:0:91" ;; rh-7.3) UMLIP="192.168.0.146" HOSTNAME="redhat73.goober.org" MACADDR="FE:FD:C0:A8:0:92" ;; rh-9) UMLIP="192.168.0.148" HOSTNAME="redhat9.goober.org" MACADDR="FE:FD:C0:A8:0:94" ;; tu-7) UMLIP="192.168.0.151" HOSTNAME="turbolinux7.goober.org" MACADDR="FE:FD:C0:A8:0:97" ;; *) UMLIP="192.168.0.250" HOSTNAME="uml-test.goober.org" MACADDR="FE:FD:C0:A8:0:FA" ;; esac GATEWAYIP="192.168.0.254" NETMASK="255.255.255.0" #addline etc/hosts "$UMLIP $HOSTNAME" addline etc/hosts "192.168.0.101 caldera24 caldera24.goober.org" addline etc/hosts "192.168.0.102 caldera311 caldera311.goober.org" addline etc/hosts "192.168.0.111 conectiva51 connectiva51.goober.org" addline etc/hosts "192.168.0.112 conectiva60 connectiva60.goober.org" addline etc/hosts "192.168.0.113 conectiva70 connectiva70.goober.org" addline etc/hosts "192.168.0.161 fedora2 fedora2.goober.org" addline etc/hosts "192.168.0.121 immunix62 immunix62.goober.org" addline etc/hosts "192.168.0.131 mandrake71 mandrake71.goober.org" addline etc/hosts "192.168.0.132 mandrake80 mandrake80.goober.org" addline etc/hosts "192.168.0.133 mandrake81 mandrake81.goober.org" addline etc/hosts "192.168.0.134 mandrake82 mandrake82.goober.org" addline etc/hosts "192.168.0.141 redhat62 redhat62.goober.org" addline etc/hosts "192.168.0.142 redhat70 redhat70.goober.org" addline etc/hosts "192.168.0.143 redhat71 redhat71.goober.org" addline etc/hosts "192.168.0.144 redhat72 redhat72.goober.org" addline etc/hosts "192.168.0.145 redhatskipjack redhatskipjack.goober.org" addline etc/hosts "192.168.0.146 redhat73 redhat73.goober.org" addline etc/hosts "192.168.0.148 redhat9 redhat9.goober.org" addline etc/hosts "192.168.0.151 turbolinux7 turbolinux7.goober.org" addline etc/hosts "192.168.0.250 uml-test uml-test.goober.org" addline etc/hosts "$GATEWAYIP router xdisplay" #addline etc/rc.d/rc.sysinit "/sbin/ifconfig eth0 hw ether $MACADDR" addline etc/resolv.conf "nameserver $GATEWAYIP" addline etc/sysconfig/network "HOSTNAME=$HOSTNAME" addline etc/sysconfig/network-scripts/ifcfg-eth0 "IPADDR=$UMLIP" addline etc/sysconfig/network-scripts/ifcfg-eth0 "GATEWAY=$GATEWAYIP" addline etc/sysconfig/network-scripts/ifcfg-eth0 "NETMASK=$NETMASK" addline etc/sysconfig/network-scripts/ifcfg-eth0 "NETWORK=`networkof $UMLIP $NETMASK`" addline etc/sysconfig/network-scripts/ifcfg-eth0 "BROADCAST=`broadcastof $UMLIP $NETMASK`" addline etc/sysconfig/static-routes "any host $GATEWAYIP dev eth0" addline etc/sysconfig/static-routes "any net 0.0.0.0 netmask 0.0.0.0 gw $GATEWAYIP" if [ -f etc/squid/squid.conf ]; then addline etc/squid/squid.conf "acl localnet src $GATEWAYIP" delline etc/squid/squid.conf "http_access deny all" addline etc/squid/squid.conf "http_access allow localnet" addline etc/squid/squid.conf "http_access deny all" #Order is important... addline etc/services "squid 3128/tcp" addline etc/services "squid-snmp 3401/udp" fi if [ -f etc/sendmail.cf ]; then addline etc/services "sendmail-aux 587/tcp" #SSL? fi #UML uses a different console. substline etc/rc.d/rc.sysinit ' /dev/tty0 ' ' /dev/ttys/0 ' substline etc/rc.d/init.d/keytable ' /dev/tty0' ' /dev/ttys/0' #Earlier initscripts miss a "]": substline etc/rc.d/init.d/network '${gateway##\[0-9}' '${gateway##\[0-9\]}' #Initscripts 5.39 seems to have the "${bogus}" = "gw" test wrong; I think it should be ! "${bogus}" = "gw". substline etc/rc.d/init.d/network '\[ "${bogus' '\[ ! "${bogus' echo -n "Enabling services: " for SERVICE in httpd identd inetd innd named network sendmail smb snmpd ssh sshd squid ; do if [ -f etc/rc.d/init.d/$SERVICE ]; then echo -n "$SERVICE..." if [ -f sbin/chkconfig ]; then $SUDO chroot . chkconfig $SERVICE on else echo This distribution doesn\'t have chkconfig - you\'ll have to initialize $SERVICE by hand. fi fi done echo Done! echo -n "Disabling services: " for SERVICE in kudzu portmap ; do if [ -f etc/rc.d/init.d/$SERVICE ]; then echo -n "$SERVICE..." if [ -f sbin/chkconfig ]; then $SUDO chroot . chkconfig $SERVICE off else echo This distribution doesn\'t have chkconfig - you\'ll have to turn off $SERVICE by hand. fi fi done echo Done! #Hmmm, I'll lose the US-centricity. #echo Removing other locales... #if cd usr/share/locale ; then # for ONELANG in * ; do # if [ -d "$ONELANG" ]; then # if [ "$ONELANG" != "en_US" ]; then # echo -n "$ONELANG"... # $SUDO rm -rf "$ONELANG" # fi # fi # done # echo Done! # cd ../../.. #else # echo Unable to change to usr/share/locale #fi #echo Zeroing out the rest of the filesystem... #$SUDO dd if=dev/zero of=tmp/allzeros bs=1024 2>/dev/null #$SUDO rm -f tmp/allzeros df . cd .. [ ! -d $FSFILE ] && $SUDO umount $MNTDIR || exit 1 CleanUp #echo Making sparse... #cp -pf --sparse=always $FSFILE $FSFILE.sparse #mv -f $FSFILE.sparse $FSFILE echo All set!