Update the rconfig examples. Correct a bug in auto.sh and add hammer.sh.
[dragonfly.git] / share / examples / rconfig / auto.sh
blob5507efbc8e9ff181de5d348807f790af5b55dc47
1 #!/bin/csh
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 $
13 set disk = ad0
14 set slice = s1
15 set xdisk = $disk$slice
17 # Refuse to do anything if the machine wasn't booted from CD
19 set cdboot = 0
20 foreach i ( `df / | awk '{ print $1; }'` )
21 if ( $i =~ acd* ) then
22 set cdboot = 1
23 endif
24 end
26 if ( $cdboot == 0 ) then
27 echo "Aborting auto init script, machine was not booted from CD"
28 exit 1
29 endif
31 # Wipe the disk entirely
34 echo "FDISK - ALL DATA ON THE DRIVE WILL BE LOST"
35 foreach i ( 5 4 3 2 1 )
36 echo -n " $i"
37 sleep 1
38 end
40 dd if=/dev/zero of=/dev/$disk bs=32k count=16
41 fdisk -IB $disk
42 boot0cfg -B $disk
43 boot0cfg -v $disk
44 dd if=/dev/zero of=/dev/$xdisk bs=32k count=16
46 echo "DISKLABEL"
47 sleep 1
49 disklabel -B -r -w $xdisk auto
50 disklabel $xdisk > /tmp/disklabel.$xdisk
51 cat >> /tmp/disklabel.$xdisk << EOF
52 a: 256m * 4.2BSD
53 b: 1024m * swap
54 d: 256m * 4.2BSD
55 e: 256m * 4.2BSD
56 f: 6144m * 4.2BSD
57 g: * * 4.2BSD
58 EOF
59 disklabel -R $xdisk /tmp/disklabel.$xdisk
60 disklabel $xdisk
62 echo "NEWFS"
63 sleep 1
65 newfs /dev/${xdisk}a
66 newfs -U /dev/${xdisk}d
67 newfs -U /dev/${xdisk}e
68 newfs -U /dev/${xdisk}f
69 newfs -U /dev/${xdisk}g
71 echo "MOUNT"
72 sleep 1
74 mount /dev/${xdisk}a /mnt
75 mkdir /mnt/var
76 mkdir /mnt/tmp
77 mkdir /mnt/usr
78 mkdir /mnt/home
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
85 echo "CPDUP ROOT"
86 cpdup / /mnt
87 echo "CPDUP VAR"
88 cpdup /var /mnt/var
89 echo "CPDUP ETC"
90 cpdup /etc.hdd /mnt/etc
91 echo "CPDUP DEV"
92 cpdup /dev /mnt/dev
93 echo "CPDUP USR"
94 cpdup /usr /mnt/usr
96 echo "CLEANUP"
97 chmod 1777 /mnt/tmp
98 rm -rf /mnt/var/tmp
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
117 ifconfig_em0="DHCP"
118 sshd_enable="YES"
119 usbd_enable="YES"
120 sendmail_enable="NONE"
121 dumpdev="/dev/${xdisk}b"
124 if ( ! -d /mnt/root/.ssh ) then
125 mkdir /mnt/root/.ssh
126 endif
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