summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Kinard <kumba@gentoo.org>2006-01-07 19:14:28 +0000
committerJoshua Kinard <kumba@gentoo.org>2006-01-07 19:14:28 +0000
commit21dd79196da0b59c66ddb01a546177feab8aae46 (patch)
treefc7390af0294a05098377da74a6014088325cc82 /netboot
parentudev compile change from runtask to utils (diff)
downloadgenkernel-21dd79196da0b59c66ddb01a546177feab8aae46.tar.gz
genkernel-21dd79196da0b59c66ddb01a546177feab8aae46.tar.bz2
genkernel-21dd79196da0b59c66ddb01a546177feab8aae46.zip
Import the Genkernel-side of things for the catalyst2 netboot2 module
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@349 67a159dc-881f-0410-a524-ba9dfbe2cb84
Diffstat (limited to 'netboot')
-rw-r--r--netboot/linuxrc.x321
-rw-r--r--netboot/misc/bin/net-setup96
-rw-r--r--netboot/misc/etc/fstab15
-rw-r--r--netboot/misc/etc/group2
-rw-r--r--netboot/misc/etc/inittab15
-rw-r--r--netboot/misc/etc/passwd2
-rw-r--r--netboot/misc/etc/profile1
-rw-r--r--netboot/misc/etc/resolv.conf3
-rw-r--r--netboot/misc/etc/shadow2
-rw-r--r--netboot/misc/etc/shells2
-rw-r--r--netboot/misc/usr/share/terminfo/p/puttybin0 -> 1605 bytes
-rw-r--r--netboot/misc/usr/share/udhcpc/default.script31
12 files changed, 490 insertions, 0 deletions
diff --git a/netboot/linuxrc.x b/netboot/linuxrc.x
new file mode 100644
index 0000000..6508970
--- /dev/null
+++ b/netboot/linuxrc.x
@@ -0,0 +1,321 @@
+#!/bin/ash
+
+# Copyright 2001-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+
+
+#// Path, basic vars
+#//--------------------------------------------------------------------------------
+
+BasicSetup() {
+ export PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+ #// Copyright year, Build date in YYYYMMDD format, and in MMDDYYYY to make busybox 'date' happy
+ MYDATE="@@MYDATE@@"
+ CPYYEAR="$(echo ${MYDATE} | cut -c 1-4)"
+ BBDATE="$(echo ${MYDATE} | cut -c 5-8)$(echo ${MYDATE} | cut -c 1-4)"
+ DISDATE="$(echo ${MYDATE} | cut -c 7-8) $(echo ${MYDATE} | cut -c 5-6) $(echo ${MYDATE} | cut -c 1-4)"
+}
+#//--------------------------------------------------------------------------------
+
+
+
+#// Startup Tasks
+#//--------------------------------------------------------------------------------
+
+StartUp() {
+ if [ ! -f "/tmp/.startup" ]; then
+ #// Mount proc && sys
+ mount none /proc -t proc # /proc
+ mount none /sys -t sysfs # /sys
+ mount udev /dev -t tmpfs -o size=250k # /dev for udev
+
+ #// Let busybox build its applets
+ /bin/busybox --install
+
+ #// Create additional mount points
+ mkdir /dev/pts
+ mkdir /dev/shm
+ mkdir /gentoo
+ mkdir -p /mnt/cdrom
+ mkdir -p /mnt/floppy
+ mkdir /root
+ mkdir /srv
+ mkdir /tmp
+
+ #// Mount remaining filesystems
+ mount none /tmp -t tmpfs -o rw # /tmp
+ mount devpts /dev/pts -t devpts # /dev/pts
+
+ #// Create mtab
+ ln -sf /proc/mounts /etc/mtab # mtab (symlink -> /proc/mounts)
+
+ #// Udevstart segfaults if this file exists; Works for our needs fine w/o it.
+ rm -f /etc/udev/rules.d/50-udev.rules
+
+ #// Start udev
+ echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
+ /sbin/udevstart
+
+ #// udev doesn't create RAID devices or std* for us
+ mknod /dev/md0 b 9 0
+ mknod /dev/md1 b 9 1
+ mknod /dev/md2 b 9 2
+ mknod /dev/md3 b 9 3
+ mknod /dev/md4 b 9 4
+ mknod /dev/md5 b 9 5
+ mknod /dev/md6 b 9 6
+ mknod /dev/md7 b 9 7
+ mknod /dev/md8 b 9 8
+ mknod /dev/md9 b 9 9
+ ln -snf /proc/self/fd /dev/fd
+ ln -snf /proc/self/fd/0 /dev/stdin
+ ln -snf /proc/self/fd/1 /dev/stdout
+ ln -snf /proc/self/fd/2 /dev/stderr
+
+ #// /dev/random blocks, use /dev/urandom instead
+ mv /dev/random /dev/random-blocks
+ ln -sf /dev/urandom /dev/random
+
+ #// Setup dropbear (sshd)
+ echo -e ""
+ mkdir /etc/dropbear
+ echo -e ">>> Generating RSA hostkey ..."
+ dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
+ echo -e ""
+ echo -e ">>> Generating DSS hostkey ..."
+ dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
+ echo -e ""
+ dropbear
+
+ #// Misc tasks
+ chmod +x /bin/net-setup
+
+ #// Hostname
+ hostname netboot-@@RELVER@@
+ fi
+
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Informative Message (copied from Gentoo /sbin/functions.sh)
+#//--------------------------------------------------------------------------------
+
+#// show an informative message (with a newline)
+einfo() {
+ echo -e " * ${*}"
+ return 0
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Determine Mips Machine Type
+#//--------------------------------------------------------------------------------
+
+DetectMips() {
+ MYARCH="MIPS"
+ MACHINFO="$(cat /proc/cpuinfo | grep "system type" | tr -d "\t" | sed -e "s/: /:/g" | cut -d":" -f2)"
+ CPUINFO="$(cat /proc/cpuinfo | grep "cpu model" | tr -d "\t" | sed -e "s/: /:/g" | cut -d":" -f2)"
+ case "${MACHINFO}" in
+ "SGI Indy") MACHTYPE="SGI Indy" ;; # Indy R4x00/R5000
+ "SGI Indigo2")
+ case "${CPUINFO}" in
+ R4*) MACHTYPE="SGI Indigo2" ;; # I2 R4x00
+ R8*) MACHTYPE="SGI Indigo2 Power" ;; # I2 R8000
+ R10*) MACHTYPE="SGI Indigo2 Impact" ;; # I2 R10000
+ esac
+ ;;
+ "SGI O2"|"SGI IP32") MACHTYPE="SGI O2" ;; # O2 R5K/RM5K2/RM7K/R10K/R12K
+ "SGI Octane"|"SGI IP30") MACHTYPE="SGI Octane" ;; # Octane R10K/R12K/R14K
+ "SGI Origin"|"SGI IP27") MACHTYPE="SGI Origin" ;; # Origin 200/2000 R10K/R12K
+ "MIPS Cobalt"|*RaQ*|*Qube*) MACHTYPE="Cobalt Microserver" ;; # Cobalt Qube/RaQ (1/2)
+ *) MACHTYPE="Unknown MIPS" ;; # ???
+ esac
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Determine Sparc Machine Type
+#//--------------------------------------------------------------------------------
+
+DetectSparc() {
+ MYARCH="SPARC"
+ MACHINFO="$(cat /proc/cpuinfo | grep "type" | tr -d "\t" | sed -e "s/: /:/g" | cut -d":" -f2)"
+
+ case "${MACHINFO}" in
+ sun4u) MACHTYPE="Sun UltraSparc" ;; # Sparc64
+ sun4c|sun4d|sun4m) MACHTYPE="Sun Sparc32" ;; # Sparc32
+ *) MACHTYPE="Unknown SPARC" ;; # ???
+ esac
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Determine Ppc Machine Type
+#//--------------------------------------------------------------------------------
+
+DetectPpc() {
+ MACHINFO="$(cat /proc/cpuinfo | grep "machine" | tr -d "\t" | sed -e "s/: /:/g" | cut -d":" -f2)"
+
+ case "${ARCHINFO}" in
+ ppc)
+ MYARCH="PPC"
+ case "${MACHINFO}" in
+ PowerMac*) MACHTYPE="Apple PowerMac" ;; # PowerMac
+ PowerBook*) MACHTYPE="Apple PowerBook" ;; # PowerBook
+ "CHRP Pegasos") MACHTYPE="Pegasos" ;; # Pegasos
+ CHRP*|PReP) MACHTYPE="IBM PPC-Based" ;; # IBM PPC
+ Amiga) MACHTYPE="Amiga" ;; # Amiga
+ *) MACHTYPE="Unknown PPC" ;; # ???
+ esac
+ ;;
+
+ ppc64)
+ MYARCH="PPC64"
+ case "${MACHINFO}" in
+ PowerMac*) MACHTYPE="Apple G5" ;; # Apple G5
+ CHRP*|PReP) MACHTYPE="IBM PPC-Based" ;; # IBM PPC
+ *iSeries*) MACHTYPE="iSeries (Old)" ;; # Old iSeries
+ *) MACHTYPE="Unknown PPC64" ;; # ???
+ esac
+ ;;
+ esac
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Discover if the network is already running for us or not
+#//--------------------------------------------------------------------------------
+
+DetectNetwork() {
+ if [ ! -f "/tmp/.startup" ]; then
+ #// If this image is loaded via NFS Root, chances are the network is autoconfigured for us
+ if [ ! -z "$(ifconfig | grep "eth0")" ]; then
+ MYIP="$(ifconfig | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1 | head -n 1)"
+ MYGW="$(route | grep default | cut -d" " -f10)"
+ fi
+ fi
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// For those in the Church of the SubGenius...
+#//--------------------------------------------------------------------------------
+
+SubGenius() {
+ BUILDDATE="Build Date: $(date -d ${BBDATE} +"%B %d, %Y")"
+ for CMDLINE in $(cat /proc/cmdline); do
+ if [ "${CMDLINE}" = "discord" ]; then
+ BUILDDATE="$(ddate +'Built on %{%A, the %e day of %B%} in the YOLD %Y. %NCelebrate %H!' ${DISDATE})"
+ fi
+ done
+}
+#//--------------------------------------------------------------------------------
+
+
+
+#// Basic Startup Stuff
+#//--------------------------------------------------------------------------------
+
+GenMotd() {
+ echo -e "" > /etc/motd
+ echo -e "" >> /etc/motd
+ echo -e "Gentoo Linux; http://www.gentoo.org/" >> /etc/motd
+ echo -e " Copyright 2001-${CPYYEAR} Gentoo Foundation; Distributed under the GPL" >> /etc/motd
+ echo -e "" >> /etc/motd
+ echo -e " Gentoo/${MYARCH} Netboot for ${MACHTYPE} Systems" >> /etc/motd
+ echo -e " ${BUILDDATE}" >> /etc/motd
+ echo -e "" >> /etc/motd
+
+ #// If this is the initial startup, then display some messages, otherwise just execute a shell for the user
+ if [ ! -f "/tmp/.startup" ]; then
+ if [ -z "${MYIP}" ]; then
+ einfo "To configure networking (eth0), do the following:" > /etc/motd2
+ echo -e "" >> /etc/motd2
+ einfo "For Static IP:" >> /etc/motd2
+ einfo "/bin/net-setup <IP Address> <Gateway Address>" >> /etc/motd2
+ echo -e "" >> /etc/motd2
+ einfo "For Dynamic IP:" >> /etc/motd2
+ einfo "/bin/net-setup dhcp" >> /etc/motd2
+ echo -e "" >> /etc/motd2
+ else
+ echo -e "" > /etc/motd2
+ einfo "Network interface eth0 has been started:" >> /etc/motd2
+ einfo " IP Address: ${MYIP}" >> /etc/motd2
+ einfo " Gateway: ${MYGW}" >> /etc/motd2
+ echo -e "" >> /etc/motd2
+ einfo "An sshd server is available on port 22. Please set a root" >> /etc/motd2
+ einfo "password via \"passwd\" before using." >> /etc/motd2
+ echo -e "" >> /etc/motd2
+ fi
+ fi
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Display Motd
+#//--------------------------------------------------------------------------------
+
+DisplayMotd() {
+ cat /etc/motd
+ [ -f "/etc/motd2" ] && cat /etc/motd2
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Launch Shell
+#//--------------------------------------------------------------------------------
+
+LaunchShell() {
+ #// Completed Startup
+ touch /tmp/.startup
+
+ #// All Done!
+ echo -e ""
+ /bin/ash
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Main
+#//--------------------------------------------------------------------------------
+
+BasicSetup
+StartUp
+
+#// Detect Arch
+ARCHINFO="$(uname -m)"
+case "${ARCHINFO}" in
+ mips*) DetectMips ;;
+ sparc*) DetectSparc ;;
+ ppc*) DetectPpc ;;
+esac
+
+DetectNetwork
+SubGenius
+GenMotd
+DisplayMotd
+LaunchShell
+
+#//--------------------------------------------------------------------------------
+
diff --git a/netboot/misc/bin/net-setup b/netboot/misc/bin/net-setup
new file mode 100644
index 0000000..8c15386
--- /dev/null
+++ b/netboot/misc/bin/net-setup
@@ -0,0 +1,96 @@
+#!/bin/ash
+
+# Copyright 2001-2006 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+MYIP=""
+MYGW=""
+
+
+#// Modified Functions copied from Gentoo's /sbin/functions.sh
+#//--------------------------------------------------------------------------------
+
+# void einfo(char* message)
+# show an informative message (with a newline)
+einfo() {
+ echo -e " * ${*}"
+ return 0
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Setup networking
+#//--------------------------------------------------------------------------------
+
+SetupNetwork() {
+ #// DHCP or Static?
+ if [ "${1}" = "dhcp" ]; then
+ #// Do DHCP
+ udhcpc -i eth0 -q
+ else
+
+ #// Check second param
+ if [ -z "${2}" ]; then
+ echo -e ""
+ einfo "Please specify a gateway address."
+ echo -e ""
+ exit
+ fi
+
+ #// Get networking params
+ BROADCAST="$(ipcalc -b ${1} | cut -d\= -f2)"
+ NETMASK="$(ipcalc -m ${1} | cut -d\= -f2)"
+
+ #// Enable static networking
+ /sbin/ifconfig eth0 ${1} broadcast ${BROADCAST} netmask ${NETMASK}
+ /sbin/route add -net default gw ${2} netmask 0.0.0.0 metric 1
+ fi
+
+ #// Setup the loopback
+ /sbin/ifconfig lo 127.0.0.1
+ /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 gw 127.0.0.1 dev lo
+
+ #// Finish
+ MYIP="${1}"
+ MYGW="${2}"
+}
+
+#//--------------------------------------------------------------------------------
+
+
+
+#// Main Function
+#//--------------------------------------------------------------------------------
+
+#// Check first param
+if [ -z "${1}" ]; then
+ echo -e ""
+ einfo "Please specify \"dhcp\" for setting up networking via dhcp or"
+ einfo "specify an IP Address and gateway address to configure static"
+ einfo "networking."
+ echo -e ""
+ exit 0
+fi
+
+
+#// Setup the Network
+SetupNetwork ${1} ${2} ${3}
+
+
+#// Was the network setup?
+if [ ! -z "$(ifconfig | grep "eth0")" ]; then
+ echo -e ""
+ einfo "Network interface eth0 has been started:"
+ einfo " IP Address: ${MYIP}"
+ einfo " Gateway: ${MYGW}"
+ echo -e ""
+ einfo "An sshd server is available on port 22. Please set a root"
+ einfo "password via \"passwd\" before using."
+ echo -e ""
+ echo -e ""
+fi
+
+#//--------------------------------------------------------------------------------
+
diff --git a/netboot/misc/etc/fstab b/netboot/misc/etc/fstab
new file mode 100644
index 0000000..4f312cd
--- /dev/null
+++ b/netboot/misc/etc/fstab
@@ -0,0 +1,15 @@
+# Copyright 1999-2006 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+# /etc/fstab: static file system information.
+# <fs> <mountpoint> <type> <opts> <dump/pass>
+
+
+#// Main Filesystems
+none /tmp tmpfs defaults,rw 0 0
+
+
+#// Miscellaneous Filesystems
+proc /proc proc defaults 0 0
+sysfs /sys sysfs defaults 0 0
+tmpfs /dev/shm tmpfs defaults 0 0
diff --git a/netboot/misc/etc/group b/netboot/misc/etc/group
new file mode 100644
index 0000000..63d63ab
--- /dev/null
+++ b/netboot/misc/etc/group
@@ -0,0 +1,2 @@
+root:x:0:root
+nobody:x:65534:
diff --git a/netboot/misc/etc/inittab b/netboot/misc/etc/inittab
new file mode 100644
index 0000000..aee5028
--- /dev/null
+++ b/netboot/misc/etc/inittab
@@ -0,0 +1,15 @@
+# /etc/inittab init(8) configuration for BusyBox
+#
+# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
+
+
+::sysinit:/linuxrc
+::askfirst:-/bin/ash
+#tty2::askfirst:-/bin/ash
+#tty3::askfirst:-/bin/ash
+#tty4::askfirst:-/bin/ash
+::restart:/sbin/init
+::ctrlaltdel:/sbin/reboot
+::shutdown:/bin/umount -a -r
+::shutdown:/sbin/swapoff -a
+
diff --git a/netboot/misc/etc/passwd b/netboot/misc/etc/passwd
new file mode 100644
index 0000000..394abe8
--- /dev/null
+++ b/netboot/misc/etc/passwd
@@ -0,0 +1,2 @@
+root:x:0:0:root:/root:/bin/ash
+nobody:x:65534:65534:nobody:/:/bin/false
diff --git a/netboot/misc/etc/profile b/netboot/misc/etc/profile
new file mode 100644
index 0000000..8825c66
--- /dev/null
+++ b/netboot/misc/etc/profile
@@ -0,0 +1 @@
+export PATH="/usr/bin:/usr/sbin:/bin:/sbin"
diff --git a/netboot/misc/etc/resolv.conf b/netboot/misc/etc/resolv.conf
new file mode 100644
index 0000000..a3434c0
--- /dev/null
+++ b/netboot/misc/etc/resolv.conf
@@ -0,0 +1,3 @@
+nameserver 204.117.214.10
+nameserver 199.2.252.10
+nameserver 204.97.212.10
diff --git a/netboot/misc/etc/shadow b/netboot/misc/etc/shadow
new file mode 100644
index 0000000..f3d078e
--- /dev/null
+++ b/netboot/misc/etc/shadow
@@ -0,0 +1,2 @@
+root:*:10770:0:::::
+nobody:*:9797:0:::::
diff --git a/netboot/misc/etc/shells b/netboot/misc/etc/shells
new file mode 100644
index 0000000..5f7a488
--- /dev/null
+++ b/netboot/misc/etc/shells
@@ -0,0 +1,2 @@
+/bin/sh
+/bin/ash
diff --git a/netboot/misc/usr/share/terminfo/p/putty b/netboot/misc/usr/share/terminfo/p/putty
new file mode 100644
index 0000000..dd5a81a
--- /dev/null
+++ b/netboot/misc/usr/share/terminfo/p/putty
Binary files differ
diff --git a/netboot/misc/usr/share/udhcpc/default.script b/netboot/misc/usr/share/udhcpc/default.script
new file mode 100644
index 0000000..246e7b7
--- /dev/null
+++ b/netboot/misc/usr/share/udhcpc/default.script
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# udhcpc script edited by Tim Riker <Tim@Rikers.org>
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+case "$1" in
+ deconfig)
+ /sbin/ifconfig $interface 0.0.0.0
+ ;;
+
+ renew|bound)
+ /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+ if [ -n "$router" ] ; then
+ echo "deleting routers"
+ while route del default gw 0.0.0.0 dev $interface ; do
+ :
+ done
+
+ for i in $router ; do
+ route add default gw $i dev $interface
+ done
+ fi
+ ;;
+esac
+
+exit 0