x86_64/ioapic: Make sure that legacy IRQ only appears on one CPU.
[dragonfly.git] / share / examples / rconfig / auto.sh
CommitLineData
ad20c46d
MD
1#!/bin/csh
2#
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.
8#
9# WARNING! THIS SCRIPT WILL COMPLETELY WIPE THE DISK!
ad20c46d
MD
10
11set disk = ad0
12set slice = s1
13set xdisk = $disk$slice
14
15# Refuse to do anything if the machine wasn't booted from CD
16#
17set cdboot = 0
18foreach i ( `df / | awk '{ print $1; }'` )
19 if ( $i =~ acd* ) then
20 set cdboot = 1
21 endif
22end
23
24if ( $cdboot == 0 ) then
25 echo "Aborting auto init script, machine was not booted from CD"
26 exit 1
27endif
28
29# Wipe the disk entirely
30#
31
32echo "FDISK - ALL DATA ON THE DRIVE WILL BE LOST"
33foreach i ( 5 4 3 2 1 )
34 echo -n " $i"
35 sleep 1
36end
37
38dd if=/dev/zero of=/dev/$disk bs=32k count=16
39fdisk -IB $disk
40boot0cfg -B $disk
41boot0cfg -v $disk
42dd if=/dev/zero of=/dev/$xdisk bs=32k count=16
43
44echo "DISKLABEL"
45sleep 1
46
0a319615 47disklabel -B -r -w $xdisk
ad20c46d
MD
48disklabel $xdisk > /tmp/disklabel.$xdisk
49cat >> /tmp/disklabel.$xdisk << EOF
50a: 256m * 4.2BSD
51b: 1024m * swap
52d: 256m * 4.2BSD
53e: 256m * 4.2BSD
54f: 6144m * 4.2BSD
55g: * * 4.2BSD
56EOF
57disklabel -R $xdisk /tmp/disklabel.$xdisk
58disklabel $xdisk
59
60echo "NEWFS"
61sleep 1
62
63newfs /dev/${xdisk}a
64newfs -U /dev/${xdisk}d
65newfs -U /dev/${xdisk}e
66newfs -U /dev/${xdisk}f
67newfs -U /dev/${xdisk}g
68
69echo "MOUNT"
70sleep 1
71
72mount /dev/${xdisk}a /mnt
73mkdir /mnt/var
74mkdir /mnt/tmp
75mkdir /mnt/usr
76mkdir /mnt/home
77
78mount /dev/${xdisk}d /mnt/var
79mount /dev/${xdisk}e /mnt/tmp
80mount /dev/${xdisk}f /mnt/usr
81mount /dev/${xdisk}g /mnt/home
82
83echo "CPDUP ROOT"
84cpdup / /mnt
85echo "CPDUP VAR"
86cpdup /var /mnt/var
87echo "CPDUP ETC"
62421adc 88cpdup /etc.hdd /mnt/etc
ad20c46d
MD
89echo "CPDUP DEV"
90cpdup /dev /mnt/dev
91echo "CPDUP USR"
92cpdup /usr /mnt/usr
93
94echo "CLEANUP"
95chmod 1777 /mnt/tmp
96rm -rf /mnt/var/tmp
97ln -s /tmp /mnt/var/tmp
98
99cat >/mnt/etc/fstab << EOF
100# Example fstab based on /README.
101#
102# Device Mountpoint FStype Options Dump Pass#
103/dev/${xdisk}a / ufs rw 1 1
104/dev/${xdisk}b none swap sw 0 0
105/dev/${xdisk}d /var ufs rw 2 2
106/dev/${xdisk}e /tmp ufs rw 2 2
107/dev/${xdisk}f /usr ufs rw 2 2
108/dev/${xdisk}g /home ufs rw 2 2
109proc /proc procfs rw 0 0
110# example MFS remount (for a pristine MFS filesystem do not use -C)
111#swap /mnt mfs rw,-C,-s=4000 0 0
112EOF
113
114cat >/mnt/etc/rc.conf << EOF
115ifconfig_em0="DHCP"
116sshd_enable="YES"
ad20c46d
MD
117sendmail_enable="NONE"
118dumpdev="/dev/${xdisk}b"
119EOF
120
121if ( ! -d /mnt/root/.ssh ) then
122 mkdir /mnt/root/.ssh
123endif
124cat > /mnt/root/.ssh/authorized_keys << EOF
125# put your ssh public keys here so you can ssh into the
126# newly configured machine
127EOF
128
129# Allow public-key-only access to the root account
130#
131sed -e 's/#PermitRootLogin no/PermitRootLogin without-password/' < /mnt/etc/ssh/sshd_config > /mnt/etc/ssh/sshd_config.new
132mv -f /mnt/etc/ssh/sshd_config.new /mnt/etc/ssh/sshd_config
133