add minimal dnsmasq dhcp/dns server
authorHarald Hoyer <harald@redhat.com>
Mon, 18 May 2009 13:33:37 +0000 (15:33 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 18 May 2009 13:33:37 +0000 (15:33 +0200)
.gitignore
test/make-server-root [new file with mode: 0755]
test/server-init [new file with mode: 0755]

index 797ff74..a17c5ca 100644 (file)
@@ -2,4 +2,5 @@ test*.img
 modules.d/99base/switch_root
 test/initramfs.testing
 test/root.ext2
+test/server.ext2
 
diff --git a/test/make-server-root b/test/make-server-root
new file mode 100755 (executable)
index 0000000..22ab83a
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+dd if=/dev/zero of=test/server.ext2 bs=1M count=20
+mke2fs -F test/server.ext2
+mkdir test/mnt
+mount -o loop test/server.ext2 test/mnt
+
+initdir=test/mnt
+kernel=$(uname -r)
+(
+    . ./dracut-functions
+    dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
+       /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient 
+    inst "modules.d/40network/dhclient-script" "/sbin/dhclient-script"
+    inst "modules.d/40network/ifup" "/sbin/ifup"
+    dracut_install grep dnsmasq agetty strace tcpdump
+    inst test/server-init /sbin/init
+    (cd "$initdir";
+       mkdir -p dev sys proc etc var/run tmp var/lib/dnsmasq
+
+    cat > etc/hosts <<EOF 
+127.0.0.1                localhost
+192.168.1.1          server
+192.168.1.100        workstation1
+192.168.1.101        workstation2
+192.168.1.102        workstation3
+192.168.1.103        workstation4
+EOF
+    cat > etc/dnsmasq.conf <<EOF
+expand-hosts
+domain=test.net
+dhcp-range=192.168.1.100,192.168.1.150,168h
+dhcp-option=17,"192.168.1.1:/mnt/root"
+EOF
+    )
+    inst /etc/nsswitch.conf /etc/nsswitch.conf
+    inst /etc/passwd /etc/passwd
+    inst /etc/group /etc/group
+    for i in /lib*/libnss_files*;do
+       inst_library $i
+    done
+)
+targetfs="$initdir"
+unset initdir
+
+umount test/mnt
+rm -fr test/mnt
diff --git a/test/server-init b/test/server-init
new file mode 100755 (executable)
index 0000000..69ee196
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh 
+export TERM=linux
+export PS1='initramfs-test:\w\$ '
+[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
+stty sane
+echo "made it to the rootfs!"
+echo 3 >/proc/sys/vm/drop_caches
+free
+if [ -x /usr/sbin/dnsmasq ]; then
+    ifconfig eth0 192.168.1.1
+    route add -net 192.168.1.0/24 dev eth0
+    /usr/sbin/dnsmasq 
+fi
+/bin/sh -i
+mount -n -o remount,ro /
+poweroff -f
+