From 73b16af8feec390afbabd9356d6e5e83c0390838 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Fri, 15 May 2015 10:20:47 +0200 Subject: busybox: imported from http://www.busybox.net/downloads/busybox-1.13.3.tar.bz2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- examples/bootfloppy/bootfloppy.txt | 180 +++++++++++++++++++++++ examples/bootfloppy/display.txt | 4 + examples/bootfloppy/etc/fstab | 2 + examples/bootfloppy/etc/init.d/rcS | 3 + examples/bootfloppy/etc/inittab | 5 + examples/bootfloppy/etc/profile | 8 + examples/bootfloppy/mkdevs.sh | 62 ++++++++ examples/bootfloppy/mkrootfs.sh | 105 +++++++++++++ examples/bootfloppy/mksyslinux.sh | 48 ++++++ examples/bootfloppy/quickstart.txt | 15 ++ examples/bootfloppy/syslinux.cfg | 7 + examples/busybox.spec | 44 ++++++ examples/depmod | 57 ++++++++ examples/depmod.pl | 292 +++++++++++++++++++++++++++++++++++++ examples/devfsd.conf | 133 +++++++++++++++++ examples/dnsd.conf | 1 + examples/inetd.conf | 73 ++++++++++ examples/inittab | 90 ++++++++++++ examples/mk2knr.pl | 84 +++++++++++ examples/udhcp/sample.bound | 31 ++++ examples/udhcp/sample.deconfig | 4 + examples/udhcp/sample.nak | 4 + examples/udhcp/sample.renew | 31 ++++ examples/udhcp/sample.script | 7 + examples/udhcp/simple.script | 40 +++++ examples/udhcp/udhcpd.conf | 123 ++++++++++++++++ examples/undeb | 53 +++++++ examples/unrpm | 48 ++++++ examples/zcip.script | 38 +++++ 29 files changed, 1592 insertions(+) create mode 100644 examples/bootfloppy/bootfloppy.txt create mode 100644 examples/bootfloppy/display.txt create mode 100644 examples/bootfloppy/etc/fstab create mode 100755 examples/bootfloppy/etc/init.d/rcS create mode 100644 examples/bootfloppy/etc/inittab create mode 100644 examples/bootfloppy/etc/profile create mode 100755 examples/bootfloppy/mkdevs.sh create mode 100755 examples/bootfloppy/mkrootfs.sh create mode 100755 examples/bootfloppy/mksyslinux.sh create mode 100644 examples/bootfloppy/quickstart.txt create mode 100644 examples/bootfloppy/syslinux.cfg create mode 100644 examples/busybox.spec create mode 100644 examples/depmod create mode 100755 examples/depmod.pl create mode 100644 examples/devfsd.conf create mode 100644 examples/dnsd.conf create mode 100644 examples/inetd.conf create mode 100644 examples/inittab create mode 100755 examples/mk2knr.pl create mode 100755 examples/udhcp/sample.bound create mode 100755 examples/udhcp/sample.deconfig create mode 100755 examples/udhcp/sample.nak create mode 100755 examples/udhcp/sample.renew create mode 100644 examples/udhcp/sample.script create mode 100644 examples/udhcp/simple.script create mode 100644 examples/udhcp/udhcpd.conf create mode 100644 examples/undeb create mode 100644 examples/unrpm create mode 100644 examples/zcip.script (limited to 'examples') diff --git a/examples/bootfloppy/bootfloppy.txt b/examples/bootfloppy/bootfloppy.txt new file mode 100644 index 0000000..9e2cbe2 --- /dev/null +++ b/examples/bootfloppy/bootfloppy.txt @@ -0,0 +1,180 @@ +Building a Busybox Boot Floppy +============================== + +This document describes how to buid a boot floppy using the following +components: + + - Linux Kernel (http://www.kernel.org) + - uClibc: C library (http://www.uclibc.org/) + - Busybox: Unix utilities (http://busybox.net/) + - Syslinux: bootloader (http://syslinux.zytor.com) + +It is based heavily on a paper presented by Erik Andersen at the 2001 Embedded +Systems Conference. + + + +Building The Software Components +-------------------------------- + +Detailed instructions on how to build Busybox, uClibc, or a working Linux +kernel are beyond the scope of this document. The following guidelines will +help though: + + - Stock Busybox from CVS or a tarball will work with no modifications to + any files. Just extract and go. + - Ditto uClibc. + - Your Linux kernel must include support for initrd or else the floppy + won't be able to mount it's root file system. + +If you require further information on building Busybox uClibc or Linux, please +refer to the web pages and documentation for those individual programs. + + + +Making a Root File System +------------------------- + +The following steps will create a root file system. + + - Create an empty file that you can format as a filesystem: + + dd if=/dev/zero of=rootfs bs=1k count=4000 + + - Set up the rootfs file we just created to be used as a loop device (may not + be necessary) + + losetup /dev/loop0 rootfs + + - Format the rootfs file with a filesystem: + + mkfs.ext2 -F -i 2000 rootfs + + - Mount the file on a mountpoint so we can place files in it: + + mkdir loop + mount -o loop rootfs loop/ + + (you will probably need to be root to do this) + + - Copy on the C library, the dynamic linking library, and other necessary + libraries. For this example, we copy the following files from the uClibc + tree: + + mkdir loop/lib + (chdir to uClibc directory) + cp -a libc.so* uClibc*.so \ + ld.so-1/d-link/ld-linux-uclibc.so* \ + ld.so-1/libdl/libdl.so* \ + crypt/libcrypt.so* \ + (path to)loop/lib + + - Install the Busybox binary and accompanying symlinks: + + (chdir to busybox directory) + make CONFIG_PREFIX=(path to)loop/ install + + - Make device files in /dev: + + This can be done by running the 'mkdevs.sh' script. If you want the gory + details, you can read the script. + + - Make necessary files in /etc: + + For this, just cp -a the etc/ directory onto rootfs. Again, if you want + all the details, you can just look at the files in the dir. + + - Unmount the rootfs from the mountpoint: + + umount loop + + - Compress it: + + gzip -9 rootfs + + +Making a SYSLINUX boot floppy +----------------------------- + +The following steps will create the boot floppy. + +Note: You will need to have the mtools package installed beforehand. + + - Insert a floppy in the drive and format it with an MSDOS filesystem: + + mformat a: + + (if the system doesn't know what device 'a:' is, look at /etc/mtools.conf) + + - Run syslinux on the floppy: + + syslinux -s /dev/fd0 + + (the -s stands for "safe, slow, and stupid" and should work better with + buggy BIOSes; it can be omitted) + + - Put on a syslinux.cfg file: + + mcopy syslinux.cfg a: + + (more on syslinux.cfg below) + + - Copy the root file system you made onto the MSDOS formatted floppy + + mcopy rootfs.gz a: + + - Build a linux kernel and copy it onto the disk with the filename 'linux' + + mcopy bzImage a:linux + + +Sample syslinux.cfg +~~~~~~~~~~~~~~~~~~~ + +The following simple syslinux.cfg file should work. You can tweak it if you +like. + +----begin-syslinux.cfg--------------- +DEFAULT linux +APPEND initrd=rootfs.gz root=/dev/ram0 +TIMEOUT 10 +PROMPT 1 +----end-syslinux.cfg--------------- + +Some changes you could make to syslinux.cfg: + + - This value is the number seconds it will wait before booting. You can set + the timeout to 0 (or omit) to boot instantly, or you can set it as high as + 10 to wait awhile. + + - PROMPT can be set to 0 to disable the 'boot:' prompt. + + - you can add this line to display the contents of a file as a welcome + message: + + DISPLAY display.txt + + + +Additional Resources +-------------------- + +Other useful information on making a Linux bootfloppy is available at the +following URLs: + +http://www.linuxdoc.org/HOWTO/Bootdisk-HOWTO/index.html +http://www.linux-embedded.com/howto/Embedded-Linux-Howto.html +http://linux-embedded.org/howto/LFS-HOWTO.html +http://linux-embedded.org/pmhowto.html +http://recycle.lbl.gov/~ldoolitt/embedded/ (Larry Doolittle's stuff) + + + +Possible TODOs +-------------- + +The following features that we might want to add later: + + - support for additional filesystems besides ext2, i.e. minix + - different libc, static vs dynamic loading + - maybe using an alternate bootloader diff --git a/examples/bootfloppy/display.txt b/examples/bootfloppy/display.txt new file mode 100644 index 0000000..399d326 --- /dev/null +++ b/examples/bootfloppy/display.txt @@ -0,0 +1,4 @@ + +This boot floppy is made with Busybox, uClibc, and the Linux kernel. +Hit RETURN to boot or enter boot parameters at the prompt below. + diff --git a/examples/bootfloppy/etc/fstab b/examples/bootfloppy/etc/fstab new file mode 100644 index 0000000..ef14ca2 --- /dev/null +++ b/examples/bootfloppy/etc/fstab @@ -0,0 +1,2 @@ +proc /proc proc defaults 0 0 + diff --git a/examples/bootfloppy/etc/init.d/rcS b/examples/bootfloppy/etc/init.d/rcS new file mode 100755 index 0000000..4f29b92 --- /dev/null +++ b/examples/bootfloppy/etc/init.d/rcS @@ -0,0 +1,3 @@ +#! /bin/sh + +/bin/mount -a diff --git a/examples/bootfloppy/etc/inittab b/examples/bootfloppy/etc/inittab new file mode 100644 index 0000000..eb3e979 --- /dev/null +++ b/examples/bootfloppy/etc/inittab @@ -0,0 +1,5 @@ +::sysinit:/etc/init.d/rcS +::respawn:-/bin/sh +tty2::askfirst:-/bin/sh +::ctrlaltdel:/bin/umount -a -r + diff --git a/examples/bootfloppy/etc/profile b/examples/bootfloppy/etc/profile new file mode 100644 index 0000000..8a7c77d --- /dev/null +++ b/examples/bootfloppy/etc/profile @@ -0,0 +1,8 @@ +# /etc/profile: system-wide .profile file for the Bourne shells + +echo +echo -n "Processing /etc/profile... " +# no-op +echo "Done" +echo + diff --git a/examples/bootfloppy/mkdevs.sh b/examples/bootfloppy/mkdevs.sh new file mode 100755 index 0000000..8e9512f --- /dev/null +++ b/examples/bootfloppy/mkdevs.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# +# makedev.sh - creates device files for a busybox boot floppy image + + +# we do our work in the dev/ directory +if [ -z "$1" ]; then + echo "usage: `basename $0` path/to/dev/dir" + exit 1 +fi + +cd $1 + + +# miscellaneous one-of-a-kind stuff +mknod console c 5 1 +mknod full c 1 7 +mknod kmem c 1 2 +mknod mem c 1 1 +mknod null c 1 3 +mknod port c 1 4 +mknod random c 1 8 +mknod urandom c 1 9 +mknod zero c 1 5 +ln -s /proc/kcore core + +# IDE HD devs +# note: not going to bother creating all concievable partitions; you can do +# that yourself as you need 'em. +mknod hda b 3 0 +mknod hdb b 3 64 +mknod hdc b 22 0 +mknod hdd b 22 64 + +# loop devs +for i in `seq 0 7`; do + mknod loop$i b 7 $i +done + +# ram devs +for i in `seq 0 9`; do + mknod ram$i b 1 $i +done +ln -s ram1 ram + +# ttys +mknod tty c 5 0 +for i in `seq 0 9`; do + mknod tty$i c 4 $i +done + +# virtual console screen devs +for i in `seq 0 9`; do + mknod vcs$i b 7 $i +done +ln -s vcs0 vcs + +# virtual console screen w/ attributes devs +for i in `seq 0 9`; do + mknod vcsa$i b 7 $((128 + i)) +done +ln -s vcsa0 vcsa diff --git a/examples/bootfloppy/mkrootfs.sh b/examples/bootfloppy/mkrootfs.sh new file mode 100755 index 0000000..5cdff21 --- /dev/null +++ b/examples/bootfloppy/mkrootfs.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# +# mkrootfs.sh - creates a root file system +# + +# TODO: need to add checks here to verify that busybox, uClibc and bzImage +# exist + + +# command-line settable variables +BUSYBOX_DIR=.. +UCLIBC_DIR=../../uClibc +TARGET_DIR=./loop +FSSIZE=4000 +CLEANUP=1 +MKFS='mkfs.ext2 -F' + +# don't-touch variables +BASE_DIR=`pwd` + + +while getopts 'b:u:s:t:Cm' opt +do + case $opt in + b) BUSYBOX_DIR=$OPTARG ;; + u) UCLIBC_DIR=$OPTARG ;; + t) TARGET_DIR=$OPTARG ;; + s) FSSIZE=$OPTARG ;; + C) CLEANUP=0 ;; + m) MKFS='mkfs.minix' ;; + *) + echo "usage: `basename $0` [-bu]" + echo " -b DIR path to busybox direcory (default ..)" + echo " -u DIR path to uClibc direcory (default ../../uClibc)" + echo " -t DIR path to target direcory (default ./loop)" + echo " -s SIZE size of root filesystem in Kbytes (default 4000)" + echo " -C don't perform cleanup (umount target dir, gzip rootfs, etc.)" + echo " (this allows you to 'chroot loop/ /bin/sh' to test it)" + echo " -m use minix filesystem (default is ext2)" + exit 1 + ;; + esac +done + + + + +# clean up from any previous work +mount | grep -q loop +[ $? -eq 0 ] && umount $TARGET_DIR +[ -d $TARGET_DIR ] && rm -rf $TARGET_DIR/ +[ -f rootfs ] && rm -f rootfs +[ -f rootfs.gz ] && rm -f rootfs.gz + + +# prepare root file system and mount as loopback +dd if=/dev/zero of=rootfs bs=1k count=$FSSIZE +$MKFS -i 2000 rootfs +mkdir $TARGET_DIR +mount -o loop,exec rootfs $TARGET_DIR # must be root + + +# install uClibc +mkdir -p $TARGET_DIR/lib +cd $UCLIBC_DIR +make INSTALL_DIR= +cp -a libc.so* $BASE_DIR/$TARGET_DIR/lib +cp -a uClibc*.so $BASE_DIR/$TARGET_DIR/lib +cp -a ld.so-1/d-link/ld-linux-uclibc.so* $BASE_DIR/$TARGET_DIR/lib +cp -a ld.so-1/libdl/libdl.so* $BASE_DIR/$TARGET_DIR/lib +cp -a crypt/libcrypt.so* $BASE_DIR/$TARGET_DIR/lib +cd $BASE_DIR + + +# install busybox and components +cd $BUSYBOX_DIR +make distclean +make CC=$BASE_DIR/$UCLIBC_DIR/extra/gcc-uClibc/i386-uclibc-gcc +make CONFIG_PREFIX=$BASE_DIR/$TARGET_DIR install +cd $BASE_DIR + + +# make files in /dev +mkdir $TARGET_DIR/dev +./mkdevs.sh $TARGET_DIR/dev + + +# make files in /etc +cp -a etc $TARGET_DIR +ln -s /proc/mounts $TARGET_DIR/etc/mtab + + +# other miscellaneous setup +mkdir $TARGET_DIR/initrd +mkdir $TARGET_DIR/proc + + +# Done. Maybe do cleanup. +if [ $CLEANUP -eq 1 ] +then + umount $TARGET_DIR + rmdir $TARGET_DIR + gzip -9 rootfs +fi + diff --git a/examples/bootfloppy/mksyslinux.sh b/examples/bootfloppy/mksyslinux.sh new file mode 100755 index 0000000..e254173 --- /dev/null +++ b/examples/bootfloppy/mksyslinux.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Formats a floppy to use Syslinux + +dummy="" + + +# need to have mtools installed +if [ -z `which mformat` -o -z `which mcopy` ]; then + echo "You must have the mtools package installed to run this script" + exit 1 +fi + + +# need an arg for the location of the kernel +if [ -z "$1" ]; then + echo "usage: `basename $0` path/to/linux/kernel" + exit 1 +fi + + +# need to have a root file system built +if [ ! -f rootfs.gz ]; then + echo "You need to have a rootfs built first." + echo "Hit RETURN to make one now or Control-C to quit." + read dummy + ./mkrootfs.sh +fi + + +# prepare the floppy +echo "Please insert a blank floppy in the drive and press RETURN to format" +echo "(WARNING: All data will be erased! Hit Control-C to abort)" +read dummy + +echo "Formatting the floppy..." +mformat a: +echo "Making it bootable with Syslinux..." +syslinux -s /dev/fd0 +echo "Copying Syslinux configuration files..." +mcopy syslinux.cfg display.txt a: +echo "Copying root filesystem file..." +mcopy rootfs.gz a: +# XXX: maybe check for "no space on device" errors here +echo "Copying linux kernel..." +mcopy $1 a:linux +# XXX: maybe check for "no space on device" errors here too +echo "Finished: boot floppy created" diff --git a/examples/bootfloppy/quickstart.txt b/examples/bootfloppy/quickstart.txt new file mode 100644 index 0000000..0d80908 --- /dev/null +++ b/examples/bootfloppy/quickstart.txt @@ -0,0 +1,15 @@ +Quickstart on making the Busybox boot-floppy: + + 1) Download Busybox and uClibc from CVS or tarballs. Make sure they share a + common parent directory. (i.e. busybox/ and uclibc/ are both right off of + /tmp, or wherever.) + + 2) Build a Linux kernel. Make sure you include support for initrd. + + 3) Put a floppy in the drive. Make sure it is a floppy you don't care about + because the contents will be overwritten. + + 4) As root, type ./mksyslinux.sh path/to/linux/kernel from this directory. + Wait patiently while the magic happens. + + 5) Boot up on the floppy. diff --git a/examples/bootfloppy/syslinux.cfg b/examples/bootfloppy/syslinux.cfg new file mode 100644 index 0000000..fa2677c --- /dev/null +++ b/examples/bootfloppy/syslinux.cfg @@ -0,0 +1,7 @@ +display display.txt +default linux +timeout 10 +prompt 1 +label linux + kernel linux + append initrd=rootfs.gz root=/dev/ram0 diff --git a/examples/busybox.spec b/examples/busybox.spec new file mode 100644 index 0000000..494eed9 --- /dev/null +++ b/examples/busybox.spec @@ -0,0 +1,44 @@ +%define name busybox +%define epoch 0 +%define version 0.61.pre +%define release %(date -I | sed -e 's/-/_/g') +%define serial 1 + +Name: %{name} +#Epoch: %{epoch} +Version: %{version} +Release: %{release} +Serial: %{serial} +Copyright: GPL +Group: System/Utilities +Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. +URL: http://busybox.net/ +Source: ftp://busybox.net/busybox/%{name}-%{version}.tar.gz +Buildroot: /var/tmp/%{name}-%{version} +Packager : Erik Andersen + +%Description +BusyBox combines tiny versions of many common UNIX utilities into a single +small executable. It provides minimalist replacements for most of the utilities +you usually find in fileutils, shellutils, findutils, textutils, grep, gzip, +tar, etc. BusyBox provides a fairly complete POSIX environment for any small +or emdedded system. The utilities in BusyBox generally have fewer options then +their full featured GNU cousins; however, the options that are provided behave +very much like their GNU counterparts. + +%Prep +%setup -q -n %{name}-%{version} + +%Build +make + +%Install +rm -rf $RPM_BUILD_ROOT +make CONFIG_PREFIX=$RPM_BUILD_ROOT install + +%Clean +rm -rf $RPM_BUILD_ROOT + +%Files +%defattr(-,root,root) +/ diff --git a/examples/depmod b/examples/depmod new file mode 100644 index 0000000..d8c4cc5 --- /dev/null +++ b/examples/depmod @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Simple depmod, use to generate modprobe.conf +# +# Copyright (C) 2008 by Vladimir Dronnikov +# +# Licensed under GPLv2 +# + +local BASE="${1:-/usr/lib/modules}" + +find "$BASE" -name '*.ko.gz' | while read I ; do + N=`basename "$I" '.ko.gz'` + echo -n "@$N" + zcat "$I" | strings | grep '^depends=' | sed -e 's/^depends=$//' -e 's/^depends=/,/' -e 's/,/ @/g' +done | awk ' +{ + # modules which has no dependencies are resolved + if ( NF == 1 ) { res[$1] = ""; next } + # others have to be resolved based on those which already resolved + i = $1; $1 = ""; deps[i] = $0; ++ndeps +} +END { + # resolve implicit dependencies + while ( ndeps ) for (mod in deps) { + if ( index(deps[mod], "@") > 0 ) { + $0 = deps[mod] + for ( i=1; i<=NF; ++i ) { + if ( substr($i,1,1) == "@" ) { + if ( $i in res ) { + $i = res[$i] " " substr($i,2) + } + } + } + deps[mod] = $0 + } else { + res[mod] = deps[mod] + delete deps[mod] + --ndeps + } + } + + # output dependencies in modules.dep format + for ( mod in res ) { + $0 = res[mod] + s = "" + delete a + for ( i=1; i<=NF; ++i ) { + if ( ! ($i in a) ) { + a[$i] = $i + s = " ," $i s + } + } + print "," substr(mod,2) ":" s + } +} +' | sort | sed -r -e "s!,([^,: ]*)!/usr/lib/modules/\\1.ko.gz!g" diff --git a/examples/depmod.pl b/examples/depmod.pl new file mode 100755 index 0000000..c356d27 --- /dev/null +++ b/examples/depmod.pl @@ -0,0 +1,292 @@ +#!/usr/bin/perl -w +# vi: set sw=4 ts=4: +# Copyright (c) 2001 David Schleef +# Copyright (c) 2001 Erik Andersen +# Copyright (c) 2001 Stuart Hughes +# Copyright (c) 2002 Steven J. Hill +# Copyright (c) 2006 Freescale Semiconductor, Inc +# +# History: +# March 2006: Stuart Hughes . +# Significant updates, including implementing the '-F' option +# and adding support for 2.6 kernels. + +# This program is free software; you can redistribute it and/or modify it +# under the same terms as Perl itself. +use Getopt::Long; +use File::Find; +use strict; + +# Set up some default values +my $kdir=""; +my $basedir=""; +my $kernel=""; +my $kernelsyms=""; +my $symprefix=""; +my $stdout=0; +my $verbose=0; +my $help=0; +my $nm = $ENV{'NM'} || "nm"; + +# more globals +my (@liblist) = (); +my $exp = {}; +my $dep = {}; +my $mod = {}; + +my $usage = < | -F } [options]... + Where: + -h --help : Show this help screen + -b --basedir : Modules base directory (e.g /lib/modules/<2.x.y>) + -k --kernel : Kernel binary for the target (e.g. vmlinux) + -F --kernelsyms : Kernel symbol file (e.g. System.map) + -n --stdout : Write to stdout instead of /modules.dep + -v --verbose : Print out lots of debugging stuff + -P --symbol-prefix : Symbol prefix +TXT + +# get command-line options +GetOptions( + "help|h" => \$help, + "basedir|b=s" => \$basedir, + "kernel|k=s" => \$kernel, + "kernelsyms|F=s" => \$kernelsyms, + "stdout|n" => \$stdout, + "verbose|v" => \$verbose, + "symbol-prefix|P=s" => \$symprefix, +); + +die $usage if $help; +die $usage unless $basedir && ( $kernel || $kernelsyms ); +die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms; + +# Strip any trailing or multiple slashes from basedir +$basedir =~ s-(/)\1+-/-g; + +# The base directory should contain /lib/modules somewhere +if($basedir !~ m-/lib/modules-) { + warn "WARNING: base directory does not match ..../lib/modules\n"; +} + +# if no kernel version is contained in the basedir, try to find one +if($basedir !~ m-/lib/modules/\d\.\d-) { + opendir(BD, $basedir) or die "can't open basedir $basedir : $!\n"; + foreach ( readdir(BD) ) { + next if /^\.\.?$/; + next unless -d "$basedir/$_"; + warn "dir = $_\n" if $verbose; + if( /^\d\.\d/ ) { + $kdir = $_; + warn("Guessed module directory as $basedir/$kdir\n"); + last; + } + } + closedir(BD); + die "Cannot find a kernel version under $basedir\n" unless $kdir; + $basedir = "$basedir/$kdir"; +} + +# Find the list of .o or .ko files living under $basedir +warn "**** Locating all modules\n" if $verbose; +find sub { + my $file; + if ( -f $_ && ! -d $_ ) { + $file = $File::Find::name; + if ( $file =~ /\.k?o$/ ) { + push(@liblist, $file); + warn "$file\n" if $verbose; + } + } +}, $basedir; +warn "**** Finished locating modules\n" if $verbose; + +foreach my $obj ( @liblist ){ + # turn the input file name into a target tag name + my ($tgtname) = $obj =~ m-(/lib/modules/.*)$-; + + warn "\nMODULE = $tgtname\n" if $verbose; + + # get a list of symbols + my @output=`$nm $obj`; + + build_ref_tables($tgtname, \@output, $exp, $dep); +} + + +# vmlinux is a special name that is only used to resolve symbols +my $tgtname = 'vmlinux'; +my @output = $kernelsyms ? `cat $kernelsyms` : `$nm $kernel`; +warn "\nMODULE = $tgtname\n" if $verbose; +build_ref_tables($tgtname, \@output, $exp, $dep); + +# resolve the dependencies for each module +# reduce dependencies: remove unresolvable and resolved from vmlinux/System.map +# remove duplicates +foreach my $module (keys %$dep) { + warn "reducing module: $module\n" if $verbose; + $mod->{$module} = {}; + foreach (@{$dep->{$module}}) { + if( $exp->{$_} ) { + warn "resolved symbol $_ in file $exp->{$_}\n" if $verbose; + next if $exp->{$_} =~ /vmlinux/; + $mod->{$module}{$exp->{$_}} = 1; + } else { + warn "unresolved symbol $_ in file $module\n"; + } + } +} + +# figure out where the output should go +if ($stdout == 0) { + open(STDOUT, ">$basedir/modules.dep") + or die "cannot open $basedir/modules.dep: $!"; +} +my $kseries = $basedir =~ m,/2\.6\.[^/]*, ? '2.6' : '2.4'; + +foreach my $module ( keys %$mod ) { + if($kseries eq '2.4') { + print "$module:\t"; + my @sorted = sort bydep keys %{$mod->{$module}}; + print join(" \\\n\t",@sorted); + print "\n\n"; + } else { + print "$module: "; + my @sorted = sort bydep keys %{$mod->{$module}}; + print join(" ",@sorted); + print "\n"; + } +} + + +sub build_ref_tables +{ + my ($name, $sym_ar, $exp, $dep) = @_; + + my $ksymtab = grep m/ __ksymtab/, @$sym_ar; + + # gather the exported symbols + if($ksymtab){ + # explicitly exported + foreach ( @$sym_ar ) { + / __ksymtab_(.*)$/ and do { + warn "sym = $1\n" if $verbose; + $exp->{$1} = $name; + }; + } + } else { + # exporting all symbols + foreach ( @$sym_ar ) { + / [ABCDGRSTW] (.*)$/ and do { + warn "syma = $1\n" if $verbose; + $exp->{$1} = $name; + }; + } + } + + # this takes makes sure modules with no dependencies get listed + push @{$dep->{$name}}, $symprefix . 'printk' unless $name eq 'vmlinux'; + + # gather the unresolved symbols + foreach ( @$sym_ar ) { + !/ __this_module/ && / U (.*)$/ and do { + warn "und = $1\n" if $verbose; + push @{$dep->{$name}}, $1; + }; + } +} + +sub bydep +{ + foreach my $f ( keys %{$mod->{$b}} ) { + if($f eq $a) { + return 1; + } + } + return -1; +} + + + +__END__ + +=head1 NAME + +depmod.pl - a cross platform script to generate kernel module +dependency lists (modules.conf) which can then be used by modprobe +on the target platform. + +It supports Linux 2.4 and 2.6 styles of modules.conf (auto-detected) + +=head1 SYNOPSIS + +depmod.pl [OPTION]... [basedir]... + +Example: + + depmod.pl -F linux/System.map -b target/lib/modules/2.6.11 + +=head1 DESCRIPTION + +The purpose of this script is to automagically generate a list of of kernel +module dependencies. This script produces dependency lists that should be +identical to the depmod program from the modutils package. Unlike the depmod +binary, however, depmod.pl is designed to be run on your host system, not +on your target system. + +This script was written by David Schleef to be used in +conjunction with the BusyBox modprobe applet. + +=head1 OPTIONS + +=over 4 + +=item B<-h --help> + +This displays the help message. + +=item B<-b --basedir> + +The base directory uner which the target's modules will be found. This +defaults to the /lib/modules directory. + +If you don't specify the kernel version, this script will search for +one under the specified based directory and use the first thing that +looks like a kernel version. + +=item B<-k --kernel> + +Kernel binary for the target (vmlinux). You must either supply a kernel binary +or a kernel symbol file (using the -F option). + +=item B<-F --kernelsyms> + +Kernel symbol file for the target (System.map). + +=item B<-n --stdout> + +Write to stdout instead of modules.dep +kernel binary for the target (using the -k option). + +=item B<--verbose> + +Verbose (debug) output + +=back + +=head1 COPYRIGHT AND LICENSE + + Copyright (c) 2001 David Schleef + Copyright (c) 2001 Erik Andersen + Copyright (c) 2001 Stuart Hughes + Copyright (c) 2002 Steven J. Hill + Copyright (c) 2006 Freescale Semiconductor, Inc + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=head1 AUTHOR + +David Schleef + +=cut diff --git a/examples/devfsd.conf b/examples/devfsd.conf new file mode 100644 index 0000000..10f1c87 --- /dev/null +++ b/examples/devfsd.conf @@ -0,0 +1,133 @@ +# Sample /etc/devfsd.conf configuration file. +# Richard Gooch 17-FEB-2002 +# +# adapted for busybox devfsd implementation by Tito +# +# Enable full compatibility mode for old device names. You may comment these +# out if you don't use the old device names. Make sure you know what you're +# doing! +REGISTER .* MKOLDCOMPAT +UNREGISTER .* RMOLDCOMPAT + +# You may comment out the above and uncomment the following if you've +# configured your system to use the original "new" devfs names or the really +# new names +#REGISTER ^vc/ MKOLDCOMPAT +#UNREGISTER ^vc/ RMOLDCOMPAT +#REGISTER ^pty/ MKOLDCOMPAT +#UNREGISTER ^pty/ RMOLDCOMPAT +#REGISTER ^misc/ MKOLDCOMPAT +#UNREGISTER ^misc/ RMOLDCOMPAT + +# You may comment these out if you don't use the original "new" names +REGISTER .* MKNEWCOMPAT +UNREGISTER .* RMNEWCOMPAT + +# Enable module autoloading. You may comment this out if you don't use +# autoloading +# Supported by busybox when CONFIG_DEVFSD_MODLOAD is set. +# This actually doesn't work with busybox modutils but needs +# the real modutils' modprobe +LOOKUP .* MODLOAD + +# Uncomment the following if you want to set the group to "tty" for the +# pseudo-tty devices. This is necessary so that mesg(1) can later be used to +# enable/disable talk requests and wall(1) messages. +REGISTER ^pty/s.* PERMISSIONS -1.tty 0600 +#REGISTER ^pts/.* PERMISSIONS -1.tty 0600 + +# Restoring /dev/log on startup would trigger the minilogd/initlog deadlock +# (minilogd falsely assuming syslogd has been started). +REGISTER ^log$ IGNORE +CREATE ^log$ IGNORE +CHANGE ^log$ IGNORE +DELETE ^log$ IGNORE + +# +# Uncomment this if you want permissions to be saved and restored +# Do not do this for pseudo-terminal devices +REGISTER ^pt[sy] IGNORE +CREATE ^pt[sy] IGNORE +CHANGE ^pt[sy] IGNORE +DELETE ^pt[sy] IGNORE +REGISTER .* COPY /lib/dev-state/$devname $devpath +CREATE .* COPY $devpath /lib/dev-state/$devname +CHANGE .* COPY $devpath /lib/dev-state/$devname +#DELETE .* CFUNCTION GLOBAL unlink /lib/dev-state/$devname +# Busybox +DELETE .* EXECUTE /bin/rm -f /lib/dev-state/$devname + +RESTORE /lib/dev-state + +# +# Uncomment this if you want the old /dev/cdrom symlink +#REGISTER ^cdroms/cdrom0$ CFUNCTION GLOBAL mksymlink $devname cdrom +#UNREGISTER ^cdroms/cdrom0$ CFUNCTION GLOBAL unlink cdrom +# busybox +REGISTER ^cdroms/cdrom0$ EXECUTE /bin/ln -sf $devname cdrom +UNREGISTER ^cdroms/cdrom0$ EXECUTE /bin/rm -f cdrom + +#REGISTER ^v4l/video0$ CFUNCTION GLOBAL mksymlink v4l/video0 video +#UNREGISTER ^v4l/video0$ CFUNCTION GLOBAL unlink video +#REGISTER ^radio0$ CFUNCTION GLOBAL mksymlink radio0 radio +#UNREGISTER ^radio0$ CFUNCTION GLOBAL unlink radio +# Busybox +REGISTER ^v4l/video0$ EXECUTE /bin/ln -sf v4l/video0 video +UNREGISTER ^v4l/video0$ EXECUTE /bin/rm -f video +REGISTER ^radio0$ EXECUTE /bin/ln -sf radio0 radio +UNREGISTER ^radio0$ EXECUTE /bin/rm -f radio + +# ALSA stuff +#LOOKUP snd MODLOAD ACTION snd + +# Uncomment this to let PAM manage devfs +# Not supported by busybox +#REGISTER .* CFUNCTION /lib/security/pam_console_apply_devfsd.so pam_console_apply_single $devpath + +# Uncomment this to manage USB mouse +# Not supported by busybox +#REGISTER ^input/mouse0$ CFUNCTION GLOBAL mksymlink $devname usbmouse +#UNREGISTER ^input/mouse0$ CFUNCTION GLOBAL unlink usbmouse +# Busybox +#REGISTER ^input/mouse0$ EXECUTE /bin/ln -sf $devname usbmouse +#UNREGISTER ^input/mouse0$ EXECUTE /bin/rm -f usbmouse +# Not supported by busybox +#REGISTER ^input/mice$ CFUNCTION GLOBAL mksymlink $devname usbmouse +#UNREGISTER ^input/mice$ CFUNCTION GLOBAL unlink usbmouse +# Busybox +REGISTER ^input/mice$ EXECUTE /bin/ln -sf $devname usbmouse +UNREGISTER ^input/mice$ EXECUTE /bin/rm -f usbmouse + +# If you have removable media and want to force media revalidation when looking +# up new or old compatibility names, uncomment the following lines +# SCSI NEWCOMPAT /dev/sd/* names +LOOKUP ^(sd/c[0-9]+b[0-9]+t[0-9]+u[0-9]+)p[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 +# SCSI OLDCOMPAT /dev/sd?? names +LOOKUP ^(sd[a-z]+)[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 +# IDE NEWCOMPAT /dev/ide/hd/* names +LOOKUP ^(ide/hd/c[0-9]+b[0-9]+t[0-9]+u[0-9]+)p[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 +# IDE OLDCOMPAT /dev/hd?? names +LOOKUP ^(hd[a-z])[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 +# IDE-SCSI NEWCOMPAT /dev/sd/* names +#LOOKUP ^(sd/c[0-9]+b[0-9]+t[0-9]+u[0-9]+)p[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 +#SCSI OLDCOMPAT /dev/scd? names +LOOKUP ^(scd+)[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 + + +REGISTER ^dvb/card[0-9]+/[^/]+$ PERMISSIONS root.video 0660 +# Not supported by busybox +#REGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ CFUNCTION GLOBAL mksymlink /dev/$devname ost/\2\1 +#UNREGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ CFUNCTION GLOBAL unlink ost/\2\1 +# Busybox +REGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ EXECUTE /bin/ln -sf /dev/$devname ost/\2\1 +UNREGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ EXECUTE /bin/rm -f ost/\2\1 + +# Include package-generated files from /etc/devfs/conf.d +# Supported by busybox +# INCLUDE /etc/devfs/conf.d/ +INCLUDE /etc/devfs/busybox/ +# Busybox: just for testing +#INCLUDE /etc/devfs/nothing/ +#INCLUDE /etc/devfs/nothing/nothing +#OPTIONAL_INCLUDE /etc/devfs/nothing/ +#OPTIONAL_INCLUDE /etc/devfs/nothing/nothing diff --git a/examples/dnsd.conf b/examples/dnsd.conf new file mode 100644 index 0000000..8af622b --- /dev/null +++ b/examples/dnsd.conf @@ -0,0 +1 @@ +thebox 192.168.1.5 diff --git a/examples/inetd.conf b/examples/inetd.conf new file mode 100644 index 0000000..ca7e3d8 --- /dev/null +++ b/examples/inetd.conf @@ -0,0 +1,73 @@ +# /etc/inetd.conf: see inetd(8) for further informations. +# +# Internet server configuration database +# +# +# If you want to disable an entry so it isn't touched during +# package updates just comment it out with a single '#' character. +# +# If you make changes to this file, either reboot your machine or +# send the inetd process a HUP signal: +# Do a "ps x" as root and look up the pid of inetd. Then do a +# kill -HUP +# inetd will re-read this file whenever it gets that signal. +# +# +#:INTERNAL: Internal services +# It is generally considered safer to keep these off. +echo stream tcp nowait root internal +echo dgram udp wait root internal +#discard stream tcp nowait root internal +#discard dgram udp wait root internal +daytime stream tcp nowait root internal +daytime dgram udp wait root internal +#chargen stream tcp nowait root internal +#chargen dgram udp wait root internal +time stream tcp nowait root internal +time dgram udp wait root internal + +# These are standard services. +# +#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd +#telnet stream tcp nowait root /sbin/telnetd /sbin/telnetd +#nntp stream tcp nowait root tcpd in.nntpd +#smtp stream tcp nowait root tcpd sendmail -v +# +# Shell, login, exec and talk are BSD protocols. +# +# If you run an ntalk daemon (such as netkit-ntalk) on the old talk +# port, that is, "talk" as opposed to "ntalk", it won't work and may +# cause certain broken talk clients to malfunction. +# +# The talkd from netkit-ntalk 0.12 and higher, however, can speak the +# old talk protocol and can be used safely. +# +#shell stream tcp nowait root /usr/sbin/tcpd in.rshd -L +#login stream tcp nowait root /usr/sbin/tcpd in.rlogind -L +#exec stream tcp nowait root /usr/sbin/tcpd in.rexecd +#talk dgram udp wait root /usr/sbin/tcpd in.talkd +#ntalk dgram udp wait root /usr/sbin/tcpd in.talkd +# +# Pop et al +# Leave these off unless you're using them. +#pop2 stream tcp nowait root /usr/sbin/tcpd in.pop2d +#pop3 stream tcp nowait root /usr/sbin/tcpd in.pop3d +# +# The Internet UUCP service. +# uucp stream tcp nowait uucp /usr/sbin/tcpd /usr/lib/uucp/uucico -l +# +# Tftp service is provided primarily for booting. Most sites +# run this only on machines acting as "boot servers." If you don't +# need it, don't use it. +# +#tftp dgram udp wait nobody /usr/sbin/tcpd in.tftpd +#bootps dgram udp wait root /usr/sbin/in.bootpd in.bootpd +# +# Finger, systat and netstat give out user information which may be +# valuable to potential "system crackers." Many sites choose to disable +# some or all of these services to improve security. +# +#finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd -w +#systat stream tcp nowait nobody /usr/sbin/tcpd /bin/ps -auwwx +#netstat stream tcp nowait root /bin/netstat /bin/netstat -a +#ident stream tcp nowait root /usr/sbin/in.identd in.identd diff --git a/examples/inittab b/examples/inittab new file mode 100644 index 0000000..5f2af87 --- /dev/null +++ b/examples/inittab @@ -0,0 +1,90 @@ +# /etc/inittab init(8) configuration for BusyBox +# +# Copyright (C) 1999-2004 by Erik Andersen +# +# +# Note, BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use sysvinit. +# +# +# Format for each entry: ::: +# +# : WARNING: This field has a non-traditional meaning for BusyBox init! +# +# The id field is used by BusyBox init to specify the controlling tty for +# the specified process to run on. The contents of this field are +# appended to "/dev/" and used as-is. There is no need for this field to +# be unique, although if it isn't you may have strange results. If this +# field is left blank, it is completely ignored. Also note that if +# BusyBox detects that a serial console is in use, then all entries +# containing non-empty id fields will be ignored. BusyBox init does +# nothing with utmp. We don't need no stinkin' utmp. +# +# : The runlevels field is completely ignored. +# +# : Valid actions include: sysinit, respawn, askfirst, wait, once, +# restart, ctrlaltdel, and shutdown. +# +# Note: askfirst acts just like respawn, but before running the specified +# process it displays the line "Please press Enter to activate this +# console." and then waits for the user to press enter before starting +# the specified process. +# +# Note: unrecognised actions (like initdefault) will cause init to emit +# an error message, and then go along with its business. +# +# : Specifies the process to be executed and it's command line. +# +# Note: BusyBox init works just fine without an inittab. If no inittab is +# found, it has the following default behavior: +# ::sysinit:/etc/init.d/rcS +# ::askfirst:/bin/sh +# ::ctrlaltdel:/sbin/reboot +# ::shutdown:/sbin/swapoff -a +# ::shutdown:/bin/umount -a -r +# ::restart:/sbin/init +# +# if it detects that /dev/console is _not_ a serial console, it will +# also run: +# tty2::askfirst:/bin/sh +# tty3::askfirst:/bin/sh +# tty4::askfirst:/bin/sh +# +# Boot-time system configuration/initialization script. +# This is run first except when booting in single-user mode. +# +::sysinit:/etc/init.d/rcS + +# /bin/sh invocations on selected ttys +# +# Note below that we prefix the shell commands with a "-" to indicate to the +# shell that it is supposed to be a login shell. Normally this is handled by +# login, but since we are bypassing login in this case, BusyBox lets you do +# this yourself... +# +# Start an "askfirst" shell on the console (whatever that may be) +::askfirst:-/bin/sh +# Start an "askfirst" shell on /dev/tty2-4 +tty2::askfirst:-/bin/sh +tty3::askfirst:-/bin/sh +tty4::askfirst:-/bin/sh + +# /sbin/getty invocations for selected ttys +tty4::respawn:/sbin/getty 38400 tty5 +tty5::respawn:/sbin/getty 38400 tty6 + +# Example of how to put a getty on a serial line (for a terminal) +#::respawn:/sbin/getty -L ttyS0 9600 vt100 +#::respawn:/sbin/getty -L ttyS1 9600 vt100 +# +# Example how to put a getty on a modem line. +#::respawn:/sbin/getty 57600 ttyS2 + +# Stuff to do when restarting the init process +::restart:/sbin/init + +# Stuff to do before rebooting +::ctrlaltdel:/sbin/reboot +::shutdown:/bin/umount -a -r +::shutdown:/sbin/swapoff -a + diff --git a/examples/mk2knr.pl b/examples/mk2knr.pl new file mode 100755 index 0000000..1259b84 --- /dev/null +++ b/examples/mk2knr.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl -w +# +# @(#) mk2knr.pl - generates a perl script that converts lexemes to K&R-style +# +# How to use this script: +# - In the busybox directory type 'examples/mk2knr.pl files-to-convert' +# - Review the 'convertme.pl' script generated and remove / edit any of the +# substitutions in there (please especially check for false positives) +# - Type './convertme.pl same-files-as-before' +# - Compile and see if it works +# +# BUGS: This script does not ignore strings inside comments or strings inside +# quotes (it probably should). + +# set this to something else if you want +$convertme = 'convertme.pl'; + +# internal-use variables (don't touch) +$convert = 0; +%converted = (); + +# if no files were specified, print usage +die "usage: $0 file.c | file.h\n" if scalar(@ARGV) == 0; + +# prepare the "convert me" file +open(CM, ">$convertme") or die "convertme.pl $!"; +print CM "#!/usr/bin/perl -p -i\n\n"; + +# process each file passed on the cmd line +while (<>) { + + # if the line says "getopt" in it anywhere, we don't want to muck with it + # because option lists tend to include strings like "cxtzvOf:" which get + # matched by the "check for mixed case" regexps below + next if /getopt/; + + # tokenize the string into just the variables + while (/([a-zA-Z_][a-zA-Z0-9_]*)/g) { + $var = $1; + + # ignore the word "BusyBox" + next if ($var =~ /BusyBox/); + + # this checks for javaStyle or szHungarianNotation + $convert++ if ($var =~ /^[a-z]+[A-Z][a-z]+/); + + # this checks for PascalStyle + $convert++ if ($var =~ /^[A-Z][a-z]+[A-Z][a-z]+/); + + # if we want to add more checks, we can add 'em here, but the above + # checks catch "just enough" and not too much, so prolly not. + + if ($convert) { + $convert = 0; + + # skip ahead if we've already dealt with this one + next if ($converted{$var}); + + # record that we've dealt with this var + $converted{$var} = 1; + + print CM "s/\\b$var\\b/"; # more to come in just a minute + + # change the first letter to lower-case + $var = lcfirst($var); + + # put underscores before all remaining upper-case letters + $var =~ s/([A-Z])/_$1/g; + + # now change the remaining characters to lower-case + $var = lc($var); + + print CM "$var/g;\n"; + } + } +} + +# tidy up and make the $convertme script executable +close(CM); +chmod 0755, $convertme; + +# print a helpful help message +print "Done. Scheduled name changes are in $convertme.\n"; +print "Please review/modify it and then type ./$convertme to do the search & replace.\n"; diff --git a/examples/udhcp/sample.bound b/examples/udhcp/sample.bound new file mode 100755 index 0000000..2a95d8b --- /dev/null +++ b/examples/udhcp/sample.bound @@ -0,0 +1,31 @@ +#!/bin/sh +# Sample udhcpc renew script + +RESOLV_CONF="/etc/udhcpc/resolv.conf" + +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +/sbin/ifconfig $interface $ip $BROADCAST $NETMASK + +if [ -n "$router" ] +then + echo "deleting routers" + while /sbin/route del default gw 0.0.0.0 dev $interface + do : + done + + metric=0 + for i in $router + do + /sbin/route add default gw $i dev $interface metric $((metric++)) + done +fi + +echo -n > $RESOLV_CONF +[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF +for i in $dns +do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF +done \ No newline at end of file diff --git a/examples/udhcp/sample.deconfig b/examples/udhcp/sample.deconfig new file mode 100755 index 0000000..b221bcf --- /dev/null +++ b/examples/udhcp/sample.deconfig @@ -0,0 +1,4 @@ +#!/bin/sh +# Sample udhcpc deconfig script + +/sbin/ifconfig $interface 0.0.0.0 diff --git a/examples/udhcp/sample.nak b/examples/udhcp/sample.nak new file mode 100755 index 0000000..f4d08e6 --- /dev/null +++ b/examples/udhcp/sample.nak @@ -0,0 +1,4 @@ +#!/bin/sh +# Sample udhcpc nak script + +echo Received a NAK: $message diff --git a/examples/udhcp/sample.renew b/examples/udhcp/sample.renew new file mode 100755 index 0000000..842bafe --- /dev/null +++ b/examples/udhcp/sample.renew @@ -0,0 +1,31 @@ +#!/bin/sh +# Sample udhcpc bound script + +RESOLV_CONF="/etc/udhcpc/resolv.conf" + +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +/sbin/ifconfig $interface $ip $BROADCAST $NETMASK + +if [ -n "$router" ] +then + echo "deleting routers" + while /sbin/route del default gw 0.0.0.0 dev $interface + do : + done + + metric=0 + for i in $router + do + /sbin/route add default gw $i dev $interface metric $((metric++)) + done +fi + +echo -n > $RESOLV_CONF +[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF +for i in $dns +do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF +done \ No newline at end of file diff --git a/examples/udhcp/sample.script b/examples/udhcp/sample.script new file mode 100644 index 0000000..9b717ac --- /dev/null +++ b/examples/udhcp/sample.script @@ -0,0 +1,7 @@ +#!/bin/sh +# Currently, we only dispatch according to command. However, a more +# elaborate system might dispatch by command and interface or do some +# common initialization first, especially if more dhcp event notifications +# are added. + +exec /usr/share/udhcpc/sample.$1 diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script new file mode 100644 index 0000000..98ebc15 --- /dev/null +++ b/examples/udhcp/simple.script @@ -0,0 +1,40 @@ +#!/bin/sh + +# udhcpc script edited by Tim Riker + +[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 + +RESOLV_CONF="/etc/resolv.conf" +[ -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 + + metric=0 + for i in $router ; do + route add default gw $i dev $interface metric $((metric++)) + done + fi + + echo -n > $RESOLV_CONF + [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF + for i in $dns ; do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF + done + ;; +esac + +exit 0 diff --git a/examples/udhcp/udhcpd.conf b/examples/udhcp/udhcpd.conf new file mode 100644 index 0000000..8c9a968 --- /dev/null +++ b/examples/udhcp/udhcpd.conf @@ -0,0 +1,123 @@ +# Sample udhcpd configuration file (/etc/udhcpd.conf) + +# The start and end of the IP lease block + +start 192.168.0.20 #default: 192.168.0.20 +end 192.168.0.254 #default: 192.168.0.254 + + +# The interface that udhcpd will use + +interface eth0 #default: eth0 + + +# The maximim number of leases (includes addressesd reserved +# by OFFER's, DECLINE's, and ARP conficts + +#max_leases 254 #default: 254 + + +# If remaining is true (default), udhcpd will store the time +# remaining for each lease in the udhcpd leases file. This is +# for embedded systems that cannot keep time between reboots. +# If you set remaining to no, the absolute time that the lease +# expires at will be stored in the dhcpd.leases file. + +#remaining yes #default: yes + + +# The time period at which udhcpd will write out a dhcpd.leases +# file. If this is 0, udhcpd will never automatically write a +# lease file. (specified in seconds) + +#auto_time 7200 #default: 7200 (2 hours) + + +# The amount of time that an IP will be reserved (leased) for if a +# DHCP decline message is received (seconds). + +#decline_time 3600 #default: 3600 (1 hour) + + +# The amount of time that an IP will be reserved (leased) for if an +# ARP conflct occurs. (seconds + +#conflict_time 3600 #default: 3600 (1 hour) + + +# How long an offered address is reserved (leased) in seconds + +#offer_time 60 #default: 60 (1 minute) + +# If a lease to be given is below this value, the full lease time is +# instead used (seconds). + +#min_lease 60 #defult: 60 + + +# The location of the leases file + +#lease_file /var/lib/misc/udhcpd.leases #defualt: /var/lib/misc/udhcpd.leases + +# The location of the pid file +#pidfile /var/run/udhcpd.pid #default: /var/run/udhcpd.pid + +# Everytime udhcpd writes a leases file, the below script will be called. +# Useful for writing the lease file to flash every few hours. + +#notify_file #default: (no script) + +#notify_file dumpleases # <--- useful for debugging + +# The following are bootp specific options, setable by udhcpd. + +#siaddr 192.168.0.22 #default: 0.0.0.0 + +#sname zorak #default: (none) + +#boot_file /var/nfs_root #default: (none) + +# The remainer of options are DHCP options and can be specifed with the +# keyword 'opt' or 'option'. If an option can take multiple items, such +# as the dns option, they can be listed on the same line, or multiple +# lines. The only option with a default is 'lease'. + +#Examles +opt dns 192.168.10.2 192.168.10.10 +option subnet 255.255.255.0 +opt router 192.168.10.2 +opt wins 192.168.10.10 +option dns 129.219.13.81 # appened to above DNS servers for a total of 3 +option domain local +option lease 864000 # 10 days of seconds + + +# Currently supported options, for more info, see options.c +#opt subnet +#opt timezone +#opt router +#opt timesrv +#opt namesrv +#opt dns +#opt logsrv +#opt cookiesrv +#opt lprsrv +#opt bootsize +#opt domain +#opt swapsrv +#opt rootpath +#opt ipttl +#opt mtu +#opt broadcast +#opt wins +#opt lease +#opt ntpsrv +#opt tftp +#opt bootfile + + +# Static leases map +#static_lease 00:60:08:11:CE:4E 192.168.0.54 +#static_lease 00:60:08:11:CE:3E 192.168.0.44 + + diff --git a/examples/undeb b/examples/undeb new file mode 100644 index 0000000..37104e9 --- /dev/null +++ b/examples/undeb @@ -0,0 +1,53 @@ +#!/bin/sh +# +# This should work with the GNU version of tar and gzip! +# This should work with the bash or ash shell! +# Requires the programs (ar, tar, gzip, and the pager more or less). +# +usage() { +echo "Usage: undeb -c package.deb " +echo " undeb -l package.deb " +echo " undeb -x package.deb /foo/boo " +exit +} + +deb=$2 + +exist() { +if [ "$deb" = "" ]; then +usage +elif [ ! -s "$deb" ]; then +echo "Can't find $deb!" +exit +fi +} + +if [ "$1" = "" ]; then +usage +elif [ "$1" = "-l" ]; then +exist +type more >/dev/null 2>&1 && pager=more +type less >/dev/null 2>&1 && pager=less +[ "$pager" = "" ] && echo "No pager found!" && exit +(ar -p $deb control.tar.gz | tar -xzO *control ; echo -e "\nPress enter to scroll, q to Quit!\n" ; ar -p $deb data.tar.gz | tar -tzv) | $pager +exit +elif [ "$1" = "-c" ]; then +exist +ar -p $deb control.tar.gz | tar -xzO *control +exit +elif [ "$1" = "-x" ]; then +exist +if [ "$3" = "" ]; then +usage +elif [ ! -d "$3" ]; then +echo "No such directory $3!" +exit +fi +ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit +echo +echo "Extracted $deb to $3!" +exit +else +usage +fi diff --git a/examples/unrpm b/examples/unrpm new file mode 100644 index 0000000..7fd3676 --- /dev/null +++ b/examples/unrpm @@ -0,0 +1,48 @@ +#!/bin/sh +# +# This should work with the GNU version of cpio and gzip! +# This should work with the bash or ash shell! +# Requires the programs (cpio, gzip, and the pager more or less). +# +usage() { +echo "Usage: unrpm -l package.rpm " +echo " unrpm -x package.rpm /foo/boo " +exit +} + +rpm=$2 + +exist() { +if [ "$rpm" = "" ]; then +usage +elif [ ! -s "$rpm" ]; then +echo "Can't find $rpm!" +exit +fi +} + +if [ "$1" = "" ]; then +usage +elif [ "$1" = "-l" ]; then +exist +type more >/dev/null 2>&1 && pager=more +type less >/dev/null 2>&1 && pager=less +[ "$pager" = "" ] && echo "No pager found!" && exit +(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager +exit +elif [ "$1" = "-x" ]; then +exist +if [ "$3" = "" ]; then +usage +elif [ ! -d "$3" ]; then +echo "No such directory $3!" +exit +fi +rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit +echo +echo "Extracted $rpm to $3!" +exit +else +usage +fi diff --git a/examples/zcip.script b/examples/zcip.script new file mode 100644 index 0000000..988e542 --- /dev/null +++ b/examples/zcip.script @@ -0,0 +1,38 @@ +#!/bin/sh + +# only for use as a "zcip" callback script +if [ "x$interface" = x ] +then + exit 1 +fi + +# zcip should start on boot/resume and various media changes +case "$1" in +init) + # for now, zcip requires the link to be already up, + # and it drops links when they go down. that isn't + # the most robust model... + exit 0 + ;; +config) + if [ "x$ip" = x ] + then + exit 1 + fi + # remember $ip for $interface, to use on restart + if [ "x$IP" != x -a -w "$IP.$interface" ] + then + echo $ip > "$IP.$interface" + fi + exec ip address add dev $interface \ + scope link local "$ip/16" broadcast + + ;; +deconfig) + if [ x$ip = x ] + then + exit 1 + fi + exec ip address del dev $interface local $ip + ;; +esac +exit 1 -- cgit v1.2.3