3 # A file like this is typically copied to /usr/local/etc/rconfig/auto.sh on
4 # the rconfig server and the rconfig demon is run via 'rconfig -s -a'. When
5 # you boot the DragonFly CD you have to bring up the network, typically
6 # via 'dhclient interfacename', then run 'rconfig -a' or
7 # 'rconfig -a ip_of_server' if the server is not on the same LAN.
9 # WARNING! THIS SCRIPT WILL COMPLETELY WIPE THE DISK!
11 # $DragonFly: src/share/examples/rconfig/auto.sh,v 1.2 2008/09/03 02:22:25 dillon Exp $
15 set xdisk
= $disk$slice
17 # Refuse to do anything if the machine wasn't booted from CD
20 foreach i
( `df / | awk '{ print $1; }'` )
21 if ( $i =~ acd
* ) then
26 if ( $cdboot == 0 ) then
27 echo "Aborting auto init script, machine was not booted from CD"
31 # Wipe the disk entirely
34 echo "FDISK - ALL DATA ON THE DRIVE WILL BE LOST"
35 foreach i
( 5 4 3 2 1 )
40 dd if=/dev
/zero of
=/dev
/$disk bs
=32k count
=16
44 dd if=/dev
/zero of
=/dev
/$xdisk bs
=32k count
=16
49 disklabel
-B -r -w $xdisk auto
50 disklabel
$xdisk > /tmp
/disklabel.
$xdisk
51 cat >> /tmp
/disklabel.
$xdisk << EOF
59 disklabel
-R $xdisk /tmp
/disklabel.
$xdisk
66 newfs
-U /dev
/${xdisk}d
67 newfs
-U /dev
/${xdisk}e
68 newfs
-U /dev
/${xdisk}f
69 newfs
-U /dev
/${xdisk}g
74 mount
/dev
/${xdisk}a
/mnt
80 mount
/dev
/${xdisk}d
/mnt
/var
81 mount
/dev
/${xdisk}e
/mnt
/tmp
82 mount
/dev
/${xdisk}f
/mnt
/usr
83 mount
/dev
/${xdisk}g
/mnt
/home
90 cpdup
/etc.hdd
/mnt
/etc
99 ln -s /tmp
/mnt
/var
/tmp
101 cat >/mnt
/etc
/fstab
<< EOF
102 # Example fstab based on /README.
104 # Device Mountpoint FStype Options Dump Pass#
105 /dev/${xdisk}a / ufs rw 1 1
106 /dev/${xdisk}b none swap sw 0 0
107 /dev/${xdisk}d /var ufs rw 2 2
108 /dev/${xdisk}e /tmp ufs rw 2 2
109 /dev/${xdisk}f /usr ufs rw 2 2
110 /dev/${xdisk}g /home ufs rw 2 2
111 proc /proc procfs rw 0 0
112 # example MFS remount (for a pristine MFS filesystem do not use -C)
113 #swap /mnt mfs rw,-C,-s=4000 0 0
116 cat >/mnt
/etc
/rc.conf
<< EOF
120 sendmail_enable="NONE"
121 dumpdev="/dev/${xdisk}b"
124 if ( ! -d /mnt
/root
/.
ssh ) then
127 cat > /mnt
/root
/.ssh
/authorized_keys
<< EOF
128 # put your ssh public keys here so you can ssh into the
129 # newly configured machine
132 # Allow public-key-only access to the root account
134 sed -e 's/#PermitRootLogin no/PermitRootLogin without-password/' < /mnt
/etc
/ssh
/sshd_config
> /mnt
/etc
/ssh
/sshd_config.new
135 mv -f /mnt
/etc
/ssh
/sshd_config.new
/mnt
/etc
/ssh
/sshd_config