Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Feb 1997 14:06:02 -0800
From:      Mitch James <mitch@hardware.com>
To:        freebsd-doc@FreeBSD.ORG
Subject:   Problem executing script from handbook129.html
Message-ID:  <32F50FCA.1450@hardware.com>

next in thread | raw e-mail | index | archive | help
Hi All,
I was getting ready upgrade from 2.1.5 to 2.1.6 and was trying 
to take prudent steps in preperation.  I was trying to use a sh 
script from the handbook for disaster recovery.
http://www.freebsd.org/handbook/handbook129.html

I mailed the html page to myself and exported it from pine. I 
edited the file in pine to remove the html and directions from
the file, both before and after the shell script.  I renamed the 
file and ran it as root. ./disaster.floppy.  Here is the error 
message I received.

mitchj: {5} ./disaster.floppy
/dev/rfd0a:     2880 sectors in 80 cylinders of 2 tracks, 18 sectors
        1.4MB in 2 cyl groups (40 c/g, 0.70MB/g, 160 i/g)
super-block backups (for fsck -b #) at:
 32, 1496,
./disaster.floppy: 47: Syntax error: "&" unexpected
mitchj: {6} whoami
root

Have I done something wrong or do I need to change something? I'd like
to be 
able to use this.  :-) TIA
Cheers,
Mitch

Shell script:

 #!/bin/sh
 #
 # create a restore floppy
 #
 # format the floppy
 #
 PATH=/bin:/sbin:/usr/sbin:/usr/bin

 fdformat -q fd0
 if [ $? -ne 0 ]
 then
         echo "Bad floppy, please use a new one"
         exit 1
 fi

 # place boot blocks on the floppy
 #
 disklabel -w -B -b /usr/mdec/fdboot -s /usr/mdec/bootfd /dev/rfd0c
fd1440

 #
 # newfs the one and only partition
 #
 newfs -t 2 -u 18 -l 1 -c 40 -i 5120 -m 5 -o space /dev/rfd0a

 #
 # mount the new floppy
 #
 mount /dev/fd0a /mnt

 #
 # create required directories
 #
 mkdir /mnt/dev
 mkdir /mnt/bin
 mkdir /mnt/sbin
 mkdir /mnt/etc
 mkdir /mnt/root
 mkdir /mnt/mnt                 # for the root partition
 mkdir /mnt/tmp
 mkdir /mnt/var

 #
 # populate the directories
 #
 if [ ! -x /sys/compile/MINI/kernel ]
 then
         cat &lt;&lt; EOM
 The MINI kernel does not exist, please create one.
 Here is an example config file:
 #
 # MINI -- A kernel to get FreeBSD on onto a disk.
 #
 machine                "i386"
cpu            "I486_CPU"
 ident          MINI
 maxusers       5

 options                INET                    # needed for _tcp
_icmpstat _ip$
                                         #            _udpstat _tcpstat
_udb
 options                FFS                     #Berkeley Fast File
System
 options                FAT_CURSOR              #block cursor in syscons
or pcc$
 options                SCSI_DELAY=15           #Be pessimistic about
Joe SCSI $
 options                NCONS=2         #1 virtual consoles
 options                USERCONFIG              #Allow user
configuration with $

 config         kernel  root on sd0 swap on sd0 and sd1 dumps on sd0

 controller     isa0
 controller     pci0
controller     fdc0    at isa? port "IO_FD1" bio irq 6 drq 2 vector
fdintr
 disk           fd0     at fdc0 drive 0

 controller     ncr0

 controller     scbus0

 device         sc0     at isa? port "IO_KBD" tty irq 1 vector scintr
 device         npx0    at isa? port "IO_NPX" irq 13 vector npxintr

 device         sd0
 device         sd1
 device         sd2

 device         st0

 pseudo-device  loop            # required by INET 
 pseudo-device  gzip            # Exec gzipped a.out's
 EOM
         exit 1
 fi

 cp -f /sys/compile/MINI/kernel /mnt

 gzip -c -best /sbin/init &gt; /mnt/sbin/init
 gzip -c -best /sbin/fsck &gt; /mnt/sbin/fsck
 gzip -c -best /sbin/mount &gt; /mnt/sbin/mount
 gzip -c -best /sbin/halt &gt; /mnt/sbin/halt
 gzip -c -best /sbin/restore &gt; /mnt/sbin/restore

 gzip -c -best /bin/sh &gt; /mnt/bin/sh
 gzip -c -best /bin/sync &gt; /mnt/bin/sync

 cp /root/.profile /mnt/root
 pseudo-device  gzip            # Exec gzipped a.out's
 EOM
         exit 1
 fi

 cp -f /sys/compile/MINI/kernel /mnt

 gzip -c -best /sbin/init &gt; /mnt/sbin/init
 gzip -c -best /sbin/fsck &gt; /mnt/sbin/fsck
 gzip -c -best /sbin/mount &gt; /mnt/sbin/mount
 gzip -c -best /sbin/halt &gt; /mnt/sbin/halt
 gzip -c -best /sbin/restore &gt; /mnt/sbin/restore

 gzip -c -best /bin/sh &gt; /mnt/bin/sh
 gzip -c -best /bin/sync &gt; /mnt/bin/sync

 cp /root/.profile /mnt/root
 ./MAKEDEV st0
 ./MAKEDEV pty0
 cd /

 #
 # create minimum filesystem table
 #
 cat &gt; /mnt/etc/fstab &lt;&lt;EOM
 /dev/fd0a      /       ufs     rw 1 1
 EOM

 #
 # create minimum passwd file
 #
 cat &gt; /mnt/etc/passwd &lt;&lt;EOM
 root:*:0:0:Charlie &amp;:/root:/bin/sh
 EOM 

 cat &gt; /mnt/etc/master.passwd &lt;&lt;EOM
 root::0:0::0:0:Charlie &amp;:/root:/bin/sh
 EOM

 chmod 600 /mnt/etc/master.passwd
 chmod 644 /mnt/etc/passwd
 /usr/sbin/pwd_mkdb -d/mnt/etc /mnt/etc/master.passwd

 #
 # umount the floppy and inform the user
 #
 /sbin/umount /mnt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32F50FCA.1450>