diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-27 04:35:04 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-27 04:35:04 +0000 |
commit | 8d42f86b146871ae4c4cafd3801a85f381249a14 (patch) | |
tree | b963999fc54eddb65f1929b894f868e24851fc9c /examples | |
download | busybox-w32-8d42f86b146871ae4c4cafd3801a85f381249a14.tar.gz busybox-w32-8d42f86b146871ae4c4cafd3801a85f381249a14.tar.bz2 busybox-w32-8d42f86b146871ae4c4cafd3801a85f381249a14.zip |
Correcting branch name to be like previous ones
Diffstat (limited to 'examples')
28 files changed, 1532 insertions, 0 deletions
diff --git a/examples/bootfloppy/bootfloppy.txt b/examples/bootfloppy/bootfloppy.txt new file mode 100644 index 000000000..b514e6305 --- /dev/null +++ b/examples/bootfloppy/bootfloppy.txt | |||
@@ -0,0 +1,180 @@ | |||
1 | Building a Busybox Boot Floppy | ||
2 | ============================== | ||
3 | |||
4 | This document describes how to buid a boot floppy using the following | ||
5 | components: | ||
6 | |||
7 | - Linux Kernel (http://www.kernel.org) | ||
8 | - uClibc: C library (http://www.uclibc.org/) | ||
9 | - Busybox: Unix utilities (http://busybox.net/) | ||
10 | - Syslinux: bootloader (http://syslinux.zytor.com) | ||
11 | |||
12 | It is based heavily on a paper presented by Erik Andersen at the 2001 Embedded | ||
13 | Systems Conference. | ||
14 | |||
15 | |||
16 | |||
17 | Building The Software Components | ||
18 | -------------------------------- | ||
19 | |||
20 | Detailed instructions on how to build Busybox, uClibc, or a working Linux | ||
21 | kernel are beyond the scope of this document. The following guidelines will | ||
22 | help though: | ||
23 | |||
24 | - Stock Busybox from CVS or a tarball will work with no modifications to | ||
25 | any files. Just extract and go. | ||
26 | - Ditto uClibc. | ||
27 | - Your Linux kernel must include support for initrd or else the floppy | ||
28 | won't be able to mount it's root file system. | ||
29 | |||
30 | If you require further information on building Busybox uClibc or Linux, please | ||
31 | refer to the web pages and documentation for those individual programs. | ||
32 | |||
33 | |||
34 | |||
35 | Making a Root File System | ||
36 | ------------------------- | ||
37 | |||
38 | The following steps will create a root file system. | ||
39 | |||
40 | - Create an empty file that you can format as a filesystem: | ||
41 | |||
42 | dd if=/dev/zero of=rootfs bs=1k count=4000 | ||
43 | |||
44 | - Set up the rootfs file we just created to be used as a loop device (may not | ||
45 | be necessary) | ||
46 | |||
47 | losetup /dev/loop0 rootfs | ||
48 | |||
49 | - Format the rootfs file with a filesystem: | ||
50 | |||
51 | mkfs.ext2 -F -i 2000 rootfs | ||
52 | |||
53 | - Mount the file on a mountpoint so we can place files in it: | ||
54 | |||
55 | mkdir loop | ||
56 | mount -o loop rootfs loop/ | ||
57 | |||
58 | (you will probably need to be root to do this) | ||
59 | |||
60 | - Copy on the C library, the dynamic linking library, and other necessary | ||
61 | libraries. For this example, we copy the following files from the uClibc | ||
62 | tree: | ||
63 | |||
64 | mkdir loop/lib | ||
65 | (chdir to uClibc directory) | ||
66 | cp -a libc.so* uClibc*.so \ | ||
67 | ld.so-1/d-link/ld-linux-uclibc.so* \ | ||
68 | ld.so-1/libdl/libdl.so* \ | ||
69 | crypt/libcrypt.so* \ | ||
70 | (path to)loop/lib | ||
71 | |||
72 | - Install the Busybox binary and accompanying symlinks: | ||
73 | |||
74 | (chdir to busybox directory) | ||
75 | make PREFIX=(path to)loop/ install | ||
76 | |||
77 | - Make device files in /dev: | ||
78 | |||
79 | This can be done by running the 'mkdevs.sh' script. If you want the gory | ||
80 | details, you can read the script. | ||
81 | |||
82 | - Make necessary files in /etc: | ||
83 | |||
84 | For this, just cp -a the etc/ directory onto rootfs. Again, if you want | ||
85 | all the details, you can just look at the files in the dir. | ||
86 | |||
87 | - Unmount the rootfs from the mountpoint: | ||
88 | |||
89 | umount loop | ||
90 | |||
91 | - Compress it: | ||
92 | |||
93 | gzip -9 rootfs | ||
94 | |||
95 | |||
96 | Making a SYSLINUX boot floppy | ||
97 | ----------------------------- | ||
98 | |||
99 | The following steps will create the boot floppy. | ||
100 | |||
101 | Note: You will need to have the mtools package installed beforehand. | ||
102 | |||
103 | - Insert a floppy in the drive and format it with an MSDOS filesystem: | ||
104 | |||
105 | mformat a: | ||
106 | |||
107 | (if the system doesn't know what device 'a:' is, look at /etc/mtools.conf) | ||
108 | |||
109 | - Run syslinux on the floppy: | ||
110 | |||
111 | syslinux -s /dev/fd0 | ||
112 | |||
113 | (the -s stands for "safe, slow, and stupid" and should work better with | ||
114 | buggy BIOSes; it can be omitted) | ||
115 | |||
116 | - Put on a syslinux.cfg file: | ||
117 | |||
118 | mcopy syslinux.cfg a: | ||
119 | |||
120 | (more on syslinux.cfg below) | ||
121 | |||
122 | - Copy the root file system you made onto the MSDOS formatted floppy | ||
123 | |||
124 | mcopy rootfs.gz a: | ||
125 | |||
126 | - Build a linux kernel and copy it onto the disk with the filename 'linux' | ||
127 | |||
128 | mcopy bzImage a:linux | ||
129 | |||
130 | |||
131 | Sample syslinux.cfg | ||
132 | ~~~~~~~~~~~~~~~~~~~ | ||
133 | |||
134 | The following simple syslinux.cfg file should work. You can tweak it if you | ||
135 | like. | ||
136 | |||
137 | ----begin-syslinux.cfg--------------- | ||
138 | DEFAULT linux | ||
139 | APPEND initrd=rootfs.gz root=/dev/ram0 | ||
140 | TIMEOUT 10 | ||
141 | PROMPT 1 | ||
142 | ----end-syslinux.cfg--------------- | ||
143 | |||
144 | Some changes you could make to syslinux.cfg: | ||
145 | |||
146 | - This value is the number seconds it will wait before booting. You can set | ||
147 | the timeout to 0 (or omit) to boot instantly, or you can set it as high as | ||
148 | 10 to wait awhile. | ||
149 | |||
150 | - PROMPT can be set to 0 to disable the 'boot:' prompt. | ||
151 | |||
152 | - you can add this line to display the contents of a file as a welcome | ||
153 | message: | ||
154 | |||
155 | DISPLAY display.txt | ||
156 | |||
157 | |||
158 | |||
159 | Additional Resources | ||
160 | -------------------- | ||
161 | |||
162 | Other useful information on making a Linux bootfloppy is available at the | ||
163 | following URLs: | ||
164 | |||
165 | http://www.linuxdoc.org/HOWTO/Bootdisk-HOWTO/index.html | ||
166 | http://www.linux-embedded.com/howto/Embedded-Linux-Howto.html | ||
167 | http://linux-embedded.org/howto/LFS-HOWTO.html | ||
168 | http://linux-embedded.org/pmhowto.html | ||
169 | http://recycle.lbl.gov/~ldoolitt/embedded/ (Larry Doolittle's stuff) | ||
170 | |||
171 | |||
172 | |||
173 | Possible TODOs | ||
174 | -------------- | ||
175 | |||
176 | The following features that we might want to add later: | ||
177 | |||
178 | - support for additional filesystems besides ext2, i.e. minix | ||
179 | - different libc, static vs dynamic loading | ||
180 | - maybe using an alternate bootloader | ||
diff --git a/examples/bootfloppy/display.txt b/examples/bootfloppy/display.txt new file mode 100644 index 000000000..399d326d9 --- /dev/null +++ b/examples/bootfloppy/display.txt | |||
@@ -0,0 +1,4 @@ | |||
1 | |||
2 | This boot floppy is made with Busybox, uClibc, and the Linux kernel. | ||
3 | Hit RETURN to boot or enter boot parameters at the prompt below. | ||
4 | |||
diff --git a/examples/bootfloppy/etc/fstab b/examples/bootfloppy/etc/fstab new file mode 100644 index 000000000..ef14ca2cc --- /dev/null +++ b/examples/bootfloppy/etc/fstab | |||
@@ -0,0 +1,2 @@ | |||
1 | proc /proc proc defaults 0 0 | ||
2 | |||
diff --git a/examples/bootfloppy/etc/init.d/rcS b/examples/bootfloppy/etc/init.d/rcS new file mode 100755 index 000000000..4f29b923f --- /dev/null +++ b/examples/bootfloppy/etc/init.d/rcS | |||
@@ -0,0 +1,3 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | /bin/mount -a | ||
diff --git a/examples/bootfloppy/etc/inittab b/examples/bootfloppy/etc/inittab new file mode 100644 index 000000000..eb3e979ce --- /dev/null +++ b/examples/bootfloppy/etc/inittab | |||
@@ -0,0 +1,5 @@ | |||
1 | ::sysinit:/etc/init.d/rcS | ||
2 | ::respawn:-/bin/sh | ||
3 | tty2::askfirst:-/bin/sh | ||
4 | ::ctrlaltdel:/bin/umount -a -r | ||
5 | |||
diff --git a/examples/bootfloppy/etc/profile b/examples/bootfloppy/etc/profile new file mode 100644 index 000000000..8a7c77d78 --- /dev/null +++ b/examples/bootfloppy/etc/profile | |||
@@ -0,0 +1,8 @@ | |||
1 | # /etc/profile: system-wide .profile file for the Bourne shells | ||
2 | |||
3 | echo | ||
4 | echo -n "Processing /etc/profile... " | ||
5 | # no-op | ||
6 | echo "Done" | ||
7 | echo | ||
8 | |||
diff --git a/examples/bootfloppy/mkdevs.sh b/examples/bootfloppy/mkdevs.sh new file mode 100755 index 000000000..03a1a8550 --- /dev/null +++ b/examples/bootfloppy/mkdevs.sh | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # makedev.sh - creates device files for a busybox boot floppy image | ||
4 | |||
5 | |||
6 | # we do our work in the dev/ directory | ||
7 | if [ -z "$1" ]; then | ||
8 | echo "usage: `basename $0` path/to/dev/dir" | ||
9 | exit 1 | ||
10 | fi | ||
11 | |||
12 | cd $1 | ||
13 | |||
14 | |||
15 | # miscellaneous one-of-a-kind stuff | ||
16 | mknod console c 5 1 | ||
17 | mknod full c 1 7 | ||
18 | mknod kmem c 1 2 | ||
19 | mknod mem c 1 1 | ||
20 | mknod null c 1 3 | ||
21 | mknod port c 1 4 | ||
22 | mknod random c 1 8 | ||
23 | mknod urandom c 1 9 | ||
24 | mknod zero c 1 5 | ||
25 | ln -s /proc/kcore core | ||
26 | |||
27 | # IDE HD devs | ||
28 | # note: not going to bother creating all concievable partitions; you can do | ||
29 | # that yourself as you need 'em. | ||
30 | mknod hda b 3 0 | ||
31 | mknod hdb b 3 64 | ||
32 | mknod hdc b 22 0 | ||
33 | mknod hdd b 22 64 | ||
34 | |||
35 | # loop devs | ||
36 | for i in `seq 0 7`; do | ||
37 | mknod loop$i b 7 $i | ||
38 | done | ||
39 | |||
40 | # ram devs | ||
41 | for i in `seq 0 9`; do | ||
42 | mknod ram$i b 1 $i | ||
43 | done | ||
44 | ln -s ram1 ram | ||
45 | |||
46 | # ttys | ||
47 | mknod tty c 5 0 | ||
48 | for i in `seq 0 9`; do | ||
49 | mknod tty$i c 4 $i | ||
50 | done | ||
51 | |||
52 | # virtual console screen devs | ||
53 | for i in `seq 0 9`; do | ||
54 | mknod vcs$i b 7 $i | ||
55 | done | ||
56 | ln -s vcs0 vcs | ||
57 | |||
58 | # virtual console screen w/ attributes devs | ||
59 | for i in `seq 0 9`; do | ||
60 | mknod vcsa$i b 7 $i | ||
61 | done | ||
62 | ln -s vcsa0 vcsa | ||
diff --git a/examples/bootfloppy/mkrootfs.sh b/examples/bootfloppy/mkrootfs.sh new file mode 100755 index 000000000..e79ed418e --- /dev/null +++ b/examples/bootfloppy/mkrootfs.sh | |||
@@ -0,0 +1,105 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # mkrootfs.sh - creates a root file system | ||
4 | # | ||
5 | |||
6 | # TODO: need to add checks here to verify that busybox, uClibc and bzImage | ||
7 | # exist | ||
8 | |||
9 | |||
10 | # command-line settable variables | ||
11 | BUSYBOX_DIR=.. | ||
12 | UCLIBC_DIR=../../uClibc | ||
13 | TARGET_DIR=./loop | ||
14 | FSSIZE=4000 | ||
15 | CLEANUP=1 | ||
16 | MKFS='mkfs.ext2 -F' | ||
17 | |||
18 | # don't-touch variables | ||
19 | BASE_DIR=`pwd` | ||
20 | |||
21 | |||
22 | while getopts 'b:u:s:t:Cm' opt | ||
23 | do | ||
24 | case $opt in | ||
25 | b) BUSYBOX_DIR=$OPTARG ;; | ||
26 | u) UCLIBC_DIR=$OPTARG ;; | ||
27 | t) TARGET_DIR=$OPTARG ;; | ||
28 | s) FSSIZE=$OPTARG ;; | ||
29 | C) CLEANUP=0 ;; | ||
30 | m) MKFS='mkfs.minix' ;; | ||
31 | *) | ||
32 | echo "usage: `basename $0` [-bu]" | ||
33 | echo " -b DIR path to busybox direcory (default ..)" | ||
34 | echo " -u DIR path to uClibc direcory (default ../../uClibc)" | ||
35 | echo " -t DIR path to target direcory (default ./loop)" | ||
36 | echo " -s SIZE size of root filesystem in Kbytes (default 4000)" | ||
37 | echo " -C don't perform cleanup (umount target dir, gzip rootfs, etc.)" | ||
38 | echo " (this allows you to 'chroot loop/ /bin/sh' to test it)" | ||
39 | echo " -m use minix filesystem (default is ext2)" | ||
40 | exit 1 | ||
41 | ;; | ||
42 | esac | ||
43 | done | ||
44 | |||
45 | |||
46 | |||
47 | |||
48 | # clean up from any previous work | ||
49 | mount | grep -q loop | ||
50 | [ $? -eq 0 ] && umount $TARGET_DIR | ||
51 | [ -d $TARGET_DIR ] && rm -rf $TARGET_DIR/ | ||
52 | [ -f rootfs ] && rm -f rootfs | ||
53 | [ -f rootfs.gz ] && rm -f rootfs.gz | ||
54 | |||
55 | |||
56 | # prepare root file system and mount as loopback | ||
57 | dd if=/dev/zero of=rootfs bs=1k count=$FSSIZE | ||
58 | $MKFS -i 2000 rootfs | ||
59 | mkdir $TARGET_DIR | ||
60 | mount -o loop,exec rootfs $TARGET_DIR # must be root | ||
61 | |||
62 | |||
63 | # install uClibc | ||
64 | mkdir -p $TARGET_DIR/lib | ||
65 | cd $UCLIBC_DIR | ||
66 | make INSTALL_DIR= | ||
67 | cp -a libc.so* $BASE_DIR/$TARGET_DIR/lib | ||
68 | cp -a uClibc*.so $BASE_DIR/$TARGET_DIR/lib | ||
69 | cp -a ld.so-1/d-link/ld-linux-uclibc.so* $BASE_DIR/$TARGET_DIR/lib | ||
70 | cp -a ld.so-1/libdl/libdl.so* $BASE_DIR/$TARGET_DIR/lib | ||
71 | cp -a crypt/libcrypt.so* $BASE_DIR/$TARGET_DIR/lib | ||
72 | cd $BASE_DIR | ||
73 | |||
74 | |||
75 | # install busybox and components | ||
76 | cd $BUSYBOX_DIR | ||
77 | make distclean | ||
78 | make CC=$BASE_DIR/$UCLIBC_DIR/extra/gcc-uClibc/i386-uclibc-gcc | ||
79 | make PREFIX=$BASE_DIR/$TARGET_DIR install | ||
80 | cd $BASE_DIR | ||
81 | |||
82 | |||
83 | # make files in /dev | ||
84 | mkdir $TARGET_DIR/dev | ||
85 | ./mkdevs.sh $TARGET_DIR/dev | ||
86 | |||
87 | |||
88 | # make files in /etc | ||
89 | cp -a etc $TARGET_DIR | ||
90 | ln -s /proc/mounts $TARGET_DIR/etc/mtab | ||
91 | |||
92 | |||
93 | # other miscellaneous setup | ||
94 | mkdir $TARGET_DIR/initrd | ||
95 | mkdir $TARGET_DIR/proc | ||
96 | |||
97 | |||
98 | # Done. Maybe do cleanup. | ||
99 | if [ $CLEANUP -eq 1 ] | ||
100 | then | ||
101 | umount $TARGET_DIR | ||
102 | rmdir $TARGET_DIR | ||
103 | gzip -9 rootfs | ||
104 | fi | ||
105 | |||
diff --git a/examples/bootfloppy/mksyslinux.sh b/examples/bootfloppy/mksyslinux.sh new file mode 100755 index 000000000..e25417353 --- /dev/null +++ b/examples/bootfloppy/mksyslinux.sh | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # Formats a floppy to use Syslinux | ||
4 | |||
5 | dummy="" | ||
6 | |||
7 | |||
8 | # need to have mtools installed | ||
9 | if [ -z `which mformat` -o -z `which mcopy` ]; then | ||
10 | echo "You must have the mtools package installed to run this script" | ||
11 | exit 1 | ||
12 | fi | ||
13 | |||
14 | |||
15 | # need an arg for the location of the kernel | ||
16 | if [ -z "$1" ]; then | ||
17 | echo "usage: `basename $0` path/to/linux/kernel" | ||
18 | exit 1 | ||
19 | fi | ||
20 | |||
21 | |||
22 | # need to have a root file system built | ||
23 | if [ ! -f rootfs.gz ]; then | ||
24 | echo "You need to have a rootfs built first." | ||
25 | echo "Hit RETURN to make one now or Control-C to quit." | ||
26 | read dummy | ||
27 | ./mkrootfs.sh | ||
28 | fi | ||
29 | |||
30 | |||
31 | # prepare the floppy | ||
32 | echo "Please insert a blank floppy in the drive and press RETURN to format" | ||
33 | echo "(WARNING: All data will be erased! Hit Control-C to abort)" | ||
34 | read dummy | ||
35 | |||
36 | echo "Formatting the floppy..." | ||
37 | mformat a: | ||
38 | echo "Making it bootable with Syslinux..." | ||
39 | syslinux -s /dev/fd0 | ||
40 | echo "Copying Syslinux configuration files..." | ||
41 | mcopy syslinux.cfg display.txt a: | ||
42 | echo "Copying root filesystem file..." | ||
43 | mcopy rootfs.gz a: | ||
44 | # XXX: maybe check for "no space on device" errors here | ||
45 | echo "Copying linux kernel..." | ||
46 | mcopy $1 a:linux | ||
47 | # XXX: maybe check for "no space on device" errors here too | ||
48 | echo "Finished: boot floppy created" | ||
diff --git a/examples/bootfloppy/quickstart.txt b/examples/bootfloppy/quickstart.txt new file mode 100644 index 000000000..0d8090824 --- /dev/null +++ b/examples/bootfloppy/quickstart.txt | |||
@@ -0,0 +1,15 @@ | |||
1 | Quickstart on making the Busybox boot-floppy: | ||
2 | |||
3 | 1) Download Busybox and uClibc from CVS or tarballs. Make sure they share a | ||
4 | common parent directory. (i.e. busybox/ and uclibc/ are both right off of | ||
5 | /tmp, or wherever.) | ||
6 | |||
7 | 2) Build a Linux kernel. Make sure you include support for initrd. | ||
8 | |||
9 | 3) Put a floppy in the drive. Make sure it is a floppy you don't care about | ||
10 | because the contents will be overwritten. | ||
11 | |||
12 | 4) As root, type ./mksyslinux.sh path/to/linux/kernel from this directory. | ||
13 | Wait patiently while the magic happens. | ||
14 | |||
15 | 5) Boot up on the floppy. | ||
diff --git a/examples/bootfloppy/syslinux.cfg b/examples/bootfloppy/syslinux.cfg new file mode 100644 index 000000000..fa2677ca8 --- /dev/null +++ b/examples/bootfloppy/syslinux.cfg | |||
@@ -0,0 +1,7 @@ | |||
1 | display display.txt | ||
2 | default linux | ||
3 | timeout 10 | ||
4 | prompt 1 | ||
5 | label linux | ||
6 | kernel linux | ||
7 | append initrd=rootfs.gz root=/dev/ram0 | ||
diff --git a/examples/busybox.spec b/examples/busybox.spec new file mode 100644 index 000000000..3986436c1 --- /dev/null +++ b/examples/busybox.spec | |||
@@ -0,0 +1,44 @@ | |||
1 | %define name busybox | ||
2 | %define epoch 0 | ||
3 | %define version 0.61.pre | ||
4 | %define release %(date -I | sed -e 's/-/_/g') | ||
5 | %define serial 1 | ||
6 | |||
7 | Name: %{name} | ||
8 | #Epoch: %{epoch} | ||
9 | Version: %{version} | ||
10 | Release: %{release} | ||
11 | Serial: %{serial} | ||
12 | Copyright: GPL | ||
13 | Group: System/Utilities | ||
14 | Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. | ||
15 | URL: http://busybox.net/ | ||
16 | Source: ftp://busybox.net/busybox/%{name}-%{version}.tar.gz | ||
17 | Buildroot: /var/tmp/%{name}-%{version} | ||
18 | Packager : Erik Andersen <andersen@codepoet.org> | ||
19 | |||
20 | %Description | ||
21 | BusyBox combines tiny versions of many common UNIX utilities into a single | ||
22 | small executable. It provides minimalist replacements for most of the utilities | ||
23 | you usually find in fileutils, shellutils, findutils, textutils, grep, gzip, | ||
24 | tar, etc. BusyBox provides a fairly complete POSIX environment for any small | ||
25 | or emdedded system. The utilities in BusyBox generally have fewer options then | ||
26 | their full featured GNU cousins; however, the options that are provided behave | ||
27 | very much like their GNU counterparts. | ||
28 | |||
29 | %Prep | ||
30 | %setup -q -n %{name}-%{version} | ||
31 | |||
32 | %Build | ||
33 | make | ||
34 | |||
35 | %Install | ||
36 | rm -rf $RPM_BUILD_ROOT | ||
37 | make PREFIX=$RPM_BUILD_ROOT install | ||
38 | |||
39 | %Clean | ||
40 | rm -rf $RPM_BUILD_ROOT | ||
41 | |||
42 | %Files | ||
43 | %defattr(-,root,root) | ||
44 | / | ||
diff --git a/examples/depmod.pl b/examples/depmod.pl new file mode 100755 index 000000000..b2bf54713 --- /dev/null +++ b/examples/depmod.pl | |||
@@ -0,0 +1,289 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # vi: set sw=4 ts=4: | ||
3 | # Copyright (c) 2001 David Schleef <ds@schleef.org> | ||
4 | # Copyright (c) 2001 Erik Andersen <andersen@codepoet.org> | ||
5 | # Copyright (c) 2001 Stuart Hughes <seh@zee2.com> | ||
6 | # Copyright (c) 2002 Steven J. Hill <shill@broadcom.com> | ||
7 | # Copyright (c) 2006 Freescale Semiconductor, Inc <stuarth@freescale.com> | ||
8 | # | ||
9 | # History: | ||
10 | # March 2006: Stuart Hughes <stuarth@freescale.com>. | ||
11 | # Significant updates, including implementing the '-F' option | ||
12 | # and adding support for 2.6 kernels. | ||
13 | |||
14 | # This program is free software; you can redistribute it and/or modify it | ||
15 | # under the same terms as Perl itself. | ||
16 | use Getopt::Long; | ||
17 | use File::Find; | ||
18 | use strict; | ||
19 | |||
20 | # Set up some default values | ||
21 | my $kdir=""; | ||
22 | my $basedir=""; | ||
23 | my $kernel=""; | ||
24 | my $kernelsyms=""; | ||
25 | my $stdout=0; | ||
26 | my $verbose=0; | ||
27 | my $help=0; | ||
28 | my $nm = $ENV{'NM'} || "nm"; | ||
29 | |||
30 | # more globals | ||
31 | my (@liblist) = (); | ||
32 | my $exp = {}; | ||
33 | my $dep = {}; | ||
34 | my $mod = {}; | ||
35 | |||
36 | my $usage = <<TXT; | ||
37 | $0 -b basedir { -k <vmlinux> | -F <System.map> } [options]... | ||
38 | Where: | ||
39 | -h --help : Show this help screen | ||
40 | -b --basedir : Modules base directory (e.g /lib/modules/<2.x.y>) | ||
41 | -k --kernel : Kernel binary for the target (e.g. vmlinux) | ||
42 | -F --kernelsyms : Kernel symbol file (e.g. System.map) | ||
43 | -n --stdout : Write to stdout instead of <basedir>/modules.dep | ||
44 | -v --verbose : Print out lots of debugging stuff | ||
45 | TXT | ||
46 | |||
47 | # get command-line options | ||
48 | GetOptions( | ||
49 | "help|h" => \$help, | ||
50 | "basedir|b=s" => \$basedir, | ||
51 | "kernel|k=s" => \$kernel, | ||
52 | "kernelsyms|F=s" => \$kernelsyms, | ||
53 | "stdout|n" => \$stdout, | ||
54 | "verbose|v" => \$verbose, | ||
55 | ); | ||
56 | |||
57 | die $usage if $help; | ||
58 | die $usage unless $basedir && ( $kernel || $kernelsyms ); | ||
59 | die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms; | ||
60 | |||
61 | # Strip any trailing or multiple slashes from basedir | ||
62 | $basedir =~ s-(/)\1+-/-g; | ||
63 | |||
64 | # The base directory should contain /lib/modules somewhere | ||
65 | if($basedir !~ m-/lib/modules-) { | ||
66 | warn "WARNING: base directory does not match ..../lib/modules\n"; | ||
67 | } | ||
68 | |||
69 | # if no kernel version is contained in the basedir, try to find one | ||
70 | if($basedir !~ m-/lib/modules/\d\.\d-) { | ||
71 | opendir(BD, $basedir) or die "can't open basedir $basedir : $!\n"; | ||
72 | foreach ( readdir(BD) ) { | ||
73 | next if /^\.\.?$/; | ||
74 | next unless -d "$basedir/$_"; | ||
75 | warn "dir = $_\n" if $verbose; | ||
76 | if( /^\d\.\d/ ) { | ||
77 | $kdir = $_; | ||
78 | warn("Guessed module directory as $basedir/$kdir\n"); | ||
79 | last; | ||
80 | } | ||
81 | } | ||
82 | closedir(BD); | ||
83 | die "Cannot find a kernel version under $basedir\n" unless $kdir; | ||
84 | $basedir = "$basedir/$kdir"; | ||
85 | } | ||
86 | |||
87 | # Find the list of .o or .ko files living under $basedir | ||
88 | warn "**** Locating all modules\n" if $verbose; | ||
89 | find sub { | ||
90 | my $file; | ||
91 | if ( -f $_ && ! -d $_ ) { | ||
92 | $file = $File::Find::name; | ||
93 | if ( $file =~ /\.k?o$/ ) { | ||
94 | push(@liblist, $file); | ||
95 | warn "$file\n" if $verbose; | ||
96 | } | ||
97 | } | ||
98 | }, $basedir; | ||
99 | warn "**** Finished locating modules\n" if $verbose; | ||
100 | |||
101 | foreach my $obj ( @liblist ){ | ||
102 | # turn the input file name into a target tag name | ||
103 | my ($tgtname) = $obj =~ m-(/lib/modules/.*)$-; | ||
104 | |||
105 | warn "\nMODULE = $tgtname\n" if $verbose; | ||
106 | |||
107 | # get a list of symbols | ||
108 | my @output=`$nm $obj`; | ||
109 | |||
110 | build_ref_tables($tgtname, \@output, $exp, $dep); | ||
111 | } | ||
112 | |||
113 | |||
114 | # vmlinux is a special name that is only used to resolve symbols | ||
115 | my $tgtname = 'vmlinux'; | ||
116 | my @output = $kernelsyms ? `cat $kernelsyms` : `$nm $kernel`; | ||
117 | warn "\nMODULE = $tgtname\n" if $verbose; | ||
118 | build_ref_tables($tgtname, \@output, $exp, $dep); | ||
119 | |||
120 | # resolve the dependencies for each module | ||
121 | # reduce dependencies: remove unresolvable and resolved from vmlinux/System.map | ||
122 | # remove duplicates | ||
123 | foreach my $module (keys %$dep) { | ||
124 | warn "reducing module: $module\n" if $verbose; | ||
125 | $mod->{$module} = {}; | ||
126 | foreach (@{$dep->{$module}}) { | ||
127 | if( $exp->{$_} ) { | ||
128 | warn "resolved symbol $_ in file $exp->{$_}\n" if $verbose; | ||
129 | next if $exp->{$_} =~ /vmlinux/; | ||
130 | $mod->{$module}{$exp->{$_}} = 1; | ||
131 | } else { | ||
132 | warn "unresolved symbol $_ in file $module\n"; | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | # figure out where the output should go | ||
138 | if ($stdout == 0) { | ||
139 | open(STDOUT, ">$basedir/modules.dep") | ||
140 | or die "cannot open $basedir/modules.dep: $!"; | ||
141 | } | ||
142 | my $kseries = $basedir =~ m,/2\.6\.[^/]*, ? '2.6' : '2.4'; | ||
143 | |||
144 | foreach my $module ( keys %$mod ) { | ||
145 | if($kseries eq '2.4') { | ||
146 | print "$module:\t"; | ||
147 | my @sorted = sort bydep keys %{$mod->{$module}}; | ||
148 | print join(" \\\n\t",@sorted); | ||
149 | print "\n\n"; | ||
150 | } else { | ||
151 | print "$module: "; | ||
152 | my @sorted = sort bydep keys %{$mod->{$module}}; | ||
153 | print join(" ",@sorted); | ||
154 | print "\n"; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | |||
159 | sub build_ref_tables | ||
160 | { | ||
161 | my ($name, $sym_ar, $exp, $dep) = @_; | ||
162 | |||
163 | my $ksymtab = grep m/ __ksymtab/, @$sym_ar; | ||
164 | |||
165 | # gather the exported symbols | ||
166 | if($ksymtab){ | ||
167 | # explicitly exported | ||
168 | foreach ( @$sym_ar ) { | ||
169 | / __ksymtab_(.*)$/ and do { | ||
170 | warn "sym = $1\n" if $verbose; | ||
171 | $exp->{$1} = $name; | ||
172 | }; | ||
173 | } | ||
174 | } else { | ||
175 | # exporting all symbols | ||
176 | foreach ( @$sym_ar ) { | ||
177 | / [ABCDGRST] (.*)$/ and do { | ||
178 | warn "syma = $1\n" if $verbose; | ||
179 | $exp->{$1} = $name; | ||
180 | }; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | # this takes makes sure modules with no dependencies get listed | ||
185 | push @{$dep->{$name}}, 'printk' unless $name eq 'vmlinux'; | ||
186 | |||
187 | # gather the unresolved symbols | ||
188 | foreach ( @$sym_ar ) { | ||
189 | !/ __this_module/ && / U (.*)$/ and do { | ||
190 | warn "und = $1\n" if $verbose; | ||
191 | push @{$dep->{$name}}, $1; | ||
192 | }; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | sub bydep | ||
197 | { | ||
198 | foreach my $f ( keys %{$mod->{$b}} ) { | ||
199 | if($f eq $a) { | ||
200 | return 1; | ||
201 | } | ||
202 | } | ||
203 | return -1; | ||
204 | } | ||
205 | |||
206 | |||
207 | |||
208 | __END__ | ||
209 | |||
210 | =head1 NAME | ||
211 | |||
212 | depmod.pl - a cross platform script to generate kernel module | ||
213 | dependency lists (modules.conf) which can then be used by modprobe | ||
214 | on the target platform. | ||
215 | |||
216 | It supports Linux 2.4 and 2.6 styles of modules.conf (auto-detected) | ||
217 | |||
218 | =head1 SYNOPSIS | ||
219 | |||
220 | depmod.pl [OPTION]... [basedir]... | ||
221 | |||
222 | Example: | ||
223 | |||
224 | depmod.pl -F linux/System.map -b target/lib/modules/2.6.11 | ||
225 | |||
226 | =head1 DESCRIPTION | ||
227 | |||
228 | The purpose of this script is to automagically generate a list of of kernel | ||
229 | module dependencies. This script produces dependency lists that should be | ||
230 | identical to the depmod program from the modutils package. Unlike the depmod | ||
231 | binary, however, depmod.pl is designed to be run on your host system, not | ||
232 | on your target system. | ||
233 | |||
234 | This script was written by David Schleef <ds@schleef.org> to be used in | ||
235 | conjunction with the BusyBox modprobe applet. | ||
236 | |||
237 | =head1 OPTIONS | ||
238 | |||
239 | =over 4 | ||
240 | |||
241 | =item B<-h --help> | ||
242 | |||
243 | This displays the help message. | ||
244 | |||
245 | =item B<-b --basedir> | ||
246 | |||
247 | The base directory uner which the target's modules will be found. This | ||
248 | defaults to the /lib/modules directory. | ||
249 | |||
250 | If you don't specify the kernel version, this script will search for | ||
251 | one under the specified based directory and use the first thing that | ||
252 | looks like a kernel version. | ||
253 | |||
254 | =item B<-k --kernel> | ||
255 | |||
256 | Kernel binary for the target (vmlinux). You must either supply a kernel binary | ||
257 | or a kernel symbol file (using the -F option). | ||
258 | |||
259 | =item B<-F --kernelsyms> | ||
260 | |||
261 | Kernel symbol file for the target (System.map). | ||
262 | |||
263 | =item B<-n --stdout> | ||
264 | |||
265 | Write to stdout instead of modules.dep | ||
266 | kernel binary for the target (using the -k option). | ||
267 | |||
268 | =item B<--verbose> | ||
269 | |||
270 | Verbose (debug) output | ||
271 | |||
272 | =back | ||
273 | |||
274 | =head1 COPYRIGHT AND LICENSE | ||
275 | |||
276 | Copyright (c) 2001 David Schleef <ds@schleef.org> | ||
277 | Copyright (c) 2001 Erik Andersen <andersen@codepoet.org> | ||
278 | Copyright (c) 2001 Stuart Hughes <seh@zee2.com> | ||
279 | Copyright (c) 2002 Steven J. Hill <shill@broadcom.com> | ||
280 | Copyright (c) 2006 Freescale Semiconductor, Inc <stuarth@freescale.com> | ||
281 | |||
282 | This program is free software; you can redistribute it and/or modify it | ||
283 | under the same terms as Perl itself. | ||
284 | |||
285 | =head1 AUTHOR | ||
286 | |||
287 | David Schleef <ds@schleef.org> | ||
288 | |||
289 | =cut | ||
diff --git a/examples/devfsd.conf b/examples/devfsd.conf new file mode 100644 index 000000000..e90e7102b --- /dev/null +++ b/examples/devfsd.conf | |||
@@ -0,0 +1,133 @@ | |||
1 | # Sample /etc/devfsd.conf configuration file. | ||
2 | # Richard Gooch <rgooch@atnf.csiro.au> 17-FEB-2002 | ||
3 | # | ||
4 | # adapted for busybox devfsd implementation by Tito <farmatito@tiscali.it> | ||
5 | # | ||
6 | # Enable full compatibility mode for old device names. You may comment these | ||
7 | # out if you don't use the old device names. Make sure you know what you're | ||
8 | # doing! | ||
9 | REGISTER .* MKOLDCOMPAT | ||
10 | UNREGISTER .* RMOLDCOMPAT | ||
11 | |||
12 | # You may comment out the above and uncomment the following if you've | ||
13 | # configured your system to use the original "new" devfs names or the really | ||
14 | # new names | ||
15 | #REGISTER ^vc/ MKOLDCOMPAT | ||
16 | #UNREGISTER ^vc/ RMOLDCOMPAT | ||
17 | #REGISTER ^pty/ MKOLDCOMPAT | ||
18 | #UNREGISTER ^pty/ RMOLDCOMPAT | ||
19 | #REGISTER ^misc/ MKOLDCOMPAT | ||
20 | #UNREGISTER ^misc/ RMOLDCOMPAT | ||
21 | |||
22 | # You may comment these out if you don't use the original "new" names | ||
23 | REGISTER .* MKNEWCOMPAT | ||
24 | UNREGISTER .* RMNEWCOMPAT | ||
25 | |||
26 | # Enable module autoloading. You may comment this out if you don't use | ||
27 | # autoloading | ||
28 | # Supported by busybox when CONFIG_DEVFSD_MODLOAD is set. | ||
29 | # This actually doesn't work with busybox modutils but needs | ||
30 | # the real modutils' modprobe | ||
31 | LOOKUP .* MODLOAD | ||
32 | |||
33 | # Uncomment the following if you want to set the group to "tty" for the | ||
34 | # pseudo-tty devices. This is necessary so that mesg(1) can later be used to | ||
35 | # enable/disable talk requests and wall(1) messages. | ||
36 | REGISTER ^pty/s.* PERMISSIONS -1.tty 0600 | ||
37 | #REGISTER ^pts/.* PERMISSIONS -1.tty 0600 | ||
38 | |||
39 | # Restoring /dev/log on startup would trigger the minilogd/initlog deadlock | ||
40 | # (minilogd falsely assuming syslogd has been started). | ||
41 | REGISTER ^log$ IGNORE | ||
42 | CREATE ^log$ IGNORE | ||
43 | CHANGE ^log$ IGNORE | ||
44 | DELETE ^log$ IGNORE | ||
45 | |||
46 | # | ||
47 | # Uncomment this if you want permissions to be saved and restored | ||
48 | # Do not do this for pseudo-terminal devices | ||
49 | REGISTER ^pt[sy] IGNORE | ||
50 | CREATE ^pt[sy] IGNORE | ||
51 | CHANGE ^pt[sy] IGNORE | ||
52 | DELETE ^pt[sy] IGNORE | ||
53 | REGISTER .* COPY /lib/dev-state/$devname $devpath | ||
54 | CREATE .* COPY $devpath /lib/dev-state/$devname | ||
55 | CHANGE .* COPY $devpath /lib/dev-state/$devname | ||
56 | #DELETE .* CFUNCTION GLOBAL unlink /lib/dev-state/$devname | ||
57 | # Busybox | ||
58 | DELETE .* EXECUTE /bin/rm -f /lib/dev-state/$devname | ||
59 | |||
60 | RESTORE /lib/dev-state | ||
61 | |||
62 | # | ||
63 | # Uncomment this if you want the old /dev/cdrom symlink | ||
64 | #REGISTER ^cdroms/cdrom0$ CFUNCTION GLOBAL mksymlink $devname cdrom | ||
65 | #UNREGISTER ^cdroms/cdrom0$ CFUNCTION GLOBAL unlink cdrom | ||
66 | # busybox | ||
67 | REGISTER ^cdroms/cdrom0$ EXECUTE /bin/ln -sf $devname cdrom | ||
68 | UNREGISTER ^cdroms/cdrom0$ EXECUTE /bin/rm -f cdrom | ||
69 | |||
70 | #REGISTER ^v4l/video0$ CFUNCTION GLOBAL mksymlink v4l/video0 video | ||
71 | #UNREGISTER ^v4l/video0$ CFUNCTION GLOBAL unlink video | ||
72 | #REGISTER ^radio0$ CFUNCTION GLOBAL mksymlink radio0 radio | ||
73 | #UNREGISTER ^radio0$ CFUNCTION GLOBAL unlink radio | ||
74 | # Busybox | ||
75 | REGISTER ^v4l/video0$ EXECUTE /bin/ln -sf v4l/video0 video | ||
76 | UNREGISTER ^v4l/video0$ EXECUTE /bin/rm -f video | ||
77 | REGISTER ^radio0$ EXECUTE /bin/ln -sf radio0 radio | ||
78 | UNREGISTER ^radio0$ EXECUTE /bin/rm -f radio | ||
79 | |||
80 | # ALSA stuff | ||
81 | #LOOKUP snd MODLOAD ACTION snd | ||
82 | |||
83 | # Uncomment this to let PAM manage devfs | ||
84 | # Not supported by busybox | ||
85 | #REGISTER .* CFUNCTION /lib/security/pam_console_apply_devfsd.so pam_console_apply_single $devpath | ||
86 | |||
87 | # Uncomment this to manage USB mouse | ||
88 | # Not supported by busybox | ||
89 | #REGISTER ^input/mouse0$ CFUNCTION GLOBAL mksymlink $devname usbmouse | ||
90 | #UNREGISTER ^input/mouse0$ CFUNCTION GLOBAL unlink usbmouse | ||
91 | # Busybox | ||
92 | #REGISTER ^input/mouse0$ EXECUTE /bin/ln -sf $devname usbmouse | ||
93 | #UNREGISTER ^input/mouse0$ EXECUTE /bin/rm -f usbmouse | ||
94 | # Not supported by busybox | ||
95 | #REGISTER ^input/mice$ CFUNCTION GLOBAL mksymlink $devname usbmouse | ||
96 | #UNREGISTER ^input/mice$ CFUNCTION GLOBAL unlink usbmouse | ||
97 | # Busybox | ||
98 | REGISTER ^input/mice$ EXECUTE /bin/ln -sf $devname usbmouse | ||
99 | UNREGISTER ^input/mice$ EXECUTE /bin/rm -f usbmouse | ||
100 | |||
101 | # If you have removable media and want to force media revalidation when looking | ||
102 | # up new or old compatibility names, uncomment the following lines | ||
103 | # SCSI NEWCOMPAT /dev/sd/* names | ||
104 | 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 | ||
105 | # SCSI OLDCOMPAT /dev/sd?? names | ||
106 | LOOKUP ^(sd[a-z]+)[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 | ||
107 | # IDE NEWCOMPAT /dev/ide/hd/* names | ||
108 | 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 | ||
109 | # IDE OLDCOMPAT /dev/hd?? names | ||
110 | LOOKUP ^(hd[a-z])[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 | ||
111 | # IDE-SCSI NEWCOMPAT /dev/sd/* names | ||
112 | #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 | ||
113 | #SCSI OLDCOMPAT /dev/scd? names | ||
114 | LOOKUP ^(scd+)[0-9]+$ EXECUTE /bin/dd if=$mntpnt/\1 of=/dev/null count=1 | ||
115 | |||
116 | |||
117 | REGISTER ^dvb/card[0-9]+/[^/]+$ PERMISSIONS root.video 0660 | ||
118 | # Not supported by busybox | ||
119 | #REGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ CFUNCTION GLOBAL mksymlink /dev/$devname ost/\2\1 | ||
120 | #UNREGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ CFUNCTION GLOBAL unlink ost/\2\1 | ||
121 | # Busybox | ||
122 | REGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ EXECUTE /bin/ln -sf /dev/$devname ost/\2\1 | ||
123 | UNREGISTER ^dvb/card([0-9]+)/([^/0-9]*)[0-9]+$ EXECUTE /bin/rm -f ost/\2\1 | ||
124 | |||
125 | # Include package-generated files from /etc/devfs/conf.d | ||
126 | # Supported by busybox | ||
127 | # INCLUDE /etc/devfs/conf.d/ | ||
128 | INCLUDE /etc/devfs/busybox/ | ||
129 | # Busybox: just for testing | ||
130 | #INCLUDE /etc/devfs/nothing/ | ||
131 | #INCLUDE /etc/devfs/nothing/nothing | ||
132 | #OPTIONAL_INCLUDE /etc/devfs/nothing/ | ||
133 | #OPTIONAL_INCLUDE /etc/devfs/nothing/nothing | ||
diff --git a/examples/dnsd.conf b/examples/dnsd.conf new file mode 100644 index 000000000..8af622b02 --- /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 000000000..ca7e3d8e1 --- /dev/null +++ b/examples/inetd.conf | |||
@@ -0,0 +1,73 @@ | |||
1 | # /etc/inetd.conf: see inetd(8) for further informations. | ||
2 | # | ||
3 | # Internet server configuration database | ||
4 | # | ||
5 | # | ||
6 | # If you want to disable an entry so it isn't touched during | ||
7 | # package updates just comment it out with a single '#' character. | ||
8 | # | ||
9 | # If you make changes to this file, either reboot your machine or | ||
10 | # send the inetd process a HUP signal: | ||
11 | # Do a "ps x" as root and look up the pid of inetd. Then do a | ||
12 | # kill -HUP <pid of inetd> | ||
13 | # inetd will re-read this file whenever it gets that signal. | ||
14 | # <service_name> <sock_type> <proto> <flags> <user> <server_path> <args> | ||
15 | # | ||
16 | #:INTERNAL: Internal services | ||
17 | # It is generally considered safer to keep these off. | ||
18 | echo stream tcp nowait root internal | ||
19 | echo dgram udp wait root internal | ||
20 | #discard stream tcp nowait root internal | ||
21 | #discard dgram udp wait root internal | ||
22 | daytime stream tcp nowait root internal | ||
23 | daytime dgram udp wait root internal | ||
24 | #chargen stream tcp nowait root internal | ||
25 | #chargen dgram udp wait root internal | ||
26 | time stream tcp nowait root internal | ||
27 | time dgram udp wait root internal | ||
28 | |||
29 | # These are standard services. | ||
30 | # | ||
31 | #ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd | ||
32 | #telnet stream tcp nowait root /sbin/telnetd /sbin/telnetd | ||
33 | #nntp stream tcp nowait root tcpd in.nntpd | ||
34 | #smtp stream tcp nowait root tcpd sendmail -v | ||
35 | # | ||
36 | # Shell, login, exec and talk are BSD protocols. | ||
37 | # | ||
38 | # If you run an ntalk daemon (such as netkit-ntalk) on the old talk | ||
39 | # port, that is, "talk" as opposed to "ntalk", it won't work and may | ||
40 | # cause certain broken talk clients to malfunction. | ||
41 | # | ||
42 | # The talkd from netkit-ntalk 0.12 and higher, however, can speak the | ||
43 | # old talk protocol and can be used safely. | ||
44 | # | ||
45 | #shell stream tcp nowait root /usr/sbin/tcpd in.rshd -L | ||
46 | #login stream tcp nowait root /usr/sbin/tcpd in.rlogind -L | ||
47 | #exec stream tcp nowait root /usr/sbin/tcpd in.rexecd | ||
48 | #talk dgram udp wait root /usr/sbin/tcpd in.talkd | ||
49 | #ntalk dgram udp wait root /usr/sbin/tcpd in.talkd | ||
50 | # | ||
51 | # Pop et al | ||
52 | # Leave these off unless you're using them. | ||
53 | #pop2 stream tcp nowait root /usr/sbin/tcpd in.pop2d | ||
54 | #pop3 stream tcp nowait root /usr/sbin/tcpd in.pop3d | ||
55 | # | ||
56 | # The Internet UUCP service. | ||
57 | # uucp stream tcp nowait uucp /usr/sbin/tcpd /usr/lib/uucp/uucico -l | ||
58 | # | ||
59 | # Tftp service is provided primarily for booting. Most sites | ||
60 | # run this only on machines acting as "boot servers." If you don't | ||
61 | # need it, don't use it. | ||
62 | # | ||
63 | #tftp dgram udp wait nobody /usr/sbin/tcpd in.tftpd | ||
64 | #bootps dgram udp wait root /usr/sbin/in.bootpd in.bootpd | ||
65 | # | ||
66 | # Finger, systat and netstat give out user information which may be | ||
67 | # valuable to potential "system crackers." Many sites choose to disable | ||
68 | # some or all of these services to improve security. | ||
69 | # | ||
70 | #finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd -w | ||
71 | #systat stream tcp nowait nobody /usr/sbin/tcpd /bin/ps -auwwx | ||
72 | #netstat stream tcp nowait root /bin/netstat /bin/netstat -a | ||
73 | #ident stream tcp nowait root /usr/sbin/in.identd in.identd | ||
diff --git a/examples/inittab b/examples/inittab new file mode 100644 index 000000000..5f2af8724 --- /dev/null +++ b/examples/inittab | |||
@@ -0,0 +1,90 @@ | |||
1 | # /etc/inittab init(8) configuration for BusyBox | ||
2 | # | ||
3 | # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
4 | # | ||
5 | # | ||
6 | # Note, BusyBox init doesn't support runlevels. The runlevels field is | ||
7 | # completely ignored by BusyBox init. If you want runlevels, use sysvinit. | ||
8 | # | ||
9 | # | ||
10 | # Format for each entry: <id>:<runlevels>:<action>:<process> | ||
11 | # | ||
12 | # <id>: WARNING: This field has a non-traditional meaning for BusyBox init! | ||
13 | # | ||
14 | # The id field is used by BusyBox init to specify the controlling tty for | ||
15 | # the specified process to run on. The contents of this field are | ||
16 | # appended to "/dev/" and used as-is. There is no need for this field to | ||
17 | # be unique, although if it isn't you may have strange results. If this | ||
18 | # field is left blank, it is completely ignored. Also note that if | ||
19 | # BusyBox detects that a serial console is in use, then all entries | ||
20 | # containing non-empty id fields will be ignored. BusyBox init does | ||
21 | # nothing with utmp. We don't need no stinkin' utmp. | ||
22 | # | ||
23 | # <runlevels>: The runlevels field is completely ignored. | ||
24 | # | ||
25 | # <action>: Valid actions include: sysinit, respawn, askfirst, wait, once, | ||
26 | # restart, ctrlaltdel, and shutdown. | ||
27 | # | ||
28 | # Note: askfirst acts just like respawn, but before running the specified | ||
29 | # process it displays the line "Please press Enter to activate this | ||
30 | # console." and then waits for the user to press enter before starting | ||
31 | # the specified process. | ||
32 | # | ||
33 | # Note: unrecognised actions (like initdefault) will cause init to emit | ||
34 | # an error message, and then go along with its business. | ||
35 | # | ||
36 | # <process>: Specifies the process to be executed and it's command line. | ||
37 | # | ||
38 | # Note: BusyBox init works just fine without an inittab. If no inittab is | ||
39 | # found, it has the following default behavior: | ||
40 | # ::sysinit:/etc/init.d/rcS | ||
41 | # ::askfirst:/bin/sh | ||
42 | # ::ctrlaltdel:/sbin/reboot | ||
43 | # ::shutdown:/sbin/swapoff -a | ||
44 | # ::shutdown:/bin/umount -a -r | ||
45 | # ::restart:/sbin/init | ||
46 | # | ||
47 | # if it detects that /dev/console is _not_ a serial console, it will | ||
48 | # also run: | ||
49 | # tty2::askfirst:/bin/sh | ||
50 | # tty3::askfirst:/bin/sh | ||
51 | # tty4::askfirst:/bin/sh | ||
52 | # | ||
53 | # Boot-time system configuration/initialization script. | ||
54 | # This is run first except when booting in single-user mode. | ||
55 | # | ||
56 | ::sysinit:/etc/init.d/rcS | ||
57 | |||
58 | # /bin/sh invocations on selected ttys | ||
59 | # | ||
60 | # Note below that we prefix the shell commands with a "-" to indicate to the | ||
61 | # shell that it is supposed to be a login shell. Normally this is handled by | ||
62 | # login, but since we are bypassing login in this case, BusyBox lets you do | ||
63 | # this yourself... | ||
64 | # | ||
65 | # Start an "askfirst" shell on the console (whatever that may be) | ||
66 | ::askfirst:-/bin/sh | ||
67 | # Start an "askfirst" shell on /dev/tty2-4 | ||
68 | tty2::askfirst:-/bin/sh | ||
69 | tty3::askfirst:-/bin/sh | ||
70 | tty4::askfirst:-/bin/sh | ||
71 | |||
72 | # /sbin/getty invocations for selected ttys | ||
73 | tty4::respawn:/sbin/getty 38400 tty5 | ||
74 | tty5::respawn:/sbin/getty 38400 tty6 | ||
75 | |||
76 | # Example of how to put a getty on a serial line (for a terminal) | ||
77 | #::respawn:/sbin/getty -L ttyS0 9600 vt100 | ||
78 | #::respawn:/sbin/getty -L ttyS1 9600 vt100 | ||
79 | # | ||
80 | # Example how to put a getty on a modem line. | ||
81 | #::respawn:/sbin/getty 57600 ttyS2 | ||
82 | |||
83 | # Stuff to do when restarting the init process | ||
84 | ::restart:/sbin/init | ||
85 | |||
86 | # Stuff to do before rebooting | ||
87 | ::ctrlaltdel:/sbin/reboot | ||
88 | ::shutdown:/bin/umount -a -r | ||
89 | ::shutdown:/sbin/swapoff -a | ||
90 | |||
diff --git a/examples/mk2knr.pl b/examples/mk2knr.pl new file mode 100755 index 000000000..1259b8436 --- /dev/null +++ b/examples/mk2knr.pl | |||
@@ -0,0 +1,84 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # @(#) mk2knr.pl - generates a perl script that converts lexemes to K&R-style | ||
4 | # | ||
5 | # How to use this script: | ||
6 | # - In the busybox directory type 'examples/mk2knr.pl files-to-convert' | ||
7 | # - Review the 'convertme.pl' script generated and remove / edit any of the | ||
8 | # substitutions in there (please especially check for false positives) | ||
9 | # - Type './convertme.pl same-files-as-before' | ||
10 | # - Compile and see if it works | ||
11 | # | ||
12 | # BUGS: This script does not ignore strings inside comments or strings inside | ||
13 | # quotes (it probably should). | ||
14 | |||
15 | # set this to something else if you want | ||
16 | $convertme = 'convertme.pl'; | ||
17 | |||
18 | # internal-use variables (don't touch) | ||
19 | $convert = 0; | ||
20 | %converted = (); | ||
21 | |||
22 | # if no files were specified, print usage | ||
23 | die "usage: $0 file.c | file.h\n" if scalar(@ARGV) == 0; | ||
24 | |||
25 | # prepare the "convert me" file | ||
26 | open(CM, ">$convertme") or die "convertme.pl $!"; | ||
27 | print CM "#!/usr/bin/perl -p -i\n\n"; | ||
28 | |||
29 | # process each file passed on the cmd line | ||
30 | while (<>) { | ||
31 | |||
32 | # if the line says "getopt" in it anywhere, we don't want to muck with it | ||
33 | # because option lists tend to include strings like "cxtzvOf:" which get | ||
34 | # matched by the "check for mixed case" regexps below | ||
35 | next if /getopt/; | ||
36 | |||
37 | # tokenize the string into just the variables | ||
38 | while (/([a-zA-Z_][a-zA-Z0-9_]*)/g) { | ||
39 | $var = $1; | ||
40 | |||
41 | # ignore the word "BusyBox" | ||
42 | next if ($var =~ /BusyBox/); | ||
43 | |||
44 | # this checks for javaStyle or szHungarianNotation | ||
45 | $convert++ if ($var =~ /^[a-z]+[A-Z][a-z]+/); | ||
46 | |||
47 | # this checks for PascalStyle | ||
48 | $convert++ if ($var =~ /^[A-Z][a-z]+[A-Z][a-z]+/); | ||
49 | |||
50 | # if we want to add more checks, we can add 'em here, but the above | ||
51 | # checks catch "just enough" and not too much, so prolly not. | ||
52 | |||
53 | if ($convert) { | ||
54 | $convert = 0; | ||
55 | |||
56 | # skip ahead if we've already dealt with this one | ||
57 | next if ($converted{$var}); | ||
58 | |||
59 | # record that we've dealt with this var | ||
60 | $converted{$var} = 1; | ||
61 | |||
62 | print CM "s/\\b$var\\b/"; # more to come in just a minute | ||
63 | |||
64 | # change the first letter to lower-case | ||
65 | $var = lcfirst($var); | ||
66 | |||
67 | # put underscores before all remaining upper-case letters | ||
68 | $var =~ s/([A-Z])/_$1/g; | ||
69 | |||
70 | # now change the remaining characters to lower-case | ||
71 | $var = lc($var); | ||
72 | |||
73 | print CM "$var/g;\n"; | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | # tidy up and make the $convertme script executable | ||
79 | close(CM); | ||
80 | chmod 0755, $convertme; | ||
81 | |||
82 | # print a helpful help message | ||
83 | print "Done. Scheduled name changes are in $convertme.\n"; | ||
84 | 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 000000000..2a95d8b7d --- /dev/null +++ b/examples/udhcp/sample.bound | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/sh | ||
2 | # Sample udhcpc renew script | ||
3 | |||
4 | RESOLV_CONF="/etc/udhcpc/resolv.conf" | ||
5 | |||
6 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | ||
7 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | ||
8 | |||
9 | /sbin/ifconfig $interface $ip $BROADCAST $NETMASK | ||
10 | |||
11 | if [ -n "$router" ] | ||
12 | then | ||
13 | echo "deleting routers" | ||
14 | while /sbin/route del default gw 0.0.0.0 dev $interface | ||
15 | do : | ||
16 | done | ||
17 | |||
18 | metric=0 | ||
19 | for i in $router | ||
20 | do | ||
21 | /sbin/route add default gw $i dev $interface metric $((metric++)) | ||
22 | done | ||
23 | fi | ||
24 | |||
25 | echo -n > $RESOLV_CONF | ||
26 | [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF | ||
27 | for i in $dns | ||
28 | do | ||
29 | echo adding dns $i | ||
30 | echo nameserver $i >> $RESOLV_CONF | ||
31 | done \ No newline at end of file | ||
diff --git a/examples/udhcp/sample.deconfig b/examples/udhcp/sample.deconfig new file mode 100755 index 000000000..b221bcf12 --- /dev/null +++ b/examples/udhcp/sample.deconfig | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | # Sample udhcpc deconfig script | ||
3 | |||
4 | /sbin/ifconfig $interface 0.0.0.0 | ||
diff --git a/examples/udhcp/sample.nak b/examples/udhcp/sample.nak new file mode 100755 index 000000000..f4d08e669 --- /dev/null +++ b/examples/udhcp/sample.nak | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | # Sample udhcpc nak script | ||
3 | |||
4 | echo Received a NAK: $message | ||
diff --git a/examples/udhcp/sample.renew b/examples/udhcp/sample.renew new file mode 100755 index 000000000..842bafe91 --- /dev/null +++ b/examples/udhcp/sample.renew | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/sh | ||
2 | # Sample udhcpc bound script | ||
3 | |||
4 | RESOLV_CONF="/etc/udhcpc/resolv.conf" | ||
5 | |||
6 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | ||
7 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | ||
8 | |||
9 | /sbin/ifconfig $interface $ip $BROADCAST $NETMASK | ||
10 | |||
11 | if [ -n "$router" ] | ||
12 | then | ||
13 | echo "deleting routers" | ||
14 | while /sbin/route del default gw 0.0.0.0 dev $interface | ||
15 | do : | ||
16 | done | ||
17 | |||
18 | metric=0 | ||
19 | for i in $router | ||
20 | do | ||
21 | /sbin/route add default gw $i dev $interface metric $((metric++)) | ||
22 | done | ||
23 | fi | ||
24 | |||
25 | echo -n > $RESOLV_CONF | ||
26 | [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF | ||
27 | for i in $dns | ||
28 | do | ||
29 | echo adding dns $i | ||
30 | echo nameserver $i >> $RESOLV_CONF | ||
31 | done \ No newline at end of file | ||
diff --git a/examples/udhcp/sample.script b/examples/udhcp/sample.script new file mode 100644 index 000000000..9b717ac3c --- /dev/null +++ b/examples/udhcp/sample.script | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | # Currently, we only dispatch according to command. However, a more | ||
3 | # elaborate system might dispatch by command and interface or do some | ||
4 | # common initialization first, especially if more dhcp event notifications | ||
5 | # are added. | ||
6 | |||
7 | exec /usr/share/udhcpc/sample.$1 | ||
diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script new file mode 100644 index 000000000..98ebc159f --- /dev/null +++ b/examples/udhcp/simple.script | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # udhcpc script edited by Tim Riker <Tim@Rikers.org> | ||
4 | |||
5 | [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 | ||
6 | |||
7 | RESOLV_CONF="/etc/resolv.conf" | ||
8 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | ||
9 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | ||
10 | |||
11 | case "$1" in | ||
12 | deconfig) | ||
13 | /sbin/ifconfig $interface 0.0.0.0 | ||
14 | ;; | ||
15 | |||
16 | renew|bound) | ||
17 | /sbin/ifconfig $interface $ip $BROADCAST $NETMASK | ||
18 | |||
19 | if [ -n "$router" ] ; then | ||
20 | echo "deleting routers" | ||
21 | while route del default gw 0.0.0.0 dev $interface ; do | ||
22 | : | ||
23 | done | ||
24 | |||
25 | metric=0 | ||
26 | for i in $router ; do | ||
27 | route add default gw $i dev $interface metric $((metric++)) | ||
28 | done | ||
29 | fi | ||
30 | |||
31 | echo -n > $RESOLV_CONF | ||
32 | [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF | ||
33 | for i in $dns ; do | ||
34 | echo adding dns $i | ||
35 | echo nameserver $i >> $RESOLV_CONF | ||
36 | done | ||
37 | ;; | ||
38 | esac | ||
39 | |||
40 | exit 0 | ||
diff --git a/examples/udhcp/udhcpd.conf b/examples/udhcp/udhcpd.conf new file mode 100644 index 000000000..f91fddebf --- /dev/null +++ b/examples/udhcp/udhcpd.conf | |||
@@ -0,0 +1,123 @@ | |||
1 | # Sample udhcpd configuration file (/etc/udhcpd.conf) | ||
2 | |||
3 | # The start and end of the IP lease block | ||
4 | |||
5 | start 192.168.0.20 #default: 192.168.0.20 | ||
6 | end 192.168.0.254 #default: 192.168.0.254 | ||
7 | |||
8 | |||
9 | # The interface that udhcpd will use | ||
10 | |||
11 | interface eth0 #default: eth0 | ||
12 | |||
13 | |||
14 | # The maximim number of leases (includes addressesd reserved | ||
15 | # by OFFER's, DECLINE's, and ARP conficts | ||
16 | |||
17 | #max_leases 254 #default: 254 | ||
18 | |||
19 | |||
20 | # If remaining is true (default), udhcpd will store the time | ||
21 | # remaining for each lease in the udhcpd leases file. This is | ||
22 | # for embedded systems that cannot keep time between reboots. | ||
23 | # If you set remaining to no, the absolute time that the lease | ||
24 | # expires at will be stored in the dhcpd.leases file. | ||
25 | |||
26 | #remaining yes #default: yes | ||
27 | |||
28 | |||
29 | # The time period at which udhcpd will write out a dhcpd.leases | ||
30 | # file. If this is 0, udhcpd will never automatically write a | ||
31 | # lease file. (specified in seconds) | ||
32 | |||
33 | #auto_time 7200 #default: 7200 (2 hours) | ||
34 | |||
35 | |||
36 | # The amount of time that an IP will be reserved (leased) for if a | ||
37 | # DHCP decline message is received (seconds). | ||
38 | |||
39 | #decline_time 3600 #default: 3600 (1 hour) | ||
40 | |||
41 | |||
42 | # The amount of time that an IP will be reserved (leased) for if an | ||
43 | # ARP conflct occurs. (seconds | ||
44 | |||
45 | #conflict_time 3600 #default: 3600 (1 hour) | ||
46 | |||
47 | |||
48 | # How long an offered address is reserved (leased) in seconds | ||
49 | |||
50 | #offer_time 60 #default: 60 (1 minute) | ||
51 | |||
52 | # If a lease to be given is below this value, the full lease time is | ||
53 | # instead used (seconds). | ||
54 | |||
55 | #min_lease 60 #defult: 60 | ||
56 | |||
57 | |||
58 | # The location of the leases file | ||
59 | |||
60 | #lease_file /var/lib/misc/udhcpd.leases #defualt: /var/lib/misc/udhcpd.leases | ||
61 | |||
62 | # The location of the pid file | ||
63 | #pidfile /var/run/udhcpd.pid #default: /var/run/udhcpd.pid | ||
64 | |||
65 | # Everytime udhcpd writes a leases file, the below script will be called. | ||
66 | # Useful for writing the lease file to flash every few hours. | ||
67 | |||
68 | #notify_file #default: (no script) | ||
69 | |||
70 | #notify_file dumpleases # <--- usefull for debugging | ||
71 | |||
72 | # The following are bootp specific options, setable by udhcpd. | ||
73 | |||
74 | #siaddr 192.168.0.22 #default: 0.0.0.0 | ||
75 | |||
76 | #sname zorak #default: (none) | ||
77 | |||
78 | #boot_file /var/nfs_root #default: (none) | ||
79 | |||
80 | # The remainer of options are DHCP options and can be specifed with the | ||
81 | # keyword 'opt' or 'option'. If an option can take multiple items, such | ||
82 | # as the dns option, they can be listed on the same line, or multiple | ||
83 | # lines. The only option with a default is 'lease'. | ||
84 | |||
85 | #Examles | ||
86 | opt dns 192.168.10.2 192.168.10.10 | ||
87 | option subnet 255.255.255.0 | ||
88 | opt router 192.168.10.2 | ||
89 | opt wins 192.168.10.10 | ||
90 | option dns 129.219.13.81 # appened to above DNS servers for a total of 3 | ||
91 | option domain local | ||
92 | option lease 864000 # 10 days of seconds | ||
93 | |||
94 | |||
95 | # Currently supported options, for more info, see options.c | ||
96 | #opt subnet | ||
97 | #opt timezone | ||
98 | #opt router | ||
99 | #opt timesvr | ||
100 | #opt namesvr | ||
101 | #opt dns | ||
102 | #opt logsvr | ||
103 | #opt cookiesvr | ||
104 | #opt lprsvr | ||
105 | #opt bootsize | ||
106 | #opt domain | ||
107 | #opt swapsvr | ||
108 | #opt rootpath | ||
109 | #opt ipttl | ||
110 | #opt mtu | ||
111 | #opt broadcast | ||
112 | #opt wins | ||
113 | #opt lease | ||
114 | #opt ntpsrv | ||
115 | #opt tftp | ||
116 | #opt bootfile | ||
117 | |||
118 | |||
119 | # Static leases map | ||
120 | #static_lease 00:60:08:11:CE:4E 192.168.0.54 | ||
121 | #static_lease 00:60:08:11:CE:3E 192.168.0.44 | ||
122 | |||
123 | |||
diff --git a/examples/undeb b/examples/undeb new file mode 100644 index 000000000..37104e9d8 --- /dev/null +++ b/examples/undeb | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # This should work with the GNU version of tar and gzip! | ||
4 | # This should work with the bash or ash shell! | ||
5 | # Requires the programs (ar, tar, gzip, and the pager more or less). | ||
6 | # | ||
7 | usage() { | ||
8 | echo "Usage: undeb -c package.deb <Print control file info>" | ||
9 | echo " undeb -l package.deb <List contents of deb package>" | ||
10 | echo " undeb -x package.deb /foo/boo <Extract deb package to this directory," | ||
11 | echo " put . for current directory>" | ||
12 | exit | ||
13 | } | ||
14 | |||
15 | deb=$2 | ||
16 | |||
17 | exist() { | ||
18 | if [ "$deb" = "" ]; then | ||
19 | usage | ||
20 | elif [ ! -s "$deb" ]; then | ||
21 | echo "Can't find $deb!" | ||
22 | exit | ||
23 | fi | ||
24 | } | ||
25 | |||
26 | if [ "$1" = "" ]; then | ||
27 | usage | ||
28 | elif [ "$1" = "-l" ]; then | ||
29 | exist | ||
30 | type more >/dev/null 2>&1 && pager=more | ||
31 | type less >/dev/null 2>&1 && pager=less | ||
32 | [ "$pager" = "" ] && echo "No pager found!" && exit | ||
33 | (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 | ||
34 | exit | ||
35 | elif [ "$1" = "-c" ]; then | ||
36 | exist | ||
37 | ar -p $deb control.tar.gz | tar -xzO *control | ||
38 | exit | ||
39 | elif [ "$1" = "-x" ]; then | ||
40 | exist | ||
41 | if [ "$3" = "" ]; then | ||
42 | usage | ||
43 | elif [ ! -d "$3" ]; then | ||
44 | echo "No such directory $3!" | ||
45 | exit | ||
46 | fi | ||
47 | ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit | ||
48 | echo | ||
49 | echo "Extracted $deb to $3!" | ||
50 | exit | ||
51 | else | ||
52 | usage | ||
53 | fi | ||
diff --git a/examples/unrpm b/examples/unrpm new file mode 100644 index 000000000..7fd3676f6 --- /dev/null +++ b/examples/unrpm | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # This should work with the GNU version of cpio and gzip! | ||
4 | # This should work with the bash or ash shell! | ||
5 | # Requires the programs (cpio, gzip, and the pager more or less). | ||
6 | # | ||
7 | usage() { | ||
8 | echo "Usage: unrpm -l package.rpm <List contents of rpm package>" | ||
9 | echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory," | ||
10 | echo " put . for current directory>" | ||
11 | exit | ||
12 | } | ||
13 | |||
14 | rpm=$2 | ||
15 | |||
16 | exist() { | ||
17 | if [ "$rpm" = "" ]; then | ||
18 | usage | ||
19 | elif [ ! -s "$rpm" ]; then | ||
20 | echo "Can't find $rpm!" | ||
21 | exit | ||
22 | fi | ||
23 | } | ||
24 | |||
25 | if [ "$1" = "" ]; then | ||
26 | usage | ||
27 | elif [ "$1" = "-l" ]; then | ||
28 | exist | ||
29 | type more >/dev/null 2>&1 && pager=more | ||
30 | type less >/dev/null 2>&1 && pager=less | ||
31 | [ "$pager" = "" ] && echo "No pager found!" && exit | ||
32 | (echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager | ||
33 | exit | ||
34 | elif [ "$1" = "-x" ]; then | ||
35 | exist | ||
36 | if [ "$3" = "" ]; then | ||
37 | usage | ||
38 | elif [ ! -d "$3" ]; then | ||
39 | echo "No such directory $3!" | ||
40 | exit | ||
41 | fi | ||
42 | rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit | ||
43 | echo | ||
44 | echo "Extracted $rpm to $3!" | ||
45 | exit | ||
46 | else | ||
47 | usage | ||
48 | fi | ||
diff --git a/examples/zcip.script b/examples/zcip.script new file mode 100644 index 000000000..988e542a4 --- /dev/null +++ b/examples/zcip.script | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # only for use as a "zcip" callback script | ||
4 | if [ "x$interface" = x ] | ||
5 | then | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | # zcip should start on boot/resume and various media changes | ||
10 | case "$1" in | ||
11 | init) | ||
12 | # for now, zcip requires the link to be already up, | ||
13 | # and it drops links when they go down. that isn't | ||
14 | # the most robust model... | ||
15 | exit 0 | ||
16 | ;; | ||
17 | config) | ||
18 | if [ "x$ip" = x ] | ||
19 | then | ||
20 | exit 1 | ||
21 | fi | ||
22 | # remember $ip for $interface, to use on restart | ||
23 | if [ "x$IP" != x -a -w "$IP.$interface" ] | ||
24 | then | ||
25 | echo $ip > "$IP.$interface" | ||
26 | fi | ||
27 | exec ip address add dev $interface \ | ||
28 | scope link local "$ip/16" broadcast + | ||
29 | ;; | ||
30 | deconfig) | ||
31 | if [ x$ip = x ] | ||
32 | then | ||
33 | exit 1 | ||
34 | fi | ||
35 | exec ip address del dev $interface local $ip | ||
36 | ;; | ||
37 | esac | ||
38 | exit 1 | ||