diff options
Diffstat (limited to 'urunlevel/my_linux')
37 files changed, 4132 insertions, 0 deletions
diff --git a/urunlevel/my_linux/Config.in b/urunlevel/my_linux/Config.in new file mode 100644 index 0000000..89f3c24 --- /dev/null +++ b/urunlevel/my_linux/Config.in | |||
@@ -0,0 +1,32 @@ | |||
1 | # | ||
2 | # For a description of the syntax of this configuration file, | ||
3 | # see scripts/kbuild/config-language.txt. | ||
4 | # | ||
5 | |||
6 | menu "My Linux Utilities" | ||
7 | |||
8 | config CONFIG_GETPKG | ||
9 | bool "getpkg" | ||
10 | default y | ||
11 | help | ||
12 | An implementation of the My Linux getpkg script. | ||
13 | |||
14 | config CONFIG_LINUXRC | ||
15 | bool "linuxrc" | ||
16 | default y | ||
17 | help | ||
18 | An implementation of the linuxrc boot script. | ||
19 | |||
20 | config CONFIG_MAN | ||
21 | bool "man" | ||
22 | default y | ||
23 | help | ||
24 | An implementation of the My Linux man script. | ||
25 | |||
26 | config CONFIG_RCS | ||
27 | bool "rcS" | ||
28 | default y | ||
29 | help | ||
30 | An implementation of rcS. | ||
31 | |||
32 | endmenu | ||
diff --git a/urunlevel/my_linux/Makefile b/urunlevel/my_linux/Makefile new file mode 100644 index 0000000..5160a99 --- /dev/null +++ b/urunlevel/my_linux/Makefile | |||
@@ -0,0 +1,32 @@ | |||
1 | # Makefile for busybox | ||
2 | # | ||
3 | # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the Free Software | ||
17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | # | ||
19 | |||
20 | top_srcdir=.. | ||
21 | top_builddir=.. | ||
22 | srcdir=$(top_srcdir)/my_linux | ||
23 | MY_LINUX_DIR:=./ | ||
24 | include $(top_builddir)/Rules.mak | ||
25 | include $(top_builddir)/.config | ||
26 | include $(srcdir)/Makefile.in | ||
27 | all: $(libraries-y) | ||
28 | -include $(top_builddir)/.depend | ||
29 | |||
30 | clean: | ||
31 | rm -f *.o *.a $(AR_TARGET) | ||
32 | |||
diff --git a/urunlevel/my_linux/Makefile.in b/urunlevel/my_linux/Makefile.in new file mode 100644 index 0000000..db30a61 --- /dev/null +++ b/urunlevel/my_linux/Makefile.in | |||
@@ -0,0 +1,40 @@ | |||
1 | # Makefile for busybox | ||
2 | # | ||
3 | # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the Free Software | ||
17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | # | ||
19 | |||
20 | MY_LINUX_AR:=my_linux.a | ||
21 | ifndef $(MY_LINUX_DIR) | ||
22 | MY_LINUX_DIR:=$(top_builddir)/my_linux/ | ||
23 | endif | ||
24 | srcdir=$(top_srcdir)/my_linux | ||
25 | |||
26 | MY_LINUX-y:= | ||
27 | MY_LINUX-$(CONFIG_GETPKG) += getpkg.o | ||
28 | MY_LINUX-$(CONFIG_LINUXRC) += linuxrc.o | ||
29 | MY_LINUX-$(CONFIG_MAN) += man.o | ||
30 | MY_LINUX-$(CONFIG_MAN) += mkrootfs.o | ||
31 | MY_LINUX-$(CONFIG_RCS) += rcS.o | ||
32 | |||
33 | libraries-y+=$(MY_LINUX_DIR)$(MY_LINUX_AR) | ||
34 | |||
35 | $(MY_LINUX_DIR)$(MY_LINUX_AR): $(patsubst %,$(MY_LINUX_DIR)%, $(MY_LINUX-y)) | ||
36 | $(AR) -ro $@ $(patsubst %,$(MY_LINUX_DIR)%, $(MY_LINUX-y)) | ||
37 | |||
38 | $(MY_LINUX_DIR)%.o: $(srcdir)/%.c | ||
39 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< | ||
40 | |||
diff --git a/urunlevel/my_linux/Trinux/README b/urunlevel/my_linux/Trinux/README new file mode 100644 index 0000000..b07fa7f --- /dev/null +++ b/urunlevel/my_linux/Trinux/README | |||
@@ -0,0 +1,346 @@ | |||
1 | Trinux Documentation Matthew Franz <mfranz@cisco.com> | ||
2 | http://trinux.sf.net/docs.txt 21 August 2003 | ||
3 | |||
4 | 0. Introduction | ||
5 | |||
6 | 0.1 What is Trinux? | ||
7 | |||
8 | Trinux is a ramdisk-based Linux distribution that was first | ||
9 | released in April of 1998 and has been maintained on and off | ||
10 | since then. Like other Linux distributions it consists of a | ||
11 | Linux kernel, base utilities, and a variety of packages. Like | ||
12 | many embedded distributions, Trinux uses Busybox, which contains | ||
13 | small versions of common utilities. See http://www.busybox.net. | ||
14 | |||
15 | 0.2 Where can I get the source? | ||
16 | |||
17 | Many of the standard utilities came from Slackware 7.1 or | ||
18 | when components needed to be upgraded, I pulled the source | ||
19 | from the Debian stable. The "original code" would be in the | ||
20 | /linuxrc script that is executed within | ||
21 | |||
22 | 0.3 Installation | ||
23 | |||
24 | Trinux is released in either 1.4 meg floppy images or small ISO | ||
25 | images. For the floppy images use dd on unix boxes or rawrite | ||
26 | on Windows. Search the web for info. | ||
27 | |||
28 | 0.4 If in doubt look at the /linuxrc script! | ||
29 | |||
30 | 1. Boot Media | ||
31 | |||
32 | 1.1 Common Format | ||
33 | |||
34 | * bzImage - compressed linux kernel | ||
35 | * tux - trinux configuration directory (like /etc on Unix) that | ||
36 | gets copied to /etc/tux when trinux boots | ||
37 | * bootpkg - packages that need to be loaded early | ||
38 | * kpkg - modular kernel packages | ||
39 | * initrd.gz - compressed initial ramdisk | ||
40 | * modules - raw (*.o) modules will be automatically loaded | ||
41 | |||
42 | 1.2 Floppy Disks | ||
43 | |||
44 | Trinux uses MS-DOS (vfat actually) formatted disks and syslinux | ||
45 | as the bootloader. The files/directories described in 1.1 are | ||
46 | directly off the root of the drive. | ||
47 | |||
48 | * syslinux.cfg - bootloader configuration file | ||
49 | * ldlinux.sys - SYSLINUX bootloader (http://syslinux.zytor.com/) | ||
50 | |||
51 | 1.3 CD-ROM | ||
52 | |||
53 | Bootable CD's are ISO9660 filesytem contain 2 directories: | ||
54 | * isolinux - bzImage, initrd.gz, isolinux.bin, isolinux.cfg | ||
55 | * trinux - bootpkg, kpkg, modules, tux | ||
56 | |||
57 | 1.4 Fixed Partition (IDE Drive) | ||
58 | |||
59 | Trinux can also be booted from a Windows 95/98, MS-DOS, or | ||
60 | FreeDOS partition using loadlin.exe. This is an option for older | ||
61 | hardware that might not have a CD-ROM (or a bootable one) or | ||
62 | if you want to load packages from a compact Flash drive using an | ||
63 | IDE Compact-Flash Adapter. | ||
64 | |||
65 | 1.4.1 Prepping the Drive | ||
66 | |||
67 | Use a Windows 95/98 or MS-DOS boot disk or the Trinux FreeDOS | ||
68 | Utility Disk (available on the downloads page) to create a FAT | ||
69 | partition. This involves running FDISK, FORMAT, and SYS. You | ||
70 | should copy loadlin.exe to the drive and it is also useful to have | ||
71 | a text editor (FreeDOS has TE) to edit batch files. You will | ||
72 | need to create trinux directory. My C:\ drive (mounted from | ||
73 | within Trinux as a vfat) looks like this: | ||
74 | |||
75 | trinux> ls -al | ||
76 | root root 16384 Jul 24 23:28 . | ||
77 | root root 832 Sep 3 2002 .. | ||
78 | root root 2048 Jul 20 18:51 .links | ||
79 | root root 50 Jul 20 17:35 autoexec.bat | ||
80 | root root 618999 Jul 20 18:11 bzimage | ||
81 | root root 86561 Aug 15 2001 command.com | ||
82 | root root 45836 Jul 20 17:35 fdisk.exe | ||
83 | root root 13741 Jul 20 17:35 format.exe | ||
84 | root root 600357 Jul 21 01:01 initrd.gz | ||
85 | root root 75663 Sep 3 2001 kernel.sys | ||
86 | root root 32177 Jul 20 17:35 loadlin.exe | ||
87 | root root 32719 Jul 20 17:35 loadlin.txt | ||
88 | root root 2048 Jul 20 18:33 old | ||
89 | root root 8634 Jul 20 17:36 sys.com | ||
90 | root root 44706 Jul 20 17:35 te.exe | ||
91 | root root 2048 Jul 21 12:31 trinux | ||
92 | |||
93 | TRINUX.BAT on the FreeDOS boot floppy contains the following | ||
94 | which I renamed to AUTOEXEC.BAT once I new it was stable. | ||
95 | |||
96 | loadlin bzimage initrd=initrd.gz root=/dev/ram0 rw | ||
97 | |||
98 | I have had mixed results with FreeDOS, so it might be best | ||
99 | to find a Windows 95/98/SE boot disk with fdisk and format. | ||
100 | I found a DOS 6.22 boot disk with the right tools from | ||
101 | http://www.bootdisk.com. | ||
102 | |||
103 | Copy a kernel that has IDE support (all the kernels on the | ||
104 | boot floppies after Trinux 0.890 should have the or a kernel | ||
105 | from the CD-ROM will work to) and an initrd.gz to the c:\ | ||
106 | drive. You can do this from DOS or from Linux. | ||
107 | |||
108 | 1.4.2 Copying necessary files to the DOS partition | ||
109 | |||
110 | Boot with a Trinux floppy (or CD-ROM) that has IDE support | ||
111 | and then mount the MS-DOS partition with the following | ||
112 | command | ||
113 | |||
114 | # mount -t vfat /dev/hda1 /mnt | ||
115 | |||
116 | This assumes the first IDE drive and should work for most | ||
117 | cases. Now create (or cd) the trinux directory on that | ||
118 | partition and create the subdirectories for packages | ||
119 | |||
120 | # cd /mnt/trinux | ||
121 | # mkdir bootpkg kpkg pkg modules | ||
122 | # mkdir -p tux/config | ||
123 | # mkdir tux/ | ||
124 | |||
125 | Now you need to get a minimum set of packages into the bootpkg | ||
126 | directory. If you have network access you can download them with | ||
127 | links (getpkg links) or you can copy them to floppies. I have | ||
128 | the following in mine: | ||
129 | |||
130 | root root 245776 Jul 20 19:17 baselib.tgz | ||
131 | root root 15932 Jul 20 18:17 dhcpcd.tgz | ||
132 | root root 90312 Jul 20 18:17 dnslibs.tgz | ||
133 | root root 163951 Jul 21 12:28 iptables.tgz | ||
134 | root root 131200 Jul 21 12:28 netfilter.tgz | ||
135 | root root 77834 Jul 20 19:22 pthread.tgz | ||
136 | root root 378444 Jul 20 19:22 term.tgz | ||
137 | |||
138 | These will always get loaded. You can also put packages in the | ||
139 | pkg directory and these may/may not load depending on your | ||
140 | configuration. | ||
141 | |||
142 | Remember, after you are through modifying the partition, it | ||
143 | needs to be unmounted with: | ||
144 | |||
145 | #umount /dev/hda1 | ||
146 | or | ||
147 | #umount /mnt | ||
148 | |||
149 | 1.4.3 Configuarition | ||
150 | |||
151 | |||
152 | 2. Networking | ||
153 | |||
154 | 2.1 Hardware Detection | ||
155 | |||
156 | In order for you to use networking your interface(s) must be | ||
157 | detected by the kernel. In order for this to occur you must either | ||
158 | have support for your NIC compiled into the kernel or use a kernel | ||
159 | module. Older versions of Trinux had support for the most common | ||
160 | NiCs built in, but that is no longer the case. | ||
161 | |||
162 | If your hardware was succuessfully found | ||
163 | |||
164 | # dmesg | grep eth0 | ||
165 | eth0: OEM i82557/i82558 10/100 Ethernet, 00:03:47:B9:12:08, IRQ 11 | ||
166 | |||
167 | 2.2 Module Selection | ||
168 | |||
169 | 3. Kernel Modules | ||
170 | |||
171 | Raw (non-packaged kernel modules are available at: | ||
172 | http://trinux.sf.net/kernel/ | ||
173 | |||
174 | Packaged kernel modules are available at http://trinux.sf.net/pkg/2.4.x/ | ||
175 | and may be installed with the "getkpkg <name>" | ||
176 | |||
177 | Trinux puts all packages in /lib/modules or /usr/lib/modules instead | ||
178 | of the standard linux convention of /lib/modules/2.4.x/... | ||
179 | |||
180 | 4. Packages | ||
181 | |||
182 | 4.1 Package Format | ||
183 | |||
184 | Packages are simply tarballs with an initialization script that | ||
185 | will be executed from within /etc/init.d/package_name or | ||
186 | /etc/init.m/kernel_package_name | ||
187 | |||
188 | 4.2 Scripts | ||
189 | |||
190 | * pkgadd - loads a package from a local filesystem | ||
191 | * getpkg - loads the package from the network | ||
192 | * getkpkg - loads a kernel package from the network | ||
193 | * pkglist - lists available packages | ||
194 | * rmpkg - deletes package | ||
195 | * mypkg - shows packages currently installed | ||
196 | |||
197 | 4.3 Building your own | ||
198 | |||
199 | All the Trinux packages are compiled with glibc 2.1.3 using | ||
200 | Slackware 7.1. I upgraded the compiler to gcc 2.95 and have upgraded | ||
201 | libraries as necessary. | ||
202 | |||
203 | 4.4 Adding packages after bootup | ||
204 | |||
205 | You can either use the getpkg/getkpkg commands to load a package | ||
206 | from the network. If /etc/tux/config/localpkg is set | ||
207 | (added 0.891) | ||
208 | |||
209 | 4.5 Configuration | ||
210 | |||
211 | Add list of package (in order) to /etc/tux/config/pkglist and these | ||
212 | will be loaded at boot | ||
213 | |||
214 | 4.6 Miscellaneous | ||
215 | |||
216 | 5. Filesystems | ||
217 | |||
218 | 5.1 Supported Filesytems | ||
219 | |||
220 | Trinux may only have support for a few filesystems such as minix | ||
221 | vfat (Windows) and ISO9660 (for CDROMs). To see which filesystems | ||
222 | are currently supported in the kernel: | ||
223 | |||
224 | # cat /proc/filesystems | grep -v nodev | ||
225 | minix | ||
226 | vfat | ||
227 | iso9660 | ||
228 | reiserfs | ||
229 | |||
230 | In this case I installed the reiserfs module: | ||
231 | |||
232 | # lsmod | ||
233 | reiserfs 165600 1 | ||
234 | 3c59x 24560 1 | ||
235 | 8139too 13396 1 | ||
236 | mii 2092 0 [8139too] | ||
237 | |||
238 | |||
239 | To mount a device you use the following command: | ||
240 | |||
241 | mount <device> -t <filesystem type> <mount point) | ||
242 | |||
243 | So to mount the floppy you would | ||
244 | |||
245 | You can determine the which IDE devices are present by the following | ||
246 | command: | ||
247 | |||
248 | # dmesg | grep hd | ||
249 | ide0: BM-DMA at 0x1850-0x1857, BIOS settings: hda:DMA, hdb:pio | ||
250 | ide1: BM-DMA at 0x1858-0x185f, BIOS settings: hdc:pio, hdd:pio | ||
251 | hda: IC25N040ATCS04-0, ATA DISK drive | ||
252 | hda: 78140160 sectors (40008 MB) w/1768KiB Cache, CHS=5168/240/63 | ||
253 | hda: hda1 hda2 hda3 < hda5 hda6 > hda4 | ||
254 | hde: LEXAR ATA FLASH, ATA DISK drive | ||
255 | hde: 96384 sectors (49 MB) w/1KiB Cache, CHS=753/4/32 | ||
256 | hde: hde1 | ||
257 | |||
258 | So assuming hde1 were a vfat partition, you would use: | ||
259 | |||
260 | # mount -t vfat /dev/hde1 /mnt | ||
261 | # mount | ||
262 | /dev/hda2 on / type ext3 (rw,errors=remount-ro) | ||
263 | proc on /proc type proc (rw) | ||
264 | devpts on /dev/pts type devpts (rw,gid=5,mode=620) | ||
265 | /dev/hda4 on /alt type reiserfs (rw) | ||
266 | /trinux/boot/trinux.img on /loop type vfat (rw,loop=/dev/loop0) | ||
267 | /dev/hde1 on /mnt type vfat (rw) | ||
268 | |||
269 | This was from my laptop. Within Trinux, the following is more | ||
270 | typical: | ||
271 | |||
272 | # mount | ||
273 | /dev/ram0 on / type minix (rw) | ||
274 | /proc on /proc type proc (rw) | ||
275 | /dev/null on /usr type tmpfs (rw) | ||
276 | /dev/null on /home type tmpfs (rw) | ||
277 | /dev/null on /var type tmpfs (rw) | ||
278 | /dev/hda2 on /hda2 type reiserfs (rw) | ||
279 | |||
280 | |||
281 | 5.3 Swap | ||
282 | |||
283 | Usually, you probably have enough memory (otherwise you wouldn't | ||
284 | be running ramdisks) but if you want to set up a swap file or swap | ||
285 | filesystem, put the name of the file (within an existing filesytem) | ||
286 | the name of the partition (/dev/hda3) in /etc/tux/config/swap and | ||
287 | the linuxrc will automatically run mkswap and swapon. You may | ||
288 | want to make sure the swaputils.tgz package is included, | ||
289 | although it will be loaded automatically if /sbin/makeswap | ||
290 | isn't found. | ||
291 | |||
292 | 5.4 Tmpfs | ||
293 | |||
294 | A neat feature that came out in 2.4 was the ability to use the | ||
295 | temporary or shared memory filesystem instead of ramdisks. The key | ||
296 | advantage is that ramdisks are completed allocated when the are | ||
297 | created, but tmpfs partitions only use RAM as they are filled. | ||
298 | |||
299 | |||
300 | Trinux only has support for a minimal set of filesystems | ||
301 | |||
302 | 6. Management and Monitoring | ||
303 | |||
304 | Although it is probably not the most common option, Trinux can be | ||
305 | used in a headless server capacity | ||
306 | |||
307 | 6.1 Serial Console | ||
308 | |||
309 | 6.2 SSH Remote Logins | ||
310 | |||
311 | 6.3 Enabling Cisco Discovery Protocol (CDP) | ||
312 | |||
313 | 6.4 Building a Local Package Server | ||
314 | |||
315 | 7. Miscellaneous | ||
316 | |||
317 | 6.1 Troubleshooting | ||
318 | |||
319 | Recent versions of trinux have a /sbin/hwinfo script that gathers | ||
320 | hardware information about the system and saves it to the file | ||
321 | /tmp/hwinfo. It basically saves the output of the dmesg command | ||
322 | and copies the values of some /proc files that can be used to help | ||
323 | troubleshoot hardware problems. The following commands allow you to | ||
324 | save this file to the boot floppy (assuming you have enough room) | ||
325 | |||
326 | # fmount | ||
327 | # cp /tmp/hwinfo /floppy | ||
328 | # fumount | ||
329 | |||
330 | You can then post some or all of this file to the trinux-talk mailing | ||
331 | list when you have a problem. | ||
332 | |||
333 | 6.2 Where to get help | ||
334 | |||
335 | You should subscribe to the trinux-talk mailing list | ||
336 | |||
337 | 6.3 Floppy Errors | ||
338 | |||
339 | If you do not have a floppy drive or you floppy drive takes very | ||
340 | long to time out, append "nofloppy" to the kernel boot arguments. | ||
341 | CD-ROM booting automatically disables this checking. I had to do | ||
342 | this on an old Compaq 486-66 because it was taking several minutes | ||
343 | to complete the bootup: | ||
344 | |||
345 | loadlin bzimage initrd=initrd.gz root=/dev/ram0 rw nofloppy | ||
346 | |||
diff --git a/urunlevel/my_linux/Trinux/chkfixed b/urunlevel/my_linux/Trinux/chkfixed new file mode 100755 index 0000000..4cbb45b --- /dev/null +++ b/urunlevel/my_linux/Trinux/chkfixed | |||
@@ -0,0 +1,99 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # chkfixed - look for legitimate parititions and build mount points | ||
4 | # and populate /etc/proc | ||
5 | # | ||
6 | |||
7 | rm /tmp/partitions 2> /dev/null | ||
8 | |||
9 | |||
10 | [ -d /etc/proc ] || mkdir /etc/proc | ||
11 | |||
12 | if [ -f /etc/tux/config/fstab ] | ||
13 | then | ||
14 | echo "fstab found, exiting..." | ||
15 | exit 1 | ||
16 | fi | ||
17 | |||
18 | for i in `grep -v nodev /proc/filesystems` | ||
19 | do | ||
20 | echo "$i" | ||
21 | done > /etc/proc/availfs | ||
22 | |||
23 | echo "The following filesystems are supported:" | ||
24 | cat /etc/proc/availfs | ||
25 | echo | ||
26 | |||
27 | cdpart=`dmesg | grep D-ROM | grep hd | cut -d: -f1` | ||
28 | |||
29 | if [ "$cdpart" ] | ||
30 | then | ||
31 | echo "A CD-ROM was found at $cdpart" | ||
32 | echo "$cdpart" > /tmp/partitions | ||
33 | fi | ||
34 | |||
35 | partitions=`dmesg | grep ' hd[abcdef]' | cut -d':' -f2` | ||
36 | scsiparts=`dmesg | grep "^ sd[abcdef][12345]"` | ||
37 | |||
38 | echo IDE Partitions: $partitions | ||
39 | echo SCSI Partitions: $scsiparts | ||
40 | |||
41 | for i in $partitions | ||
42 | do | ||
43 | |||
44 | if echo "$partitions" | grep unknown > /dev/null | ||
45 | then | ||
46 | echo "Unkown partition" | ||
47 | else | ||
48 | echo $i >> /tmp/partitions | ||
49 | fi | ||
50 | done | ||
51 | |||
52 | for i in $partitions | ||
53 | do | ||
54 | |||
55 | if echo "$partitions" | grep unknown > /dev/null | ||
56 | then | ||
57 | echo "Unkown partition" | ||
58 | else | ||
59 | echo $i >> /tmp/partitions | ||
60 | fi | ||
61 | done | ||
62 | |||
63 | |||
64 | for i in $scsiparts | ||
65 | do | ||
66 | echo $i >> /tmp/partitions | ||
67 | done | ||
68 | |||
69 | if [ ! -f /tmp/partitions ] | ||
70 | then | ||
71 | echo "No fixed partitions found!" | ||
72 | exit | ||
73 | fi | ||
74 | |||
75 | sort /tmp/partitions | uniq | grep "hd" > /etc/proc/partitions | ||
76 | sort /tmp/partitions | uniq | grep "sd" >> /etc/proc/partitions | ||
77 | |||
78 | echo "The following partitions were found: " | ||
79 | cat /etc/proc/partitions | ||
80 | echo | ||
81 | |||
82 | ##echo "The following filesystems were found: " | ||
83 | for i in `cat /etc/proc/partitions` | ||
84 | do | ||
85 | mkdir /$i 2> /dev/null | ||
86 | |||
87 | for j in `cat /etc/proc/availfs` | ||
88 | do | ||
89 | echo -n Checking $i: | ||
90 | if mount -o ro -t $j /dev/$i /$i 2> /dev/null > /dev/null | ||
91 | then | ||
92 | echo " found $j" | ||
93 | echo "$i:$j" >> /etc/tux/config/fstab | ||
94 | umount /dev/$i 2> /dev/null > /dev/null | ||
95 | else | ||
96 | echo | ||
97 | fi | ||
98 | done | ||
99 | done | ||
diff --git a/urunlevel/my_linux/Trinux/fmount b/urunlevel/my_linux/Trinux/fmount new file mode 100755 index 0000000..db8595b --- /dev/null +++ b/urunlevel/my_linux/Trinux/fmount | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/sh | ||
2 | mount -t vfat /dev/fd0 /floppy | ||
diff --git a/urunlevel/my_linux/Trinux/fumount b/urunlevel/my_linux/Trinux/fumount new file mode 100755 index 0000000..003ce14 --- /dev/null +++ b/urunlevel/my_linux/Trinux/fumount | |||
@@ -0,0 +1,3 @@ | |||
1 | #!/bin/sh | ||
2 | cd / | ||
3 | umount /dev/fd0 | ||
diff --git a/urunlevel/my_linux/Trinux/gethome b/urunlevel/my_linux/Trinux/gethome new file mode 100755 index 0000000..c47c238 --- /dev/null +++ b/urunlevel/my_linux/Trinux/gethome | |||
@@ -0,0 +1,61 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ "$1" ] | ||
4 | then | ||
5 | home=$1 | ||
6 | else | ||
7 | home="home" | ||
8 | fi | ||
9 | |||
10 | homeline=`cat /etc/tux/config/home` | ||
11 | |||
12 | if [ "$homeline" ] | ||
13 | then | ||
14 | PROTO=`cut -d':' -f1 /etc/tux/config/home` | ||
15 | HOST=`cut -d':' -f2 /etc/tux/config/home` | ||
16 | USER=`cut -d':' -f3 /etc/tux/config/home` | ||
17 | else | ||
18 | echo -n "ftp or ssh: " | ||
19 | read PROTO | ||
20 | echo -n "Host: " | ||
21 | read HOST | ||
22 | echo -n "User: " | ||
23 | read USER | ||
24 | echo $PROTO:$HOST:$USER > /etc/tux/config/home | ||
25 | fi | ||
26 | |||
27 | |||
28 | echo "Retrieving home directory from $USER@$HOST via $PROTO" | ||
29 | |||
30 | if [ $PROTO = "ssh" ] | ||
31 | then | ||
32 | scp $USER@$HOST:~/$home.tgz / | ||
33 | fi | ||
34 | |||
35 | if [ $PROTO = "ftp" ] | ||
36 | then | ||
37 | echo "Using FTP to transfor $home.tgz -- your passwords are sniffable" | ||
38 | |||
39 | if [ -x /usr/bin/curl ] | ||
40 | then | ||
41 | curl -u $USER ftp://$HOST/$home.tgz > /$home.tgz | ||
42 | |||
43 | else | ||
44 | echo "Curl is not installed. You will have to login with your" | ||
45 | echo "username and upload $home.tgz manually" | ||
46 | |||
47 | ftp $HOST | ||
48 | |||
49 | fi | ||
50 | fi | ||
51 | |||
52 | cd / | ||
53 | echo | ||
54 | echo "Uncompressing archive..." | ||
55 | gunzip -c $home.tgz | tar xvf - | ||
56 | rm /$home.tgz 2> /dev/null | ||
57 | |||
58 | |||
59 | |||
60 | |||
61 | |||
diff --git a/urunlevel/my_linux/Trinux/getkpkg b/urunlevel/my_linux/Trinux/getkpkg new file mode 100755 index 0000000..ceab0ce --- /dev/null +++ b/urunlevel/my_linux/Trinux/getkpkg | |||
@@ -0,0 +1,9 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ "$1" ] | ||
4 | then | ||
5 | KERNEL=`uname -r` | ||
6 | getpkg $KERNEL/$1 | ||
7 | else | ||
8 | echo "No package specified!" | ||
9 | fi | ||
diff --git a/urunlevel/my_linux/Trinux/getpkg b/urunlevel/my_linux/Trinux/getpkg new file mode 100755 index 0000000..adeab02 --- /dev/null +++ b/urunlevel/my_linux/Trinux/getpkg | |||
@@ -0,0 +1,171 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # getpkg - retrieves a single package from package server | ||
4 | # | ||
5 | # Author: Matthew D. Franz <mdfranz@io.com> | ||
6 | # | ||
7 | # $1 - name of package | ||
8 | # $2 - URL of server | ||
9 | # | ||
10 | ############################################################################ | ||
11 | |||
12 | [ -d /var/pkg/contents ] || mkdir -p /var/pkg/contents | ||
13 | |||
14 | # if in current directory, call pkgadd | ||
15 | |||
16 | if [ -f "$1" ] | ||
17 | then | ||
18 | pkgadd $i | ||
19 | else | ||
20 | if [ -f /etc/tux/config/localpkg ] | ||
21 | then | ||
22 | print "Using local package repository" | ||
23 | if [ -f /etc/proc/fixed ] | ||
24 | then | ||
25 | print "Found /etc/proc/fixed" | ||
26 | fi | ||
27 | fi | ||
28 | fi | ||
29 | |||
30 | |||
31 | if [ -f /etc/tux/config/proxy ] | ||
32 | then | ||
33 | SNARF_PROXY=`cat /etc/tux/config/proxy` | ||
34 | export SNARF_PROXY | ||
35 | fi | ||
36 | |||
37 | mkdir /etc/init.d/running 2> /dev/null | ||
38 | |||
39 | if [ "$1" = "list" ] | ||
40 | then | ||
41 | pkglist | ||
42 | exit | ||
43 | fi | ||
44 | |||
45 | if [ "$1" = "all" ] | ||
46 | then | ||
47 | echo "Downloading all packages..." | ||
48 | |||
49 | if [ ! -f /etc/tux/config/eth0 ] | ||
50 | then | ||
51 | echo "Network was not configured" | ||
52 | if dmesg | grep eth0 > /dev/null | ||
53 | then | ||
54 | echo -n "Attempting DHCP on eth0: " | ||
55 | if dhcpcd > /dev/null 2> /dev/null | ||
56 | then | ||
57 | echo "Successful" | ||
58 | else | ||
59 | echo "Failed" | ||
60 | exit | ||
61 | fi | ||
62 | else | ||
63 | echo "No ethernet interfaces were found" | ||
64 | exit | ||
65 | fi | ||
66 | fi | ||
67 | |||
68 | if [ -f /etc/tux/config/pkglist ] | ||
69 | then | ||
70 | pkglist=`cat /etc/tux/config/pkglist` | ||
71 | for i in $pkglist | ||
72 | do | ||
73 | getpkg $i | ||
74 | done | ||
75 | else | ||
76 | echo "No package list found, retrieving a minimal set" | ||
77 | getpkg baselib | ||
78 | getpkg term | ||
79 | getpkg vi | ||
80 | getpkg tcpdump | ||
81 | fi | ||
82 | |||
83 | exit | ||
84 | fi | ||
85 | |||
86 | if [ "$1" = "" ] | ||
87 | then | ||
88 | echo; echo "You did not specify a package or server!"; echo | ||
89 | echo "getpkg all will load all the packages from /etc/tux/config/pkglist" | ||
90 | getpkg all | ||
91 | else | ||
92 | if [ "$2" = "" ] | ||
93 | then | ||
94 | if [ "$URL" = "" ] | ||
95 | then | ||
96 | if [ -f /etc/tux/config/server ] | ||
97 | then | ||
98 | blah=1 | ||
99 | else | ||
100 | echo -n "Enter URL for package retrieval: " | ||
101 | read URL | ||
102 | if [ "$URL" != "" ] | ||
103 | then | ||
104 | echo "Using $URL as your package server from now on..." | ||
105 | echo "$URL" > /etc/tux/config/server | ||
106 | fi | ||
107 | fi | ||
108 | fi | ||
109 | else | ||
110 | URL=$2 | ||
111 | fi | ||
112 | |||
113 | if echo $1 | grep tgz > /dev/null | ||
114 | then | ||
115 | FILE=$1 | ||
116 | else | ||
117 | FILE=$1.tgz | ||
118 | fi | ||
119 | |||
120 | cd / | ||
121 | |||
122 | PREFIX=`basename $FILE ".tgz"` | ||
123 | |||
124 | #echo $PREFIX | ||
125 | |||
126 | MODPKGNAME=`echo ${1} | cut -d'/' -f2` | ||
127 | |||
128 | |||
129 | if echo $MODPKGNAME | grep tgz > /dev/null | ||
130 | then | ||
131 | MODPKGNAME=`basename $MODPKGNAME ".tgz"` | ||
132 | fi | ||
133 | |||
134 | # Loop through servers listed in | ||
135 | |||
136 | for URL in `cat /etc/tux/config/server` | ||
137 | do | ||
138 | if snarf $URL - > /dev/null 2> /dev/null | ||
139 | then | ||
140 | echo "Retrieving ${URL}${FILE}" | ||
141 | output=`snarf ${URL}/${FILE} - | gunzip -c | tar xvf -` | ||
142 | fi | ||
143 | |||
144 | echo $output > /var/pkg/contents/$PREFIX | ||
145 | |||
146 | if [ -f /etc/init.d/${PREFIX} ] | ||
147 | then | ||
148 | chmod a+x /etc/init.d/${PREFIX} 2> /dev/null | ||
149 | echo; echo "Initializing ${PREFIX}" | ||
150 | /etc/init.d/${PREFIX} 2> /dev/null | ||
151 | fi | ||
152 | |||
153 | |||
154 | if [ "$MODPKGNAME" ] | ||
155 | then | ||
156 | chmod a+x /etc/init.m/${MODPKGNAME} 2> /dev/null | ||
157 | if [ -x /etc/init.m/$MODPKGNAME ] | ||
158 | then | ||
159 | /etc/init.m/$MODPKGNAME | ||
160 | echo "Initializing $1 modules" | ||
161 | fi | ||
162 | fi | ||
163 | |||
164 | |||
165 | break | ||
166 | done | ||
167 | |||
168 | [ $? -eq 0 ] || exit 1 | ||
169 | |||
170 | fi | ||
171 | |||
diff --git a/urunlevel/my_linux/Trinux/hwinfo b/urunlevel/my_linux/Trinux/hwinfo new file mode 100755 index 0000000..5e32126 --- /dev/null +++ b/urunlevel/my_linux/Trinux/hwinfo | |||
@@ -0,0 +1,23 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo "Gathering hardware information, saving to /tmp/hwinfo" | ||
4 | |||
5 | echo "[--- dmesg ---]" > /tmp/hwinfo | ||
6 | dmesg >> /tmp/hwinfo | ||
7 | echo "[--- /proc/devices ---]" >> /tmp/hwinfo | ||
8 | cat /proc/devices >> /tmp/hwinfo | ||
9 | echo "[--- /proc/iomem ---]" >> /tmp/hwinfo | ||
10 | cat /proc/iomem >> /tmp/hwinfo | ||
11 | echo "[--- /proc/ioports ---]" >> /tmp/hwinfo | ||
12 | cat /proc/ioports >> /tmp/hwinfo | ||
13 | echo "[--- /proc/interrupts ---]" >> /tmp/hwinfo | ||
14 | cat /proc/interrupts >> /tmp/hwinfo | ||
15 | echo "[--- /proc/pci ---]" >> /tmp/hwinfo | ||
16 | cat /proc/pci >> /tmp/hwinfo | ||
17 | echo "[--- /proc/meminfo ---]" >> /tmp/hwinfo | ||
18 | cat /proc/meminfo >> /tmp/hwinfo | ||
19 | echo "[--- /proc/partitions ---]" >> /tmp/hwinfo | ||
20 | cat /proc/partitions >> /tmp/hwinfo | ||
21 | echo "[--- /proc/modules ---]" >> /tmp/hwinfo | ||
22 | cat /proc/modules >> /tmp/hwinfo | ||
23 | |||
diff --git a/urunlevel/my_linux/Trinux/killmod b/urunlevel/my_linux/Trinux/killmod new file mode 100755 index 0000000..7dc80b6 --- /dev/null +++ b/urunlevel/my_linux/Trinux/killmod | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo "Unloading all kernel modules" | ||
4 | for i in `lsmod` | ||
5 | do | ||
6 | mod=`echo $i | cut -d' ' -f1` | ||
7 | rmmod $mod 2> /dev/null | ||
8 | done | ||
diff --git a/urunlevel/my_linux/Trinux/linuxrc b/urunlevel/my_linux/Trinux/linuxrc new file mode 100755 index 0000000..4597234 --- /dev/null +++ b/urunlevel/my_linux/Trinux/linuxrc | |||
@@ -0,0 +1,1261 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # linuxrc - main trinux initialization script | ||
4 | # | ||
5 | # Author: Matthew Franz <mfranz@cisco.com> | ||
6 | # Bill Burdick for the User-Mode-Linux fixes | ||
7 | ######################################################################## | ||
8 | # | ||
9 | # Attempts to do the following: | ||
10 | # | ||
11 | # - Determine where trinux booted from [ Floppy/CD-ROM/IDE/UML ] | ||
12 | # - Mount boot device and copy configuration files to /etc/tux | ||
13 | # - Initialize and create ramdisks/tmpfs or mount filesystems | ||
14 | # - Determine where packages are located and to be loaded from | ||
15 | # - Initialize kernel modules and detect hardware | ||
16 | # - Configure and enable networking | ||
17 | # - Load and initialize packages | ||
18 | # - Initialize system daemons | ||
19 | # | ||
20 | ######################################################################## | ||
21 | ## Define stuff that is probably rejected by busybox | ||
22 | ######################################################################## | ||
23 | |||
24 | UMLROOT="/trinux-uml" | ||
25 | PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin" | ||
26 | TERM=linux | ||
27 | PS1="trinux> " | ||
28 | PS2='>' | ||
29 | |||
30 | export PATH TERM PS1 PS2 VERSION PKGSRC BOOT PKGSRC BOOTFS FLCFG FXCFG PKGLIST FIXED | ||
31 | umask 022 | ||
32 | [ -d /etc/proc ] || mkdir -p /etc/proc | ||
33 | mount -t proc proc /proc | ||
34 | mkdir -p /lib/modules | ||
35 | mkdir -p /etc/tux/config | ||
36 | ln -sf /proc/self/fd/0 /dev/stdin | ||
37 | ln -sf /proc/self/fd/2 /dev/stderr | ||
38 | ln -sf /proc/self/fd/1 /dev/stdout | ||
39 | |||
40 | chmod a+w /tmp | ||
41 | chmod a+w /dev/null | ||
42 | |||
43 | ##################################################################### | ||
44 | ## Gather information about system | ||
45 | ##################################################################### | ||
46 | |||
47 | MEMORY=`grep MemTotal /proc/meminfo | cut -d':' -f2 | cut -d'k' -f1` | ||
48 | KERNEL=`cat /proc/version | cut -d' ' -f3` | ||
49 | CDEV=`dmesg | grep D-ROM | grep hd | cut -d: -f1 | sort | uniq` # CD-ROM devices | ||
50 | FDEV=`dmesg | grep -v LDM | grep -v "ldm_val" | grep "^ [sh]d[a-f]" | cut -d':' -f2 | sort | uniq` # FIXED | ||
51 | |||
52 | echo "Checking for fixed disks" | ||
53 | /sbin/chkfixed | ||
54 | |||
55 | |||
56 | |||
57 | echo "FDEV: $FDEV" | ||
58 | echo "CDEV: $CDEV" | ||
59 | sleep 1 | ||
60 | |||
61 | echo "$FDEV" > /tmp/fixed | ||
62 | |||
63 | |||
64 | for i in `cat /tmp/fixed` | ||
65 | do | ||
66 | echo $i | ||
67 | done > /etc/proc/fixed | ||
68 | |||
69 | |||
70 | [ "$CDEV" ] && echo "$CDEV" >> /etc/proc/fixed | ||
71 | |||
72 | |||
73 | #check initial filesytem support | ||
74 | |||
75 | for i in `grep -v nodev /proc/filesystems` | ||
76 | do | ||
77 | echo $i | ||
78 | done > /etc/proc/filesystems | ||
79 | |||
80 | |||
81 | ###################################################################### | ||
82 | ### Special Probing stuff | ||
83 | ###################################################################### | ||
84 | |||
85 | ## Did we boot from UML? | ||
86 | #if dmesg | grep 'User-mode Linux' > /dev/null | ||
87 | |||
88 | if grep ' ubd' /proc/devices > /dev/null | ||
89 | then | ||
90 | echo "Trinux booted via User Mode Linux (UML)" | ||
91 | sleep 3 | ||
92 | UML="true" | ||
93 | BOOT="UML" | ||
94 | fi | ||
95 | |||
96 | ## Did we boot from ms-dos loadlin | ||
97 | |||
98 | echo "Checking all vfat partitions for loadlin.exe" | ||
99 | |||
100 | for i in `cat /etc/proc/fixed 2> /dev/null` | ||
101 | do | ||
102 | # [ -d /${i} ] || mkdir /${i} | ||
103 | # echo "Checking $i" | ||
104 | |||
105 | if mount -o ro -t vfat /dev/${i} /mnt 2> /dev/null | ||
106 | then | ||
107 | echo -n "VFAT found on $i" | ||
108 | if ls /mnt/loadlin.exe 2> /dev/null | ||
109 | then | ||
110 | echo -n " found loadlin.exe" | ||
111 | if [ -d /mnt/trinux ] | ||
112 | then | ||
113 | echo " found trinux" | ||
114 | BOOT="/dev/${i}" | ||
115 | BOOTFS="vfat" | ||
116 | echo "BOOT=$BOOT" | ||
117 | echo "$i" > /etc/proc/fixedpkg | ||
118 | LOADLIN="true" | ||
119 | cd / | ||
120 | umount /mnt 2> /dev/null | ||
121 | break | ||
122 | fi | ||
123 | fi | ||
124 | |||
125 | fi | ||
126 | umount /mnt 2> /dev/null | ||
127 | done | ||
128 | |||
129 | # Check to see if checking for floppy drive should be disabled | ||
130 | |||
131 | if grep nofloppy /proc/cmdline > /dev/null | ||
132 | then | ||
133 | NOFLOPPY="true" | ||
134 | echo "Disabling checks for floppy drive" | ||
135 | fi | ||
136 | |||
137 | ######################################################################## | ||
138 | # Determine where Trinux booted from in order of likelihood | ||
139 | # | ||
140 | # /dev/fd0 - floppy (this is normally the case) | ||
141 | # /dev/hd[alpha] - IDE CD-ROM (usually /dev/hdc) | ||
142 | # /dev/hd[numeric] - IDE Hard Disk (including flash disk) | ||
143 | # | ||
144 | # We assume that if a floppy is present and no-› | ||
145 | # | ||
146 | ######################################################################## | ||
147 | # | ||
148 | # first check if CD-ROM is present | ||
149 | |||
150 | if [ "$CDEV" ] | ||
151 | then | ||
152 | echo -n "Attempting to mount CD-ROM at $CDEV:" | ||
153 | |||
154 | if mount -t iso9660 /dev/${CDEV} /mnt 2> /dev/null > /dev/null | ||
155 | then | ||
156 | echo "successful" | ||
157 | if [ -d /mnt/trinux ] | ||
158 | then | ||
159 | echo "/trinux found on $CDEV" | ||
160 | PKGSRC=$CDEV # we assume packages will be loaded from it | ||
161 | |||
162 | # Now check and see if we booted from CD-ROM | ||
163 | |||
164 | if [ -d /mnt/isolinux ] | ||
165 | then | ||
166 | BOOT=/dev/${CDEV} | ||
167 | BOOTFS="iso9660" | ||
168 | NOFLOPPY="true" | ||
169 | echo $CDEV > /etc/proc/fixedpkg | ||
170 | fi | ||
171 | cd / | ||
172 | umount /mnt 2> /dev/null | ||
173 | fi | ||
174 | else | ||
175 | echo "failed" | ||
176 | [ "$UML" ] || BOOT="/dev/fd0" | ||
177 | fi | ||
178 | fi | ||
179 | |||
180 | if [ ! "$NOFLOPPY" ] | ||
181 | then | ||
182 | echo "Checking for floppy in /dev/fd0" | ||
183 | sleep 1 | ||
184 | |||
185 | if mount -t vfat /dev/fd0 /boot 2> /dev/null | ||
186 | then | ||
187 | [ -d /boot/bootpkg ] && BOOT="/dev/fd0" | ||
188 | [ -d /boot/tux ] && FLCFG="true" | ||
189 | [ -f /boot/tux/options/floppy ] && PKGSRC="/dev/fd0" | ||
190 | umount /boot 2> /dev/null | ||
191 | |||
192 | [ "$BOOT" = "/dev/fd0" ] && echo "Trinux booted from a floppy." | ||
193 | [ "$PKGSRC" = "/dev/fd0" ] && echo "Trinux will load packages from one or more floppies." | ||
194 | else | ||
195 | echo "Unable to mount boot floppy" | ||
196 | fi | ||
197 | else | ||
198 | echo "Floppy checking is disabled" | ||
199 | fi | ||
200 | |||
201 | echo $BOOT > /etc/proc/boot | ||
202 | echo $BOOTFS > /etc/proc/bootfs | ||
203 | |||
204 | echo | ||
205 | echo "========================" | ||
206 | echo "BOOT: $BOOT" | ||
207 | echo "KERNEL: $KERNEL" | ||
208 | echo -n "CDEV: " | ||
209 | |||
210 | if [ $CDEV ] | ||
211 | then | ||
212 | echo "$CDEV" | ||
213 | else | ||
214 | echo "none" | ||
215 | fi | ||
216 | |||
217 | echo -n "FDEV: " | ||
218 | |||
219 | if [ "$FDEV" ] | ||
220 | then | ||
221 | echo $FDEV | ||
222 | else | ||
223 | echo "none" | ||
224 | fi | ||
225 | |||
226 | |||
227 | ## Determine boot filesystem type | ||
228 | |||
229 | if [ "$BOOT" = "/dev/fd0" ] | ||
230 | then | ||
231 | BOOTFS="vfat" | ||
232 | elif [ "$UML" ] | ||
233 | then | ||
234 | BOOTFS="ext2" | ||
235 | elif [ "$BOOT" = "$CDEV" ] | ||
236 | then | ||
237 | BOOTFS="iso9660" | ||
238 | fi | ||
239 | |||
240 | echo "BOOTFS: $BOOTFS" | ||
241 | echo "========================" | ||
242 | sleep 2 | ||
243 | |||
244 | #################################################################### | ||
245 | # Determine where packages should be loaded from. By default, Trinux | ||
246 | # will look at /etc/tux/config/pkgsrc otherwise it will look at | ||
247 | # parameters passed from syslinux.cfg (i.e. pkgsrc=/dev/hda1). | ||
248 | # Otherwise Trinux will assume network package loading unlesss | ||
249 | # the network is unable to be configured | ||
250 | #################################################################### | ||
251 | |||
252 | if grep 'pkg=floppy' /proc/cmdline > /dev/null | ||
253 | then | ||
254 | PKGSRC="/dev/fd0" | ||
255 | fi | ||
256 | |||
257 | PKGSRC="network" ## Assume network package loading unless... | ||
258 | |||
259 | ##################################################################### | ||
260 | ## Mount the boot filesystem | ||
261 | ## 1) copy config from tux over | ||
262 | ## 2) install kernel module pkgs from kpkg | ||
263 | ##################################################################### | ||
264 | |||
265 | if [ "$UML" ] | ||
266 | then | ||
267 | echo | ||
268 | # mount the host ext2 filesystem RO so initial packages can be installed | ||
269 | mount none /boot -t hostfs -o $UMLROOT,ro | ||
270 | else | ||
271 | mount -o ro -t $BOOTFS $BOOT /boot | ||
272 | VERSION=`cat /boot/version 2> /dev/null` | ||
273 | PS1="Trinux $VERSION> " | ||
274 | fi | ||
275 | |||
276 | [ "$BOOT" != "/dev/fd0" ] && PREFIX="trinux/" | ||
277 | |||
278 | cd /boot | ||
279 | |||
280 | #pwd | ||
281 | #ls -al | ||
282 | |||
283 | echo "Copying /tux from boot filesystem..." | ||
284 | cp -a ${PREFIX}tux /etc | ||
285 | |||
286 | |||
287 | echo "Copying modules from boot filesystem..." | ||
288 | |||
289 | # support either within /trinux/modules or /trinux/*.o | ||
290 | |||
291 | cp ${PREFIX}*.o /lib/modules 2> /dev/null | ||
292 | cp ${PREFIX}modules/*.o /lib/modules 2> /dev/null | ||
293 | cp ${PREFIX}modules/*.gz /lib/modules 2> /dev/null | ||
294 | |||
295 | cd /lib/modules | ||
296 | |||
297 | for i in `ls *.gz` | ||
298 | do | ||
299 | FNAME=`basename $i .gz` | ||
300 | echo "Uncompressing $i" | ||
301 | gunzip $i | ||
302 | mv $FNAME $FNAME.o | ||
303 | done | ||
304 | |||
305 | if [ -f /etc/tux/version ] | ||
306 | then | ||
307 | VERSION=`cat /etc/tux/version 2> /dev/null` | ||
308 | else | ||
309 | VERSION="unknown" | ||
310 | fi | ||
311 | |||
312 | cd /boot | ||
313 | if cd ${PREFIX}kpkg 2> /dev/null | ||
314 | then | ||
315 | echo "Installing kernel module packages from boot device" | ||
316 | for i in `ls` | ||
317 | do | ||
318 | pkgadd $i | ||
319 | echo $i >> /etc/proc/kpkg.installed | ||
320 | done | ||
321 | fi | ||
322 | |||
323 | ######## Store temporary scripts in scripts directory ########### | ||
324 | |||
325 | if [ -d ${PREFIX}scripts ] | ||
326 | then | ||
327 | echo "Copying local scripts to /bin:" | ||
328 | cd ${PREFIX}scripts | ||
329 | for i in `ls` | ||
330 | do | ||
331 | cp $i /bin/ | ||
332 | chmod u+x /bin/$i | ||
333 | done | ||
334 | fi | ||
335 | |||
336 | cd / | ||
337 | umount /boot | ||
338 | |||
339 | echo "Unmounting boot filesystem" | ||
340 | |||
341 | # load in kernel modules | ||
342 | |||
343 | #cd /lib/modules | ||
344 | |||
345 | if [ -f /etc/tux/config/modules ] | ||
346 | then | ||
347 | while read i | ||
348 | do | ||
349 | echo "Installing $i" | ||
350 | insmod /lib/modules/$i 2> /dev/null > /dev/null | ||
351 | done < /etc/tux/config/modules | ||
352 | fi | ||
353 | |||
354 | |||
355 | echo "Waiting for modules to settle..." | ||
356 | |||
357 | sleep 3 | ||
358 | |||
359 | #### Since modules have already been loaded now is a good | ||
360 | #### time to scour the partitions, checking for devices | ||
361 | |||
362 | echo "Checking for fixed disks" | ||
363 | |||
364 | /sbin/chkfixed | ||
365 | |||
366 | #### Check for a saved fixedpkg to avoid checking all found partitions | ||
367 | |||
368 | if [ -f /etc/tux/config/fixedpkg ] | ||
369 | then | ||
370 | echo -n "Found previously saved fixed package source: " | ||
371 | FIXEDPKG=`cat /etc/tux/config/fixedpkg` | ||
372 | if [ "$FIXEDPKG" = "cdrom" -o "$FIXEDPKG" = "cd-rom" ] | ||
373 | then | ||
374 | FIXEDPKG=$CDEV | ||
375 | fi | ||
376 | |||
377 | echo $FIXEDPKG | ||
378 | echo $FIXEDPKG > /etc/proc/fixed | ||
379 | fi | ||
380 | |||
381 | for i in `cat /etc/proc/fixed` # loop through fixed devices | ||
382 | do | ||
383 | [ -d /${i} ] || mkdir /${i} # create mount point | ||
384 | |||
385 | for j in `cat /etc/proc/filesystems` # loop through supported fstype | ||
386 | do | ||
387 | #echo -n "Checking $i:" | ||
388 | if mount -o ro -t $j /dev/$i /$i 2> /dev/null > /dev/null | ||
389 | then | ||
390 | #echo " found $j" | ||
391 | echo "$i:$j" >> /etc/tux/config/fstab | ||
392 | umount /dev/$i 2> /dev/null > /dev/null 2> /dev/null | ||
393 | else | ||
394 | echo | ||
395 | fi | ||
396 | done | ||
397 | done | ||
398 | |||
399 | if [ -f /etc/tux/config/fstab ] | ||
400 | then | ||
401 | echo "The following partitions/filesytems were found:" | ||
402 | cat /etc/tux/config/fstab | ||
403 | cat /etc/tux/config/fstab | sort | uniq > /tmp/fstab | ||
404 | cat /tmp/fstab > /etc/tux/config/fstab | ||
405 | fi | ||
406 | |||
407 | ######### | ||
408 | # Search filesystems for /trinux directories | ||
409 | |||
410 | if [ -f /etc/proc/fixedpkg ] | ||
411 | then | ||
412 | fixedpkg=`cat /etc/proc/fixedpkg` | ||
413 | echo "/trinux already found on $fixedpkg, aborting search" | ||
414 | mount | ||
415 | else | ||
416 | if [ -f /etc/tux/config/fstab ] | ||
417 | then | ||
418 | for i in `cat /etc/tux/config/fstab` | ||
419 | do | ||
420 | part=`cut -d: -f1 /etc/tux/config/fstab` | ||
421 | fstype=`cut -d: -f2 /etc/tux/config/fstab` | ||
422 | |||
423 | if mount -t $fstype /dev/${part} /mnt 2> /dev/null | ||
424 | then | ||
425 | echo -n "Checking $part for trinux directory: " | ||
426 | |||
427 | if [ -d /mnt/trinux/ ] | ||
428 | then | ||
429 | echo " found" | ||
430 | umount /mnt 2> /dev/null | ||
431 | echo $part > /etc/proc/fixedpkg | ||
432 | break | ||
433 | else | ||
434 | echo " not found" | ||
435 | fi | ||
436 | |||
437 | cd /; umount /mnt 2> /dev/null | ||
438 | else | ||
439 | echo -n "Failed to mount $part" | ||
440 | fi | ||
441 | done | ||
442 | fi | ||
443 | fi | ||
444 | |||
445 | chmod a+x /etc/tux/init/first 2> /dev/null | ||
446 | if [ -x /etc/tux/init/first ] | ||
447 | then | ||
448 | . /etc/tux/init/first | ||
449 | fi | ||
450 | |||
451 | ################################################################# | ||
452 | ################### Ramdisk building stuff ###################### | ||
453 | ################################################################# | ||
454 | |||
455 | if grep ' 2.4' /proc/version 2> /dev/null | ||
456 | then | ||
457 | echo "Found 2.4.x kernel: tmpfs capable" | ||
458 | if [ -f /etc/tux/config/tmpfs ] | ||
459 | then | ||
460 | echo "Using tmpfs" | ||
461 | TMPFS="true" | ||
462 | fi | ||
463 | else | ||
464 | TMPFS="false" | ||
465 | fi | ||
466 | |||
467 | #### If /etc/tux/config/corefs is present we use that for | ||
468 | #### partitions *other* than root. If fstab is blank then | ||
469 | #### everything is mounted as root. Trinux will attempt to mount | ||
470 | #### to filesystem and will *not* reformat | ||
471 | #### | ||
472 | #### An additional file (/etc/tux/config/suppfs) will be mounted | ||
473 | #### later so that nfs/smbfs can be mounted | ||
474 | #### | ||
475 | #### corefs format | ||
476 | #### partition:mount point:size in Kb:filesystem:options | ||
477 | #### | ||
478 | #### /dev/sda1:/var:512:minix:keep,ro | ||
479 | #### | ||
480 | #### | ||
481 | #### possible filesystems | ||
482 | #### vfat, minix, tmpfs, ram (actually minix) | ||
483 | #### | ||
484 | #### plus anything compiled in your kernel | ||
485 | |||
486 | if [ -f /etc/tux/config/corefs ] | ||
487 | then | ||
488 | for i in `cat /etc/tux/config/corefs` | ||
489 | do | ||
490 | DEV=`echo $i | cut -d: -f1` | ||
491 | MOUNT=`echo $i | cut -d: -f2` | ||
492 | SIZE=`echo $i | cut -d: -f3` | ||
493 | FSTYPE=`echo $i | cut -d: -f4` | ||
494 | OPTIONS=`echo $i | cut -d: -f5` | ||
495 | |||
496 | echo "[DEV: $DEV]" | ||
497 | echo "MOUNT: $MOUNT" | ||
498 | echo "SIZE: $SIZE" | ||
499 | echo "FSTYPE: $FSTYPE" | ||
500 | echo "OPTIONS: $OPTIONS" | ||
501 | |||
502 | if [ ! "$DEV" ] | ||
503 | then | ||
504 | # if no device is specified, assume tmpfs | ||
505 | mount -n -t tmpfs -o size=${SIZE}000 /dev/null $MOUNT | ||
506 | else | ||
507 | mkdir $MOUNT 2> /dev/null | ||
508 | |||
509 | if grep "$FSTYPE" /proc/filesystems > /dev/null | ||
510 | then | ||
511 | if [ ! "$SIZE" ] | ||
512 | then | ||
513 | |||
514 | # assume entire partition should formatted | ||
515 | if [ "$FSTYPE" = "minix" ] | ||
516 | then | ||
517 | mkfs.minix $DEV | ||
518 | mount -t minix $DEV $MOUNT | ||
519 | else | ||
520 | echo "Currently only minix is supported: skipping $$DEV" | ||
521 | fi | ||
522 | |||
523 | fi # not $SIZE | ||
524 | else | ||
525 | # if no FSTYPE is specified, assume minix | ||
526 | mkfs.minix $DEV # 2> /dev/null > /dev/null | ||
527 | mount -t minix $DEV $MOUNT | ||
528 | fi | ||
529 | |||
530 | fi # no $DEV | ||
531 | done # loop through each line of corefs | ||
532 | else | ||
533 | # | ||
534 | # Autosize ramdisks based on amount of RAM discovered | ||
535 | # | ||
536 | |||
537 | LIB="" | ||
538 | VAR="" | ||
539 | USR="" | ||
540 | USRLOC="" | ||
541 | HOMEP="" | ||
542 | |||
543 | echo "RAM: $MEMORY MB" | ||
544 | echo -n "RAM is " | ||
545 | |||
546 | if [ $MEMORY -lt 16000 ] | ||
547 | then | ||
548 | echo "< 16MB, you may run into problems" | ||
549 | USR="2048" | ||
550 | HOMEP="128" | ||
551 | VAR="512" | ||
552 | PKGMEM="min" | ||
553 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
554 | elif [ $MEMORY -lt 24000 ] | ||
555 | then | ||
556 | echo "> 16MB" | ||
557 | USR="4096" | ||
558 | HOMEP="256" | ||
559 | VAR="512" | ||
560 | PKGMEM="16" | ||
561 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
562 | elif [ $MEMORY -lt 32000 ] | ||
563 | then | ||
564 | echo "> 24MB" | ||
565 | USR="8192" | ||
566 | HOMEP="512" | ||
567 | VAR="1024" | ||
568 | PKGMEM="24" | ||
569 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
570 | elif [ $MEMORY -lt 48000 ] | ||
571 | then | ||
572 | echo "> 32MB" | ||
573 | USR="16384" | ||
574 | HOMEP="1024" | ||
575 | VAR="1024" | ||
576 | LIB="4896" | ||
577 | PKGMEM="32" | ||
578 | |||
579 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
580 | elif [ $MEMORY -lt 64000 ] | ||
581 | then | ||
582 | echo "> 48MB" | ||
583 | USR="16384" | ||
584 | LIB="8192" | ||
585 | USRLOC="8192" | ||
586 | HOMEP="2048" | ||
587 | VAR="2048" | ||
588 | PKGMEM="48" | ||
589 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
590 | elif [ $MEMORY -lt 96000 ] | ||
591 | then | ||
592 | echo "> 64MB" | ||
593 | |||
594 | LIB="8192" | ||
595 | USR="16384" | ||
596 | USRLOC="16384" | ||
597 | HOMEP="4096" | ||
598 | VAR="2048" | ||
599 | PKGMEM="64" | ||
600 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
601 | elif [ $MEMORY -lt 128000 ] | ||
602 | then | ||
603 | echo "> 96MB" | ||
604 | LIB="16384" | ||
605 | USR="16384" | ||
606 | USRLOC="32768" | ||
607 | HOMEP="8192" | ||
608 | VAR="4192" | ||
609 | PKGMEM="96" | ||
610 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
611 | else | ||
612 | echo "> 128MB" | ||
613 | USR="16384" | ||
614 | USRLOC="16384" | ||
615 | HOMEP="16384" | ||
616 | VAR="4192" | ||
617 | PKGMEM="128" | ||
618 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
619 | fi | ||
620 | |||
621 | #if [ "$LIB" != "" ] | ||
622 | #then | ||
623 | # echo "Creating /lib" | ||
624 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
625 | |||
626 | # if [ "$TMPFS" = "true" ] | ||
627 | # then | ||
628 | # mount -n -t tmpfs -o size=${LIB}000 /dev/null /lib | ||
629 | # else | ||
630 | # mkdir /usr 2> /dev/null | ||
631 | # mkfs.minix /dev/ram3 $LIB 2> /dev/null > /dev/null | ||
632 | # mount -t minix /dev/ram7 /lib | ||
633 | # fi | ||
634 | #fi | ||
635 | |||
636 | if [ "$USR" != "" ] | ||
637 | then | ||
638 | echo "Creating /usr" | ||
639 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
640 | |||
641 | if [ "$TMPFS" = "true" ] | ||
642 | then | ||
643 | mount -n -t tmpfs -o size=${USR}000 /dev/null /usr | ||
644 | else | ||
645 | mkdir /usr 2> /dev/null | ||
646 | mkfs.minix /dev/ram3 $USR 2> /dev/null > /dev/null | ||
647 | mount -t minix /dev/ram3 /usr | ||
648 | fi | ||
649 | fi | ||
650 | |||
651 | if [ "$USRLOC" -gt 0 ] | ||
652 | then | ||
653 | |||
654 | echo "Creating /usr/local" | ||
655 | # echo "USR: $USR USRLOC: $USRLOC HOME: $HOMEP" | ||
656 | mkdir /usr/local 2> /dev/null | ||
657 | |||
658 | if [ "$TMPFS" = "true" ] | ||
659 | then | ||
660 | mount -n -t tmpfs -o size=${USRLOC}000 /dev/null /usr/local | ||
661 | else | ||
662 | mkfs.minix /dev/ram4 $USRLOC 2> /dev/null > /dev/null | ||
663 | mount -t minix /dev/ram4 /usr/local | ||
664 | fi | ||
665 | fi | ||
666 | |||
667 | if [ "$HOME" != "" ] | ||
668 | then | ||
669 | echo "Creating /home" | ||
670 | mkdir /home 2> /dev/null | ||
671 | if [ "$TMPFS" = "true" ] | ||
672 | then | ||
673 | mount -n -t tmpfs -o size=${HOMEP}000 /dev/null /home | ||
674 | else | ||
675 | mkfs.minix /dev/ram5 $HOMEP 2> /dev/null > /dev/null | ||
676 | mount -t minix /dev/ram5 /home | ||
677 | fi | ||
678 | fi | ||
679 | |||
680 | # | ||
681 | # Need to add a check for "physical" var | ||
682 | # | ||
683 | |||
684 | if [ "$VAR" != "" ] | ||
685 | then | ||
686 | echo "Creating /var" | ||
687 | mkdir /var 2> /dev/null | ||
688 | if [ "$TMPFS" = "true" ] | ||
689 | then | ||
690 | mount -n -t tmpfs -o size=${VAR}000 /dev/null /var | ||
691 | else | ||
692 | mkfs.minix /dev/ram5 $VAR 2> /dev/null > /dev/null | ||
693 | mount -t minix /dev/ram6 /var | ||
694 | fi | ||
695 | fi | ||
696 | |||
697 | fi | ||
698 | |||
699 | ############################################################################ | ||
700 | # | ||
701 | # handle /etc/tux/config/permfs | ||
702 | # | ||
703 | # mount "permanent filesystems" -- for now these should be umounted | ||
704 | # manually to avoid corruption | ||
705 | # | ||
706 | # partition:mount point:filesystem:options | ||
707 | # | ||
708 | ############################################################################ | ||
709 | |||
710 | |||
711 | |||
712 | |||
713 | if [ -f /etc/tux/config/permfs ] | ||
714 | then | ||
715 | echo "Mounting permanent (non-ramdisk) filesystems based on /etc/tux/config/permfs" | ||
716 | |||
717 | for i in `/etc/tux/config/permfs` | ||
718 | do | ||
719 | DEV=`cat /etc/tux/config/permfs | cut -d":" -f1` | ||
720 | MOUNT=`cat /etc/tux/config/permfs | cut -d":" -f2` | ||
721 | FSTYPE=`cat /etc/tux/config/permfs | cut -d":" -f3` | ||
722 | |||
723 | if mount -t $FSTYPE $DEV $MOUNT | ||
724 | then | ||
725 | echo "-- $DEV ($FSTYPE) was mounted at $MOUNT" | ||
726 | else | ||
727 | echo "-- $DEV ($FSTYPE) failed to mount at $MOUNT!" | ||
728 | fi | ||
729 | done | ||
730 | |||
731 | echo "Remember, these must be manually umounted prior to reboot" | ||
732 | fi | ||
733 | |||
734 | echo "--------------------- FILESYSTEM CONFIGURATION ------------------------" | ||
735 | df | ||
736 | sleep 1 | ||
737 | echo "-----------------------------------------------------------------------" | ||
738 | echo | ||
739 | |||
740 | ################################################################# | ||
741 | # | ||
742 | # Kludgy stuff to do after the filesystems have been created | ||
743 | # | ||
744 | ################################################################ | ||
745 | |||
746 | echo "Creating misc links and directories..." | ||
747 | |||
748 | mkdir -p /lib/modules/`uname -r` | ||
749 | touch /lib/modules/`uname -r`/modules.dep | ||
750 | mkdir /usr/lib/ 2> /dev/null | ||
751 | ln -sf /lib/terminfo /usr/lib/terminfo | ||
752 | mkdir /usr/home | ||
753 | cd /var | ||
754 | mkdir pkg log spool run 2> /dev/null | ||
755 | cd log | ||
756 | cp /dev/null mtp | ||
757 | cd / | ||
758 | echo | ||
759 | |||
760 | if [ -f /etc/proc/fixedpkg -o "$UML" ] | ||
761 | then | ||
762 | if [ -f /etc/proc/fixedpkg ] | ||
763 | then | ||
764 | part=`cat /etc/proc/fixedpkg 2> /dev/null` | ||
765 | echo "Trinux packages were found on $part" | ||
766 | PKGSRC=$part | ||
767 | |||
768 | cat /etc/tux/config/fstab | grep $part | cut -d: -f2 2> /dev/null | ||
769 | |||
770 | fstype=`cat /etc/tux/config/fstab | grep $part | cut -d: -f2 2> /dev/null` | ||
771 | fi | ||
772 | |||
773 | ##echo "[PKGSRC] = $PKGSRC" | ||
774 | ##echo "[fstype] = $fstype" | ||
775 | |||
776 | if [ "$fstype" ] | ||
777 | then | ||
778 | if mount -t $fstype /dev/${part} /mnt 2> /dev/null | ||
779 | then | ||
780 | mounted="true" | ||
781 | fi | ||
782 | fi | ||
783 | |||
784 | |||
785 | |||
786 | if [ "$UML" ] | ||
787 | then | ||
788 | echo -n "Attempting to mount UML host filesystem: " | ||
789 | if mount none /mnt -t hostfs -o $UMLROOT,ro | ||
790 | then | ||
791 | mounted="true" | ||
792 | echo "ok" | ||
793 | else | ||
794 | echo "failed" | ||
795 | fi | ||
796 | fi | ||
797 | |||
798 | echo "[mounted] = $mounted" | ||
799 | |||
800 | if [ "$mounted" ] | ||
801 | then | ||
802 | echo "Preparing to load base packages from $part" | ||
803 | if cd /mnt/trinux/bootpkg 2> /dev/null | ||
804 | then | ||
805 | for i in `ls *.tgz 2> /dev/null` | ||
806 | do | ||
807 | pkgadd $i | ||
808 | done | ||
809 | else | ||
810 | "No base packages found, hmmm..." | ||
811 | fi | ||
812 | |||
813 | echo "Preparing to load kernel packages from $part" | ||
814 | if cd /mnt/trinux/kpkg 2> /dev/null | ||
815 | then | ||
816 | if [ -f /etc/tux/conf/kpkglist ] | ||
817 | then | ||
818 | for i in `cat /etc/tux/conf/pkglist` | ||
819 | do | ||
820 | pkgadd $i | ||
821 | done | ||
822 | else | ||
823 | echo "No kpkglist found, loading everything" | ||
824 | for i in `ls *.tgz 2> /dev/null` | ||
825 | do | ||
826 | if grep $i /etc/proc/kpkg.installed > /dev/null | ||
827 | then | ||
828 | echo "$i is already installed." | ||
829 | else | ||
830 | pkgadd $i | ||
831 | fi | ||
832 | done | ||
833 | |||
834 | fi | ||
835 | else | ||
836 | echo "Kernel package directory not found on $part!" | ||
837 | fi | ||
838 | |||
839 | echo "Preparing to load packages from $part" | ||
840 | |||
841 | if cd /mnt/trinux/pkg 2> /dev/null | ||
842 | then | ||
843 | if [ -f /etc/tux/conf/pkglist ] | ||
844 | then | ||
845 | for i in `cat /etc/tux/conf/pkglist` | ||
846 | do | ||
847 | pkgadd $i | ||
848 | done | ||
849 | |||
850 | # NOTE: now the desired behavior is to put whatever | ||
851 | # you want to load into bootpkg | ||
852 | # | ||
853 | #else | ||
854 | # echo "No pkglist found, loading everything" | ||
855 | # for i in `ls *.tgz 2> /dev/null` | ||
856 | # do | ||
857 | # pkgadd $i | ||
858 | # done | ||
859 | |||
860 | fi | ||
861 | else | ||
862 | echo "Package directory not found on $part!" | ||
863 | fi | ||
864 | |||
865 | cd / | ||
866 | umount /mnt | ||
867 | else | ||
868 | echo -n "Failed to mount $part" | ||
869 | fi | ||
870 | else | ||
871 | ### This should only go for a floppy | ||
872 | ### Load required packages from boot device | ||
873 | ### echo "For some reason we made it here" | ||
874 | |||
875 | sleep 1 | ||
876 | |||
877 | if mount -t $BOOTFS $BOOT /boot 2> /dev/null | ||
878 | then | ||
879 | if [ "$PKGSRC" != "$CDEV" ] | ||
880 | then | ||
881 | if cd /boot/bootpkg | ||
882 | then | ||
883 | echo "Installing base packages from boot device" | ||
884 | for i in `ls` | ||
885 | do | ||
886 | pkgadd $i | ||
887 | done | ||
888 | echo | ||
889 | fi | ||
890 | fi | ||
891 | cd / | ||
892 | umount /boot | ||
893 | else | ||
894 | echo "Unable to mount $BOOT on $BOOTFS" | ||
895 | fi | ||
896 | cd / | ||
897 | umount /boot 2> /dev/null | ||
898 | fi | ||
899 | |||
900 | |||
901 | [ -x /etc/init.d/pcmcia ] && . /etc/init.d/pcmcia | ||
902 | |||
903 | sleep 1 | ||
904 | |||
905 | |||
906 | |||
907 | |||
908 | ############### Syslog Configuration ################### | ||
909 | |||
910 | LOGHOST=`cat /etc/tux/options/loghost 2> /dev/null` | ||
911 | if [ "$LOGHOST" ] | ||
912 | then | ||
913 | if [ "$LOGHOST" = "prompt" ] | ||
914 | then | ||
915 | echo -n "Enter syslog server: " | ||
916 | read $LOGHOST | ||
917 | fi | ||
918 | $REMOTELOG="-R $LOGHOST" | ||
919 | fi | ||
920 | |||
921 | echo "Starting syslogd" | ||
922 | [ -x /sbin/syslogd ] && syslogd $REMOTELOG | ||
923 | |||
924 | # | ||
925 | # At this point we have loaded all the packages if a CD-ROM | ||
926 | # boot or package load from fixed partition | ||
927 | # otherwise base packages have been loaded from the | ||
928 | # floppy. We also have any saved config data. Now we attempt | ||
929 | # to configure the network, then load packages from an HTTP/FTP server | ||
930 | # | ||
931 | |||
932 | chmod a+x /etc/tux/init/prenet 2> /dev/null | ||
933 | if [ -x /etc/tux/init/prenet ] | ||
934 | then | ||
935 | . /etc/tux/init/prenet | ||
936 | fi | ||
937 | |||
938 | |||
939 | ##### Attempt to initialize networking ####################### | ||
940 | |||
941 | |||
942 | ifconfig lo 127.0.0.1 up | ||
943 | |||
944 | |||
945 | |||
946 | # [ "$IPADDR" ] && echo "Network configured successfully" | ||
947 | |||
948 | |||
949 | if [ -f /etc/tux/config/eth0 ] | ||
950 | then | ||
951 | /sbin/net-start | ||
952 | IPADDR=`cat /etc/proc/ipaddr 2> /dev/null` | ||
953 | else | ||
954 | echo 'No network configuration found. Type "net-config"' | ||
955 | fi | ||
956 | |||
957 | if [ -f /etc/tux/config/proxy ] | ||
958 | then | ||
959 | SNARF_PROXY=`cat /etc/tux/config/proxy` | ||
960 | export SNARF_PROXY | ||
961 | echo "Found proxy: $SNARF_PROXY" | ||
962 | echo | ||
963 | fi | ||
964 | |||
965 | if [ "$PKGSRC" = "network" ] | ||
966 | then | ||
967 | |||
968 | if [ "$IPADDR" != "" ] | ||
969 | then | ||
970 | echo "The network was succesfully configured" | ||
971 | |||
972 | [ -f /etc/tux/config/pkglist ] && PKGLIST=`cat /etc/tux/config/pkglist` | ||
973 | |||
974 | # attempt to connect to servers in /etc/tux/config/server | ||
975 | |||
976 | #snarf $server | grep tgz | cut -d">" -f3 | cut -d"<" -f1 > /tmp/packages | ||
977 | |||
978 | #echo "3" > /proc/sys/net/ipv4/tcp_syn_retries | ||
979 | #echo "3" > /proc/sys/net/ipv4/tcp_retries1 | ||
980 | #echo "3" > /proc/sys/net/ipv4/tcp_retries2 | ||
981 | |||
982 | if [ -f /etc/tux/config/server ] | ||
983 | then | ||
984 | |||
985 | for SERVER in `cat /etc/tux/config/server` | ||
986 | do | ||
987 | echo "Contacting $SERVER..." | ||
988 | if snarf $SERVER > /dev/null 2> /dev/null | ||
989 | then | ||
990 | getpkg all | ||
991 | # echo; echo "Retrieving base packages from $SERVER" | ||
992 | # for i in $PKGLIST | ||
993 | # do | ||
994 | # getpkg $i $SERVER | ||
995 | # done | ||
996 | |||
997 | if [ -f /etc/tux/config/kpkglist ] | ||
998 | then | ||
999 | KPKGLIST=`cat /etc/tux/config/kpkglist` | ||
1000 | echo "Retrieving Linux $KERNEL packages from $SERVER" | ||
1001 | for i in $KPKGLIST | ||
1002 | do | ||
1003 | getpkg $KERNEL/${i} $SERVER | ||
1004 | done | ||
1005 | fi | ||
1006 | |||
1007 | break | ||
1008 | fi | ||
1009 | done | ||
1010 | fi | ||
1011 | else | ||
1012 | PKGSRC="/dev/fd0" | ||
1013 | fi | ||
1014 | fi | ||
1015 | |||
1016 | if [ "$PKGSRC" = "/dev/fd0" ] | ||
1017 | then | ||
1018 | echo -n "Do you have a package disk? " | ||
1019 | read response | ||
1020 | |||
1021 | until [ "$response" != "y" ] | ||
1022 | do | ||
1023 | if mount -t vfat -r /dev/fd0 /floppy 2> /dev/null | ||
1024 | then | ||
1025 | cd /floppy | ||
1026 | |||
1027 | if ls *.o > /dev/null 2> /dev/null | ||
1028 | then | ||
1029 | echo "Copying modules from package disk" | ||
1030 | cp *.o /lib/modules 2> /dev/null | ||
1031 | cp modules/*.o /lib/modules 2> /dev/null | ||
1032 | fi | ||
1033 | |||
1034 | for i in *.tgz | ||
1035 | do | ||
1036 | cd /floppy | ||
1037 | pkgadd $i | ||
1038 | done | ||
1039 | fi | ||
1040 | |||
1041 | cd /; umount /floppy | ||
1042 | echo -n "Do you have another floppy? " | ||
1043 | read response | ||
1044 | done | ||
1045 | |||
1046 | |||
1047 | #if ifconfig | grep eth0 /dev/null 2> /dev/null | ||
1048 | #then | ||
1049 | # echo "Network was sucessfully initialized" | ||
1050 | #else | ||
1051 | #net-start | ||
1052 | # fi | ||
1053 | else | ||
1054 | if echo $PKGSRC | grep "/dev/[sh]d" > /dev/null | ||
1055 | then | ||
1056 | echo "Packages will be loaded from fixed disk: $PKGSRC" | ||
1057 | fi | ||
1058 | fi | ||
1059 | |||
1060 | |||
1061 | if [ -x /etc/tux/init/postnet ] | ||
1062 | then | ||
1063 | chmod a+x /etc/tux/init/postnet 2> /dev/null | ||
1064 | . /etc/tux/init/postnet | ||
1065 | fi | ||
1066 | |||
1067 | # Install modules that end up in /lib/modules | ||
1068 | # this will include any on the boot disk | ||
1069 | # | ||
1070 | # Consult /etc/tux/config/modules for any parameters | ||
1071 | # (i.e. irq's io's for NIC modules | ||
1072 | # | ||
1073 | |||
1074 | # This should be moved to /etc/init.d/system | ||
1075 | |||
1076 | echo "Enabling port scan (scanlogd)" | ||
1077 | [ -x /sbin/scanlogd ] && scanlogd | ||
1078 | |||
1079 | |||
1080 | ### Fix the linker/library stuff | ||
1081 | if [ -x /usr/sbin/ldconfig ] | ||
1082 | then | ||
1083 | echo "Rebuilding ld.so.cache one last time" | ||
1084 | ldconfig -v 2> /dev/null > /dev/null | ||
1085 | else | ||
1086 | echo "Unable to rebuild run-time link bindings" | ||
1087 | fi | ||
1088 | |||
1089 | |||
1090 | chmod a+x /etc/tux/init/prepkg 2> /dev/null | ||
1091 | if [ -x /etc/tux/init/prepkg ] | ||
1092 | then | ||
1093 | . /etc/tux/init/prepkg | ||
1094 | fi | ||
1095 | |||
1096 | [ -x /usr/bin/bash ] && ln -sf /usr/bin/bash /bin/sh | ||
1097 | |||
1098 | |||
1099 | |||
1100 | ## This needs to be fixed *bad* | ||
1101 | |||
1102 | ##/sbin/loadmodules # load any last minute kernel modules | ||
1103 | |||
1104 | chmod a+x /etc/tux/init/last 2> /dev/null | ||
1105 | if [ -x /etc/tux/init/last ] | ||
1106 | then | ||
1107 | . /etc/tux/init/last | ||
1108 | fi | ||
1109 | |||
1110 | # Increasing syn_retries to something more reasonable | ||
1111 | echo "7" > /proc/sys/net/ipv4/tcp_syn_retries | ||
1112 | |||
1113 | ###################################################################### | ||
1114 | # Set up swap space | ||
1115 | ###################################################################### | ||
1116 | |||
1117 | SWAPCONF=`cat /etc/tux/config/swap 2> /dev/null` | ||
1118 | |||
1119 | if [ "$SWAPCONF" ] | ||
1120 | then | ||
1121 | echo "Configuring swap space" | ||
1122 | |||
1123 | [ -x /sbin/mkswap ] || getpkg swaputil | ||
1124 | |||
1125 | SWAPFILE=`echo $SWAPCONF | cut -d: -f1` | ||
1126 | SWAPSIZE=`echo $SWAPCONF | cut -d: -f2` | ||
1127 | |||
1128 | [ "$SWAPSIZE" ] || SWAPSIZE=8192 # default to 8MB swap | ||
1129 | |||
1130 | if echo "$SWAPFILE" | grep "dev" > /dev/null | ||
1131 | then | ||
1132 | # user specified a partition | ||
1133 | echo "Attempting to use $SWAPFILE for swap partition" | ||
1134 | else | ||
1135 | echo "Using $SWAPFILE as your swap file" | ||
1136 | dd if=/dev/zero of=$SWAPFILE bs=512 count=$SWAPSIZE | ||
1137 | fi | ||
1138 | |||
1139 | mkswap $SWAPFILE | ||
1140 | swapon $SWAPFILE | ||
1141 | free | ||
1142 | fi | ||
1143 | |||
1144 | |||
1145 | #### | ||
1146 | |||
1147 | if [ -f /etc/tux/config/ipfwd ] | ||
1148 | then | ||
1149 | echo "Enabling IP forwarding" | ||
1150 | echo "1" > /proc/sys/net/ipv4/ip_forward | ||
1151 | fi | ||
1152 | |||
1153 | if [ -f /etc/tux/config/noping ] | ||
1154 | then | ||
1155 | echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all | ||
1156 | fi | ||
1157 | |||
1158 | |||
1159 | |||
1160 | #### This stuff should all get moved to the system direcotry ###### | ||
1161 | ### | ||
1162 | #### Notify any emails addr in /etc/tux/options/mailmon that you're up | ||
1163 | |||
1164 | if [ -f /etc/tux/config/monitor/smtp ] | ||
1165 | then | ||
1166 | for ADDR in `cat /etc/tux/config/emaildst` | ||
1167 | do | ||
1168 | echo | mail $ADDR UP | ||
1169 | done | ||
1170 | fi | ||
1171 | |||
1172 | if [ -f /etc/tux/config/monitor/http ] | ||
1173 | then | ||
1174 | webmon | ||
1175 | # add to crontab | ||
1176 | echo '0,10,20,30,40,50 * * * * /usr/sbin/webmon' >> /etc/tux/config/crontab | ||
1177 | fi | ||
1178 | |||
1179 | if [ -f /etc/tux/config/monitor/cdp ] | ||
1180 | then | ||
1181 | echo "Starting CDP (Cisco Discovery Protocol)" | ||
1182 | echo '* * * * * /usr/sbin/cdpdump' >> /etc/tux/config/crontab | ||
1183 | fi | ||
1184 | |||
1185 | |||
1186 | if [ -f /etc/tux/config/crontab ] | ||
1187 | then | ||
1188 | if /usr/sbin/crond 2> /dev/null | ||
1189 | then | ||
1190 | echo "Starting crond" | ||
1191 | sort /etc/tux/config/crontab | uniq > /tmp/crontab 2> /dev/null | ||
1192 | cat /tmp/crontab > /etc/tux/config/crontab 2> /dev/null | ||
1193 | /usr/sbin/crontab /etc/tux/config/crontab 2> /dev/null | ||
1194 | crontab -l | ||
1195 | echo | ||
1196 | else | ||
1197 | echo "Unable to start crond" | ||
1198 | fi | ||
1199 | else | ||
1200 | echo "No crontab config found, not starting" | ||
1201 | fi | ||
1202 | |||
1203 | ### Erase /floppy/tux/options/console to disable console access | ||
1204 | ### | ||
1205 | ##if [ -f /etc/tux/options/console ] | ||
1206 | ##then | ||
1207 | ## [ -f /etc/tux/config/home ] && gethome | ||
1208 | ##else | ||
1209 | ## grep -v askfirst /etc/inittab > /etc/inittab.new | ||
1210 | ## rm /etc/inittab | ||
1211 | ## mv /etc/inittab.new /etc/inittab | ||
1212 | ##fi | ||
1213 | |||
1214 | ### Add a hack for dropbear with fixed partition | ||
1215 | |||
1216 | |||
1217 | # check for custom /etc/inittab | ||
1218 | |||
1219 | if [ -f /etc/tux/config/inittab ] | ||
1220 | then | ||
1221 | echo "Found custom inittab" | ||
1222 | cp /etc/tux/config/inittab /etc/inittab | ||
1223 | else | ||
1224 | echo "Using default inittab" | ||
1225 | fi | ||
1226 | |||
1227 | if [ -x /etc/init.d/dropbear ] | ||
1228 | then | ||
1229 | killall dropbear >2 | ||
1230 | echo "Restarting dropbear" | ||
1231 | /etc/init.d/dropbear | ||
1232 | fi | ||
1233 | |||
1234 | ### This shouldn't be necessary, but just in case | ||
1235 | |||
1236 | if [ -x /usr/local/sbin/sshd ] | ||
1237 | then | ||
1238 | if ps | grep -v sshd > /dev/null | ||
1239 | then | ||
1240 | echo "SSH server failed to start, trying again" | ||
1241 | /etc/init.d/opensshd | ||
1242 | fi | ||
1243 | fi | ||
1244 | |||
1245 | cat /README | tr '\t' ' ' > /usr/doc/trinux | ||
1246 | |||
1247 | ################################################################# | ||
1248 | |||
1249 | sleep 1 | ||
1250 | clear | ||
1251 | echo -n "Welcome to Trinux: A Linux Security Toolkit" | ||
1252 | if [ "$VERSION" ] | ||
1253 | then | ||
1254 | echo -n " (version " | ||
1255 | echo -n $VERSION | ||
1256 | echo ")" | ||
1257 | fi | ||
1258 | echo | ||
1259 | echo "Type 'man' for a list of help topics or 'man trinux' for docs." | ||
1260 | echo "ALT-<Left/Right> allows you to view other virtual terminals. " | ||
1261 | echo | ||
diff --git a/urunlevel/my_linux/Trinux/loadmodules b/urunlevel/my_linux/Trinux/loadmodules new file mode 100755 index 0000000..69c28ad --- /dev/null +++ b/urunlevel/my_linux/Trinux/loadmodules | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ls /lib/modules/*.o > /tmp/modules.in 2> /dev/null | ||
4 | ls /usr/local/lib/modules/*.o >> /tmp/modules.in 2> /dev/null | ||
5 | |||
6 | sort /tmp/modules.in | uniq > /tmp/modules | ||
7 | |||
8 | for module in `cat /tmp/modules` | ||
9 | do | ||
10 | base=`basename $module` | ||
11 | naked=`basename $base .o` | ||
12 | |||
13 | |||
14 | #echo "base: $base" | ||
15 | #echo "naked: $naked" | ||
16 | |||
17 | |||
18 | if grep $naked /etc/tux/config/modules 2> /dev/null | ||
19 | then | ||
20 | param=`grep $naked /etc/tux/config/modules | cut -d' ' -f2- 2> /dev/null` | ||
21 | echo "Loading $module $param" | ||
22 | if insmod $module $param 2> /dev/null | ||
23 | then | ||
24 | echo $module >> /etc/proc/modules.in | ||
25 | else | ||
26 | echo $module >> /etc/proc/modules.out | ||
27 | fi | ||
28 | fi | ||
29 | done | ||
30 | |||
diff --git a/urunlevel/my_linux/Trinux/net-config b/urunlevel/my_linux/Trinux/net-config new file mode 100755 index 0000000..2b85baa --- /dev/null +++ b/urunlevel/my_linux/Trinux/net-config | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo "By default Trinux configures eth0 via DHCP" | ||
4 | found_faces=`dmesg | grep eth[0-9]: | cut -d: -f1` | ||
5 | |||
6 | |||
7 | # Check for pcmcia | ||
8 | if lsmod | grep pcmcia_core > /dev/null 2> /dev/null | ||
9 | then | ||
10 | echo "PCMCIA modules running" | ||
11 | if ifconfig $face | grep UP > /dev/null 2> /dev/null | ||
12 | then | ||
13 | echo "PCMCIA interface already configured: exiting..." | ||
14 | exit | ||
15 | else | ||
16 | echo "PCMCIA interface was not configured: trying again" | ||
17 | fi | ||
18 | fi | ||
diff --git a/urunlevel/my_linux/Trinux/net-start b/urunlevel/my_linux/Trinux/net-start new file mode 100755 index 0000000..a090d85 --- /dev/null +++ b/urunlevel/my_linux/Trinux/net-start | |||
@@ -0,0 +1,141 @@ | |||
1 | #!/bin/sh | ||
2 | # net-start | ||
3 | # | ||
4 | # can also be run via "start net" or "start network" | ||
5 | # | ||
6 | |||
7 | |||
8 | # find which dhcp client | ||
9 | |||
10 | |||
11 | if [ -x /usr/sbin/dhcpcd ] | ||
12 | then | ||
13 | DHCPCLIENT="/usr/sbin/dhcpcd" | ||
14 | elif [ -x /sbin/udhcpc ] | ||
15 | then | ||
16 | DHCPCLIENT="/sbin/udhcpc" | ||
17 | else | ||
18 | echo "No DHCP client found!" | ||
19 | fi | ||
20 | |||
21 | /sbin/net-stop # bring down any interfaces and kill dhcp clients | ||
22 | |||
23 | [ -d /etc/proc ] || mkdir /etc/proc | ||
24 | |||
25 | probed=`dmesg | grep eth[0-9]: | cut -d: -f1` | ||
26 | |||
27 | cd /etc/tux/config/ | ||
28 | found_faces=`ls eth*` | ||
29 | |||
30 | echo "Found configs for: $found_faces" | ||
31 | |||
32 | # first bring up interfaces | ||
33 | |||
34 | for i in $found_faces | ||
35 | do | ||
36 | echo -n "Configuring $i:" | ||
37 | |||
38 | if grep dhcp /etc/tux/config/$i > /dev/null 2> /dev/null | ||
39 | then | ||
40 | DHCP="true" | ||
41 | # things are really easy we just do dhcp | ||
42 | echo " using DHCP" | ||
43 | killall dhcpcd 2> /dev/null | ||
44 | sleep 1 | ||
45 | if [ $DHCPCLIENT = "/usr/sbin/dhcpcd" ] | ||
46 | then | ||
47 | $DHCPCLIENT $i 2> /dev/null | ||
48 | else | ||
49 | $DHCPCLIENT -i $i 2> /dev/null | ||
50 | fi | ||
51 | |||
52 | else # static IP | ||
53 | |||
54 | if [ -f /etc/tux/config/$i ] | ||
55 | then | ||
56 | echo "settings found" | ||
57 | IP=`cut -d" " -f1 /etc/tux/config/$i` | ||
58 | MASK=`cut -d" " -f2 /etc/tux/config/$i` | ||
59 | |||
60 | if [ "$IP" ] | ||
61 | then | ||
62 | ifconfig $i $IP netmask $MASK up | ||
63 | fi | ||
64 | |||
65 | else | ||
66 | echo "no settings found, skipping..." | ||
67 | fi | ||
68 | fi | ||
69 | |||
70 | |||
71 | if [ "$i" = "eth0" ] | ||
72 | then | ||
73 | ifconfig $face | grep inet | cut -d":" -f2 | cut -d" " -f1 | grep -v 127.0.0.1 > /etc/proc/ipaddr | ||
74 | ln -sf /etc/proc/ipaddr /etc/proc/$i | ||
75 | nslookup `cat /etc/proc/ipaddr` | grep -v default | grep Name | cut -d":" -f2 | tr -d ' ' | tail -n 1 > /etc/proc/hostname | ||
76 | fi | ||
77 | |||
78 | done | ||
79 | |||
80 | if [ "$DHCP" ] | ||
81 | then | ||
82 | echo "Skipping DNS and gateway config" | ||
83 | else | ||
84 | echo -n "Adding default route: " | ||
85 | |||
86 | GW=`cat /etc/tux/config/gateway` | ||
87 | |||
88 | echo "$GW" | ||
89 | if [ "$GW" ] | ||
90 | then | ||
91 | route add default gw $GW | ||
92 | echo "done" | ||
93 | else | ||
94 | echo "failed" | ||
95 | fi | ||
96 | |||
97 | echo -n "Builing /etc/resolv.conf (DNS): " | ||
98 | # need to fix this for multiple DNS servers | ||
99 | |||
100 | DNS=`cat /etc/tux/config/dns 2>/dev/null` | ||
101 | |||
102 | if [ "$DNS" ] | ||
103 | then | ||
104 | echo "nameserver $DNS" > /etc/resolv.conf | ||
105 | else | ||
106 | echo "failed" | ||
107 | fi | ||
108 | fi | ||
109 | |||
110 | |||
111 | # update /etc/hosts and set HOSTNAME | ||
112 | |||
113 | IPADDR=`cat /etc/proc/ipaddr` | ||
114 | |||
115 | if [ -f /etc/tux/config/hostname ] | ||
116 | then | ||
117 | HOSTNAME=`cat /etc/tux/config/hostname` | ||
118 | else | ||
119 | HOSTNAME=`cat /etc/proc/hostname` | ||
120 | hlen=`length "$HOSTNAME"` | ||
121 | |||
122 | if [ "$hlen" -lt 1 ] | ||
123 | then | ||
124 | HOSTNAME='trinux' | ||
125 | fi | ||
126 | fi | ||
127 | |||
128 | echo "Setting hostname: $HOSTNAME" | ||
129 | hostname $HOSTNAME | ||
130 | |||
131 | echo "Building /etc/hosts" | ||
132 | if [ -f /etc/tux/config/hosts ] | ||
133 | then | ||
134 | cp /etc/tux/config/hosts /etc/hosts | ||
135 | fi | ||
136 | |||
137 | echo "127.0.0.1 localhost" >> /etc/hosts | ||
138 | echo "$IPADDR $HOSTNAME" >> /etc/hosts | ||
139 | |||
140 | sleep 3 | ||
141 | |||
diff --git a/urunlevel/my_linux/Trinux/net-stop b/urunlevel/my_linux/Trinux/net-stop new file mode 100755 index 0000000..4b60457 --- /dev/null +++ b/urunlevel/my_linux/Trinux/net-stop | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | killall udhcpcd 2> /dev/null | ||
4 | killall dhcpcd 2> /dev/null | ||
5 | killall pump 2> /dev/mull | ||
6 | |||
7 | for i in `grep eth /proc/net/dev | cut -d: -f1` | ||
8 | do | ||
9 | echo "Bringing down $i" | ||
10 | ifconfig $i down 2> /dev/null | ||
11 | done | ||
diff --git a/urunlevel/my_linux/Trinux/pkgadd b/urunlevel/my_linux/Trinux/pkgadd new file mode 100755 index 0000000..f04834b --- /dev/null +++ b/urunlevel/my_linux/Trinux/pkgadd | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # pkgadd - adds trinux packages (c) 1999 OpenSEC under GPL | ||
4 | # | ||
5 | # Author: Matthew Franz <mfranz@cisco.com> | ||
6 | # | ||
7 | # $1 = name of package | ||
8 | # | ||
9 | ########################################################################## | ||
10 | |||
11 | if [ $# -ne 0 ] | ||
12 | then | ||
13 | rm /*.tgz 2> /dev/null; rm /*.md5 2> /dev/null | ||
14 | |||
15 | # accepting package name with/without tarball extension | ||
16 | |||
17 | if echo $1 | grep -v tgz > /dev/null | ||
18 | then | ||
19 | FILE="$1.tgz" | ||
20 | else | ||
21 | FILE=$1 | ||
22 | fi | ||
23 | |||
24 | PREFIX=`echo $FILE | cut -d"." -f1` | ||
25 | |||
26 | if [ -f $FILE ] | ||
27 | then | ||
28 | echo "Adding $FILE" | ||
29 | PF=`pwd` | ||
30 | #cp $FILE /; cd / | ||
31 | cd / | ||
32 | gunzip -c $PF/${FILE} | tar xf - | ||
33 | |||
34 | if [ -f /etc/init.d/${PREFIX} ] | ||
35 | then | ||
36 | chmod a+x /etc/init.d/${PREFIX} 2> /dev/null | ||
37 | echo; echo "Initializing package: $PREFIX" | ||
38 | /etc/init.d/${PREFIX} 2> /dev/null | ||
39 | elif [ -f /etc/init.m/${PREFIX} ] | ||
40 | then | ||
41 | chmod a+x /etc/init.m/${PREFIX} 2> /dev/null | ||
42 | echo; echo "Initializing module: $PREFIX" | ||
43 | /etc/init.m/${PREFIX} 2> /dev/null | ||
44 | fi | ||
45 | |||
46 | # base=`echo $FILE | cut -d"." -f1` | ||
47 | # tar xf $base.tar | ||
48 | |||
49 | #rm $FILE | ||
50 | |||
51 | [ -x /etc/pkg/$PREFIX ] && ./etc/pkg/$PREFIX | ||
52 | else | ||
53 | echo "$FILE not found" | ||
54 | fi | ||
55 | |||
56 | else # no parameters !! | ||
57 | echo "Usage: " | ||
58 | echo ' pkgadd filename[.tgz] ' | ||
59 | echo | ||
60 | fi | ||
61 | |||
62 | |||
diff --git a/urunlevel/my_linux/Trinux/pkglist b/urunlevel/my_linux/Trinux/pkglist new file mode 100755 index 0000000..0fc82b0 --- /dev/null +++ b/urunlevel/my_linux/Trinux/pkglist | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ -f /etc/tux/config/server ] | ||
4 | then | ||
5 | SERVER=`cat /etc/tux/config/server` | ||
6 | else | ||
7 | SERVER="http://trinux.sf.net/pkg" | ||
8 | fi | ||
9 | |||
10 | snarf $SERVER - | cut -d'"' -f6 | grep "tgz" | sort | more | ||
11 | |||
12 | |||
diff --git a/urunlevel/my_linux/Trinux/quit b/urunlevel/my_linux/Trinux/quit new file mode 100755 index 0000000..555644b --- /dev/null +++ b/urunlevel/my_linux/Trinux/quit | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo "Preparing for reboot..." | ||
4 | |||
5 | savehome | ||
6 | savecfg | ||
7 | sync | ||
8 | sync | ||
9 | sync | ||
10 | reboot | ||
diff --git a/urunlevel/my_linux/Trinux/rmpkg b/urunlevel/my_linux/Trinux/rmpkg new file mode 100755 index 0000000..28e105a --- /dev/null +++ b/urunlevel/my_linux/Trinux/rmpkg | |||
@@ -0,0 +1,24 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ ! "$1" ] | ||
4 | then | ||
5 | echo "No package specified"; exit | ||
6 | fi | ||
7 | |||
8 | if [ -f /var/pkg/contents/$1 ] | ||
9 | then | ||
10 | |||
11 | echo "Deleting $1:" | ||
12 | |||
13 | for i in `cat /var/pkg/contents/$1` | ||
14 | do | ||
15 | if echo $i | grep -v "\/$" 2> /dev/null | ||
16 | then | ||
17 | rm /${i} 2> /dev/null | ||
18 | fi | ||
19 | done | ||
20 | |||
21 | rm /var/pkg/contents/$1 2> /dev/null | ||
22 | else | ||
23 | echo "/var/pkg/contents/$1 does not exist!" | ||
24 | fi | ||
diff --git a/urunlevel/my_linux/Trinux/save-config b/urunlevel/my_linux/Trinux/save-config new file mode 100755 index 0000000..587728b --- /dev/null +++ b/urunlevel/my_linux/Trinux/save-config | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo | ||
4 | echo "Trinux will save configuration information to the /tux directory" | ||
5 | echo "on a DOS formatted floppy or to C:\trinux\tux\ if you booted " | ||
6 | echo "from a fixed disk using loadlin" | ||
7 | |||
8 | if [ -f /etc/proc/boot ] | ||
9 | then | ||
10 | BOOT=`cat /etc/proc/boot` | ||
11 | else | ||
12 | BOOT="/dev/fd0" | ||
13 | fi | ||
14 | |||
15 | echo | ||
16 | echo "Boot device: $BOOT" | ||
17 | |||
18 | if [ "$BOOT" = "/dev/fd0" ] | ||
19 | then | ||
20 | echo -n "Please enter your boot/config floppy, then hit return: " | ||
21 | read blah | ||
22 | else | ||
23 | PREFIX="/trinux" | ||
24 | fi | ||
25 | |||
26 | if mount -t vfat $BOOT /boot | ||
27 | then | ||
28 | echo "Backing up old configuration" | ||
29 | cd /boot${PREFIX} | ||
30 | rm -r tux.bak 2> /dev/null | ||
31 | mv tux tux.bak | ||
32 | cp -a /etc/tux . | ||
33 | |||
34 | echo "Unmounting $BOOT" | ||
35 | cd /; umount /boot | ||
36 | else | ||
37 | echo "Unable to mount boot device!" | ||
38 | fi | ||
diff --git a/urunlevel/my_linux/Trinux/savecfg b/urunlevel/my_linux/Trinux/savecfg new file mode 100755 index 0000000..587728b --- /dev/null +++ b/urunlevel/my_linux/Trinux/savecfg | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo | ||
4 | echo "Trinux will save configuration information to the /tux directory" | ||
5 | echo "on a DOS formatted floppy or to C:\trinux\tux\ if you booted " | ||
6 | echo "from a fixed disk using loadlin" | ||
7 | |||
8 | if [ -f /etc/proc/boot ] | ||
9 | then | ||
10 | BOOT=`cat /etc/proc/boot` | ||
11 | else | ||
12 | BOOT="/dev/fd0" | ||
13 | fi | ||
14 | |||
15 | echo | ||
16 | echo "Boot device: $BOOT" | ||
17 | |||
18 | if [ "$BOOT" = "/dev/fd0" ] | ||
19 | then | ||
20 | echo -n "Please enter your boot/config floppy, then hit return: " | ||
21 | read blah | ||
22 | else | ||
23 | PREFIX="/trinux" | ||
24 | fi | ||
25 | |||
26 | if mount -t vfat $BOOT /boot | ||
27 | then | ||
28 | echo "Backing up old configuration" | ||
29 | cd /boot${PREFIX} | ||
30 | rm -r tux.bak 2> /dev/null | ||
31 | mv tux tux.bak | ||
32 | cp -a /etc/tux . | ||
33 | |||
34 | echo "Unmounting $BOOT" | ||
35 | cd /; umount /boot | ||
36 | else | ||
37 | echo "Unable to mount boot device!" | ||
38 | fi | ||
diff --git a/urunlevel/my_linux/Trinux/savehome b/urunlevel/my_linux/Trinux/savehome new file mode 100755 index 0000000..837c639 --- /dev/null +++ b/urunlevel/my_linux/Trinux/savehome | |||
@@ -0,0 +1,79 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # savehome - saves home directory to | ||
4 | |||
5 | if [ "$1" ] | ||
6 | then | ||
7 | home=$1 | ||
8 | else | ||
9 | home="home" | ||
10 | fi | ||
11 | |||
12 | |||
13 | |||
14 | if [ -f /etc/tux/config/home ] | ||
15 | then | ||
16 | PROTO=`cut -d':' -f1 /etc/tux/config/home` | ||
17 | HOST=`cut -d':' -f2 /etc/tux/config/home` | ||
18 | USER=`cut -d':' -f3 /etc/tux/config/home` | ||
19 | else | ||
20 | echo -n "ftp or ssh: " | ||
21 | read PROTO | ||
22 | echo -n "Host: " | ||
23 | read HOST | ||
24 | echo -n "User: " | ||
25 | read USER | ||
26 | echo $PROTO:$HOST:$USER > /etc/tux/config/home | ||
27 | fi | ||
28 | |||
29 | [ -d /usr/local/tmp ] || mkdir -p /usr/local/tmp | ||
30 | |||
31 | cd / | ||
32 | tar cf - home | gzip -f > /usr/local/tmp/$home.tgz | ||
33 | echo "Saving home directory to $USER@$HOST via $PROTO" | ||
34 | |||
35 | cd /usr/local/tmp | ||
36 | |||
37 | if [ "$PROTO" = "ssh" ] | ||
38 | then | ||
39 | scp $home.tgz $USER@$HOST:~ | ||
40 | fi | ||
41 | |||
42 | if [ "$PROTO" = "ftp" ] | ||
43 | then | ||
44 | echo "Using FTP to transfor $home.tgz -- your passwords are sniffable" | ||
45 | if [ -x /usr/bin/curl ] | ||
46 | then | ||
47 | curl -u $USER -T $home.tgz ftp://$HOST | ||
48 | |||
49 | else | ||
50 | echo "Curl is not installed. You will have to login with your" | ||
51 | echo "username and upload $home.tgz manually" | ||
52 | |||
53 | ftp $HOST | ||
54 | |||
55 | fi | ||
56 | fi | ||
57 | |||
58 | if [ "$PROTO" = "fixed" ] | ||
59 | then | ||
60 | if mount -t $PROTO $HOST /mnt | ||
61 | then | ||
62 | [ "$USER" ] && cd /mnt/$USER | ||
63 | cp /usr/local/tmp/$home.tgz . | ||
64 | cd / | ||
65 | umount /mnt | ||
66 | fi | ||
67 | fi | ||
68 | |||
69 | if [ "$PROTO" = "floppy" ] | ||
70 | then | ||
71 | if mount -t vfat /dev/fd0 /mnt | ||
72 | then | ||
73 | cp /usr/local/tmp/$home.tgz /mnt | ||
74 | cd / | ||
75 | umount /mnt | ||
76 | else | ||
77 | echo "Unable to mount floppy" | ||
78 | fi | ||
79 | fi | ||
diff --git a/urunlevel/my_linux/Trinux/update b/urunlevel/my_linux/Trinux/update new file mode 100755 index 0000000..ebeff6b --- /dev/null +++ b/urunlevel/my_linux/Trinux/update | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ ! "$*" ] | ||
4 | then | ||
5 | echo | ||
6 | echo "Usage: " | ||
7 | echo " update [kernel|initrd|pkglist]" | ||
8 | exit | ||
9 | fi | ||
10 | |||
11 | |||
12 | if [ -f /etc/proc/boot ] | ||
13 | then | ||
14 | BOOT=`cat /etc/proc/boot` | ||
15 | else | ||
16 | BOOT="/dev/fd0" | ||
17 | fi | ||
18 | |||
19 | echo | ||
20 | echo "Boot device: $BOOT" | ||
21 | |||
22 | if [ "$BOOT" = "/dev/fd0" ] | ||
23 | then | ||
24 | echo -n "Please enter your boot/config floppy, then hit return: " | ||
25 | read blah | ||
26 | else | ||
27 | PREFIX="/trinux" | ||
28 | fi | ||
29 | |||
30 | if mount -t vfat $BOOT /boot | ||
31 | then | ||
32 | if echo $* | grep "initrd" | ||
33 | then | ||
34 | INITRD=`cat /etc/tux/config/src/initrd` | ||
35 | if [ "$INITRD" ] | ||
36 | then | ||
37 | echo "Updating initrd from $INITRD" | ||
38 | cd /tmp | ||
39 | if snarf $INITRD | ||
40 | then | ||
41 | echo -n "Are you sure? " | ||
42 | read quest | ||
43 | if [ "$quest" != "n" ] | ||
44 | then | ||
45 | echo "Deleting existing initrd.gz" | ||
46 | cd /boot/$PREFIX | ||
47 | ls -al | ||
48 | rm initrd.gz | ||
49 | mv /tmp/initrd.gz . | ||
50 | fi | ||
51 | fi | ||
52 | else | ||
53 | echo "No initrd found" | ||
54 | fi | ||
55 | fi | ||
56 | |||
57 | sync | ||
58 | echo "Unmounting $BOOT" | ||
59 | cd /; umount /boot | ||
60 | else | ||
61 | echo "Unable to mount boot device!" | ||
62 | fi | ||
diff --git a/urunlevel/my_linux/bootrc b/urunlevel/my_linux/bootrc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/urunlevel/my_linux/bootrc | |||
diff --git a/urunlevel/my_linux/getpkg.c b/urunlevel/my_linux/getpkg.c new file mode 100644 index 0000000..9127c45 --- /dev/null +++ b/urunlevel/my_linux/getpkg.c | |||
@@ -0,0 +1,240 @@ | |||
1 | /* | ||
2 | * Mini getpkg implementation for busybox. | ||
3 | * | ||
4 | * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
19 | * 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | #include <unistd.h> | ||
26 | #include <sys/utsname.h> /* for uname(2) */ | ||
27 | |||
28 | #include "busybox.h" | ||
29 | #include "lib_init_d.h" | ||
30 | #include "my_linux.h" | ||
31 | |||
32 | |||
33 | #define GETPKG_OPT_ALL 1 | ||
34 | #define GETPKG_OPT_FILE 2 | ||
35 | #define GETPKG_OPT_KERNEL 4 | ||
36 | |||
37 | |||
38 | void init_package(char *temp) | ||
39 | { | ||
40 | if (stat(temp, &path_stat) == 0) | ||
41 | { | ||
42 | doit(0, "chmod a+x %s 2> /dev/null", temp); | ||
43 | bb_printf("Initializing %s\n", temp); | ||
44 | doit(0, "%s 2> /dev/null", temp); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | |||
49 | static char *DEFAULT_PACKAGES = | ||
50 | "LIB\n" | ||
51 | "system\n" | ||
52 | "baselib\n" | ||
53 | "term\n" | ||
54 | "modutil\n" | ||
55 | "swaputil\n" | ||
56 | "bash2\n" | ||
57 | "pthread\n" | ||
58 | "mc\n" | ||
59 | "ext2tools\n" | ||
60 | "sysutil\n" | ||
61 | "fileutil\n" | ||
62 | "diskutil\n" | ||
63 | "modutils\n" | ||
64 | "portmap\n" | ||
65 | "openssh\n" | ||
66 | "links"; | ||
67 | |||
68 | static char *DEFAULT_SERVERS = | ||
69 | "ftp://0.0.0.0/distros/Linux-on-net/Trinux/pkg/\n" | ||
70 | "ftp://192.168.146.25/distros/Linux-on-net/Trinux/pkg/\n" | ||
71 | "http://0.0.0.0/ftp/distros/Linux-on-net/Trinux/pkg/\n" | ||
72 | "http://www.trinux.org/pkg/\n" | ||
73 | "http://www.io.com/~mdfranz/trinux/pkg/"; | ||
74 | |||
75 | static char *DEFAULT_PATHS = | ||
76 | "/trinux/pkg\n" | ||
77 | "/trinux/bootpkg\n" | ||
78 | "/trinux/kpkg\n" | ||
79 | "/trinux\n" | ||
80 | "/pkg"; | ||
81 | |||
82 | static llist_t *package_head = NULL; /* growable list of packages */ | ||
83 | static llist_t *source_head = NULL; /* growable list of sources */ | ||
84 | |||
85 | |||
86 | int get_package(int opt, char *source, char *package, const char *KERNEL) | ||
87 | { | ||
88 | int result = 0; | ||
89 | int incomplete = 0; | ||
90 | char *PACKAGE = 0; | ||
91 | char *PRE = 0; | ||
92 | char *temp = ""; | ||
93 | |||
94 | if (strcmp(&package[bb_strlen(package) - 4], ".tgz") != 0) | ||
95 | temp = ".tgz"; | ||
96 | |||
97 | bb_xasprintf(&PACKAGE, "%s%s%s", KERNEL, package, temp); | ||
98 | bb_xasprintf(&PRE, "%s%s", KERNEL, package); | ||
99 | |||
100 | if (opt & GETPKG_OPT_FILE) | ||
101 | { | ||
102 | temp = concat_path_file(source, PACKAGE); | ||
103 | free(PACKAGE); | ||
104 | PACKAGE = temp; | ||
105 | bb_printf("Installing %s\n", PACKAGE); | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | char *URL; | ||
110 | |||
111 | temp = concat_path_file("/tmp", PACKAGE); | ||
112 | bb_xasprintf(&URL, "%s%s", source, PACKAGE); | ||
113 | free(PACKAGE); | ||
114 | PACKAGE = temp; | ||
115 | |||
116 | //bb_printf("Retrieving %s\n", URL); | ||
117 | doit(0, "wget -O %s %s", PACKAGE, URL); | ||
118 | if (errno) | ||
119 | incomplete = 1; | ||
120 | |||
121 | free(URL); | ||
122 | } | ||
123 | |||
124 | temp = ""; | ||
125 | if ((incomplete == 0) && (stat(PACKAGE, &path_stat) == 0)) | ||
126 | { | ||
127 | bb_xasprintf(&temp, doit(0, "gunzip -c %s | tar xvf -", PACKAGE)); | ||
128 | result = 1; | ||
129 | if (!(opt & GETPKG_OPT_FILE)) | ||
130 | remove_file(PACKAGE, FILEUTILS_FORCE); | ||
131 | } | ||
132 | doit(0, "echo \"%s\" > /var/lib/my_linux/contents/%s", temp, PRE); | ||
133 | |||
134 | if (result) | ||
135 | { | ||
136 | free(temp); | ||
137 | bb_xasprintf(&temp, "/etc/init.d/%s", PRE); | ||
138 | init_package(temp); | ||
139 | temp[10] = 'm'; | ||
140 | init_package(temp); | ||
141 | free(temp); | ||
142 | bb_xasprintf(&temp, "/etc/pkg/%s", PRE); | ||
143 | init_package(temp); | ||
144 | } | ||
145 | |||
146 | free(temp); | ||
147 | free(PACKAGE); | ||
148 | return result; | ||
149 | } | ||
150 | |||
151 | |||
152 | int getpkg_main(int argc, char **argv) | ||
153 | { | ||
154 | int i; | ||
155 | unsigned long opt; | ||
156 | char *PACKAGE = 0; | ||
157 | char *KERNEL = ""; | ||
158 | char *SRC = 0; | ||
159 | char *token; | ||
160 | char *strtok_temp; | ||
161 | |||
162 | opt = bb_getopt_ulflags(argc, argv, "afk"); | ||
163 | |||
164 | if (argv[optind]) | ||
165 | PACKAGE = argv[optind++]; | ||
166 | if (argv[optind]) | ||
167 | SRC = argv[optind++]; | ||
168 | if (PACKAGE == 0) | ||
169 | opt |= GETPKG_OPT_ALL; | ||
170 | if (opt & GETPKG_OPT_KERNEL) | ||
171 | { | ||
172 | struct utsname name; | ||
173 | |||
174 | if (uname(&name) == -1) | ||
175 | bb_perror_msg_and_die("cannot get system information"); | ||
176 | bb_xasprintf(&KERNEL, "%s/", name.release); | ||
177 | } | ||
178 | |||
179 | if (opt & GETPKG_OPT_ALL) | ||
180 | { | ||
181 | if (PACKAGE != 0) | ||
182 | { | ||
183 | SRC = PACKAGE; | ||
184 | PACKAGE = 0; | ||
185 | } | ||
186 | PACKAGE = quick_read("/var/lib/my_linux/config/pkglist"); | ||
187 | if ((PACKAGE == 0) || (PACKAGE[0] == '\0')) | ||
188 | { | ||
189 | PACKAGE = (char *) xmalloc (sizeof (char) * bb_strlen(DEFAULT_PACKAGES) + 1); | ||
190 | strcpy(PACKAGE, DEFAULT_PACKAGES); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | if (SRC == 0) | ||
195 | { | ||
196 | SRC = quick_read("/var/lib/my_linux/config/server"); | ||
197 | if ((SRC == 0) || (SRC[0] == '\0')) | ||
198 | { | ||
199 | if (opt & GETPKG_OPT_FILE) | ||
200 | token = DEFAULT_PATHS; | ||
201 | else | ||
202 | token = DEFAULT_SERVERS; | ||
203 | SRC = (char *) xmalloc (sizeof (char) * bb_strlen(token) + 1); | ||
204 | strcpy(SRC, token); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | token = strtok_r(PACKAGE, " \r\n", &strtok_temp); | ||
209 | for (i = 0; token != NULL; i++) | ||
210 | { | ||
211 | package_head = llist_add_to_end(package_head, token); | ||
212 | token = strtok_r(NULL, " \r\n", &strtok_temp); | ||
213 | } | ||
214 | |||
215 | token = strtok_r(SRC, " \r\n", &strtok_temp); | ||
216 | for (i = 0; token != NULL; i++) | ||
217 | { | ||
218 | source_head = llist_add_to_end(source_head, token); | ||
219 | token = strtok_r(NULL, " \r\n", &strtok_temp); | ||
220 | } | ||
221 | |||
222 | |||
223 | llist_t *package_current = package_head; | ||
224 | while (package_current) | ||
225 | { | ||
226 | int found = 0; | ||
227 | llist_t *source_current = source_head; | ||
228 | |||
229 | while (source_current) | ||
230 | { | ||
231 | if ((found = get_package(opt, source_current->data, package_current->data, KERNEL))) | ||
232 | break; | ||
233 | source_current = source_current->link; | ||
234 | } | ||
235 | |||
236 | package_current = package_current->link; | ||
237 | } | ||
238 | |||
239 | return EXIT_SUCCESS; | ||
240 | } | ||
diff --git a/urunlevel/my_linux/inittab b/urunlevel/my_linux/inittab new file mode 100644 index 0000000..2f90616 --- /dev/null +++ b/urunlevel/my_linux/inittab | |||
@@ -0,0 +1,17 @@ | |||
1 | ::sysinit:/sbin/rcS | ||
2 | #tty1::respawn:/sbin/getty 38400 tty1 | ||
3 | #tty2::respawn:/sbin/getty 38400 tty2 | ||
4 | tty1::respawn:/sbin/getty -inl /usr/sbin/tw1 38400 tty1 | ||
5 | tty2::respawn:/sbin/getty -inl /usr/sbin/tw2 38400 tty2 | ||
6 | tty3::respawn:/sbin/getty -inl /usr/sbin/tw3 38400 tty3 | ||
7 | tty4::respawn:/sbin/getty -inl /usr/sbin/tw4 38400 tty4 | ||
8 | #tty5::respawn:/usr/X11R6/bin/X | ||
9 | tty9::once:/sbin/rc | ||
10 | tty10::respawn:/bin/tail -f /var/log/messages | ||
11 | tty11::once:/bin/dmesg | ||
12 | tty11::respawn:/sbin/klogd -n | ||
13 | ::ctrlaltdel:/sbin/reboot | ||
14 | ::shutdown:/sbin/rc 0 | ||
15 | ::shutdown:/sbin/swapoff -a | ||
16 | ::shutdown:/bin/umount -a -r | ||
17 | ::restart:/sbin/init | ||
diff --git a/urunlevel/my_linux/lib_init_d.h b/urunlevel/my_linux/lib_init_d.h new file mode 100644 index 0000000..13253e9 --- /dev/null +++ b/urunlevel/my_linux/lib_init_d.h | |||
@@ -0,0 +1,183 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
17 | * 02111-1307 USA | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #ifndef _INIT_D_H | ||
22 | #define _INIT_D_H | ||
23 | |||
24 | |||
25 | /* | ||
26 | * init script defines | ||
27 | */ | ||
28 | |||
29 | #define INIT_D_COMMENT "\n#// " | ||
30 | #define INIT_D_BEGIN "\n### BEGIN INIT INFO " | ||
31 | #define INIT_D_PROV "\n# Provides: " | ||
32 | #define INIT_D_RSTART "\n# Required-Start: " | ||
33 | #define INIT_D_RSTOP "\n# Required-Stop: " | ||
34 | #define INIT_D_SSTART "\n# Should-Start: " | ||
35 | #define INIT_D_SSTOP "\n# Should-Stop: " | ||
36 | #define INIT_D_DSTART "\n# Default-Start: " | ||
37 | #define INIT_D_DSTOP "\n# Default-Stop: " | ||
38 | #define INIT_D_SDESC "\n# Short-Description: " | ||
39 | #define INIT_D_DESC "\n# Description: " | ||
40 | #define INIT_D_CONT "\n#\t" | ||
41 | #define INIT_D_CONT2 "\n# " | ||
42 | #define INIT_D_END "\n### END INIT INFO\n" | ||
43 | #define INIT_D_CUSTOM "\n# X-" | ||
44 | |||
45 | |||
46 | /* | ||
47 | * init info | ||
48 | */ | ||
49 | |||
50 | typedef struct init_d_info_s { | ||
51 | char **provides; | ||
52 | char **reqstart; | ||
53 | char **reqstop; | ||
54 | char **shouldstart; | ||
55 | char **shouldstop; | ||
56 | int *defstart; | ||
57 | int *defstop; | ||
58 | char *shortdesc; | ||
59 | char *desc; | ||
60 | char *comment; | ||
61 | int sizes[11]; | ||
62 | char *path; | ||
63 | llist_t *start; | ||
64 | } init_d_info_t; | ||
65 | |||
66 | |||
67 | /* | ||
68 | * init commands | ||
69 | */ | ||
70 | |||
71 | typedef struct init_d_handle_s { | ||
72 | int (*start)(struct init_d_handle_s *); | ||
73 | int (*stop)(struct init_d_handle_s *); | ||
74 | int (*restart)(struct init_d_handle_s *); | ||
75 | int (*try_restart)(struct init_d_handle_s *); | ||
76 | int (*reload)(struct init_d_handle_s *); | ||
77 | int (*force_reload)(struct init_d_handle_s *); | ||
78 | int (*status)(struct init_d_handle_s *, int); | ||
79 | int (*show_info)(struct init_d_handle_s *); | ||
80 | char *basename; | ||
81 | char *pathname; | ||
82 | char *args; | ||
83 | char *pidfile; | ||
84 | char *info; | ||
85 | } init_d_handle_t; | ||
86 | |||
87 | |||
88 | int do_init_from_main(int argc, char **argv, struct init_d_handle_s *init_d); | ||
89 | int do_init(struct init_d_handle_s *init_d, const char *command); | ||
90 | |||
91 | int default_start(struct init_d_handle_s *); | ||
92 | int default_stop(struct init_d_handle_s *); | ||
93 | int default_restart(struct init_d_handle_s *); | ||
94 | int default_try_restart(struct init_d_handle_s *); | ||
95 | int default_reload(struct init_d_handle_s *); | ||
96 | int default_force_reload(struct init_d_handle_s *); | ||
97 | int default_status(struct init_d_handle_s *, int); | ||
98 | int default_show_info(struct init_d_handle_s *); | ||
99 | |||
100 | int no_stop(struct init_d_handle_s *); | ||
101 | int no_reload(struct init_d_handle_s *); | ||
102 | int no_status(struct init_d_handle_s *, int); | ||
103 | |||
104 | /* | ||
105 | * error codes | ||
106 | */ | ||
107 | |||
108 | #define INIT_D_OK 0 | ||
109 | #define INIT_D_ERROR_GENERIC 1 | ||
110 | #define INIT_D_ERROR_ARGS 2 | ||
111 | #define INIT_D_ERROR_NOT_IMPLEMENTED 3 | ||
112 | #define INIT_D_ERROR_SECURITY 4 | ||
113 | #define INIT_D_ERROR_NOT_INSTALLED 5 | ||
114 | #define INIT_D_ERROR_NOT_CONFIGURED 6 | ||
115 | #define INIT_D_ERROR_NOT_RUNNING 7 | ||
116 | |||
117 | |||
118 | /* | ||
119 | * status codes | ||
120 | */ | ||
121 | |||
122 | #define INIT_D_STATUS_OK 0 | ||
123 | #define INIT_D_STATUS_DEAD_PID 1 | ||
124 | #define INIT_D_STATUS_DEAD_LOCK 2 | ||
125 | #define INIT_D_STATUS_NOT_RUNNING 3 | ||
126 | #define INIT_D_STATUS_UNKNOWN 4 | ||
127 | |||
128 | |||
129 | /* | ||
130 | * /lib/lsb/init-functions | ||
131 | */ | ||
132 | int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args); | ||
133 | int killproc(char *pidfile, char *pathname, int my_signal); | ||
134 | int checkpid(char *pid); | ||
135 | int pidofproc(char *pidfile, char *pathname, char **pids); | ||
136 | void log_success_msg(char *message); | ||
137 | void log_failure_msg(char *message); | ||
138 | void log_warning_msg(char *message); | ||
139 | |||
140 | |||
141 | #define REDIR 1 | ||
142 | #define QUIET 2 | ||
143 | #define ERRONLY 4 | ||
144 | #define FORK 8 | ||
145 | #define NOFORK 16 | ||
146 | #define DAEMON 32 | ||
147 | |||
148 | extern struct stat path_stat; | ||
149 | |||
150 | typedef struct nodes_s | ||
151 | { | ||
152 | const char *name; | ||
153 | mode_t mode; | ||
154 | int major; | ||
155 | int minor; | ||
156 | int count; | ||
157 | } nodes_t; | ||
158 | |||
159 | |||
160 | char *argv_cat(int argc, char **argv); | ||
161 | char *big_chomp(char *s); | ||
162 | int checkpid(char *pid); | ||
163 | char *doit(int mode, char *command, ...); | ||
164 | |||
165 | #ifndef CONFIG_IFUPDOWN | ||
166 | #define RUNLEVEL_LIST 1 | ||
167 | #endif | ||
168 | #ifdef RUNLEVEL_LIST | ||
169 | // From ifupdown, so it should probably be in libbb. | ||
170 | llist_t *llist_add_to_end(llist_t *list_head, char *data); | ||
171 | #else | ||
172 | extern llist_t *llist_add_to_end(llist_t *list_head, char *data); | ||
173 | #endif | ||
174 | |||
175 | llist_t *llist_delete(llist_t **unsorted, llist_t *previous, llist_t *current); | ||
176 | void make_disk(char *token, const nodes_t *nodes); | ||
177 | void make_ram_disk(int size, int number, char *place, int TMPFS); | ||
178 | void quick_mount(char *type, char *device, char *path, char *data, ...); | ||
179 | char *quick_read(char *filename); | ||
180 | void quick_write(const char *filename, const char *data, ...); | ||
181 | |||
182 | |||
183 | #endif | ||
diff --git a/urunlevel/my_linux/linuxrc.c b/urunlevel/my_linux/linuxrc.c new file mode 100644 index 0000000..15fba1a --- /dev/null +++ b/urunlevel/my_linux/linuxrc.c | |||
@@ -0,0 +1,829 @@ | |||
1 | /* | ||
2 | * Mini linuxrc implementation for busybox. | ||
3 | * An implementation of the linuxrc boot script. | ||
4 | * | ||
5 | * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
20 | * 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <dirent.h> | ||
25 | #include <fcntl.h> | ||
26 | #include <unistd.h> | ||
27 | #include <errno.h> | ||
28 | #include <signal.h> | ||
29 | #include <string.h> | ||
30 | #include <sys/poll.h> | ||
31 | #include <sys/wait.h> | ||
32 | #include <sys/utsname.h> /* for uname(2) */ | ||
33 | |||
34 | #include "busybox.h" | ||
35 | #include "lib_init_d.h" | ||
36 | #include "my_linux.h" | ||
37 | |||
38 | |||
39 | const static char *directories[] = | ||
40 | { | ||
41 | "boot", | ||
42 | "dev/pts", | ||
43 | "dev/input", | ||
44 | "lib", | ||
45 | "media/ROOT", | ||
46 | "media/cdrom", | ||
47 | "media/floppy", | ||
48 | "mnt", | ||
49 | "opt", | ||
50 | "proc", | ||
51 | "sbin", | ||
52 | "sys", | ||
53 | "udev", | ||
54 | "usr/bin", | ||
55 | "usr/etc/init.d", | ||
56 | "usr/lib", | ||
57 | "usr/sbin", | ||
58 | "var/cache", | ||
59 | "var/etc/network/if-down.d", | ||
60 | "var/etc/network/if-post-down.d", | ||
61 | "var/etc/network/if-pre-up.d", | ||
62 | "var/etc/network/if-up.d", | ||
63 | "var/etc/sysconfig", | ||
64 | "var/home/root", | ||
65 | "var/lib/misc", | ||
66 | "var/lib/network", | ||
67 | "var/lib/my_linux/init.m/done", | ||
68 | "var/lib/my_linux/pkg", | ||
69 | "var/lib/my_linux/config", | ||
70 | "var/lib/my_linux/contents", | ||
71 | "var/log", | ||
72 | "var/spool/cron/crontabs", | ||
73 | "var/temp", | ||
74 | "var/tmp", | ||
75 | #ifdef CONFIG_FEATURE_FULL_LSB | ||
76 | "boot/grub", | ||
77 | "bin", | ||
78 | "dev/net", | ||
79 | "etc/X11", | ||
80 | "etc/cron.d", | ||
81 | "etc/cron.daily", | ||
82 | "etc/cron.fortnightly", | ||
83 | "etc/cron.hourly", | ||
84 | "etc/cron.monthly", | ||
85 | "etc/cron.weekly", | ||
86 | "etc/cups", | ||
87 | "etc/opt", | ||
88 | "etc/sgml", | ||
89 | "etc/udev", | ||
90 | "lib/lsb", | ||
91 | "lib/modules/2.6.9/kernel", | ||
92 | "opt/bin", | ||
93 | "opt/doc", | ||
94 | "opt/include", | ||
95 | "opt/info", | ||
96 | "opt/lib", | ||
97 | "opt/man", | ||
98 | "usr/X11R6", | ||
99 | "usr/X11R6/bin", | ||
100 | "usr/X11R6/include/X11", | ||
101 | "usr/X11R6/lib/X11", | ||
102 | "usr/X11R6/man/en/man8", | ||
103 | "usr/doc", | ||
104 | "usr/games", | ||
105 | "usr/i386-linux-uclibc/include", | ||
106 | "usr/i386-linux-uclibc/lib", | ||
107 | "usr/i386-linux-uclibc/games", | ||
108 | "usr/i386-linux-uclibc/lsb", | ||
109 | "usr/include/bsd", | ||
110 | "usr/local/bin", | ||
111 | "usr/local/games", | ||
112 | "usr/local/i386-linux-uclibc/include", | ||
113 | "usr/local/i386-linux-uclibc/lib", | ||
114 | "usr/local/include", | ||
115 | "usr/local/lib", | ||
116 | "usr/local/man/en/man8", | ||
117 | "usr/local/sbin", | ||
118 | "usr/local/share", | ||
119 | "usr/local/src", | ||
120 | "usr/share/dict", | ||
121 | "usr/share/doc", | ||
122 | "usr/share/games", | ||
123 | "usr/share/ghostscript", | ||
124 | "usr/share/groff", | ||
125 | "usr/share/info", | ||
126 | "usr/share/kbd", | ||
127 | "usr/share/locale", | ||
128 | "usr/share/man/en/man8", | ||
129 | "usr/share/misc/getopt", | ||
130 | "usr/share/nls", | ||
131 | "usr/share/perl", | ||
132 | "usr/share/sgml/docbook", | ||
133 | "usr/share/sgml/html/dtd", | ||
134 | "usr/share/sgml/tei", | ||
135 | "usr/share/terminfo", | ||
136 | "usr/share/texmf", | ||
137 | "usr/share/zoneinfo", | ||
138 | "usr/src/linux-2.6.9/include", | ||
139 | "usr/src/packages/BUILD", | ||
140 | "usr/src/packages/RPMS/athlon", | ||
141 | "usr/src/packages/RPMS/i386", | ||
142 | "usr/src/packages/RPMS/i486", | ||
143 | "usr/src/packages/RPMS/i586", | ||
144 | "usr/src/packages/RPMS/i686", | ||
145 | "usr/src/packages/RPMS/noarch", | ||
146 | "usr/src/packages/SOURCES", | ||
147 | "usr/src/packages/SPECS", | ||
148 | "usr/src/packages/SRPMS", | ||
149 | "var/account", | ||
150 | "var/backups", | ||
151 | "var/cache/fonts", | ||
152 | "var/cache/man/en/man8", | ||
153 | "var/cache/www", | ||
154 | "var/cron", | ||
155 | "var/games", | ||
156 | "var/lib/hwclock", | ||
157 | "var/lib/xdm", | ||
158 | "var/local", | ||
159 | "var/msgs", | ||
160 | "var/nis", | ||
161 | "var/opt", | ||
162 | "var/preserve", | ||
163 | "var/spool/lpd", | ||
164 | "var/spool/mail", | ||
165 | "var/spool/mqueue", | ||
166 | "var/spool/news", | ||
167 | "var/spool/rwho", | ||
168 | "var/spool/uucp", | ||
169 | "var/yp", | ||
170 | #endif | ||
171 | NULL | ||
172 | }; | ||
173 | |||
174 | |||
175 | const static nodes_t nodes[] = | ||
176 | { | ||
177 | {"initctl", S_IFIFO, 0, 0, 0}, | ||
178 | {"log", S_IFIFO, 0, 0, 0}, | ||
179 | {"mem", S_IFCHR, 1, 1, 0}, | ||
180 | {"kmem", S_IFCHR, 1, 2, 0}, | ||
181 | {"port", S_IFCHR, 1, 4, 0}, | ||
182 | {"zero", S_IFCHR, 1, 5, 0}, | ||
183 | {"full", S_IFCHR, 1, 7, 0}, | ||
184 | {"random", S_IFCHR, 1, 8, 0}, | ||
185 | {"urandom", S_IFCHR, 1, 9, 0}, | ||
186 | {"tty", S_IFCHR, 5, 0, 0}, | ||
187 | {"psaux", S_IFCHR, 10, 1, 0}, | ||
188 | {"hda", S_IFBLK, 3, 0, 0}, | ||
189 | {"hdb", S_IFBLK, 3, 64, 0}, | ||
190 | {"hdc", S_IFBLK, 22, 0, 0}, | ||
191 | {"hdd", S_IFBLK, 22, 64, 0}, | ||
192 | {"ram", S_IFBLK, 1, 0, 9}, | ||
193 | {"fd", S_IFBLK, 2, 0, 1}, | ||
194 | {"tty", S_IFCHR, 4, 0,12}, | ||
195 | {"ttyS", S_IFCHR, 4, 64,47}, | ||
196 | {"loop", S_IFBLK, 7, 0,63}, | ||
197 | {"cloop", S_IFBLK, 240, 0, 7}, | ||
198 | {"vcs", S_IFBLK, 7, 0, 9}, | ||
199 | {"vcsa", S_IFBLK, 7, 0, 9}, | ||
200 | {"input/keyboard", S_IFCHR, 10,150, 0}, | ||
201 | {"input/js", S_IFCHR, 13, 0, 31}, | ||
202 | {"input/mouse", S_IFCHR, 13, 32, 30}, | ||
203 | {"input/mice", S_IFCHR, 13, 63, 0}, | ||
204 | {"input/event", S_IFCHR, 13, 64, 63}, | ||
205 | #ifdef CONFIG_FEATURE_FULL_LSB | ||
206 | {"net/tun", S_IFCHR, 10,200, 0}, | ||
207 | {"fb0", S_IFCHR, 29, 0, 0}, | ||
208 | {"fb1", S_IFCHR, 29, 32, 0}, | ||
209 | {"fb2", S_IFCHR, 29, 64, 0}, | ||
210 | {"fb3", S_IFCHR, 29, 96, 0}, | ||
211 | #endif | ||
212 | {0, 0, 0, 0, 0} | ||
213 | }; | ||
214 | |||
215 | |||
216 | const static char *files[][2] = | ||
217 | { | ||
218 | {"/var/etc/crontab", ""}, | ||
219 | // {"/var/etc/fstab", "none\t/dev/shm\tshm\tdefaults\t0 0\n/\t/dev/ram0\tminix\tdefaults\t0 0\n"}, | ||
220 | {"/var/etc/fstab", ""}, | ||
221 | {"/var/etc/group", "root:x:0:\ndaemon:x:2:\nshadow:x:42:\nusers:x:100:\nnogroup:x:65534:\n"}, | ||
222 | {"/var/etc/host.conf", "order hosts,bind\nmulti on\n"}, | ||
223 | {"/var/etc/hosts", "127.0.0.1 localhost\n"}, | ||
224 | {"/var/etc/inittab", "::sysinit:/sbin/rcS\ntty1::respawn:/bin/ash\ntty9::once:/sbin/rc 1\ntty11::once:/bin/dmesg\n::ctrlaltdel:/sbin/reboot\n::shutdown:/sbin/rc 0\n::shutdown:/sbin/swapoff -a\n::shutdown:/bin/umount -a -r\n::restart:/sbin/init\n"}, | ||
225 | {"/var/etc/ld.so.conf", ""}, | ||
226 | {"/var/etc/network/interfaces", "auto lo eth0\niface lo inet loopback\niface eth0 inet dhcp\n"}, | ||
227 | {"/var/etc/passwd", "root::0:0:My Linux Root:/root:/bin/sh\nftp:x:40:2:ftp:/tmp:/bin/sh\nsshd:x:41:2:sshd:/tmp:/bin/sh\nnobody:x:65534:65534:nobody:/tmp:/bin/sh\n"}, | ||
228 | {"/var/etc/resolv.conf", "search cluster.meeting.humbug.org.au\nnameserver 192.168.254.254\n"}, | ||
229 | {"/var/etc/securetty", "tty1\n"}, | ||
230 | {"/var/etc/shells", "/bin/ash\n/bin/hush\n/bin/lash\n/bin/msh\n/bin/sh\n"}, | ||
231 | #ifdef CONFIG_FEATURE_FULL_LSB | ||
232 | {"/boot/grub/device.map", "(hd0)\t/dev/hda\n(hd1)\t/dev/hdb\n(hd2)\t/dev/hdc\n(hd3)\t/dev/hdd\n(fd0)\t/dev/fd0\n"}, | ||
233 | #endif | ||
234 | {NULL, NULL} | ||
235 | }; | ||
236 | |||
237 | |||
238 | const static char *scripts[][2] = | ||
239 | { | ||
240 | {"/sbin/shownet", "#!/bin/sh\necho \"\"\nifconfig\nroute\nip addr list\nip link list\nip route list\necho \"\"\n"}, | ||
241 | {"/var/etc/profile", "#!/bin/sh\nPATH=/usr/bin:/usr/sbin:/bin:/sbin\nexport PATH\n"}, | ||
242 | #ifdef CONFIG_FEATURE_FULL_LSB | ||
243 | #endif | ||
244 | {NULL, NULL} | ||
245 | }; | ||
246 | |||
247 | |||
248 | const static char *links[][2] = | ||
249 | { | ||
250 | {"/proc/kcore", "/dev/core"}, | ||
251 | {"/dev/ram1", "/dev/ram"}, | ||
252 | {"/dev/vcs0", "/dev/vcs"}, | ||
253 | {"/dev/vcsa0", "/dev/vcsa"}, | ||
254 | {"/var/home", "/home"}, | ||
255 | {"/home/root", "/root"}, | ||
256 | {"/bin/busybox", "/sbin/init"}, | ||
257 | {"/bin/busybox", "/sbin/local_fs"}, | ||
258 | {"/bin/busybox", "/sbin/network"}, | ||
259 | {"/var/temp", "/tmp"}, | ||
260 | {"/sbin/local_fs", "/usr/etc/init.d/local_fs" }, | ||
261 | {"/sbin/boot_named", "/usr/etc/init.d/boot_named"}, | ||
262 | {"/sbin/network", "/usr/etc/init.d/network"}, | ||
263 | {"/sbin/boot_portmap", "/usr/etc/init.d/boot_portmap"}, | ||
264 | {"/sbin/remote_fs", "/usr/etc/init.d/remote_fs" }, | ||
265 | {"/sbin/boot_syslog", "/usr/etc/init.d/boot_syslog"}, | ||
266 | {"/sbin/boot_time", "/usr/etc/init.d/boot_time"}, | ||
267 | {"/usr/sbin/install_initd", "/usr/lib/lsb/install_initd" }, | ||
268 | {"/usr/sbin/remove_initd", "/usr/lib/lsb/remove_initd" }, | ||
269 | {"/usr/etc/init.d", "/var/etc/init.d"}, | ||
270 | {"/usr/etc/protocols", "/var/etc/protocols"}, | ||
271 | {"/usr/etc/rpc", "/var/etc/rpc"}, | ||
272 | {"/usr/etc/services", "/var/etc/services"}, | ||
273 | {"/var/lib/my_linux", "/var/etc/tux"}, | ||
274 | {"/.mc", "/var/home/root/.mc"}, | ||
275 | {"/tmp", "/var/lock"}, | ||
276 | {"/tmp", "/var/run"}, | ||
277 | #ifdef CONFIG_FEATURE_FULL_LSB | ||
278 | #endif | ||
279 | {NULL, NULL} | ||
280 | }; | ||
281 | |||
282 | |||
283 | const static char *modules[] = | ||
284 | { | ||
285 | // "af_packet", | ||
286 | // Should try all NICS instead. | ||
287 | // "mii", | ||
288 | // "ne2k-pci", | ||
289 | // "nfs", | ||
290 | NULL | ||
291 | }; | ||
292 | |||
293 | |||
294 | llist_t *floppies_list = NULL; | ||
295 | llist_t *cdroms_list = NULL; | ||
296 | llist_t *hard_disks_list = NULL; | ||
297 | static void find_all_drives(void) | ||
298 | { | ||
299 | int count; | ||
300 | struct dirent **dir; | ||
301 | |||
302 | if ((floppies_list == NULL) && (cdroms_list == NULL) && (hard_disks_list == NULL)) | ||
303 | { | ||
304 | // This is hard coded for now. | ||
305 | floppies_list = llist_add_to(floppies_list, "fd0"); | ||
306 | if ((count = scandir("/proc/ide", &dir, 0, alphasort))) | ||
307 | { | ||
308 | int n; | ||
309 | |||
310 | for (n = 0; n < count; n++) | ||
311 | { | ||
312 | struct dirent *script = dir[n]; | ||
313 | struct stat script_stat; | ||
314 | char *info_text = NULL; | ||
315 | |||
316 | bb_xasprintf(&info_text, "/proc/ide/%s", script->d_name); | ||
317 | if (stat(info_text, &script_stat) == 0) | ||
318 | { | ||
319 | if (strncmp(info_text, "/proc/ide/hd", 12) == 0) | ||
320 | { | ||
321 | char *text = NULL; | ||
322 | char *name = NULL; | ||
323 | |||
324 | bb_xasprintf(&text, "%s", doit(REDIR, "cat %s/media", info_text)); | ||
325 | bb_xasprintf(&name, "%s", script->d_name); | ||
326 | if (strcmp(text, "disk") == 0) | ||
327 | { | ||
328 | // Should add partitions instead. | ||
329 | hard_disks_list = llist_add_to(hard_disks_list, name); | ||
330 | } | ||
331 | else | ||
332 | cdroms_list = llist_add_to(cdroms_list, name); | ||
333 | } | ||
334 | free(info_text); | ||
335 | } | ||
336 | free(dir[n]); | ||
337 | } | ||
338 | free(dir); | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | |||
343 | |||
344 | static int is_boot_device(char *device, char *image, char **type); | ||
345 | static int find_boot_device_in_list(llist_t *disks, char *image, char **device, char **type) | ||
346 | { | ||
347 | int result = 0; | ||
348 | char *original = *device; | ||
349 | llist_t *current = disks; | ||
350 | |||
351 | while (current) | ||
352 | { | ||
353 | char *disc = current->data; | ||
354 | |||
355 | bb_printf("Checking %s for %s\n", disc, image); | ||
356 | bb_xasprintf(device, "/dev/%s", disc); | ||
357 | if (is_boot_device(*device, image, type)) | ||
358 | { | ||
359 | result = 1; | ||
360 | free(*device); | ||
361 | bb_xasprintf(device, "/dev/%s", disc); | ||
362 | *device = concat_path_file(*device, image); | ||
363 | break; | ||
364 | } | ||
365 | current = current->link; | ||
366 | free(*device); | ||
367 | *device = original; | ||
368 | } | ||
369 | return result; | ||
370 | } | ||
371 | |||
372 | |||
373 | static int is_boot_device(char *device, char *image, char **type) | ||
374 | { | ||
375 | int result = 0; | ||
376 | |||
377 | if (*type == NULL) | ||
378 | { | ||
379 | // Should try to detect it. | ||
380 | *type = "auto"; | ||
381 | } | ||
382 | quick_mount(*type, device, "/boot", "-o ro"); | ||
383 | if (errno == 0) | ||
384 | { | ||
385 | char *dest = concat_path_file("/boot", image); | ||
386 | |||
387 | if (stat(dest, &path_stat) == 0) | ||
388 | { | ||
389 | if (stat("/boot/bootrc", &path_stat) == 0) | ||
390 | result = 1; | ||
391 | } | ||
392 | if (result == 0) | ||
393 | doit(QUIET, "umount /boot"); | ||
394 | free(dest); | ||
395 | } | ||
396 | |||
397 | return result; | ||
398 | } | ||
399 | |||
400 | |||
401 | static void pivot_dir(char *place, const char *root) | ||
402 | { | ||
403 | char *dest = concat_path_file(root, place); | ||
404 | |||
405 | remove_file(place, FILEUTILS_FORCE | FILEUTILS_RECUR); | ||
406 | symlink(dest, place); | ||
407 | free(dest); | ||
408 | } | ||
409 | |||
410 | |||
411 | static int rebuild_fs(char *root) | ||
412 | { | ||
413 | int result = 0; | ||
414 | char *check = concat_path_file(root, "var/lib/distro"); | ||
415 | |||
416 | if (stat(check, &path_stat) == 0) | ||
417 | { | ||
418 | free(check); | ||
419 | bb_printf("Rebuilding root fs from %s.\n", root); | ||
420 | check = concat_path_file(root, "bootrc"); | ||
421 | copy_file(check, "/bootrc", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS); | ||
422 | free(check); | ||
423 | pivot_dir("/boot", root); | ||
424 | pivot_dir("/etc", root); | ||
425 | remove_file("/var/etc", FILEUTILS_FORCE | FILEUTILS_RECUR); | ||
426 | pivot_dir("/opt", root); | ||
427 | pivot_dir("/sbin", root); | ||
428 | pivot_dir("/usr", root); | ||
429 | // Should pivot dev and var if root is writable. | ||
430 | check = concat_path_file(root, "dev"); | ||
431 | copy_file(check, "/dev", FILEUTILS_FORCE | FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); | ||
432 | free(check); | ||
433 | check = concat_path_file(root, "var"); | ||
434 | copy_file(check, "/var", FILEUTILS_FORCE | FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); | ||
435 | // doit(QUIET, "ln -sf %s/lib/* /lib", root); | ||
436 | pivot_dir("/lib", root); | ||
437 | doit(0, "/sbin/ldconfig"); | ||
438 | pivot_dir("/bin", root); | ||
439 | result = 1; | ||
440 | } | ||
441 | |||
442 | free(check); | ||
443 | return result; | ||
444 | } | ||
445 | |||
446 | |||
447 | void set_boot_env(char *token); | ||
448 | void read_bootrc(void) | ||
449 | { | ||
450 | if (stat("/bootrc", &path_stat) == 0) | ||
451 | { | ||
452 | char *line; | ||
453 | FILE *contents; | ||
454 | |||
455 | contents = fopen("/bootrc", "r"); | ||
456 | if (contents != NULL) | ||
457 | { | ||
458 | char *buffer = (char *) xmalloc(sizeof (char) * 256); | ||
459 | |||
460 | bb_printf("Parsing configuration.\n"); | ||
461 | do | ||
462 | { | ||
463 | line = fgets(buffer, 255, contents); | ||
464 | if (line != NULL) | ||
465 | set_boot_env(buffer); | ||
466 | } while (line != NULL); | ||
467 | } | ||
468 | } | ||
469 | } | ||
470 | |||
471 | |||
472 | void set_boot_env(char *token) | ||
473 | { | ||
474 | int i; | ||
475 | char *eq = NULL; | ||
476 | char *ha = NULL; | ||
477 | |||
478 | //bb_printf("$$ %s\n", token); | ||
479 | for(i = 0; token[i] != '\0'; i++) | ||
480 | { | ||
481 | switch (token[i]) | ||
482 | { | ||
483 | case '=' : if (eq == NULL) eq = &token[i]; break; | ||
484 | case '#' : if (ha == NULL) ha = &token[i]; break; | ||
485 | } | ||
486 | } | ||
487 | |||
488 | if ((eq != token) && (ha != token)) | ||
489 | { | ||
490 | char *name = (char *) xmalloc(sizeof (char) * (i + 5)); | ||
491 | |||
492 | if (eq != NULL) | ||
493 | *eq = '\0'; | ||
494 | if (ha != NULL) | ||
495 | *ha = '\0'; | ||
496 | sprintf(name, "%s", token); | ||
497 | trim(name); | ||
498 | if (name[0] != '\0') | ||
499 | { | ||
500 | if (eq != NULL) | ||
501 | { | ||
502 | setenv(name, &eq[1], 1); | ||
503 | //bb_printf(" SET %s=%s\n", name, &eq[1]); | ||
504 | } | ||
505 | else | ||
506 | { | ||
507 | setenv(name, "", 1); | ||
508 | //bb_printf(" SET %s=\n", name); | ||
509 | } | ||
510 | } | ||
511 | free(name); | ||
512 | if (eq != NULL) | ||
513 | *eq = '='; | ||
514 | if (ha != NULL) | ||
515 | *ha = '#'; | ||
516 | } | ||
517 | } | ||
518 | |||
519 | |||
520 | int linuxrc_main(int argc, char **argv) | ||
521 | { | ||
522 | int i; | ||
523 | int root_write = 0; | ||
524 | long MEMORY = 0; | ||
525 | char *CMDLINE = 0; | ||
526 | char *BOOT = 0; | ||
527 | char *ROOT = 0; | ||
528 | char *ROOT_TYPE = "auto"; | ||
529 | char *BOOTFS = 0; | ||
530 | char *ROOT_MOUNT = "/media/ROOT"; | ||
531 | // char *PKGSRC = "network"; | ||
532 | int TMPFS = 0; | ||
533 | int USR = 0; | ||
534 | int VAR = 0; | ||
535 | char *NFSADDR = 0; | ||
536 | char temp[32]; | ||
537 | char *token; | ||
538 | char *strtok_temp; | ||
539 | struct sysinfo info; | ||
540 | struct utsname name; | ||
541 | |||
542 | mkrootfs(directories, nodes, files, scripts, links); | ||
543 | |||
544 | for (i = 0; modules[i] != 0; i++) | ||
545 | { | ||
546 | //bb_printf("\n\n modprobe %s\n\n\n", modules[i]); | ||
547 | doit(0, "modprobe %s", modules[i]); | ||
548 | } | ||
549 | // quick_mount("usbfs", "usbfs", "/proc/bus/usb", ""); | ||
550 | |||
551 | |||
552 | doit(0, "dmesg >/var/log/dmesg.txt"); | ||
553 | |||
554 | sysinfo(&info); | ||
555 | /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */ | ||
556 | if (info.mem_unit==0) { | ||
557 | info.mem_unit=1; | ||
558 | } | ||
559 | if ( info.mem_unit == 1 ) { | ||
560 | info.mem_unit=1024; | ||
561 | |||
562 | /* TODO: Make all this stuff not overflow when mem >= 4 Gib */ | ||
563 | info.totalram/=info.mem_unit; | ||
564 | } else { | ||
565 | info.mem_unit/=1024; | ||
566 | /* TODO: Make all this stuff not overflow when mem >= 4 Gib */ | ||
567 | info.totalram*=info.mem_unit; | ||
568 | } | ||
569 | MEMORY = info.totalram; | ||
570 | USR = MEMORY / 2.5; | ||
571 | VAR = MEMORY / 16; | ||
572 | |||
573 | if (uname(&name) == -1) | ||
574 | bb_perror_msg_and_die("cannot get system information"); | ||
575 | if (atof(name.release) > 2.4) | ||
576 | TMPFS = 1; | ||
577 | |||
578 | make_ram_disk(VAR, 2, "/var", TMPFS); | ||
579 | |||
580 | bb_xasprintf(&CMDLINE, "%s", doit(REDIR, "cat /proc/cmdline")); | ||
581 | //bb_printf("%s\n", CMDLINE); | ||
582 | for (token = strtok_r(CMDLINE, " \t\n\r", &strtok_temp); token != NULL; token = strtok_r(NULL, " \t\n\r", &strtok_temp)) | ||
583 | { | ||
584 | if (strcmp(token, "RW") == 0) | ||
585 | { | ||
586 | root_write = 1; | ||
587 | sprintf(temp, "ROOT_MODE=RW"); | ||
588 | set_boot_env(temp); | ||
589 | } | ||
590 | else if (strcmp(token, "RO") == 0) | ||
591 | { | ||
592 | root_write = 0; | ||
593 | sprintf(temp, "ROOT_MODE=RO"); | ||
594 | set_boot_env(temp); | ||
595 | } | ||
596 | } | ||
597 | |||
598 | BOOT = getenv("BOOT_IMAGE"); | ||
599 | if (BOOT != NULL) | ||
600 | { | ||
601 | #define CDROM 1 | ||
602 | #define FLOPPY 2 | ||
603 | #define HD 3 | ||
604 | #define NETWORK 4 | ||
605 | int type = 0; | ||
606 | int disk = -1; | ||
607 | int part = -1; | ||
608 | char *image = BOOT; | ||
609 | char device[16]; | ||
610 | |||
611 | /* | ||
612 | * BOOT_IMAGE=(hd0,4)/boot/bzImage | ||
613 | * BOOT_IMAGE=(hd3)/boot/bzImage | ||
614 | * BOOT_IMAGE=(hdx,y)/boot/bzImage | ||
615 | * translate to /dev/hd(x+1)(y+1) | ||
616 | * BOOT_IMAGE=(cd)/boot/bzImage | ||
617 | * scan cd drives | ||
618 | * BOOT_IMAGE=/boot/bzImage | ||
619 | * try to avoid this, but scan all disks | ||
620 | * BOOT_IMAGE=bzImage | ||
621 | * probably syslinux, assume floppy boot (see next) | ||
622 | * BOOT_IMAGE=(fd0)/bzImage | ||
623 | * try to find bootrc on first floppy | ||
624 | * BOOT_IMAGE=(nd)/tftpboot/vmlinux | ||
625 | * try to tftp bootrc from network | ||
626 | */ | ||
627 | if ((BOOT[0] == '(') && (BOOT[2] == 'd') ) /* This is a grub boot, based on my BOOT_IMAGE patch for grub1. */ | ||
628 | { | ||
629 | while (image[0] != '\0') | ||
630 | { | ||
631 | if (image[0] == ')') | ||
632 | { | ||
633 | image++; | ||
634 | break; | ||
635 | } | ||
636 | image++; | ||
637 | } | ||
638 | switch (BOOT[1]) | ||
639 | { | ||
640 | case 'c' : type = CDROM; break; | ||
641 | case 'f' : type = FLOPPY; break; | ||
642 | case 'h' : type = HD; break; | ||
643 | case 'n' : type = NETWORK; break; | ||
644 | } | ||
645 | if (BOOT[3] != ')') | ||
646 | { | ||
647 | disk = atoi(&BOOT[3]) + 1; | ||
648 | if (BOOT[4] == ',') | ||
649 | part = atoi(&BOOT[5]) + 1; | ||
650 | } | ||
651 | } | ||
652 | |||
653 | device[0] = '\0'; | ||
654 | switch (type) | ||
655 | { | ||
656 | case FLOPPY : | ||
657 | sprintf(device, "/dev/fd%d", disk - 1); | ||
658 | break; | ||
659 | |||
660 | case HD : | ||
661 | sprintf(device, "/dev/hd%c%d", 'a' + disk, part); | ||
662 | break; | ||
663 | |||
664 | case NETWORK : | ||
665 | sprintf(device, "tftp:/"); | ||
666 | break; | ||
667 | } | ||
668 | |||
669 | if (device[0] == '\0') | ||
670 | { | ||
671 | find_all_drives(); | ||
672 | if (type == CDROM) | ||
673 | { | ||
674 | BOOTFS="iso9660"; | ||
675 | bb_printf("Scanning all CD and DVD drives for %s.\n", image); | ||
676 | if (find_boot_device_in_list(cdroms_list, image, &BOOT, &BOOTFS) == 0) | ||
677 | BOOTFS=NULL; | ||
678 | } | ||
679 | else | ||
680 | { | ||
681 | BOOTFS="vfat"; | ||
682 | bb_printf("Scanning all drives for %s.\n", image); | ||
683 | if (find_boot_device_in_list(floppies_list, image, &BOOT, &BOOTFS) == 0) | ||
684 | { | ||
685 | BOOTFS="iso9660"; | ||
686 | if (find_boot_device_in_list(cdroms_list, image, &BOOT, &BOOTFS) == 0) | ||
687 | { | ||
688 | BOOTFS=NULL; | ||
689 | if (find_boot_device_in_list(hard_disks_list, image, &BOOT, &BOOTFS) == 0) | ||
690 | BOOTFS=NULL; | ||
691 | } | ||
692 | } | ||
693 | } | ||
694 | } | ||
695 | else | ||
696 | { | ||
697 | if (type == NETWORK) | ||
698 | { | ||
699 | bb_xasprintf(&BOOT, "%s%s", device, image); | ||
700 | BOOTFS="Network"; | ||
701 | bb_printf("Kicking network into life.\n"); | ||
702 | doit(0, "rc network start"); | ||
703 | if (stat("/var/lib/network/tftpaddr", &path_stat) == 0) | ||
704 | { | ||
705 | bb_printf("\nDownloading configuration from network.\n"); | ||
706 | doit(QUIET, "tftp -gr /tftpboot/bootrc -l /bootrc %s", quick_read("/var/lib/network/tftpaddr")); | ||
707 | } | ||
708 | else if (stat("/var/lib/network/nfsaddr", &path_stat) == 0) | ||
709 | { | ||
710 | bb_printf("\nDownloading configuration from network.\n"); | ||
711 | doit(QUIET, "tftp -gr /tftpboot/bootrc -l /bootrc %s", quick_read("/var/lib/network/nfsaddr")); | ||
712 | } | ||
713 | } | ||
714 | else | ||
715 | { | ||
716 | bb_xasprintf(&BOOT, "%s%s", device, image); | ||
717 | if (is_boot_device(device, image, &BOOTFS)) | ||
718 | BOOT=device; | ||
719 | } | ||
720 | } | ||
721 | |||
722 | if (BOOTFS == NULL) | ||
723 | BOOTFS = "Unknown"; | ||
724 | |||
725 | if (stat("/boot/bootrc", &path_stat) == 0) | ||
726 | { | ||
727 | bb_printf("Copying configuration from boot filesystem.\n"); | ||
728 | copy_file("/boot/bootrc", "/bootrc", FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); | ||
729 | doit(QUIET, "umount /boot"); | ||
730 | } | ||
731 | } | ||
732 | else | ||
733 | { | ||
734 | BOOT = ""; | ||
735 | BOOTFS = ""; | ||
736 | } | ||
737 | |||
738 | read_bootrc(); | ||
739 | |||
740 | ROOT = getenv("ROOT"); | ||
741 | if (ROOT == 0) | ||
742 | { | ||
743 | if (strncmp(BOOT, "/dev/", 5) == 0) | ||
744 | { | ||
745 | bb_xasprintf(&ROOT, "%s", BOOT); | ||
746 | for (i = 5; ROOT[i] != '\0'; i++) | ||
747 | { | ||
748 | if (ROOT[i] == '/') | ||
749 | { | ||
750 | ROOT[i] = '\0'; | ||
751 | ROOT_TYPE = BOOTFS; | ||
752 | break; | ||
753 | } | ||
754 | } | ||
755 | } | ||
756 | } | ||
757 | |||
758 | /* | ||
759 | #VERSION=`cat /boot/version 2> /dev/null` | ||
760 | #PS1="My Linux $VERSION> " | ||
761 | */ | ||
762 | |||
763 | bb_printf("================================\n"); | ||
764 | bb_printf("Kernel: %s %s\n", name.release, TMPFS ? "- tmpfs capable" : ""); | ||
765 | bb_printf("RAM: %li MB %s\n", MEMORY / 1024, (MEMORY < (16 * 1024)) ? "< 16 MB, you may run into problems" : "" ); | ||
766 | bb_printf("Boot: %s - %s\n", BOOT, BOOTFS); | ||
767 | bb_printf("Root: %s - %s\n", ROOT, root_write ? "read/write" : "read only"); | ||
768 | bb_printf("================================\n"); | ||
769 | |||
770 | /* | ||
771 | ROOT=/dev/hda6 | ||
772 | ROOT=nfs://REAL/MDS/TEST | ||
773 | */ | ||
774 | if (ROOT == 0) | ||
775 | { | ||
776 | ; | ||
777 | } | ||
778 | else | ||
779 | { | ||
780 | if (strncmp(ROOT, "/dev/", 5) == 0) | ||
781 | { | ||
782 | // PKGSRC=BOOT; | ||
783 | // Should fsck this partition first. | ||
784 | bb_printf("Mounting %s \n on %s as type %s\n", ROOT, ROOT_MOUNT, ROOT_TYPE); | ||
785 | make_disk(&ROOT[5], nodes); | ||
786 | quick_mount(ROOT_TYPE, ROOT, ROOT_MOUNT, root_write ? "-o rw" : "-o ro"); | ||
787 | } | ||
788 | else if (strncmp(ROOT, "nfs://", 5) == 0) | ||
789 | { | ||
790 | doit(0, "rc network start"); | ||
791 | if (stat("/var/lib/network/ipaddr", &path_stat) == 0) | ||
792 | NFSADDR = quick_read("/var/lib/network/nfsaddr"); | ||
793 | if ((NFSADDR != 0) && (NFSADDR[0] != '\0')) | ||
794 | { | ||
795 | char *NFSMOUNT = 0; | ||
796 | |||
797 | ROOT_TYPE = "nfs"; | ||
798 | if (NFSMOUNT == 0) | ||
799 | bb_xasprintf(&NFSMOUNT, "%s:%s", NFSADDR, &ROOT[5]); | ||
800 | bb_printf("Mounting %s \n on %s as type %s\n", NFSMOUNT, ROOT_MOUNT, ROOT_TYPE); | ||
801 | quick_mount(ROOT_TYPE, NFSMOUNT, ROOT_MOUNT, root_write ? "-o nolock,rw" : "-o nolock,ro"); | ||
802 | |||
803 | free(NFSMOUNT); | ||
804 | } | ||
805 | free(NFSADDR); | ||
806 | } | ||
807 | } | ||
808 | |||
809 | if (root_write) | ||
810 | copy_file("/bin/busybox", "/media/ROOT/bin/busybox", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS); | ||
811 | |||
812 | if (!rebuild_fs(ROOT_MOUNT)) | ||
813 | { | ||
814 | // make_ram_disk(USR, 3, "/usr", TMPFS); | ||
815 | // doit(0, "getpkg"); | ||
816 | } | ||
817 | else | ||
818 | { | ||
819 | read_bootrc(); | ||
820 | } | ||
821 | |||
822 | doit(0, "/sbin/ldconfig"); | ||
823 | |||
824 | free(CMDLINE); | ||
825 | |||
826 | execl("/sbin/init", "/sbin/init"); | ||
827 | return EXIT_FAILURE; | ||
828 | } | ||
829 | |||
diff --git a/urunlevel/my_linux/man.c b/urunlevel/my_linux/man.c new file mode 100644 index 0000000..162cac8 --- /dev/null +++ b/urunlevel/my_linux/man.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * Mini man implementation for busybox. | ||
3 | * | ||
4 | * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
19 | * 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <unistd.h> | ||
24 | |||
25 | #include "busybox.h" | ||
26 | #include "lib_init_d.h" | ||
27 | #include "my_linux.h" | ||
28 | |||
29 | |||
30 | int man_main(int argc, char **argv) | ||
31 | { | ||
32 | argv += optind; | ||
33 | if (!*argv) | ||
34 | { | ||
35 | bb_printf("\nThe following manual topics are available:\n"); | ||
36 | doit(NOFORK, "ls -m /usr/doc"); | ||
37 | } | ||
38 | else | ||
39 | doit(NOFORK, "less /usr/doc/%s", *argv); | ||
40 | return EXIT_SUCCESS; | ||
41 | } | ||
diff --git a/urunlevel/my_linux/mkrootfs.c b/urunlevel/my_linux/mkrootfs.c new file mode 100644 index 0000000..9098be6 --- /dev/null +++ b/urunlevel/my_linux/mkrootfs.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
17 | * 02111-1307 USA | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #include <dirent.h> | ||
22 | #include <fcntl.h> | ||
23 | #include <unistd.h> | ||
24 | #include <errno.h> | ||
25 | #include <signal.h> | ||
26 | #include <string.h> | ||
27 | #include <sys/poll.h> | ||
28 | #include <sys/wait.h> | ||
29 | #include <sys/utsname.h> /* for uname(2) */ | ||
30 | |||
31 | #include "busybox.h" | ||
32 | #include "lib_init_d.h" | ||
33 | |||
34 | |||
35 | void mkrootfs(const char *directories[], const nodes_t *nodes, const char *files[][2], const char *scripts[][2], const char *links[][2]) | ||
36 | { | ||
37 | int i; | ||
38 | char temp[64]; | ||
39 | |||
40 | umask(022); | ||
41 | sprintf(temp, "/dev"); | ||
42 | bb_make_directory(temp, -1l, FILEUTILS_RECUR); | ||
43 | mknod("/dev/console", S_IFCHR, makedev(4, 0)); | ||
44 | chmod("/dev/console", S_IRUSR | S_IWUSR); | ||
45 | mknod("/dev/null", S_IFCHR, makedev(1, 3)); | ||
46 | chmod("/dev/null", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); | ||
47 | mknod("/dev/ptmx", S_IFCHR, makedev(5, 2)); | ||
48 | chmod("/dev/ptmx", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); | ||
49 | sprintf(temp, "/bin"); | ||
50 | bb_make_directory(temp, -1l, FILEUTILS_RECUR); | ||
51 | symlink("/bin/busybox", "/bin/sh"); | ||
52 | |||
53 | bb_printf("\n\nCreating directories, devices, files, and links.\n"); | ||
54 | for (i = 0; directories[i] != 0; i++) | ||
55 | { | ||
56 | /* Can't use it directly, coz bb_make_directory segfaults. */ | ||
57 | sprintf(temp, "/%s", directories[i]); | ||
58 | bb_make_directory(temp, -1l, FILEUTILS_RECUR); | ||
59 | } | ||
60 | |||
61 | symlink("/var/etc", "/etc"); | ||
62 | symlink("/proc/mounts", "/var/etc/mtab"); | ||
63 | quick_mount("proc", "proc", "/proc", ""); | ||
64 | quick_mount("sysfs", "sysfs", "/sys", ""); | ||
65 | for (i = 0; nodes[i].name != 0; i++) | ||
66 | { | ||
67 | if (nodes[i].count) | ||
68 | { | ||
69 | int j; | ||
70 | for (j = 0; j <= nodes[i].count; j++) | ||
71 | { | ||
72 | sprintf(temp, "/dev/%s%i", nodes[i].name, j); | ||
73 | mknod(temp, nodes[i].mode, makedev(nodes[i].major, nodes[i].minor + j)); | ||
74 | } | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | sprintf(temp, "/dev/%s", nodes[i].name); | ||
79 | mknod(temp, nodes[i].mode, makedev(nodes[i].major, nodes[i].minor)); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | for (i = 0; files[i][0] != NULL; i++) | ||
84 | quick_write(files[i][0], files[i][1]); | ||
85 | |||
86 | for (i = 0; scripts[i][0] != NULL; i++) | ||
87 | { | ||
88 | quick_write(scripts[i][0], scripts[i][1]); | ||
89 | chmod(scripts[i][0], S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); | ||
90 | } | ||
91 | |||
92 | for (i = 0; links[i][0] != NULL; i++) | ||
93 | symlink(links[i][0], links[i][1]); | ||
94 | |||
95 | quick_mount("devpts", "devpts", "/dev/pts", ""); | ||
96 | doit(0, "busybox --install"); | ||
97 | |||
98 | /* This must be last, as it currently defines a valid install. */ | ||
99 | /* Can't use it directly, coz bb_make_directory segfaults. */ | ||
100 | sprintf(temp, "/var/lib/distro"); | ||
101 | bb_make_directory(temp, -1l, FILEUTILS_RECUR); | ||
102 | |||
103 | bb_printf("Created.\n"); | ||
104 | } | ||
diff --git a/urunlevel/my_linux/my_linux.h b/urunlevel/my_linux/my_linux.h new file mode 100644 index 0000000..7be8fe4 --- /dev/null +++ b/urunlevel/my_linux/my_linux.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
18 | * 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #ifndef _MY_LINUX_H | ||
23 | #define _MY_LINUX_H | ||
24 | |||
25 | void mkrootfs(const char *directories[], const nodes_t *nodes, const char *files[][2], const char *scripts[][2], const char *links[][2]); | ||
26 | |||
27 | #endif | ||
diff --git a/urunlevel/my_linux/rcS b/urunlevel/my_linux/rcS new file mode 100755 index 0000000..5d3785e --- /dev/null +++ b/urunlevel/my_linux/rcS | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/sh | ||
2 | /bin/busybox rcS | ||
diff --git a/urunlevel/my_linux/rcS.c b/urunlevel/my_linux/rcS.c new file mode 100644 index 0000000..6d1f64f --- /dev/null +++ b/urunlevel/my_linux/rcS.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Mini rcS implementation for busybox. | ||
3 | * | ||
4 | * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
19 | * 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <unistd.h> | ||
24 | |||
25 | #include "busybox.h" | ||
26 | #include "lib_init_d.h" | ||
27 | #include "my_linux.h" | ||
28 | |||
29 | |||
30 | int rcS_main(int argc, char **argv) | ||
31 | { | ||
32 | doit(FORK | QUIET, "gpm -m /dev/input/mice -t exps2 -M -m /dev/ttyS0 -t ms"); | ||
33 | |||
34 | // doit(FORK | QUIET, "/usr/sbin/crond"); | ||
35 | // if (errno == 0) | ||
36 | // { | ||
37 | // bb_printf("Starting cron.\n"); | ||
38 | // doit(0, "sort /etc/crontab | uniq > /tmp/crontab 2> /dev/null"); | ||
39 | // copy_file("/tmp/crontab", "/etc/crontab", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS); | ||
40 | // doit(0, "/usr/sbin/crontab /etc/crontab 2> /dev/null"); | ||
41 | // doit(0, "crontab -l"); | ||
42 | // } | ||
43 | |||
44 | bb_printf("\n\nALT-<Left/Right> allows you to view other virtual terminals.\n"); | ||
45 | |||
46 | return EXIT_SUCCESS; | ||
47 | } | ||
diff --git a/urunlevel/my_linux/shownet b/urunlevel/my_linux/shownet new file mode 100755 index 0000000..94f1172 --- /dev/null +++ b/urunlevel/my_linux/shownet | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | echo "" | ||
3 | ifconfig | ||
4 | route | ||
5 | ip addr list | ||
6 | ip link list | ||
7 | ip route list | ||
8 | echo "" | ||
diff --git a/urunlevel/my_linux/vt_manager b/urunlevel/my_linux/vt_manager new file mode 100755 index 0000000..978f2ec --- /dev/null +++ b/urunlevel/my_linux/vt_manager | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | runlevel=`cat /etc/runlevel` | ||
4 | |||
5 | if [ -f /var/lib/misc/runlevel ] | ||
6 | then | ||
7 | runlevel=`/var/lib/misc/runlevel` | ||
8 | fi | ||
9 | |||
10 | if [ "$runlevel" = "3" ] | ||
11 | then | ||
12 | /sbin/getty 38400 tty$1 | ||
13 | elif [ "$runlevel" = "4" ] | ||
14 | then | ||
15 | sleep 1 | ||
16 | /usr/bin/openvt $1 twdm --quiet --hw=tty@/dev/tty$1,stdout,TERM=linux | ||
17 | sleep 1d | ||
18 | elif [ "$runlevel" = "5" ] | ||
19 | then | ||
20 | /usr/bin/openvt $1 /usr/X11R6/bin/X | ||
21 | sleep 1d | ||
22 | fi | ||