summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoronefang2005-03-31 05:37:25 +0000
committeronefang2005-03-31 05:37:25 +0000
commit9f23832b7e53b0b8ccc7b1a8f9c79a8568315744 (patch)
tree8e582fc918f4a9289595f7e68765d2a1a100d2be
parentDamn eclipse, seems to think these are binary. (diff)
downloadurunlevel-9f23832b7e53b0b8ccc7b1a8f9c79a8568315744.zip
urunlevel-9f23832b7e53b0b8ccc7b1a8f9c79a8568315744.tar.gz
urunlevel-9f23832b7e53b0b8ccc7b1a8f9c79a8568315744.tar.bz2
urunlevel-9f23832b7e53b0b8ccc7b1a8f9c79a8568315744.tar.xz
Added patch files and web site.
-rw-r--r--urunlevel/runlevel/Changelog19
-rw-r--r--urunlevel/runlevel/Config.in74
-rw-r--r--urunlevel/runlevel/INSTALL14
-rw-r--r--urunlevel/runlevel/LICENSE340
-rw-r--r--urunlevel/runlevel/README10
-rw-r--r--urunlevel/runlevel/TODO55
-rw-r--r--urunlevel/runlevel/apply_patch9
-rw-r--r--urunlevel/runlevel/boot_named.c47
-rw-r--r--urunlevel/runlevel/boot_portmap.c70
-rw-r--r--urunlevel/runlevel/boot_syslog.c69
-rw-r--r--urunlevel/runlevel/boot_time.c58
-rw-r--r--urunlevel/runlevel/diff_excludes14
-rw-r--r--urunlevel/runlevel/install_initd.c91
-rw-r--r--urunlevel/runlevel/killproc.c173
-rw-r--r--urunlevel/runlevel/lib_init_d.c721
-rw-r--r--urunlevel/runlevel/lib_init_d.h39
-rw-r--r--urunlevel/runlevel/local_fs.c238
-rw-r--r--urunlevel/runlevel/log_failure_msg.c20
-rw-r--r--urunlevel/runlevel/log_success_msg.c20
-rw-r--r--urunlevel/runlevel/log_warning_msg.c20
-rw-r--r--urunlevel/runlevel/make_patch10
-rw-r--r--urunlevel/runlevel/network.c176
-rw-r--r--urunlevel/runlevel/pidofproc.c217
-rw-r--r--urunlevel/runlevel/rc.c2013
-rw-r--r--urunlevel/runlevel/remote_fs.c59
-rw-r--r--urunlevel/runlevel/remove_initd.c108
-rw-r--r--urunlevel/runlevel/runlevel.patch533
-rw-r--r--urunlevel/runlevel/runlevels.conf17
-rw-r--r--urunlevel/runlevel/start_daemon.c168
-rw-r--r--urunlevel/runlevel/sysconfig/cron98
-rw-r--r--urunlevel/runlevel/sysconfig/named65
-rw-r--r--urunlevel/runlevel/sysconfig/network5
-rw-r--r--urunlevel/runlevel/sysconfig/syslog102
-rw-r--r--urunlevel/runlevel/sysconfig/time18
-rw-r--r--urunlevel/runlevel/sysconfig/ulimit253
-rw-r--r--urunlevel/runlevel/sysconfig/xntp38
-rw-r--r--urunlevel/runlevel/udhcpc_script.c281
-rw-r--r--urunlevel/runlevel/ugly_stick6
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/LICENSE340
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/DONE.shtml13
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/TODO.shtml8
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/coding.shtml13
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/design.shtml5
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/index.shtml17
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/keywords.shtml18
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coders/people.shtml9
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/coming.shtml13
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/crontab.in1
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/crontab.sh4
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/fetch-html.sh11
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/footer.shtml10
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/footer_line.shtml10
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/header.inc2
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/home.inc40
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/home.shtml9
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1.gifbin0 -> 35 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1space.gifbin0 -> 43 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/bug.pngbin0 -> 1050 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/cvs16b.pngbin0 -> 549 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/docman16b.pngbin0 -> 530 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1-smile_mini.gifbin0 -> 1172 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1.xface3
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_XFace.gifbin0 -> 332 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_mini.gifbin0 -> 1404 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/ftp16b.pngbin0 -> 431 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/mail16b.pngbin0 -> 587 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix-RAD.jpgbin0 -> 69182 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix.gifbin0 -> 43463 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/mock_dave_icon.trans.gifbin0 -> 1609 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/notes16.pngbin0 -> 253 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/taskman16b.pngbin0 -> 598 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/title.pngbin0 -> 99911 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/trans.gifbin0 -> 886 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/undercon.gifbin0 -> 1133 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/images/wait.gifbin0 -> 2329 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/index.shtml16
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/keywords.shtml16
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/navigation.inc43
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/navigation.shtml11
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/news.inc1
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/news.shtml7
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/project.inc24
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/bug.pngbin0 -> 1050 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/cvs16b.pngbin0 -> 549 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/docman16b.pngbin0 -> 530 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/ftp16b.pngbin0 -> 431 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/mail16b.pngbin0 -> 587 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/notes16.pngbin0 -> 253 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/taskman16b.pngbin0 -> 598 bytes
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/testers/TODO.shtml5
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/testers/index.shtml28
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/testers/keywords.shtml13
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/testers/method.shtml7
-rw-r--r--urunlevel/runlevel/urunlevel.sourceforge.net/testers/people.shtml9
94 files changed, 4812 insertions, 2162 deletions
diff --git a/urunlevel/runlevel/Changelog b/urunlevel/runlevel/Changelog
new file mode 100644
index 0000000..b0de10b
--- /dev/null
+++ b/urunlevel/runlevel/Changelog
@@ -0,0 +1,19 @@
1---------------------
2Date: 2005/03/19 03:40:00
3Author: onefang
4Log:
5Updated various Config.in's to reflect some of the dependencies.
6
7---------------------
8Date: 2005/03/19 03:42:00
9Author: onefang
10Log:
11Finished install_initd and remove_initd.
12
13---------------------
14Date: 2005/03/19 05:18:00
15Author: onefang
16Log:
17Implemented sysconfig file support.
18Update boot_syslog, network, and udhcpc_script to suit.
19
diff --git a/urunlevel/runlevel/Config.in b/urunlevel/runlevel/Config.in
index 36be84b..ca4c44a 100644
--- a/urunlevel/runlevel/Config.in
+++ b/urunlevel/runlevel/Config.in
@@ -7,75 +7,110 @@ menu "Runlevel Utilities"
7 7
8config CONFIG_BOOT_NAMED 8config CONFIG_BOOT_NAMED
9 bool "boot_named" 9 bool "boot_named"
10 default y 10 default n
11 help 11 help
12 An implementation of LSB $named. 12 An implementation of LSB $named.
13 13
14config CONFIG_BOOT_PORTMAP 14config CONFIG_BOOT_PORTMAP
15 bool "boot_portmap" 15 bool "boot_portmap"
16 default y 16 default n
17 help 17 help
18 An implementation of LSB $. 18 An implementation of LSB $.
19 19
20config CONFIG_BOOT_SYSLOG 20config CONFIG_BOOT_SYSLOG
21 bool "boot_syslog" 21 bool "boot_syslog"
22 default y 22 default n
23 help 23 help
24 An implementation of LSB $syslog. 24 An implementation of LSB $syslog.
25 25
26config CONFIG_BOOT_TIME 26config CONFIG_BOOT_TIME
27 bool "boot_time" 27 bool "boot_time"
28 default y 28 default n
29 help 29 help
30 An implementation of LSB $time. 30 An implementation of LSB $time.
31 31
32config CONFIG_INSTALL_INITD 32config CONFIG_INSTALL_INITD
33 bool "install_initd" 33 bool "install_initd"
34 default y 34 default n
35 help 35 help
36 An implementation of install_initd. 36 An implementation of install_initd.
37 37
38config CONFIG_KILLPROC 38if CONFIG_RC
39 config CONFIG_KILLPROC
40 default y
41 comment "killproc (forced enabled for use with rc)"
42endif
43if !CONFIG_RC
44 config CONFIG_KILLPROC
39 bool "killproc" 45 bool "killproc"
40 default y 46 default y
41 help 47 help
42 An implementation of killproc. 48 An implementation of killproc.
49endif
43 50
44config CONFIG_LOCAL_FS 51config CONFIG_LOCAL_FS
45 bool "local_fs" 52 bool "local_fs"
46 default y 53 default n
47 help 54 help
48 A $local_fs boot script. 55 A $local_fs boot script.
49 56
50config CONFIG_LOG_FAILURE_MSG 57if CONFIG_RC
58 config CONFIG_LOG_FAILURE_MSG
59 default y
60 comment "log_failure_msg (forced enabled for use with rc)"
61endif
62if !CONFIG_RC
63 config CONFIG_LOG_FAILURE_MSG
51 bool "log_failure_msg" 64 bool "log_failure_msg"
52 default y 65 default y
53 help 66 help
54 An implementation of log_failure_msg. 67 An implementation of log_failure_msg.
68endif
55 69
56config CONFIG_LOG_SUCCESS_MSG 70if CONFIG_RC
71 config CONFIG_LOG_SUCCESS_MSG
72 default y
73 comment "log_success_msg (forced enabled for use with rc)"
74endif
75if !CONFIG_RC
76 config CONFIG_LOG_SUCCESS_MSG
57 bool "log_success_msg" 77 bool "log_success_msg"
58 default y 78 default y
59 help 79 help
60 An implementation of log_success_msg. 80 An implementation of log_success_msg.
81endif
61 82
62config CONFIG_LOG_WARNING_MSG 83if CONFIG_RC
84 config CONFIG_LOG_WARNING_MSG
85 default y
86 comment "log_warning_msg (forced enabled for use with rc)"
87endif
88if !CONFIG_RC
89 config CONFIG_LOG_WARNING_MSG
63 bool "log_warning_msg" 90 bool "log_warning_msg"
64 default y 91 default y
65 help 92 help
66 An implementation of log_warning_msg. 93 An implementation of log_warning_msg.
94endif
67 95
68config CONFIG_NETWORK 96config CONFIG_NETWORK
69 bool "network" 97 bool "network"
70 default y 98 default n
71 help 99 help
72 A $network boot script. 100 A $network boot script.
73 101
74config CONFIG_PIDOFPROC 102if CONFIG_RC
103 config CONFIG_PIDOFPROC
104 default y
105 comment "pidofproc (forced enabled for use with rc)"
106endif
107if !CONFIG_RC
108 config CONFIG_PIDOFPROC
75 bool "pidofproc" 109 bool "pidofproc"
76 default y 110 default y
77 help 111 help
78 An implementation of pidofproc. 112 An implementation of pidofproc.
113endif
79 114
80config CONFIG_RC 115config CONFIG_RC
81 bool "rc" 116 bool "rc"
@@ -85,25 +120,32 @@ config CONFIG_RC
85 120
86config CONFIG_REMOTE_FS 121config CONFIG_REMOTE_FS
87 bool "remote_fs" 122 bool "remote_fs"
88 default y 123 default n
89 help 124 help
90 A $remote_fs boot script. 125 A $remote_fs boot script.
91 126
92config CONFIG_REMOVE_INITD 127config CONFIG_REMOVE_INITD
93 bool "remove_initd" 128 bool "remove_initd"
94 default y 129 default n
95 help 130 help
96 An implementation of remove_initd. 131 An implementation of remove_initd.
97 132
98config CONFIG_START_DAEMON 133if CONFIG_RC
134 config CONFIG_START_DAEMON
135 default y
136 comment "start_daemon (forced enabled for use with rc)"
137endif
138if !CONFIG_RC
139 config CONFIG_START_DAEMON
99 bool "start_daemon" 140 bool "start_daemon"
100 default y 141 default y
101 help 142 help
102 An implementation of start_daemon. 143 An implementation of start_daemon.
144endif
103 145
104config CONFIG_UDHCPC_SCRIPT 146config CONFIG_UDHCPC_SCRIPT
105 bool "udhcpc_script" 147 bool "udhcpc_script"
106 default y 148 default n
107 help 149 help
108 An implementation of udhcpc.script. 150 An implementation of udhcpc.script.
109 151
diff --git a/urunlevel/runlevel/INSTALL b/urunlevel/runlevel/INSTALL
new file mode 100644
index 0000000..40cba2b
--- /dev/null
+++ b/urunlevel/runlevel/INSTALL
@@ -0,0 +1,14 @@
1Download busybox-1.00.tar.bz2.
2
3Unpack it.
4
5Copy this directory (runlevel) and the my_linux directory into the busybox-1.00
6directory.
7
8Change to the busybox-1.00/runlevel directory.
9
10Run the apply_patch script.
11
12The apply_patch script will run "make oldconfig" for you.
13
14Follow the instructions in busybox-1.00/INSTALL.
diff --git a/urunlevel/runlevel/LICENSE b/urunlevel/runlevel/LICENSE
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/urunlevel/runlevel/LICENSE
@@ -0,0 +1,340 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Library General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License
307 along with this program; if not, write to the Free Software
308 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
310
311Also add information on how to contact you by electronic and paper mail.
312
313If the program is interactive, make it output a short notice like this
314when it starts in an interactive mode:
315
316 Gnomovision version 69, Copyright (C) year name of author
317 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 This is free software, and you are welcome to redistribute it
319 under certain conditions; type `show c' for details.
320
321The hypothetical commands `show w' and `show c' should show the appropriate
322parts of the General Public License. Of course, the commands you use may
323be called something other than `show w' and `show c'; they could even be
324mouse-clicks or menu items--whatever suits your program.
325
326You should also get your employer (if you work as a programmer) or your
327school, if any, to sign a "copyright disclaimer" for the program, if
328necessary. Here is a sample; alter the names:
329
330 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
333 <signature of Ty Coon>, 1 April 1989
334 Ty Coon, President of Vice
335
336This General Public License does not permit incorporating your program into
337proprietary programs. If your program is a subroutine library, you may
338consider it more useful to permit linking proprietary applications with the
339library. If this is what you want to do, use the GNU Library General
340Public License instead of this License.
diff --git a/urunlevel/runlevel/README b/urunlevel/runlevel/README
index 7c3e2ce..2c4db5c 100644
--- a/urunlevel/runlevel/README
+++ b/urunlevel/runlevel/README
@@ -1,3 +1,9 @@
1Busybox does not include named and portmap applets, so boot_named.c and 1Clean room implementation of runlevel/init.d/SYS V init applets for
2boot_portmap.c should be considered as examples. Skeleton is also an example. 2busybox, aiming for LSB compliance.
3 3
4Busybox <http://www.busybox.net> currently has no support for runlevels
5and init.d scripts, also known as the SYS V init system. Micro runlevel
6adds that support as standard busybox applets written in the C langauge.
7
8Most of the documentation is in the urunlevel.sourceforge.net directory,
9which is a copy of the web site.
diff --git a/urunlevel/runlevel/TODO b/urunlevel/runlevel/TODO
index d522d93..be8664e 100644
--- a/urunlevel/runlevel/TODO
+++ b/urunlevel/runlevel/TODO
@@ -1,15 +1,6 @@
1+ LSB niceness
2* LSB compliance
3! fix bug 1! fix bug
4$ store config info in - 2* LSB compliance
5 kernel command line 3+ LSB niceness
6 boot://bootrc
7 /etc/sysconfig/* syslog network/config network/routes
8
9 if (stat("/var/lib/my_linux/config/ipfwd", &path_stat) == 0)
10 if (stat("/var/lib/my_linux/config/noping", &path_stat) == 0)
11 /var/lib/my_linux/config/hostname - hostname
12 /var/lib/my_linux/config/loghost - syslogd remote host
13 4
14 5
15 review init.d script dependencies 6 review init.d script dependencies
@@ -21,35 +12,33 @@ $ store config info in -
21 portmap - network 12 portmap - network
22 named - network and syslog 13 named - network and syslog
23 14
24$ write a proper network & friends 15* add database editing command to rc
25 add fsck support to local_fs and linuxrc
26 local_fs should only umount things it mounted
27! try to detect ext3 before mount whinges
28! redirect console to some other VT
29
30* do something with info->shouldstart's in rc 16* do something with info->shouldstart's in rc
31+ rc foo start - start dependencies of foo first 17+ rc foo start - start dependencies of foo first
32+ rc foo stop - stop things dependent on foo first 18+ rc foo stop - stop things dependent on foo first
33* add a database of runlevels per script 19+ dependencies should be per runlevel as well.
34* add database editing and reporting commands to rc 20 I don't think LSB explicitly requires this, but it makes sense.
35 21 OTOH, there is much that could go wrong with a dependency script,
36* finish install_initd & remove_initd 22 so how paranoid do we want to be?
37$ finish boot_syslog 23 #ifdef CONFIG_FEATURE_RUNLEVEL_PARANOID
38$ finish boot_time
39! double check status functions 24! double check status functions
40
41+ write init_d_from_script
42+ rewrite skeleton to use initd_from_script
43
44! pidofproc needs to check the name of the proc as well as the pid in /proc/$pid 25! pidofproc needs to check the name of the proc as well as the pid in /proc/$pid
45 remove start_daemon's reliance on start-stop-daemon 26 remove start_daemon's reliance on start-stop-daemon
46! remove need for sleep(1) in start_daemon 27! remove need for sleep(1) in start_daemon
28
29 finish boot_time
30 write a proper network & friends
31 add fsck support to local_fs and linuxrc
32 local_fs should only umount things it mounted
33! try to detect ext3 before mount whinges
34! redirect console to some other VT
35
36+ write init_d_from_script
37+ rewrite skeleton to use initd_from_script
47! fix forking, daemon begat's daemon, and daemonic hell breaks loose. 38! fix forking, daemon begat's daemon, and daemonic hell breaks loose.
48 My doit() is probably to blame. 39 My doit() is probably to blame.
40 #ifdef CONFIG_FEATURE_CLEAN_UP
41 replace some doit's with C code
42 force enable of remaining doit's
49 43
50 on boot - hard link /linuxrc to /bin/busybox 44 hit it with the ugly_stick
51 turn makefs into a full blown applet
52 CONFIG_FEATURE_FULL_LSB
53 permissions for files
54 move cron out of rcS
55
diff --git a/urunlevel/runlevel/apply_patch b/urunlevel/runlevel/apply_patch
new file mode 100644
index 0000000..3396de6
--- /dev/null
+++ b/urunlevel/runlevel/apply_patch
@@ -0,0 +1,9 @@
1#! /bin/sh
2
3pushd ..
4make clean
5patch -ufp1 <runlevel/runlevel.patch
6# This is needed to support My Linux, and no one wants that.
7#patch -ufp1 <my_linux/my_linux.patch
8make oldconfig
9popd
diff --git a/urunlevel/runlevel/boot_named.c b/urunlevel/runlevel/boot_named.c
index fba83c7..381896c 100644
--- a/urunlevel/runlevel/boot_named.c
+++ b/urunlevel/runlevel/boot_named.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -26,32 +29,30 @@
26#include "lib_init_d.h" 29#include "lib_init_d.h"
27 30
28 31
29static init_d_handle_t my_commands = 32static init_d_handle_t my_commands = {
30{ 33 NULL,
31 NULL, 34 NULL,
32 NULL, 35 NULL,
33 NULL, 36 NULL,
34 NULL, 37 &sighup_reload,
35 &sighup_reload, 38 NULL,
36 NULL, 39 NULL,
37 NULL, 40 NULL,
38 NULL, 41 "named",
39 "boot_named", 42 "named",
40 "named", 43 NULL,
41 NULL, 44 NULL,
42 NULL, 45 INIT_D_BEGIN
43 INIT_D_BEGIN \ 46 INIT_D_PROV "$named"
44 INIT_D_PROV "$named" \ 47 INIT_D_RSTART "$network $syslog"
45 INIT_D_RSTART "$network $syslog" \ 48 INIT_D_DSTART "3 4 5"
46 INIT_D_DSTART "3 4 5" \ 49 INIT_D_DSTOP "0 1 2 6"
47 INIT_D_DSTOP "0 1 2 6" \ 50 INIT_D_SDESC "Hostname resolution service."
48 INIT_D_SDESC "Hostname resolution service." \ 51 INIT_D_DESC "Hostname resolution service." INIT_D_END
49 INIT_D_DESC "Hostname resolution service." \
50 INIT_D_END
51}; 52};
52 53
53 54
54int boot_named_main(int argc, char **argv) 55int boot_named_main(int argc, char **argv)
55{ 56{
56 return do_init_from_main(argc, argv, &my_commands); 57 return do_init_from_main(argc, argv, &my_commands);
57} 58}
diff --git a/urunlevel/runlevel/boot_portmap.c b/urunlevel/runlevel/boot_portmap.c
index d354b3b..f5ab3ad 100644
--- a/urunlevel/runlevel/boot_portmap.c
+++ b/urunlevel/runlevel/boot_portmap.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Based on SuSE's init.d/portmap
7 *
6 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * 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 10 * the Free Software Foundation; either version 2 of the License, or
@@ -28,51 +30,47 @@
28static int restart(struct init_d_handle_s *init_d, int just_checking); 30static int restart(struct init_d_handle_s *init_d, int just_checking);
29 31
30 32
31static init_d_handle_t my_commands = 33static init_d_handle_t my_commands = {
32{ 34 NULL,
33 NULL, 35 NULL,
34 NULL, 36 &restart,
35 &restart, 37 NULL,
36 NULL, 38 NULL,
37 NULL, 39 NULL,
38 NULL, 40 NULL,
39 NULL, 41 NULL,
40 NULL, 42 "portmap",
41 "boot_portmap", 43 "/sbin/portmap",
42 "/sbin/portmap", 44 NULL,
43 NULL, 45 NULL,
44 NULL, 46 INIT_D_BEGIN
45 INIT_D_BEGIN \ 47 INIT_D_PROV "$portmap"
46 INIT_D_PROV "$portmap" \ 48 INIT_D_RSTART "$network"
47 INIT_D_RSTART "$network" \ 49 INIT_D_DSTART "3 4 5"
48 INIT_D_DSTART "3 4 5" \ 50 INIT_D_DSTOP "0 1 2 6"
49 INIT_D_DSTOP "0 1 2 6" \ 51 INIT_D_SDESC "RPC port mapper."
50 INIT_D_SDESC "RPC port mapper." \ 52 INIT_D_DESC "The RPC port mapper provides SunPRC/ONCRPC portmapping"
51 INIT_D_DESC "The RPC port mapper provides SunPRC/ONCRPC portmapping" \ 53 INIT_D_CONT "services." INIT_D_END
52 INIT_D_CONT "services." \
53 INIT_D_END
54}; 54};
55 55
56 56
57int boot_portmap_main(int argc, char **argv) 57int boot_portmap_main(int argc, char **argv)
58{ 58{
59 return do_init_from_main(argc, argv, &my_commands); 59 return do_init_from_main(argc, argv, &my_commands);
60} 60}
61 61
62 62
63static const char *state = "/var/run/portmap.state";
64static int restart(struct init_d_handle_s *init_d, int just_checking) 63static int restart(struct init_d_handle_s *init_d, int just_checking)
65{ 64{
66 int status = (init_d->status)(init_d, 0); 65 int status = (init_d->status) (init_d, 0);
66 const char *state = "/var/run/portmap.state";
67 67
68 if (status == INIT_D_STATUS_OK) 68 if (status == INIT_D_STATUS_OK) {
69 { 69 doit(0, "pmap_dump > %s", state);
70 doit(0, "pmap_dump > %s", state); 70 status = default_restart(init_d, 0);
71 status = default_restart(init_d, 0); 71 doit(0, "pmap_set < %s", state);
72 doit(0, "pmap_set < %s", state); 72 remove_file(state, FILEUTILS_FORCE);
73 remove_file(state, FILEUTILS_FORCE); 73 } else
74 } 74 status = default_restart(init_d, 0);
75 else 75 return status;
76 status = default_restart(init_d, 0);
77 return status;
78} 76}
diff --git a/urunlevel/runlevel/boot_syslog.c b/urunlevel/runlevel/boot_syslog.c
index dc7548a..a3e7432 100644
--- a/urunlevel/runlevel/boot_syslog.c
+++ b/urunlevel/runlevel/boot_syslog.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Originally based on code from Trinux.
7 *
6 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * 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 10 * the Free Software Foundation; either version 2 of the License, or
@@ -29,51 +31,46 @@
29static int start(struct init_d_handle_s *, int); 31static int start(struct init_d_handle_s *, int);
30 32
31 33
32static init_d_handle_t my_commands = 34static init_d_handle_t my_commands = {
33{ 35 &start,
34 &start, 36 NULL,
35 NULL, 37 NULL,
36 NULL, 38 NULL,
37 NULL, 39 &no_reload,
38 &no_reload, 40 NULL,
39 NULL, 41 NULL,
40 NULL, 42 NULL,
41 NULL, 43 "syslog",
42 "boot_syslogd", 44 "/sbin/syslogd",
43 "/sbin/syslogd", 45 "-n",
44 "-n", 46 NULL,
45 NULL, 47 INIT_D_BEGIN
46 INIT_D_BEGIN \ 48 INIT_D_PROV "$syslog"
47 INIT_D_PROV "$syslog" \ 49 INIT_D_RSTART "$local_fs $time"
48 INIT_D_RSTART "$local_fs $time" \ 50 INIT_D_SSTART "$network"
49 INIT_D_SSTART "$network" \ 51 INIT_D_DSTART "1 2 3 4 5"
50 INIT_D_DSTART "1 2 3 4 5" \ 52 INIT_D_DSTOP "0 6"
51 INIT_D_DSTOP "0 6" \ 53 INIT_D_SDESC "System logger." INIT_D_DESC "System logger." INIT_D_END
52 INIT_D_SDESC "System logger." \
53 INIT_D_DESC "System logger." \
54 INIT_D_END
55}; 54};
56 55
57 56
58int boot_syslog_main(int argc, char **argv) 57int boot_syslog_main(int argc, char **argv)
59{ 58{
60 return do_init_from_main(argc, argv, &my_commands); 59 return do_init_from_main(argc, argv, &my_commands);
61} 60}
62 61
63 62
64static int start(struct init_d_handle_s *init_d, int just_checking) 63static int start(struct init_d_handle_s *init_d, int just_checking)
65{ 64{
66/* 65 char *LOGHOST = getenv("SYSLOGD_LOGHOST");
67#LOGHOST=`cat /var/lib/my_linux/config/loghost 2> /dev/null` 66
68#if [ "$LOGHOST" ] 67 if (LOGHOST && (LOGHOST[0] != '\0')) {
69#then 68 char *temp; /* Being paranoid here, probably. */
70# if [ "$LOGHOST" = "prompt" ] 69
71# then 70 bb_xasprintf(&temp, "%s", init_d->args);
72# echo -n "Enter syslog server: " 71 bb_xasprintf(&(init_d->args), "%s -R %s", temp, LOGHOST);
73# read $LOGHOST 72 free(temp);
74# fi 73 }
75# $REMOTELOG = "-R $LOGHOST" 74
76#fi
77*/
78 return default_start(init_d, 0); 75 return default_start(init_d, 0);
79} 76}
diff --git a/urunlevel/runlevel/boot_time.c b/urunlevel/runlevel/boot_time.c
index aa1fde7..88227ac 100644
--- a/urunlevel/runlevel/boot_time.c
+++ b/urunlevel/runlevel/boot_time.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -31,35 +34,34 @@ static int status(struct init_d_handle_s *, int);
31static int stop(struct init_d_handle_s *, int); 34static int stop(struct init_d_handle_s *, int);
32 35
33 36
34static init_d_handle_t my_commands = 37static init_d_handle_t my_commands = {
35{ 38 &start,
36 &start, 39 &stop,
37 &stop, 40 NULL,
38 NULL, 41 NULL,
39 NULL, 42 &no_reload,
40 &no_reload, 43 NULL,
41 NULL, 44 &status,
42 &status, 45 NULL,
43 NULL, 46 "time",
44 "boot_time", 47 NULL,
45 NULL, 48 NULL,
46 NULL, 49 NULL,
47 NULL, 50 INIT_D_BEGIN
48 INIT_D_BEGIN \ 51 INIT_D_PROV "$time"
49 INIT_D_PROV "$time" \ 52 INIT_D_DSTART "1 2 3 4 5"
50 INIT_D_DSTART "1 2 3 4 5" \ 53 INIT_D_DSTOP "0 6"
51 INIT_D_DSTOP "0 6" \ 54 INIT_D_SDESC "Set the system time."
52 INIT_D_SDESC "Set the system time." \ 55 INIT_D_DESC "Set the system time, maybe from the hardware clock,"
53 INIT_D_DESC "Set the system time, maybe from the hardware clock," \ 56 INIT_D_CONT "maybe from the network via NTP or DATE." INIT_D_END
54 INIT_D_CONT "maybe from the network via NTP or DATE." \
55 INIT_D_END
56}; 57};
58
57// INIT_D_SSTART "$network" \ 59// INIT_D_SSTART "$network" \
58 60
59 61
60int boot_time_main(int argc, char **argv) 62int boot_time_main(int argc, char **argv)
61{ 63{
62 return do_init_from_main(argc, argv, &my_commands); 64 return do_init_from_main(argc, argv, &my_commands);
63} 65}
64 66
65 67
@@ -67,22 +69,22 @@ static int start(struct init_d_handle_s *init_d, int just_checking)
67{ 69{
68// Should check if we need to NTP or whatever 70// Should check if we need to NTP or whatever
69// Should check for -l/-u 71// Should check for -l/-u
70 doit(0, "/sbin/hwclock -su"); 72 doit(0, "/sbin/hwclock -su");
71// Should check errno and convert into INIT_D_ERROR_? 73// Should check errno and convert into INIT_D_ERROR_?
72 return INIT_D_OK; 74 return INIT_D_OK;
73} 75}
74 76
75 77
76static int status(struct init_d_handle_s *init_d, int quiet) 78static int status(struct init_d_handle_s *init_d, int quiet)
77{ 79{
78 return print_status(init_d, quiet, INIT_D_STATUS_OK); 80 return print_status(init_d, quiet, INIT_D_STATUS_OK);
79} 81}
80 82
81 83
82static int stop(struct init_d_handle_s *init_d, int just_checking) 84static int stop(struct init_d_handle_s *init_d, int just_checking)
83{ 85{
84// Should check for -l/-u 86// Should check for -l/-u
85 doit(0, "/sbin/hwclock -wu"); 87 doit(0, "/sbin/hwclock -wu");
86// Should check errno and convert into INIT_D_ERROR_? 88// Should check errno and convert into INIT_D_ERROR_?
87 return INIT_D_OK; 89 return INIT_D_OK;
88} 90}
diff --git a/urunlevel/runlevel/diff_excludes b/urunlevel/runlevel/diff_excludes
new file mode 100644
index 0000000..04fab03
--- /dev/null
+++ b/urunlevel/runlevel/diff_excludes
@@ -0,0 +1,14 @@
1config.h
2.config
3.config.cmd
4.depend
5conf
6mconf
7mkdep
8lex.zconf.c
9lkc_defs.h
10zconf.tab.c
11zconf.tab.h
12gzip.c
13runlevel
14my_linux
diff --git a/urunlevel/runlevel/install_initd.c b/urunlevel/runlevel/install_initd.c
index 4b9ab88..270e4d0 100644
--- a/urunlevel/runlevel/install_initd.c
+++ b/urunlevel/runlevel/install_initd.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -20,6 +23,7 @@
20 * 23 *
21 */ 24 */
22 25
26#include <string.h>
23#include <unistd.h> 27#include <unistd.h>
24 28
25#include "busybox.h" 29#include "busybox.h"
@@ -28,21 +32,74 @@
28 32
29int install_initd_main(int argc, char **argv) 33int install_initd_main(int argc, char **argv)
30{ 34{
31 llist_t *sorted = NULL; 35 int result = EXIT_FAILURE;
32 llist_t *unsorted = get_scripts(); 36
33// char *info_text = NULL; 37 argv += optind;
34// char *pathname = NULL; 38 if (!*argv)
35// init_d_info_t *info = NULL; 39 bb_show_usage();
36 40 else {
37// bb_xasprintf(&pathname, "/etc/init.d/%s", script->d_name); 41 int in_init = 0;
38// info_text = get_init_info(pathname); 42 llist_t *current = NULL;
39// info = parse_init_info(info_text, script->d_name); 43 llist_t *unsorted = get_scripts();
40// if (info) 44 init_d_info_t *info = NULL;
41// result = llist_add_to(result, (char *) info); 45 char *info_text = NULL;
42 46 char *pathname = NULL;
43 sorted = sort_scripts(unsorted); 47 RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
44// Should return 1 if this script is in unsorted. 48
45 49 bb_xasprintf(&pathname, "%s", *argv);
46// free(info_text); 50 if ((*argv)[0] != '/') {
47 return EXIT_SUCCESS; 51 char *cwd = xgetcwd(NULL);
52
53 if (cwd) {
54 free(pathname);
55 bb_xasprintf(&pathname, "%s/%s", cwd, *argv);
56 }
57 }
58
59 if (realpath(pathname, resolved_path) != NULL) {
60 if (strncmp("/etc/init.d/", resolved_path, 12) == 0)
61 in_init = 1;
62 } else {
63 bb_perror_msg("%s", pathname);
64 }
65
66 if (!in_init) {
67 bb_xasprintf(&info_text, "/etc/init.d/%s", bb_get_last_path_component(pathname));
68 symlink(pathname, info_text);
69 free(info_text);
70 }
71
72 info_text = get_init_info(pathname);
73 info = parse_init_info(info_text, bb_get_last_path_component(pathname));
74
75 sort_scripts(unsorted, info);
76 current = unsorted;
77 result = EXIT_SUCCESS;
78 while (current) {
79 init_d_info_t *this_one = (init_d_info_t *) current->data;
80
81 if (this_one) {
82 if (strcmp(this_one->path, info->path) == 0) {
83 result = EXIT_FAILURE;
84 free(info_text);
85 bb_xasprintf(&info_text, "/etc/init.d/%s", bb_get_last_path_component(pathname));
86 remove_file(info_text, FILEUTILS_FORCE);
87 break;
88 }
89 }
90 current = current->link;
91 }
92
93 if (result == EXIT_FAILURE)
94 bb_error_msg("Unable to install the %s init.d script.", pathname);
95
96#ifdef CONFIG_FEATURE_CLEAN_UP
97 RELEASE_CONFIG_BUFFER(resolved_path);
98#endif
99 free(info);
100 free(pathname);
101 free(info_text);
102 }
103
104 return result;
48} 105}
diff --git a/urunlevel/runlevel/killproc.c b/urunlevel/runlevel/killproc.c
index fd91c10..2d802bd 100644
--- a/urunlevel/runlevel/killproc.c
+++ b/urunlevel/runlevel/killproc.c
@@ -3,6 +3,10 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 *
7 * Clean room implementation of LSB init.d specs.
8 * A tiny bit was stolen from procps/kill.c in busybox.
9 *
6 * This program is free software; you can redistribute it and/or modify 10 * 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 11 * 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 12 * the Free Software Foundation; either version 2 of the License, or
@@ -31,61 +35,53 @@
31 35
32int killproc(char *pidfile, char *pathname, int my_signal) 36int killproc(char *pidfile, char *pathname, int my_signal)
33{ 37{
34 char *pids = NULL; 38 char *pids = NULL;
35 int status = pidofproc(pidfile, pathname, &pids); 39 int status = pidofproc(pidfile, pathname, &pids);
40
41 if (status == INIT_D_STATUS_OK) {
42 int i;
43 char *pid;
44 char *strtok_temp;
45
46 pid = strtok_r(pids, " ", &strtok_temp);
47 for (i = 0; pid != NULL; i++) {
48 int pid_num;
49
50 if (!isdigit(*pid))
51 bb_error_msg("Bad PID '%s'", pid);
52 pid_num = strtol(pid, NULL, 0);
53 if (my_signal != 0) {
54 if (kill(pid_num, my_signal) != 0)
55 bb_perror_msg("Could not kill pid '%d'", pid_num);
56 } else {
57 if (kill(pid_num, SIGTERM) != 0)
58 bb_perror_msg("Could not kill pid '%d'", pid_num);
59 sleep(1);
60 status = pidofproc(pidfile, pathname, &pids);
61 if (status == INIT_D_STATUS_OK) {
62 sleep(5);
63 status = pidofproc(pidfile, pathname, &pids);
64 if (status == INIT_D_STATUS_OK) {
65 if (kill(pid_num, SIGKILL) != 0)
66 bb_perror_msg("Could not kill pid '%d'", pid_num);
67 }
68 }
69 }
70
71 pid = strtok_r(NULL, " ", &strtok_temp);
72 }
36 73
37 if (status == INIT_D_STATUS_OK)
38 {
39 int i;
40 char *pid;
41 char *strtok_temp;
42
43 pid = strtok_r(pids, " ", &strtok_temp);
44 for (i = 0; pid != NULL; i++)
45 {
46 int pid_num;
47
48 if (!isdigit(*pid))
49 bb_error_msg( "Bad PID '%s'", pid);
50 pid_num = strtol(pid, NULL, 0);
51 if (my_signal != 0)
52 {
53 if (kill(pid_num, my_signal) != 0)
54 bb_perror_msg( "Could not kill pid '%d'", pid_num);
55 }
56 else
57 {
58 if (kill(pid_num, SIGTERM) != 0)
59 bb_perror_msg( "Could not kill pid '%d'", pid_num);
60 sleep(1);
61 status = pidofproc(pidfile, pathname, &pids); 74 status = pidofproc(pidfile, pathname, &pids);
62 if (status == INIT_D_STATUS_OK) 75 if (status == INIT_D_STATUS_DEAD_PID) {
63 { 76 if (pidfile != NULL)
64 sleep(5); 77 remove_file(pidfile, FILEUTILS_FORCE);
65 status = pidofproc(pidfile, pathname, &pids); 78 status = INIT_D_STATUS_NOT_RUNNING;
66 if (status == INIT_D_STATUS_OK)
67 {
68 if (kill(pid_num, SIGKILL) != 0)
69 bb_perror_msg( "Could not kill pid '%d'", pid_num);
70 }
71 } 79 }
72 } 80 if ((my_signal == 0) && (status == INIT_D_STATUS_NOT_RUNNING))
73 81 status = INIT_D_STATUS_OK;
74 pid = strtok_r(NULL, " ", &strtok_temp);
75 }
76
77 status = pidofproc(pidfile, pathname, &pids);
78 if (status == INIT_D_STATUS_DEAD_PID)
79 {
80 if (pidfile != NULL)
81 remove_file(pidfile, FILEUTILS_FORCE);
82 status = INIT_D_STATUS_NOT_RUNNING;
83 } 82 }
84 if ((my_signal == 0) && (status == INIT_D_STATUS_NOT_RUNNING))
85 status = INIT_D_STATUS_OK;
86 }
87 83
88 return status; 84 return status;
89} 85}
90 86
91 87
@@ -111,52 +107,45 @@ killproc [-p pidfile] pathname [signal]
111*/ 107*/
112 108
113 109
110 /* getopt not used, because I don't think it can handle [signal] */
114int killproc_main(int argc, char **argv) 111int killproc_main(int argc, char **argv)
115{ 112{
116 int i; 113 int i;
117 int my_signal = 0; 114 int my_signal = 0;
118 char *pidfile = NULL; 115 char *pidfile = NULL;
119 char *pathname = NULL; 116 char *pathname = NULL;
120 char *signame = NULL; 117 char *signame = NULL;
121 118
122 for (i = 1; i < argc; i++) 119 for (i = 1; i < argc; i++) {
123 { 120 char *p = argv[i];
124 char *p = argv[i]; 121
125 122 if (*p == '-') {
126 if (*p == '-') 123 p++;
127 { 124 if (*p == 'p') {
128 p++; 125 if ((i + 1) < argc)
129 if (*p == 'p') 126 pidfile = argv[++i];
130 { 127 else
131 if ((i + 1) < argc) 128 bb_show_usage();
132 pidfile = argv[++i]; 129 } else
130 signame = &argv[i][1];
131 } else if (pathname == NULL)
132 pathname = p;
133 else if (signame == NULL)
134 signame = p;
133 else 135 else
134 bb_show_usage(); 136 bb_show_usage();
135 }
136 else
137 signame = &argv[i][1];
138 }
139 else if (pathname == NULL)
140 pathname = p;
141 else if (signame == NULL)
142 signame = p;
143 else
144 bb_show_usage();
145 }
146
147 if (pathname == NULL)
148 bb_show_usage();
149
150 if (signame != NULL)
151 {
152 u_signal_names(signame, &my_signal, 1);
153 if (my_signal == 0)
154 {
155 log_failure_msg("unknown signal.");
156 bb_show_usage();
157 } 137 }
158 }
159 138
139 if (pathname == NULL)
140 bb_show_usage();
141
142 if (signame != NULL) {
143 u_signal_names(signame, &my_signal, 1);
144 if (my_signal == 0) {
145 log_failure_msg("unknown signal.");
146 bb_show_usage();
147 }
148 }
160//bb_printf("ARGS - %s %s %d = %s\n", pidfile, pathname, my_signal, u_signal_names(NULL, &signal, 1)); 149//bb_printf("ARGS - %s %s %d = %s\n", pidfile, pathname, my_signal, u_signal_names(NULL, &signal, 1));
161 return killproc(pidfile, pathname, my_signal); 150 return killproc(pidfile, pathname, my_signal);
162} 151}
diff --git a/urunlevel/runlevel/lib_init_d.c b/urunlevel/runlevel/lib_init_d.c
index 866888c..25d21a1 100644
--- a/urunlevel/runlevel/lib_init_d.c
+++ b/urunlevel/runlevel/lib_init_d.c
@@ -1,6 +1,9 @@
1/* 1/*
2 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au 2 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au
3 * 3 *
4 * llist_add_to_end() lifted whole from busybox networking/ifupdown.c,
5 * so it should probably be in libbb.
6 *
4 * This program is free software; you can redistribute it and/or modify 7 * 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 8 * 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 9 * the Free Software Foundation; either version 2 of the License, or
@@ -26,237 +29,235 @@
26#include <string.h> 29#include <string.h>
27#include <sys/poll.h> 30#include <sys/poll.h>
28#include <sys/wait.h> 31#include <sys/wait.h>
29#include <sys/utsname.h> /* for uname(2) */ 32#include <sys/utsname.h> /* for uname(2) */
30 33
31#include "busybox.h" 34#include "busybox.h"
32#include "lib_init_d.h" 35#include "lib_init_d.h"
33 36
34 37
38const static nodes_t nodes[] = {
39 {"hda", S_IFBLK, 3, 0, 0},
40 {"hdb", S_IFBLK, 3, 64, 0},
41 {"hdc", S_IFBLK, 22, 0, 0},
42 {"hdd", S_IFBLK, 22, 64, 0},
43 {"ram", S_IFBLK, 1, 0, 9},
44 {"fd", S_IFBLK, 2, 0, 1},
45 {"loop", S_IFBLK, 7, 0, 63},
46 {"cloop", S_IFBLK, 240, 0, 7},
47 {"vcs", S_IFBLK, 7, 0, 9},
48 {"vcsa", S_IFBLK, 7, 0, 9},
49 {0, 0, 0, 0, 0}
50};
51
52
35static char *shell = 0; 53static char *shell = 0;
36struct stat path_stat; 54struct stat path_stat;
37 55
38 56
39char *argv_cat(int argc, char **argv) 57char *argv_cat(int argc, char **argv)
40{ 58{
41 int i; 59 int i;
42 int length = 1; 60 int length = 1;
43 char *message = NULL; 61 char *message = NULL;
44 62
45 for (i = 0; i < argc; i++) 63 for (i = 0; i < argc; i++)
46 length += strlen(argv[i]); 64 length += strlen(argv[i]) + 1;
47 message = (char *) xmalloc(sizeof (char) * length); 65 message = (char *) xmalloc(sizeof(char) * length);
48 66
49 if (message != NULL) 67 if (message != NULL) {
50 { 68 message[0] = '\0';
51 message[0] = '\0'; 69 for (i = 1; i < argc; i++) {
52 for (i = 1; i < argc; i++) 70 /* These strcat's are not dangerous, since we checked sizes above. */
53 { 71 strcat(message, argv[i]);
54 strcat(message, argv[i]); 72 if (i < (argc - 1))
55 if (i < (argc - 1)) 73 strcat(message, " ");
56 strcat(message, " "); 74 }
57 } 75 }
58 } 76 return message;
59 return message;
60} 77}
61 78
62 79
63char *big_chomp(char *s) 80char *big_chomp(char *s)
64{ 81{
65 char *lc = index(s, '\n'); 82 char *lc = index(s, '\n');
66 83
67 if(lc) 84 if (lc)
68 *lc = '\0'; 85 *lc = '\0';
69 return s; 86 return s;
70} 87}
71 88
72 89
90/* I found out that networking/ifupdown.c has a similar function
91 * with an identical name AFTER I wrote this.
92 */
73char *doit(int mode, char *command, ...) 93char *doit(int mode, char *command, ...)
74{ 94{
75 int buffsize = 63; 95 int buffsize = 63;
76 char *buffer = NULL; 96 char *buffer = NULL;
77 int dataPipe[2] = { -1, -1 }; 97 int dataPipe[2] = { -1, -1 };
78 int statusPipe[2] = { -1, -1 }; 98 int statusPipe[2] = { -1, -1 };
79 int n; 99 int n;
80 pid_t pid = 0; 100 pid_t pid = 0;
81 volatile int vfork_exec_errno = 0; 101 volatile int vfork_exec_errno = 0;
82 char **args; 102 char **args;
83 char *commandBuffer; 103 char *commandBuffer;
84 104
85 if (mode & DAEMON) 105 if (mode & DAEMON)
86 mode |= FORK | QUIET; 106 mode |= FORK | QUIET;
87 107
88 va_list p; 108 va_list p;
89 int r; 109 int r;
90 110
91 va_start(p, command); 111 va_start(p, command);
92 r = vasprintf(&commandBuffer, command, p); 112 r = vasprintf(&commandBuffer, command, p);
93 va_end(p); 113 va_end(p);
94 114
95 if (r < 0) 115 if (r < 0)
96 bb_perror_msg_and_die("doit"); 116 bb_perror_msg_and_die("doit");
97 117
98 if (shell == 0) 118 if (shell == 0) {
99 { 119 shell = getenv("SHELL");
100 shell = getenv("SHELL"); 120 if (shell == 0)
101 if (shell == 0) 121 shell = "/bin/sh";
102 shell = "/bin/sh";
103 }
104
105 args = (char **) xmalloc (sizeof (char *) * 4);
106 n = 0;
107 args[n++] = shell;
108 args[n++] = "-c";
109 if (mode & QUIET)
110 bb_xasprintf(&(args[n++]), "%s 2>/dev/null", commandBuffer);
111 else
112 args[n++] = commandBuffer;
113 args[n++] = 0;
114
115 if (!(mode & NOFORK))
116 {
117 if (!(mode & DAEMON))
118 {
119 if (pipe(dataPipe) < 0 || pipe(statusPipe) < 0)
120 bb_perror_msg("Failed to create pipe");
121 signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
122 }
123// pid = vfork();
124 pid = fork();
125 }
126 if (pid == 0) /* child */
127 {
128 if ((!(mode & NOFORK)) && (!(mode & NOFORK)))
129 {
130 close(STDIN_FILENO);
131 dup2(dataPipe[1], STDOUT_FILENO);
132 dup2(dataPipe[1], STDERR_FILENO);
133 close(dataPipe[0]);
134 close(statusPipe[0]);
135 fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */
136 } 122 }
137 123
138 if ((mode & DAEMON)) 124 args = (char **) xmalloc(sizeof(char *) * 4);
139 { 125 n = 0;
140 if (!(mode & NOFORK)) 126 args[n++] = shell;
141 { 127 args[n++] = "-c";
142 close(dataPipe[1]); 128 if (mode & QUIET)
143 close(statusPipe[1]); 129 bb_xasprintf(&(args[n++]), "%s 2>/dev/null", commandBuffer);
144 close(STDOUT_FILENO); 130 else
145 close(STDERR_FILENO); 131 args[n++] = commandBuffer;
146 } 132 args[n++] = 0;
147 daemon(1, 0); 133
148 } 134 if (!(mode & NOFORK)) {
149 errno = 0; 135 if (!(mode & DAEMON)) {
150 execvp(shell, (char **) args ); 136 if (pipe(dataPipe) < 0 || pipe(statusPipe) < 0)
151 137 bb_perror_msg("Failed to create pipe");
152 vfork_exec_errno = errno; 138 signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
153 if (!(mode & NOFORK)) 139 }
154 close(statusPipe[1]); 140// pid = vfork();
155 _exit(-1); 141 pid = fork();
156 }
157 else if (pid > 0) /* parent */
158 {
159 close(dataPipe[1]);
160 close(statusPipe[1]);
161
162 while (1)
163 {
164 char buf;
165
166 n = read(statusPipe[0], &buf, 1);
167
168 if ((n < 0) && ((errno == EAGAIN) || (errno == EINTR)) && !(mode & FORK))
169 continue; /* try it again */
170 else if (n == 0 && vfork_exec_errno != 0)
171 {
172 errno = vfork_exec_errno;
173 bb_perror_msg("Could not exec process");
174 }
175 break;
176 } 142 }
177 close(statusPipe[0]); 143 if (pid == 0) { /* child */
178 144 if ((!(mode & NOFORK)) && (!(mode & NOFORK))) {
179 if (buffer == NULL) 145 close(STDIN_FILENO);
180 buffer = (char *) xcalloc(buffsize + 1, sizeof (char)); 146 dup2(dataPipe[1], STDOUT_FILENO);
181 147 dup2(dataPipe[1], STDERR_FILENO);
182 if ((mode & FORK) == 0) 148 close(dataPipe[0]);
183 { 149 close(statusPipe[0]);
184 ssize_t cc; 150 fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */
185 struct pollfd poller[1]; 151 }
186 152
187 poller[0].fd = dataPipe[0]; 153 if ((mode & DAEMON)) {
188 poller[0].events = POLLIN | POLLPRI; 154 if (!(mode & NOFORK)) {
189 poller[0].revents = 0; 155 close(dataPipe[1]);
156 close(statusPipe[1]);
157 close(STDOUT_FILENO);
158 close(STDERR_FILENO);
159 }
160 daemon(1, 0);
161 }
162 errno = 0;
163 execvp(shell, (char **) args);
190 164
191 n = 0; 165 vfork_exec_errno = errno;
192 while (1) 166 if (!(mode & NOFORK))
193 { 167 close(statusPipe[1]);
194 if ((buffsize - n) <= 0) 168 _exit(-1);
195 { 169 } else if (pid > 0) { /* parent */
196 int i; 170 close(dataPipe[1]);
171 close(statusPipe[1]);
197 172
198 buffsize += buffsize; 173 while (1) {
199 buffer = xrealloc(buffer, sizeof(char) * (buffsize + 1)); 174 char buf;
200 for (i = n; i <= buffsize; i++)
201 buffer[i] = '\0';
202 }
203 175
204 errno = 0; 176 n = read(statusPipe[0], &buf, 1);
205 cc = poll(poller, 1, 1010); /* network sleeps for 1000 between '.' outputs */
206 if (cc > 0)
207 cc = read(dataPipe[0], &buffer[n], buffsize - n);
208 177
209 if (cc < 0) 178 if ((n < 0) && ((errno == EAGAIN) || (errno == EINTR))
210 { 179 && !(mode & FORK))
211 if (errno == EINTR) 180 continue; /* try it again */
212 continue; 181 else if (n == 0 && vfork_exec_errno != 0) {
213 if (errno == EAGAIN) 182 errno = vfork_exec_errno;
214 continue; 183 bb_perror_msg("Could not exec process");
184 }
215 break; 185 break;
216 } 186 }
217 else if (cc == 0) 187 close(statusPipe[0]);
218 break; 188
189 if (buffer == NULL)
190 buffer = (char *) xcalloc(buffsize + 1, sizeof(char));
191
192 if ((mode & FORK) == 0) {
193 ssize_t cc;
194 struct pollfd poller[1];
195
196 poller[0].fd = dataPipe[0];
197 poller[0].events = POLLIN | POLLPRI;
198 poller[0].revents = 0;
199
200 n = 0;
201 while (1) {
202 if ((buffsize - n) <= 0) {
203 int i;
204
205 buffsize += buffsize;
206 buffer = xrealloc(buffer, sizeof(char) * (buffsize + 1));
207 for (i = n; i <= buffsize; i++)
208 buffer[i] = '\0';
209 }
210
211 errno = 0;
212 cc = poll(poller, 1, 1010); /* network sleeps for 1000 between '.' outputs */
213 if (cc > 0)
214 cc = read(dataPipe[0], &buffer[n], buffsize - n);
215
216 if (cc < 0) {
217 if (errno == EINTR)
218 continue;
219 if (errno == EAGAIN)
220 continue;
221 break;
222 } else if (cc == 0)
223 break;
224
225 if ((mode & (QUIET | REDIR)) == 0)
226 bb_printf(&buffer[n]);
227 n += cc;
228 }
229 }
219 230
220 if ((mode & (QUIET | REDIR)) == 0) 231 if (mode & REDIR)
221 bb_printf(&buffer[n]); 232 chomp(buffer);
222 n += cc; 233 } else {
223 } 234 bb_perror_msg("Failed to fork process");
224 } 235 }
225 236
226 if (mode & REDIR) 237 n = 0;
227 chomp(buffer); 238 if (pid) {
228 } 239 close(dataPipe[0]);
229 else 240
230 { 241 if ((mode & FORK) == 0) {
231 bb_perror_msg("Failed to fork process"); 242 if (waitpid(pid, &n, 0) == -1)
232 } 243 bb_printf("Couldn't wait?");
233 244 }
234 n = 0; 245 if (WIFEXITED(n))
235 if (pid) 246 n = WEXITSTATUS(n);
236 { 247 else
237 close(dataPipe[0]); 248 n = -1;
238
239 if ((mode & FORK) == 0)
240 {
241 if (waitpid(pid, &n, 0) == -1)
242 bb_printf("Couldn't wait?");
243 } 249 }
244 if (WIFEXITED(n))
245 n = WEXITSTATUS(n);
246 else
247 n = -1;
248 }
249 250
250 free(args); 251 free(args);
251 free(commandBuffer); 252 free(commandBuffer);
252 errno = n; 253 errno = n;
253 return buffer; 254 return buffer;
254} 255}
255 256
256 257
257#ifdef RUNLEVEL_LIST 258#ifdef RUNLEVEL_LIST
258// From ifupdown, so it should probably be in libbb. 259// From ifupdown, so it should probably be in libbb.
259llist_t *llist_add_to_end(llist_t *list_head, char *data) 260llist_t *llist_add_to_end(llist_t * list_head, char *data)
260{ 261{
261 llist_t *new_item, *tmp, *prev; 262 llist_t *new_item, *tmp, *prev;
262 263
@@ -266,160 +267,270 @@ llist_t *llist_add_to_end(llist_t *list_head, char *data)
266 267
267 prev = NULL; 268 prev = NULL;
268 tmp = list_head; 269 tmp = list_head;
269 while(tmp) 270 while (tmp) {
270 { 271 prev = tmp;
271 prev = tmp; 272 tmp = tmp->link;
272 tmp = tmp->link;
273 } 273 }
274 if (prev) 274 if (prev)
275 prev->link = new_item; 275 prev->link = new_item;
276 else 276 else
277 list_head = new_item; 277 list_head = new_item;
278 278
279 return(list_head); 279 return (list_head);
280} 280}
281#endif 281#endif
282 282
283 283
284llist_t *llist_delete(llist_t **head, llist_t *previous, llist_t *current) 284llist_t *llist_delete(llist_t ** head, llist_t * previous, llist_t * current)
285{ 285{
286 if (previous == NULL) 286 if (previous == NULL) {
287 { 287 *head = current->link;
288 *head = current->link; 288 free(current);
289 free(current); 289 current = *head;
290 current = *head; 290 } else {
291 } 291 previous->link = current->link;
292 else 292 free(current);
293 { 293 current = previous->link;
294 previous->link = current->link; 294 }
295 free(current); 295
296 current = previous->link; 296 return current;
297 }
298
299 return current;
300} 297}
301 298
302 299
303void make_disk(char *token, const nodes_t *nodes) 300void make_disk(char *token)
304{ 301{
305 int i; 302 int i;
306 char temp[32]; 303
307 304 RESERVE_CONFIG_BUFFER(temp, PATH_MAX);
308 for (i = 0; nodes[i].name != 0; i++) 305
309 { 306 if (nodes == NULL)
310 if (strncmp(nodes[i].name, token, 3) == 0) 307 return;
311 { 308
312 int m = atoi(&token[3]); 309 for (i = 0; nodes[i].name != NULL; i++) {
313 sprintf(temp, "/dev/%s", token); 310 if (strncmp(nodes[i].name, token, 3) == 0) {
314 mknod(temp, nodes[i].mode, makedev(nodes[i].major, nodes[i].minor + m)); 311 int m = atoi(&token[3]);
315 break; 312
313 snprintf(temp, PATH_MAX, "/dev/%s", token);
314 mknod(temp, nodes[i].mode,
315 makedev(nodes[i].major, nodes[i].minor + m));
316 break;
317 }
316 } 318 }
317 } 319 snprintf(temp, PATH_MAX, "/media/%s", token);
318 sprintf(temp, "/media/%s", token); 320 bb_make_directory(temp, -1l, FILEUTILS_RECUR);
319 bb_make_directory(temp, -1l, FILEUTILS_RECUR); 321 RELEASE_CONFIG_BUFFER(temp);
320} 322}
321 323
322 324
323void make_ram_disk(int size, int number, char *place, int TMPFS) 325void make_ram_disk(int size, int number, char *place, int TMPFS)
324{ 326{
325 if (size > 0) 327 if (size > 0) {
326 { 328 char *place2;
327 char *place2; 329
328 330 bb_printf("Creating ramdisk at %s\n", place);
329 bb_printf( "Creating ramdisk at %s\n", place); 331 bb_xasprintf(&place2, "%s2", place);
330 bb_xasprintf(&place2, "%s2", place); 332 if (copy_file
331 if (copy_file(place, place2, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0) 333 (place, place2, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0)
332 remove_file(place, FILEUTILS_RECUR | FILEUTILS_FORCE); 334 remove_file(place, FILEUTILS_RECUR | FILEUTILS_FORCE);
333 bb_make_directory (place, -1l, 0); 335 bb_make_directory(place, -1l, 0);
334 if (TMPFS) 336 if (TMPFS)
335 quick_mount("tmpfs", "/dev/null", place, "-n -o size=%i", size * 1024); 337 quick_mount("tmpfs", "/dev/null", place, "-n -o size=%i",
336 else 338 size * 1024);
337 { 339 else {
338 doit(QUIET, "mkfs.minix /dev/ram%i %i", number, size); 340 doit(QUIET, "mkfs.minix /dev/ram%i %i", number, size);
339 quick_mount("minix", "", "", "/dev/ram%i %s", number, place); 341 quick_mount("minix", "", "", "/dev/ram%i %s", number, place);
342 }
343 if (copy_file
344 (place2, place, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0)
345 remove_file(place2, FILEUTILS_RECUR | FILEUTILS_FORCE);
346 free(place2);
340 } 347 }
341 if (copy_file(place2, place, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0)
342 remove_file(place2, FILEUTILS_RECUR | FILEUTILS_FORCE);
343 free(place2);
344 }
345} 348}
346 349
347 350
348void quick_mount(char *type, char *device, char *path, char *data, ...) 351void quick_mount(char *type, char *device, char *path, char *data, ...)
349{ 352{
350 char *dataBuffer; 353 char *dataBuffer;
351 va_list p; 354 va_list p;
352 int r; 355 int r;
353 356
354 va_start(p, data); 357 va_start(p, data);
355 r = vasprintf(&dataBuffer, data, p); 358 r = vasprintf(&dataBuffer, data, p);
356 va_end(p); 359 va_end(p);
357 if (r < 0) 360 if (r < 0)
358 bb_perror_msg("quick_mount"); 361 bb_perror_msg("quick_mount");
359 else 362 else {
360 { 363 doit(QUIET, "busybox mount -t %s %s %s %s", type, device, path,
361 doit(QUIET, "busybox mount -t %s %s %s %s", type, device, path, dataBuffer); 364 dataBuffer);
362 } 365 }
363 366
364 free(dataBuffer); 367 free(dataBuffer);
365} 368}
366 369
367 370
368char *quick_read(char *filename) 371char *quick_read(char *filename)
369{ 372{
370 char *result = NULL; 373 char *result = NULL;
371 374
372 if (stat(filename, &path_stat) == 0) 375 if (stat(filename, &path_stat) == 0) {
373 { 376// if (S_ISREG(path_stat.st_mode))
374// if (S_ISREG(path_stat.st_mode)) 377 {
375 { 378 int ifd;
376 int ifd; 379 ssize_t size = path_stat.st_size;
377 ssize_t size = path_stat.st_size; 380
378 381 if (size <= 0)
379 if (size <= 0) 382 size = 1024;
380 size = 1024; 383 result = (char *) xmalloc(sizeof(char) * size + 1);
381 result = (char *) xmalloc (sizeof (char) * size + 1); 384 if ((ifd = open(filename, O_RDONLY)) < 0)
382 if ((ifd = open(filename, O_RDONLY)) < 0) 385 bb_perror_msg("%s", filename);
383 bb_perror_msg("%s", filename); 386 else {
384 else 387 ssize_t total = bb_full_read(ifd, result, size);
385 { 388
386 ssize_t total = bb_full_read(ifd, result, size); 389// result[path_stat.st_size] = '\0';
387// result[path_stat.st_size] = '\0'; 390 result[total] = '\0';
388 result[total] = '\0'; 391 if (close(ifd) < 0)
389 if (close (ifd) < 0) 392 bb_perror_msg("%s", filename);
390 bb_perror_msg("%s", filename); 393 }
391 } 394 }
392 } 395 }
393 }
394 396
395 return result; 397 return result;
396} 398}
397 399
398 400
399void quick_write(const char *filename, const char *data, ...) 401void quick_write(const char *filename, const char *data, ...)
400{ 402{
401 char *dataBuffer; 403 char *dataBuffer;
402 va_list p; 404 va_list p;
403 int r; 405 int r;
404 406
405 va_start(p, data); 407 va_start(p, data);
406 r = vasprintf(&dataBuffer, data, p); 408 r = vasprintf(&dataBuffer, data, p);
407 va_end(p); 409 va_end(p);
408 if (r >= 0) 410 if (r >= 0) {
409 { 411 int ofd;
410 int ofd; 412
411 413 if ((ofd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
412 if ((ofd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) 414 bb_perror_msg("%s", filename);
413 bb_perror_msg("%s", filename); 415 else {
414 else 416 r = bb_full_write(ofd, dataBuffer, r);
415 { 417 if (close(ofd) < 0)
416 r = bb_full_write(ofd, dataBuffer, r); 418 bb_perror_msg("%s", filename);
417 if (close (ofd) < 0) 419 }
418 bb_perror_msg("%s", filename); 420 }
421 if (r < 0)
422 bb_perror_msg("quick_write");
423
424 free(dataBuffer);
425}
426
427
428void read_sysconfig(char *sysconfig)
429{
430 if (sysconfig == NULL)
431 sysconfig = "/bootconfig";
432 if (stat(sysconfig, &path_stat) == 0) {
433 char *line;
434 FILE *contents;
435
436 contents = fopen(sysconfig, "r");
437 if (contents != NULL) {
438 char *buffer = (char *) xmalloc(sizeof(char) * 256);
439
440//bb_printf("Parsing configuration.\n");
441 do {
442 line = fgets(buffer, 255, contents);
443 set_sysconfig_env(buffer);
444 } while (line != NULL);
445 }
446 }
447}
448
449
450void set_sysconfig_env(char *token)
451{
452 int i;
453 char *eq = NULL;
454 char *ha = NULL;
455 char quote = 0;
456
457 if (token == NULL)
458 return;
459 trim(token);
460 if (token[0] == '\0')
461 return;
462 for (i = 0; token[i] != '\0'; i++) {
463 switch (token[i]) {
464 case '=':
465 if (quote == 0) {
466 if (eq == NULL)
467 eq = &token[i];
468 }
469 break;
470 case '#':
471 if (quote == 0) {
472 if (ha == NULL)
473 ha = &token[i];
474 }
475 break;
476
477 case '"':
478 if (quote == 0) {
479 quote = '"';
480 if (eq) {
481 *eq = '\0';
482 eq = &token[i];
483 }
484 }
485 else if (quote == '"') {
486 quote = 0;
487 token[i] = '\0';
488 }
489 break;
490
491 case '\'':
492 if (quote == 0) {
493 quote = '\'';
494 if (eq) {
495 *eq = '\0';
496 eq = &token[i];
497 }
498 }
499 else if (quote == '\'') {
500 quote = 0;
501 token[i] = '\0';
502 }
503 break;
504 }
419 } 505 }
420 }
421 if (r < 0)
422 bb_perror_msg("quick_write");
423 506
424 free(dataBuffer); 507 if (eq == NULL)
508 return;
509
510 if ((eq != token) && (ha != token)) {
511 char *name = (char *) xmalloc(sizeof(char) * (i + 5));
512
513 if (eq != NULL)
514 *eq = '\0';
515 if (ha != NULL)
516 *ha = '\0';
517 sprintf(name, "%s", token);
518 trim(name);
519 if (name[0] != '\0') {
520 if (eq != NULL) {
521 // Don't override previously set env.
522 if (getenv(name) == NULL) {
523 setenv(name, &eq[1], 1);
524 }
525 } else {
526 setenv(name, "", 1);
527 }
528 }
529 free(name);
530// if (eq != NULL)
531// *eq = '=';
532// if (ha != NULL)
533// *ha = '#';
534 }
425} 535}
536
diff --git a/urunlevel/runlevel/lib_init_d.h b/urunlevel/runlevel/lib_init_d.h
index a9179d5..21ce71c 100644
--- a/urunlevel/runlevel/lib_init_d.h
+++ b/urunlevel/runlevel/lib_init_d.h
@@ -53,8 +53,8 @@ typedef struct init_d_info_s {
53 char **reqstop; 53 char **reqstop;
54 char **shouldstart; 54 char **shouldstart;
55 char **shouldstop; 55 char **shouldstop;
56 int *defstart; 56 int *defstart;
57 int *defstop; 57 int *defstop;
58 char *shortdesc; 58 char *shortdesc;
59 char *desc; 59 char *desc;
60 char *comment; 60 char *comment;
@@ -69,14 +69,14 @@ typedef struct init_d_info_s {
69 */ 69 */
70 70
71typedef struct init_d_handle_s { 71typedef struct init_d_handle_s {
72 int (*start)(struct init_d_handle_s *, int); 72 int (*start) (struct init_d_handle_s *, int);
73 int (*stop)(struct init_d_handle_s *, int); 73 int (*stop) (struct init_d_handle_s *, int);
74 int (*restart)(struct init_d_handle_s *, int); 74 int (*restart) (struct init_d_handle_s *, int);
75 int (*try_restart)(struct init_d_handle_s *, int); 75 int (*try_restart) (struct init_d_handle_s *, int);
76 int (*reload)(struct init_d_handle_s *, int); 76 int (*reload) (struct init_d_handle_s *, int);
77 int (*force_reload)(struct init_d_handle_s *, int); 77 int (*force_reload) (struct init_d_handle_s *, int);
78 int (*status)(struct init_d_handle_s *, int); 78 int (*status) (struct init_d_handle_s *, int);
79 int (*show_info)(struct init_d_handle_s *, int); 79 int (*show_info) (struct init_d_handle_s *, int);
80 char *basename; 80 char *basename;
81 char *pathname; 81 char *pathname;
82 char *args; 82 char *args;
@@ -142,7 +142,8 @@ int print_status(struct init_d_handle_s *init_d, int quiet, int status);
142/* 142/*
143 * /lib/lsb/init-functions 143 * /lib/lsb/init-functions
144 */ 144 */
145int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args); 145int start_daemon(int force, int nice_level, char *pidfile, char *pathname,
146 char *args);
146int killproc(char *pidfile, char *pathname, int my_signal); 147int killproc(char *pidfile, char *pathname, int my_signal);
147int checkpid(char *pid); 148int checkpid(char *pid);
148int pidofproc(char *pidfile, char *pathname, char **pids); 149int pidofproc(char *pidfile, char *pathname, char **pids);
@@ -154,7 +155,7 @@ void log_warning_msg(char *message);
154init_d_info_t *parse_init_info(char *info_text, char *name); 155init_d_info_t *parse_init_info(char *info_text, char *name);
155char *get_init_info(char *pathname); 156char *get_init_info(char *pathname);
156llist_t *get_scripts(void); 157llist_t *get_scripts(void);
157llist_t *sort_scripts(llist_t *unsorted); 158llist_t *sort_scripts(llist_t * unsorted, init_d_info_t *for_script);
158 159
159 160
160#define REDIR 1 161#define REDIR 1
@@ -166,8 +167,7 @@ llist_t *sort_scripts(llist_t *unsorted);
166 167
167extern struct stat path_stat; 168extern struct stat path_stat;
168 169
169typedef struct nodes_s 170typedef struct nodes_s {
170{
171 const char *name; 171 const char *name;
172 mode_t mode; 172 mode_t mode;
173 int major; 173 int major;
@@ -186,17 +186,20 @@ char *doit(int mode, char *command, ...);
186#endif 186#endif
187#ifdef RUNLEVEL_LIST 187#ifdef RUNLEVEL_LIST
188// From ifupdown, so it should probably be in libbb. 188// From ifupdown, so it should probably be in libbb.
189llist_t *llist_add_to_end(llist_t *list_head, char *data); 189llist_t *llist_add_to_end(llist_t * list_head, char *data);
190#else 190#else
191extern llist_t *llist_add_to_end(llist_t *list_head, char *data); 191extern llist_t *llist_add_to_end(llist_t * list_head, char *data);
192#endif 192#endif
193 193
194llist_t *llist_delete(llist_t **unsorted, llist_t *previous, llist_t *current); 194llist_t *llist_delete(llist_t ** unsorted, llist_t * previous,
195void make_disk(char *token, const nodes_t *nodes); 195 llist_t * current);
196void make_disk(char *token);
196void make_ram_disk(int size, int number, char *place, int TMPFS); 197void make_ram_disk(int size, int number, char *place, int TMPFS);
197void quick_mount(char *type, char *device, char *path, char *data, ...); 198void quick_mount(char *type, char *device, char *path, char *data, ...);
198char *quick_read(char *filename); 199char *quick_read(char *filename);
199void quick_write(const char *filename, const char *data, ...); 200void quick_write(const char *filename, const char *data, ...);
201void read_sysconfig(char *sysconfig);
202void set_sysconfig_env(char *token);
200 203
201 204
202#endif 205#endif
diff --git a/urunlevel/runlevel/local_fs.c b/urunlevel/runlevel/local_fs.c
index 17b45f6..137ff0a 100644
--- a/urunlevel/runlevel/local_fs.c
+++ b/urunlevel/runlevel/local_fs.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Originally based on code from Trinux.
7 *
6 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * 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 10 * the Free Software Foundation; either version 2 of the License, or
@@ -27,62 +29,44 @@
27#include "lib_init_d.h" 29#include "lib_init_d.h"
28 30
29 31
30const static nodes_t nodes[] =
31{
32 {"hda", S_IFBLK, 3, 0, 0},
33 {"hdb", S_IFBLK, 3, 64, 0},
34 {"hdc", S_IFBLK, 22, 0, 0},
35 {"hdd", S_IFBLK, 22, 64, 0},
36 {"ram", S_IFBLK, 1, 0, 9},
37 {"fd", S_IFBLK, 2, 0, 1},
38 {"loop", S_IFBLK, 7, 0,63},
39 {"cloop", S_IFBLK, 240, 0, 7},
40 {"vcs", S_IFBLK, 7, 0, 9},
41 {"vcsa", S_IFBLK, 7, 0, 9},
42 {0, 0, 0, 0, 0}
43};
44
45
46static int start(struct init_d_handle_s *, int); 32static int start(struct init_d_handle_s *, int);
47static int status(struct init_d_handle_s *, int); 33static int status(struct init_d_handle_s *, int);
48static int stop(struct init_d_handle_s *, int); 34static int stop(struct init_d_handle_s *, int);
49 35
50 36
51static init_d_handle_t my_commands = 37static init_d_handle_t my_commands = {
52{ 38 &start,
53 &start, 39 &stop,
54 &stop, 40 NULL,
55 NULL, 41 NULL,
56 NULL, 42 &no_reload,
57 &no_reload, 43 NULL,
58 NULL, 44 &status,
59 &status, 45 NULL,
60 NULL, 46 "local_fs",
61 "local_fs", 47 NULL,
62 NULL, 48 NULL,
63 NULL, 49 NULL,
64 NULL, 50 INIT_D_BEGIN
65 INIT_D_BEGIN \ 51 INIT_D_PROV "$local_fs"
66 INIT_D_PROV "$local_fs" \ 52 INIT_D_DSTART "1 2 3 4 5"
67 INIT_D_DSTART "1 2 3 4 5" \ 53 INIT_D_DSTOP "0 6"
68 INIT_D_DSTOP "0 6" \ 54 INIT_D_SDESC "Mount all local file systems."
69 INIT_D_SDESC "Mount all local file systems." \ 55 INIT_D_DESC "Mount all local file systems."
70 INIT_D_DESC "Mount all local file systems." \ 56 INIT_D_CONT
71 INIT_D_CONT "Including any left over partitions not otherwise mounted." \ 57 "Including any left over partitions not otherwise mounted." INIT_D_END
72 INIT_D_END
73}; 58};
74 59
75 60
76static const char *i386_sys_types[] = 61static const char *i386_sys_types[] = {
77{ 62// " 0Empty",
78// " 0Empty", 63// " 1fat",
79// " 1fat", 64// " 4fat",
80// " 4fat", 65// " 6fat",
81// " 6fat", 66// " bvfat",
82// " bvfat",
83 " cvfat", 67 " cvfat",
84// " evfat", 68// " evfat",
85// " fvfat", 69// " fvfat",
86 "80minix", 70 "80minix",
87 "81minix", 71 "81minix",
88 "82swap", 72 "82swap",
@@ -94,98 +78,98 @@ static const char *i386_sys_types[] =
94 78
95int local_fs_main(int argc, char **argv) 79int local_fs_main(int argc, char **argv)
96{ 80{
97 return do_init_from_main(argc, argv, &my_commands); 81 return do_init_from_main(argc, argv, &my_commands);
98} 82}
99 83
100 84
101static int start(struct init_d_handle_s *init_d, int just_checking) 85static int start(struct init_d_handle_s *init_d, int just_checking)
102{ 86{
103 int i; 87 int i;
104 char *CMDLINE = 0; 88 char *CMDLINE = 0;
105 char *ROOT = 0; 89 char *ROOT = 0;
106 char *CDEV = 0; 90 char *CDEV = 0;
107 char *FDEV = 0; 91 char *FDEV = 0;
108 char *token; 92 char *token;
109 char *strtok_temp; 93 char *strtok_temp;
110 94
111sleep(5); // delay it for testing purposes 95 sleep(5); // delay it for testing purposes
112// Should fsck all non root partitions first. 96// Should fsck all non root partitions first.
113 doit(0, "/bin/mount -a"); 97 doit(0, "/bin/mount -a");
114 bb_xasprintf(&CMDLINE, "%s", doit(REDIR, "cat /proc/cmdline")); 98 bb_xasprintf(&CMDLINE, "%s", doit(REDIR, "cat /proc/cmdline"));
115 for (token = strtok_r(CMDLINE, " \t\n\r", &strtok_temp); token != NULL; token = strtok_r(NULL, " \t\n\r", &strtok_temp)) 99 for (token = strtok_r(CMDLINE, " \t\n\r", &strtok_temp); token != NULL;
116 { 100 token = strtok_r(NULL, " \t\n\r", &strtok_temp)) {
117 if (strncmp(token, "ROOT=", 5) == 0) 101 if (strncmp(token, "ROOT=", 5) == 0)
118 ROOT = &token[5]; 102 ROOT = &token[5];
119 } 103 }
120 104
121 bb_xasprintf(&CDEV, "%s", doit(REDIR, "dmesg | grep D-ROM | grep hd | cut -d: -f1 | sort | uniq")); 105 bb_xasprintf(&CDEV, "%s",
122 106 doit(REDIR,
123 bb_xasprintf(&FDEV, "%s %s", doit(REDIR, "dmesg | grep -v LDM | grep \"^ [sh]d[a-f]\" | cut -d':' -f2 | sort | uniq"), (CDEV != 0) ? CDEV : ""); 107 "dmesg | grep D-ROM | grep hd | cut -d: -f1 | sort | uniq"));
124 token = strtok_r(FDEV, " \r\n", &strtok_temp); 108
125 for (i = 0; token != NULL; i++) 109 bb_xasprintf(&FDEV, "%s %s",
126 { 110 doit(REDIR,
127 if (strlen(token) > 2) 111 "dmesg | grep -v LDM | grep \"^ [sh]d[a-f]\" | cut -d':' -f2 | sort | uniq"),
128 make_disk(token, nodes); 112 (CDEV != 0) ? CDEV : "");
129 token = strtok_r(NULL, " \r\n", &strtok_temp); 113 token = strtok_r(FDEV, " \r\n", &strtok_temp);
130 } 114 for (i = 0; token != NULL; i++) {
131 115 if (strlen(token) > 2)
132 bb_xasprintf(&FDEV, "%s", doit(REDIR, "fdisk -l | grep \"^/dev/\" | cut -b6-10,52-55")); 116 make_disk(token);
133 token = strtok_r(FDEV, "\r\n", &strtok_temp); 117 token = strtok_r(NULL, " \r\n", &strtok_temp);
134 for (i = 0; token != NULL; i++) 118 }
135 { 119
136 int j; 120 bb_xasprintf(&FDEV, "%s",
137 int found = 0; 121 doit(REDIR,
138 char *type = &token[6]; 122 "fdisk -l | grep \"^/dev/\" | cut -b6-10,52-55"));
139 token[4] = '\0'; 123 token = strtok_r(FDEV, "\r\n", &strtok_temp);
140 for (j = 0; i386_sys_types[j] != 0; j++) 124 for (i = 0; token != NULL; i++) {
141 { 125 int j;
142 if (strncmp(i386_sys_types[j], type, 2) == 0) 126 int found = 0;
143 { 127 char *type = &token[6];
144 char *DEV = 0; 128
145 char *MOUNT = 0; 129 token[4] = '\0';
146 char *TYPE = 0; 130 for (j = 0; i386_sys_types[j] != 0; j++) {
147 131 if (strncmp(i386_sys_types[j], type, 2) == 0) {
148 bb_xasprintf(&DEV, "/dev/%s", token); 132 char *DEV = 0;
149 bb_xasprintf(&MOUNT, "/media/%s", token); 133 char *MOUNT = 0;
150 bb_xasprintf(&TYPE, "%s", &i386_sys_types[j][2]); 134 char *TYPE = 0;
151 found = 1; 135
152 if (strncmp(&i386_sys_types[j][2], "swap", 4) == 0) 136 bb_xasprintf(&DEV, "/dev/%s", token);
153 { 137 bb_xasprintf(&MOUNT, "/media/%s", token);
154 doit(QUIET, "mkswap %s", DEV); 138 bb_xasprintf(&TYPE, "%s", &i386_sys_types[j][2]);
155 doit(QUIET, "swapon %s", DEV); 139 found = 1;
156 } 140 if (strncmp(&i386_sys_types[j][2], "swap", 4) == 0) {
157 else 141 doit(QUIET, "mkswap %s", DEV);
158 { 142 doit(QUIET, "swapon %s", DEV);
143 } else {
159// Should not mount it if it is already mounted. 144// Should not mount it if it is already mounted.
160 if ((ROOT == 0) || strcmp(ROOT, DEV) != 0) /* Don't try to remount ROOT, */ 145 if ((ROOT == 0) || strcmp(ROOT, DEV) != 0) { /* Don't try to remount ROOT, */
161 { 146 make_disk(token);
162 make_disk(token, nodes); 147 quick_mount(TYPE, DEV, MOUNT, "-o ro");
163 quick_mount(TYPE, DEV, MOUNT, "-o ro"); 148// quick_mount("auto", DEV, MOUNT, "-o ro");
164// quick_mount("auto", DEV, MOUNT, "-o ro"); 149 }
165 } 150 }
151
152 break;
153 }
166 } 154 }
155// if (found == 0)
156// bb_printf(" %s - unknown\n", token);
167 157
168 break; 158 token = strtok_r(NULL, "\r\n", &strtok_temp);
169 }
170 } 159 }
171// if (found == 0) 160
172// bb_printf(" %s - unknown\n", token); 161 free(FDEV);
173 162 free(CDEV);
174 token = strtok_r(NULL, "\r\n", &strtok_temp); 163 free(ROOT);
175 } 164 free(CMDLINE);
176 165
177 free(FDEV); 166 return INIT_D_OK;
178 free(CDEV);
179 free(ROOT);
180 free(CMDLINE);
181
182 return INIT_D_OK;
183} 167}
184 168
185 169
186static int status(struct init_d_handle_s *init_d, int quiet) 170static int status(struct init_d_handle_s *init_d, int quiet)
187{ 171{
188 return print_status(init_d, quiet, INIT_D_STATUS_OK); 172 return print_status(init_d, quiet, INIT_D_STATUS_OK);
189} 173}
190 174
191 175
@@ -193,7 +177,7 @@ static int stop(struct init_d_handle_s *init_d, int just_checking)
193{ 177{
194// Should only umount things we mounted in the first place. 178// Should only umount things we mounted in the first place.
195// Same for swap 179// Same for swap
196 doit(0, "/sbin/swapoff -a"); 180 doit(0, "/sbin/swapoff -a");
197 doit(0, "/bin/umount -a -r"); 181 doit(0, "/bin/umount -a -r");
198 return INIT_D_OK; 182 return INIT_D_OK;
199} 183}
diff --git a/urunlevel/runlevel/log_failure_msg.c b/urunlevel/runlevel/log_failure_msg.c
index 47f43f7..7ec4c07 100644
--- a/urunlevel/runlevel/log_failure_msg.c
+++ b/urunlevel/runlevel/log_failure_msg.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -28,7 +31,7 @@
28 31
29void log_failure_msg(char *message) 32void log_failure_msg(char *message)
30{ 33{
31 bb_perror_msg("Failure - %s\n", message); 34 bb_error_msg("Failure - %s\n", message);
32} 35}
33 36
34 37
@@ -41,14 +44,13 @@ log_failure_msg "message"
41 44
42int log_failure_msg_main(int argc, char **argv) 45int log_failure_msg_main(int argc, char **argv)
43{ 46{
44 char *message = argv_cat(argc, argv); 47 char *message = argv_cat(argc, argv);
45 48
46 if (message != NULL) 49 if (message != NULL) {
47 { 50 log_failure_msg(message);
48 log_failure_msg(message);
49 51
50 free(message); 52 free(message);
51 return EXIT_SUCCESS; 53 return EXIT_SUCCESS;
52 } 54 }
53 return EXIT_FAILURE; 55 return EXIT_FAILURE;
54} 56}
diff --git a/urunlevel/runlevel/log_success_msg.c b/urunlevel/runlevel/log_success_msg.c
index caa1eed..c1c352c 100644
--- a/urunlevel/runlevel/log_success_msg.c
+++ b/urunlevel/runlevel/log_success_msg.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -28,7 +31,7 @@
28 31
29void log_success_msg(char *message) 32void log_success_msg(char *message)
30{ 33{
31 bb_printf("Success - %s\n", message); 34 bb_printf("Success - %s\n", message);
32} 35}
33 36
34 37
@@ -41,14 +44,13 @@ log_success_msg "message"
41 44
42int log_success_msg_main(int argc, char **argv) 45int log_success_msg_main(int argc, char **argv)
43{ 46{
44 char *message = argv_cat(argc, argv); 47 char *message = argv_cat(argc, argv);
45 48
46 if (message != NULL) 49 if (message != NULL) {
47 { 50 log_success_msg(message);
48 log_success_msg(message);
49 51
50 free(message); 52 free(message);
51 return EXIT_SUCCESS; 53 return EXIT_SUCCESS;
52 } 54 }
53 return EXIT_FAILURE; 55 return EXIT_FAILURE;
54} 56}
diff --git a/urunlevel/runlevel/log_warning_msg.c b/urunlevel/runlevel/log_warning_msg.c
index 81ef204..2737e11 100644
--- a/urunlevel/runlevel/log_warning_msg.c
+++ b/urunlevel/runlevel/log_warning_msg.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -28,7 +31,7 @@
28 31
29void log_warning_msg(char *message) 32void log_warning_msg(char *message)
30{ 33{
31 bb_perror_msg("Warning - %s\n", message); 34 bb_error_msg("Warning - %s\n", message);
32} 35}
33 36
34 37
@@ -41,14 +44,13 @@ log_warning_msg "message"
41 44
42int log_warning_msg_main(int argc, char **argv) 45int log_warning_msg_main(int argc, char **argv)
43{ 46{
44 char *message = argv_cat(argc, argv); 47 char *message = argv_cat(argc, argv);
45 48
46 if (message != NULL) 49 if (message != NULL) {
47 { 50 log_warning_msg(message);
48 log_warning_msg(message);
49 51
50 free(message); 52 free(message);
51 return EXIT_SUCCESS; 53 return EXIT_SUCCESS;
52 } 54 }
53 return EXIT_FAILURE; 55 return EXIT_FAILURE;
54} 56}
diff --git a/urunlevel/runlevel/make_patch b/urunlevel/runlevel/make_patch
new file mode 100644
index 0000000..e0a906e
--- /dev/null
+++ b/urunlevel/runlevel/make_patch
@@ -0,0 +1,10 @@
1#! /bin/sh
2
3pushd ..
4make clean
5pushd ..
6diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original busybox-1.00 >busybox-1.00/runlevel/runlevel.patch
7# This is needed to support My Linux, and no one wants that.
8#diff -urN busybox-1.00-original/archival/gzip.c busybox-1.00/archival/gzip.c >busybox-1.00/my_linux/my_linux.patch
9popd
10popd
diff --git a/urunlevel/runlevel/network.c b/urunlevel/runlevel/network.c
index dff5fc1..99d4717 100644
--- a/urunlevel/runlevel/network.c
+++ b/urunlevel/runlevel/network.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Originally based on code from Trinux.
7 *
6 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * 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 10 * the Free Software Foundation; either version 2 of the License, or
@@ -32,115 +34,111 @@ static int status(struct init_d_handle_s *init_d, int);
32static int stop(struct init_d_handle_s *, int); 34static int stop(struct init_d_handle_s *, int);
33 35
34 36
35static init_d_handle_t my_commands = 37static init_d_handle_t my_commands = {
36{ 38 &start,
37 &start, 39 &stop,
38 &stop, 40 NULL,
39 NULL, 41 NULL,
40 NULL, 42 NULL,
41 NULL, 43 NULL,
42 NULL, 44 &status,
43 &status, 45 NULL,
44 NULL, 46 "network",
45 "network", 47 NULL,
46 NULL, 48 NULL,
47 NULL, 49 NULL,
48 NULL, 50 INIT_D_BEGIN
49 INIT_D_BEGIN \ 51 INIT_D_PROV "$network"
50 INIT_D_PROV "$network" \ 52 INIT_D_RSTART "$syslog"
51 INIT_D_RSTART "$syslog" \ 53 INIT_D_DSTART "3 4 5"
52 INIT_D_DSTART "3 4 5" \ 54 INIT_D_DSTOP "0 1 2 6"
53 INIT_D_DSTOP "0 1 2 6" \ 55 INIT_D_SDESC "Basic network setup"
54 INIT_D_SDESC "Basic network setup" \ 56 INIT_D_DESC "Configures all your network interfaces,"
55 INIT_D_DESC "Configures all your network interfaces," \ 57 INIT_D_CONT "brings them all up and sets up routing."
56 INIT_D_CONT "brings them all up and sets up routing." \ 58 INIT_D_CONT "Also configures things like port forwarding,"
57 INIT_D_CONT "Also configures things like port forwarding," \ 59 INIT_D_CONT "hostnames, etc." INIT_D_END
58 INIT_D_CONT "hostnames, etc." \
59 INIT_D_END
60}; 60};
61 61
62 62
63int network_main(int argc, char **argv) 63int network_main(int argc, char **argv)
64{ 64{
65 return do_init_from_main(argc, argv, &my_commands); 65 return do_init_from_main(argc, argv, &my_commands);
66} 66}
67 67
68 68
69static int start(struct init_d_handle_s *init_d, int just_checking) 69static int start(struct init_d_handle_s *init_d, int just_checking)
70{ 70{
71 int i; 71 int i;
72 int my_status = (init_d->status)(init_d, 0); 72 int my_status = (init_d->status) (init_d, 0);
73 char *IPADDR = 0; 73 char *IPADDR = 0;
74 74
75 if (my_status == INIT_D_STATUS_NOT_RUNNING) 75 if (my_status == INIT_D_STATUS_NOT_RUNNING) {
76 { 76 my_status = INIT_D_ERROR_NOT_RUNNING;
77 my_status = INIT_D_ERROR_NOT_RUNNING; 77// if (stat("/proc/net/pnp", &path_stat) == 0)
78// if (stat("/proc/net/pnp", &path_stat) == 0) 78// copy_file("/proc/net/pnp", "/etc/resolv.conf", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS);
79// copy_file("/proc/net/pnp", "/etc/resolv.conf", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS); 79
80 80 fflush(stdout);
81 fflush(stdout); 81 doit(QUIET, "ifup -af");
82 doit(QUIET, "ifup -af"); 82 for (i = 20; stat("/var/lib/network/ipaddr", &path_stat) != 0; i--) {
83 for (i = 20; stat("/var/lib/network/ipaddr", &path_stat) != 0; i--) 83 bb_printf(".");
84 { 84 fflush(stdout);
85 bb_printf("."); 85 sleep(2);
86 fflush(stdout); 86 if (i <= 0) {
87 sleep(2); 87 bb_printf(" timeout.");
88 if (i <= 0) 88 break;
89 { 89 }
90 bb_printf(" timeout."); 90 }
91 break; 91
92 } 92 if (stat("/var/lib/network/ipaddr", &path_stat) == 0)
93 } 93 IPADDR = quick_read("/var/lib/network/ipaddr");
94 94
95 if (stat("/var/lib/network/ipaddr", &path_stat) == 0) 95 if ((IPADDR != 0) && (IPADDR[0] != '\0')) {
96 IPADDR = quick_read("/var/lib/network/ipaddr"); 96 char *tcp_syn_retries = getenv("tcp_syn_retries");
97 97 char *ip_forward = getenv("ip_forward");
98 if ((IPADDR != 0) && (IPADDR[0] != '\0')) 98 char *icmp_echo_ignore_all = getenv("icmp_echo_ignore_all");
99 { 99
100 if (stat("/proc/sys/net/ipv4/tcp_syn_retries", &path_stat) == 0) 100 if (tcp_syn_retries)
101 quick_write("/proc/sys/net/ipv4/tcp_syn_retries", "7"); 101 quick_write("/proc/sys/net/ipv4/tcp_syn_retries", tcp_syn_retries);
102 if (stat("/var/lib/my_linux/config/ipfwd", &path_stat) == 0) 102 if (ip_forward) {
103 { 103 bb_printf("Enabling IP forwarding\n");
104 bb_printf("Enabling IP forwarding\n"); 104 quick_write("/proc/sys/net/ipv4/ip_forward", ip_forward);
105 quick_write("/proc/sys/net/ipv4/ip_forward", "1"); 105 }
106 } 106 if (icmp_echo_ignore_all)
107 if (stat("/var/lib/my_linux/config/noping", &path_stat) == 0) 107 quick_write("/proc/sys/net/ipv4/icmp_echo_ignore_all", icmp_echo_ignore_all);
108 quick_write("/proc/sys/net/ipv4/icmp_echo_ignore_all", "1"); 108 my_status = INIT_D_OK;
109 my_status = INIT_D_OK; 109 } else
110 } 110 my_status = INIT_D_ERROR_GENERIC;
111 else 111
112 my_status = INIT_D_ERROR_GENERIC; 112 free(IPADDR);
113 113 } else
114 free(IPADDR); 114 my_status = INIT_D_OK;
115 } 115
116 else 116 return my_status;
117 my_status = INIT_D_OK;
118
119 return my_status;
120} 117}
121 118
122 119
123static int status(struct init_d_handle_s *init_d, int quiet) 120static int status(struct init_d_handle_s *init_d, int quiet)
124{ 121{
125 int my_status = INIT_D_STATUS_NOT_RUNNING; 122 int my_status = INIT_D_STATUS_NOT_RUNNING;
126 char *ip = NULL; 123 char *ip = NULL;
127 124
128 bb_xasprintf(&ip, "%s", doit(REDIR, "ip -o addr | grep lo: | cut -d\" \" -f3 | cut -d\",\" -f2")); 125 bb_xasprintf(&ip, "%s",
129 if ((ip != NULL) && (strncmp("UP", ip, 2) == 0)) 126 doit(REDIR,
130 my_status = INIT_D_STATUS_OK; 127 "ip -o addr | grep lo: | cut -d\" \" -f3 | cut -d\",\" -f2"));
128 if ((ip != NULL) && (strncmp("UP", ip, 2) == 0))
129 my_status = INIT_D_STATUS_OK;
131 130
132 return print_status(init_d, quiet, my_status); 131 return print_status(init_d, quiet, my_status);
133} 132}
134 133
135 134
136static int stop(struct init_d_handle_s *init_d, int just_checking) 135static int stop(struct init_d_handle_s *init_d, int just_checking)
137{ 136{
138 int my_status = default_stop(init_d, 1); 137 int my_status = default_stop(init_d, 1);
139 138
140 if (my_status == INIT_D_ERROR_JUST_RUNNING) 139 if (my_status == INIT_D_ERROR_JUST_RUNNING) {
141 { 140 doit(QUIET, "ifdown -af");
142 doit(QUIET, "ifdown -af"); 141 my_status = INIT_D_OK;
143 my_status = INIT_D_OK; 142 }
144 } 143 return my_status;
145 return my_status;
146} 144}
diff --git a/urunlevel/runlevel/pidofproc.c b/urunlevel/runlevel/pidofproc.c
index 6d03ae8..dfb3c91 100644
--- a/urunlevel/runlevel/pidofproc.c
+++ b/urunlevel/runlevel/pidofproc.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -30,112 +33,104 @@
30 33
31int checkpid(char *pid) 34int checkpid(char *pid)
32{ 35{
33 int found = 0; 36 int found = 0;
34 char proc[132]; 37
35 38 RESERVE_CONFIG_BUFFER(proc, PATH_MAX);
36 sprintf(proc, "/proc/%s", pid); 39
37 if (stat(proc, &path_stat) == 0) 40 snprintf(proc, PATH_MAX, "/proc/%s", pid);
38 { 41 if (stat(proc, &path_stat) == 0) {
39 char *state = NULL; 42 char *state = NULL;
40 43
41 sprintf(proc, "/proc/%s/stat", pid); 44 snprintf(proc, PATH_MAX, "/proc/%s/stat", pid);
42 state = quick_read(proc); 45 state = quick_read(proc);
43 if (state != NULL) 46 if (state != NULL) {
44 { 47 /* Read and interpret the third space seperated field (State - DRSW = OK - ZX = DEAD_PID - T = STOPPED) */
45 /* Read and interpret the third space seperated field (State - DRSW = OK - ZX = DEAD_PID - T = STOPPED) */ 48 if (state[0] != '\0') {
46 if (state[0] != '\0') 49 while ((*state != ' ') && (*state != '\0'))
47 { 50 state++;
48 while (*state != ' ') state++; 51 while (*state == ' ')
49 while (*state == ' ') state++; 52 state++;
50 while (*state != ' ') state++ 53 while ((*state != ' ') && (*state != '\0'))
54 state++
51// Should compare the name while scanning this. 55// Should compare the name while scanning this.
52 ; 56 ;
53 while (*state == ' ') state++; 57 while (*state == ' ')
54 switch (*state) 58 state++;
55 { 59 switch (*state) {
56 case 'D' : 60 case 'D':
57 case 'R' : 61 case 'R':
58 case 'S' : 62 case 'S':
59 case 'W' : 63 case 'W':
60 case 'T' : /* Until proven otherwise, I'm assuming this means OK. */ 64 case 'T': /* Until proven otherwise, I'm assuming this means OK. */
61 found = 1; 65 found = 1;
62 } 66 }
63 } 67 }
64 } 68 } else { /* Paranoid fallbacks. */
65 else /* Paranoid fallbacks. */ 69
66 { 70 snprintf(proc, PATH_MAX, "/proc/%s/exe", pid);
67 sprintf(proc, "/proc/%s/exe", pid); 71 if (stat(proc, &path_stat) == 0) {
68 if (stat(proc, &path_stat) == 0)
69 {
70// Should check that it is a link to our executable. 72// Should check that it is a link to our executable.
71 found = 1; 73 found = 1;
72 } 74 } else {
73 else 75 snprintf(proc, PATH_MAX, "/proc/%s/cmdline", pid);
74 { 76 if (stat(proc, &path_stat) == 0) {
75 sprintf(proc, "/proc/%s/cmdline", pid);
76 if (stat(proc, &path_stat) == 0)
77 {
78// Should compare the name. 77// Should compare the name.
79 found = 1; 78 found = 1;
79 }
80 }
80 } 81 }
81 } 82
82 } 83 }
83
84 }
85 84
86 return found; 85 RELEASE_CONFIG_BUFFER(proc);
86 return found;
87} 87}
88 88
89 89
90int pidofproc(char *pidfile, char *pathname, char **pids) 90int pidofproc(char *pidfile, char *pathname, char **pids)
91{ 91{
92 int status = INIT_D_STATUS_UNKNOWN; 92 int status = INIT_D_STATUS_UNKNOWN;
93 char *our_pidfile = pidfile; 93 char *our_pidfile = pidfile;
94 char *our_pids = NULL; 94 char *our_pids = NULL;
95 95
96 if (our_pidfile == NULL) 96 if (our_pidfile == NULL)
97 bb_xasprintf(&our_pidfile, "/var/run/%s.pid", bb_get_last_path_component(pathname)); 97 bb_xasprintf(&our_pidfile, "/var/run/%s.pid",
98 bb_get_last_path_component(pathname));
98 99
99 our_pids = quick_read(our_pidfile); 100 our_pids = quick_read(our_pidfile);
100 101
101 if (our_pids != NULL) 102 if (our_pids != NULL) {
102 { 103 int i;
103 int i; 104 char *pid;
104 char *pid; 105 char *strtok_temp;
105 char *strtok_temp;
106 106
107 status = INIT_D_STATUS_DEAD_PID; 107 status = INIT_D_STATUS_DEAD_PID;
108 if (pids != NULL) 108 if (pids != NULL) {
109 { 109 (*pids) = (char *) xmalloc(sizeof(char) * strlen(our_pids) + 1);
110 (*pids) = (char *) xmalloc(sizeof (char) * strlen(our_pids) + 1); 110 (*pids)[0] = '\0';
111 (*pids)[0] = '\0';
112 }
113
114 pid = strtok_r(our_pids, " \n\r", &strtok_temp);
115 for (i = 0; pid != NULL; i++)
116 {
117 if (checkpid(pid))
118 {
119 if (pids != NULL)
120 {
121 strcat(*pids, pid);
122 strcat(*pids, " ");
123 } 111 }
124 status = INIT_D_STATUS_OK;
125 }
126 112
127 pid = strtok_r(NULL, " \n\r", &strtok_temp); 113 pid = strtok_r(our_pids, " \n\r", &strtok_temp);
128 } 114 for (i = 0; pid != NULL; i++) {
115 if (checkpid(pid)) {
116 if (pids != NULL) {
117 strcat(*pids, pid);
118 strcat(*pids, " ");
119 }
120 status = INIT_D_STATUS_OK;
121 }
122
123 pid = strtok_r(NULL, " \n\r", &strtok_temp);
124 }
129 125
130 free(our_pids); 126 free(our_pids);
131 } 127 } else
132 else 128 status = INIT_D_STATUS_NOT_RUNNING;
133 status = INIT_D_STATUS_NOT_RUNNING;
134 129
135 if (pidfile == NULL) 130 if (pidfile == NULL)
136 free(our_pidfile); 131 free(our_pidfile);
137 132
138 return status; 133 return status;
139} 134}
140 135
141 136
@@ -154,39 +149,31 @@ pidofproc [-p pidfile] pathname
154 running and not 0 otherwise. 149 running and not 0 otherwise.
155*/ 150*/
156 151
157static const struct option long_options[] =
158{
159 { "pidfile", 1, NULL, 'p' },
160 { 0, 0, 0, 0 }
161};
162
163int pidofproc_main(int argc, char **argv) 152int pidofproc_main(int argc, char **argv)
164{ 153{
165 int result = EXIT_FAILURE; 154 int result = EXIT_FAILURE;
166 char *pidfile = NULL; 155 char *pidfile = NULL;
167 char *pids = NULL; 156 char *pids = NULL;
168 int opt; 157 int opt;
169 158
170 while ((opt = getopt_long (argc, argv, "p:", long_options, NULL)) > 0) 159 while ((opt = getopt(argc, argv, "p:")) > 0) {
171 { 160 switch (opt) {
172 switch (opt) 161 case 'p':
173 { 162 pidfile = optarg;
174 case 'p': 163 break;
175 pidfile = optarg; 164
176 break; 165 default:
177 166 bb_show_usage();
178 default: 167 }
179 bb_show_usage();
180 } 168 }
181 }
182 169
183 /* We require exactly one argument: the path name */ 170 /* We require exactly one argument: the path name */
184 if (optind != (argc - 1)) 171 if (optind != (argc - 1))
185 bb_show_usage(); 172 bb_show_usage();
186 173
187 result = pidofproc(pidfile, argv[optind], &pids); 174 result = pidofproc(pidfile, argv[optind], &pids);
188 if (pids != NULL) 175 if (pids != NULL)
189 bb_printf("%s\n", pids); 176 bb_printf("%s\n", pids);
190 177
191 return result; 178 return result;
192} 179}
diff --git a/urunlevel/runlevel/rc.c b/urunlevel/runlevel/rc.c
index 9efe84d..8a69e77 100644
--- a/urunlevel/runlevel/rc.c
+++ b/urunlevel/runlevel/rc.c
@@ -1,8 +1,11 @@
1/* 1/*
2 * Mini rc implementation for busybox. 2 * init.d runlevel implementation for busybox.
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -33,1209 +36,1299 @@
33#include "lib_init_d.h" 36#include "lib_init_d.h"
34 37
35 38
36const static char *commands[] = 39const static char *commands[] = {
37{ 40 "start",
38 "start", 41 "stop",
39 "stop", 42 "restart",
40 "restart", 43 "try-restart",
41 "try-restart", 44 "reload",
42 "reload", 45 "force-reload",
43 "force-reload", 46 "status",
44 "status", 47 "info",
45 "info", 48 NULL
46 NULL
47}; 49};
48 50
49 51
50const static char *INFOS[] = 52const static char *INFOS[] = {
51{ 53 INIT_D_BEGIN,
52 INIT_D_BEGIN, 54 INIT_D_PROV,
53 INIT_D_PROV, 55 INIT_D_RSTART,
54 INIT_D_RSTART, 56 INIT_D_RSTOP,
55 INIT_D_RSTOP, 57 INIT_D_SSTART,
56 INIT_D_SSTART, 58 INIT_D_SSTOP,
57 INIT_D_SSTOP, 59 INIT_D_DSTART,
58 INIT_D_DSTART, 60 INIT_D_DSTOP,
59 INIT_D_DSTOP, 61 INIT_D_SDESC,
60 INIT_D_SDESC, 62 INIT_D_DESC,
61 INIT_D_DESC, 63 INIT_D_COMMENT,
62 INIT_D_COMMENT, 64 INIT_D_CONT,
63 INIT_D_CONT, 65 INIT_D_CONT2,
64 INIT_D_CONT2, 66 INIT_D_END,
65 INIT_D_END, 67 NULL
66 NULL
67}; 68};
68 69
69 70
70int default_start(struct init_d_handle_s *init_d, int just_checking) 71int default_start(struct init_d_handle_s *init_d, int just_checking)
71{ 72{
72 int status = (init_d->status)(init_d, 0); 73 int status = (init_d->status) (init_d, 0);
73 74
74 switch (status) 75 switch (status) {
75 { 76 case INIT_D_STATUS_OK:
76 case INIT_D_STATUS_OK :
77 { 77 {
78 status = INIT_D_OK; 78 status = INIT_D_OK;
79 break; 79 break;
80 } 80 }
81 81
82 case INIT_D_STATUS_DEAD_PID : 82 case INIT_D_STATUS_DEAD_PID:
83 { 83 {
84 log_warning_msg("Stale pid file exists!"); 84 log_warning_msg("Stale pid file exists!");
85 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. 85 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition.
86 break; 86 break;
87 } 87 }
88 88
89 case INIT_D_STATUS_DEAD_LOCK : 89 case INIT_D_STATUS_DEAD_LOCK:
90 { 90 {
91 log_warning_msg("Stale lock file exists!"); 91 log_warning_msg("Stale lock file exists!");
92 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. 92 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition.
93 break; 93 break;
94 } 94 }
95 95
96 case INIT_D_STATUS_NOT_RUNNING : 96 case INIT_D_STATUS_NOT_RUNNING:
97 { 97 {
98 struct stat script_stat; 98 struct stat script_stat;
99 99
100 if (stat(init_d->pathname, &script_stat) == 0) 100 if (stat(init_d->pathname, &script_stat) == 0) {
101 { 101 if (just_checking)
102 if (just_checking) 102 status = INIT_D_ERROR_JUST_NOT_RUNNING;
103 status = INIT_D_ERROR_JUST_NOT_RUNNING; 103 else
104 else 104 status =
105 status = start_daemon(0, 0, init_d->pidfile, init_d->pathname, init_d->args); 105 start_daemon(0, 0, init_d->pidfile, init_d->pathname,
106 } 106 init_d->args);
107 else 107 } else
108 status = INIT_D_ERROR_NOT_INSTALLED; 108 status = INIT_D_ERROR_NOT_INSTALLED;
109 break; 109 break;
110 } 110 }
111 111
112 default : 112 default:
113 { 113 {
114 status = INIT_D_ERROR_GENERIC; 114 status = INIT_D_ERROR_GENERIC;
115 break; 115 break;
116 }
116 } 117 }
117 }
118 118
119 return status; 119 return status;
120} 120}
121 121
122 122
123int default_stop(struct init_d_handle_s *init_d, int just_checking) 123int default_stop(struct init_d_handle_s *init_d, int just_checking)
124{ 124{
125 int status = (init_d->status)(init_d, 0); 125 int status = (init_d->status) (init_d, 0);
126 126
127 switch (status) 127 switch (status) {
128 { 128 case INIT_D_STATUS_OK:
129 case INIT_D_STATUS_OK :
130 { 129 {
131 if (just_checking) 130 if (just_checking)
132 status = INIT_D_ERROR_JUST_RUNNING; 131 status = INIT_D_ERROR_JUST_RUNNING;
133 else 132 else
134 status = killproc(init_d->pidfile, init_d->pathname, 0); 133 status = killproc(init_d->pidfile, init_d->pathname, 0);
135 break; 134 break;
136 } 135 }
137 136
138 case INIT_D_STATUS_DEAD_PID : 137 case INIT_D_STATUS_DEAD_PID:
139 { 138 {
140 log_warning_msg("Stale pid file exists!"); 139 log_warning_msg("Stale pid file exists!");
141 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. 140 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition.
142 break; 141 break;
143 } 142 }
144 143
145 case INIT_D_STATUS_DEAD_LOCK : 144 case INIT_D_STATUS_DEAD_LOCK:
146 { 145 {
147 log_warning_msg("Stale lock file exists!"); 146 log_warning_msg("Stale lock file exists!");
148 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. 147 status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition.
149 break; 148 break;
150 } 149 }
151 150
152 case INIT_D_STATUS_NOT_RUNNING : 151 case INIT_D_STATUS_NOT_RUNNING:
153 { 152 {
154 status = INIT_D_OK; 153 status = INIT_D_OK;
155 break; 154 break;
156 } 155 }
157 156
158 default : 157 default:
159 { 158 {
160 status = INIT_D_ERROR_GENERIC; 159 status = INIT_D_ERROR_GENERIC;
161 break; 160 break;
161 }
162 } 162 }
163 }
164 163
165 return status; 164 return status;
166} 165}
167 166
168 167
169int default_restart(struct init_d_handle_s *init_d, int just_checking) 168int default_restart(struct init_d_handle_s *init_d, int just_checking)
170{ 169{
171 int status = (init_d->status)(init_d, 0); 170 int status = (init_d->status) (init_d, 0);
172 171
173 switch (status) 172 switch (status) {
174 { 173 case INIT_D_STATUS_OK:
175 case INIT_D_STATUS_OK :
176 { 174 {
177 status = (init_d->stop)(init_d, just_checking); 175 status = (init_d->stop) (init_d, just_checking);
178 if ((status == INIT_D_OK) || (status == INIT_D_ERROR_NOT_RUNNING)) 176 if ((status == INIT_D_OK) || (status == INIT_D_ERROR_NOT_RUNNING))
179 status = INIT_D_STATUS_NOT_RUNNING; 177 status = INIT_D_STATUS_NOT_RUNNING;
180 else 178 else
181 status = INIT_D_STATUS_UNKNOWN; 179 status = INIT_D_STATUS_UNKNOWN;
182 break; 180 break;
183 } 181 }
184 182
185 case INIT_D_STATUS_DEAD_PID : 183 case INIT_D_STATUS_DEAD_PID:
186 { 184 {
187 log_warning_msg("Stale pid file exists!"); 185 log_warning_msg("Stale pid file exists!");
188 break; 186 break;
189 } 187 }
190 188
191 case INIT_D_STATUS_DEAD_LOCK : 189 case INIT_D_STATUS_DEAD_LOCK:
192 { 190 {
193 log_warning_msg("Stale lock file exists!"); 191 log_warning_msg("Stale lock file exists!");
194 break; 192 break;
195 } 193 }
196 } 194 }
197 if (status == INIT_D_STATUS_NOT_RUNNING) 195 if (status == INIT_D_STATUS_NOT_RUNNING)
198 status = (init_d->start)(init_d, just_checking); 196 status = (init_d->start) (init_d, just_checking);
199 else 197 else
200 status = INIT_D_ERROR_GENERIC; 198 status = INIT_D_ERROR_GENERIC;
201 199
202 return status; 200 return status;
203} 201}
204 202
205 203
206int default_try_restart(struct init_d_handle_s *init_d, int just_checking) 204int default_try_restart(struct init_d_handle_s *init_d, int just_checking)
207{ 205{
208 int status = (init_d->status)(init_d, 0); 206 int status = (init_d->status) (init_d, 0);
209 207
210 switch (status) 208 switch (status) {
211 { 209 case INIT_D_STATUS_OK:
212 case INIT_D_STATUS_OK :
213 { 210 {
214 status = (init_d->stop)(init_d, just_checking); 211 status = (init_d->stop) (init_d, just_checking);
215 if (status == INIT_D_OK) 212 if (status == INIT_D_OK)
216 status = (init_d->start)(init_d, just_checking); 213 status = (init_d->start) (init_d, just_checking);
217 else if (status == INIT_D_ERROR_NOT_RUNNING) /* I think this is what LSB 8.2.61 means. LSB 8.2.59 means that this should never happen though. */ 214 else if (status == INIT_D_ERROR_NOT_RUNNING) /* I think this is what LSB 8.2.61 means. LSB 8.2.59 means that this should never happen though. */
218 status = INIT_D_OK; 215 status = INIT_D_OK;
219 break; 216 break;
220 } 217 }
221 218
222 case INIT_D_STATUS_NOT_RUNNING : /* I think this is what LSB 8.2.61 means. */ 219 case INIT_D_STATUS_NOT_RUNNING: /* I think this is what LSB 8.2.61 means. */
223 { /* If try-restart was meant to start a stopped service, then it would be no different from restart. 220 { /* If try-restart was meant to start a stopped service, then it would be no different from restart.
224 * LSB 8.2.42-44 may have some bearing on this, but the english is broken, rendering it unintelligable. 221 * LSB 8.2.42-44 may have some bearing on this, but the english is broken, rendering it unintelligable.
225 * OTH, try-restart is optional, so a broken implentation is no problem B-). 222 * OTH, try-restart is optional, so a broken implentation is no problem B-).
226 * OTGH, our force-reload uses this as it's fallback position. 223 * OTGH, our force-reload uses this as it's fallback position.
227 */ 224 */
228 status = INIT_D_OK; 225 status = INIT_D_OK;
229 break; 226 break;
230 } 227 }
231 228
232 default : 229 default:
233 { 230 {
234 status = INIT_D_ERROR_GENERIC; 231 status = INIT_D_ERROR_GENERIC;
232 }
235 } 233 }
236 }
237 234
238 return status; 235 return status;
239} 236}
240 237
241 238
242int default_reload(struct init_d_handle_s *init_d, int just_checking) 239int default_reload(struct init_d_handle_s *init_d, int just_checking)
243{ 240{
244 return INIT_D_ERROR_NOT_IMPLEMENTED; 241 return INIT_D_ERROR_NOT_IMPLEMENTED;
245} 242}
246 243
247 244
248int sighup_reload(struct init_d_handle_s *init_d, int just_checking) 245int sighup_reload(struct init_d_handle_s *init_d, int just_checking)
249{ 246{
250 int status = (init_d->status)(init_d, 0); 247 int status = (init_d->status) (init_d, 0);
251 248
252 switch (status) 249 switch (status) {
253 { 250 case INIT_D_STATUS_OK:
254 case INIT_D_STATUS_OK :
255 { 251 {
256 if (just_checking) 252 if (just_checking)
257 status = INIT_D_ERROR_JUST_RUNNING; 253 status = INIT_D_ERROR_JUST_RUNNING;
258 else 254 else
259 status = killproc(init_d->pidfile, init_d->pathname, SIGHUP); 255 status = killproc(init_d->pidfile, init_d->pathname, SIGHUP);
260 break; 256 break;
261 } 257 }
262 258
263 case INIT_D_STATUS_NOT_RUNNING : 259 case INIT_D_STATUS_NOT_RUNNING:
264 { 260 {
265 status = INIT_D_ERROR_NOT_RUNNING; 261 status = INIT_D_ERROR_NOT_RUNNING;
266 break; 262 break;
267 } 263 }
268 264
269 default : 265 default:
270 { 266 {
271 status = INIT_D_ERROR_GENERIC; 267 status = INIT_D_ERROR_GENERIC;
272 break; 268 break;
269 }
273 } 270 }
274 }
275 271
276 return status; 272 return status;
277} 273}
278 274
279 275
280int default_force_reload(struct init_d_handle_s *init_d, int just_checking) 276int default_force_reload(struct init_d_handle_s *init_d, int just_checking)
281{ 277{
282 int status = (init_d->reload)(init_d, just_checking); 278 int status = (init_d->reload) (init_d, just_checking);
283 279
284 if (status == INIT_D_ERROR_NOT_IMPLEMENTED) 280 if (status == INIT_D_ERROR_NOT_IMPLEMENTED)
285 status = (init_d->try_restart)(init_d, just_checking); 281 status = (init_d->try_restart) (init_d, just_checking);
286 282
287 return status; 283 return status;
288} 284}
289 285
290 286
291int print_status(struct init_d_handle_s *init_d, int quiet, int status) 287int print_status(struct init_d_handle_s *init_d, int quiet, int status)
292{ 288{
293 if (quiet) 289 if (quiet)
294 switch (status) 290 switch (status) {
295 { 291 case INIT_D_STATUS_OK:
296 case INIT_D_STATUS_OK : 292 {
297 { 293 bb_printf("%s is running.\n", init_d->basename);
298 bb_printf("%s is running.\n", init_d->basename); 294 break;
299 break; 295 }
300 }
301 296
302 case INIT_D_STATUS_DEAD_PID : 297 case INIT_D_STATUS_DEAD_PID:
303 { 298 {
304 bb_printf("%s is not running, but there is a stale %s.\n", init_d->basename, init_d->pidfile); 299 bb_printf("%s is not running, but there is a stale %s.\n",
305 break; 300 init_d->basename, init_d->pidfile);
306 } 301 break;
302 }
307 303
308 case INIT_D_STATUS_DEAD_LOCK : 304 case INIT_D_STATUS_DEAD_LOCK:
309 { 305 {
310 bb_printf("%s is not running, but there is a stale lock file.\n", init_d->basename); 306 bb_printf("%s is not running, but there is a stale lock file.\n",
311 break; 307 init_d->basename);
312 } 308 break;
309 }
313 310
314 case INIT_D_STATUS_NOT_RUNNING : 311 case INIT_D_STATUS_NOT_RUNNING:
315 { 312 {
316 bb_printf("%s is not running.\n", init_d->basename); 313 bb_printf("%s is not running.\n", init_d->basename);
317 break; 314 break;
318 } 315 }
319
320 default :
321 {
322 bb_printf("The status of %s is not known.\n", init_d->basename);
323 break;
324 }
325 }
326 316
327 return status; 317 default:
318 {
319 bb_printf("The status of %s is not known.\n", init_d->basename);
320 break;
321 }
322 }
323
324 return status;
328} 325}
329 326
330 327
331int default_status(struct init_d_handle_s *init_d, int quiet) 328int default_status(struct init_d_handle_s *init_d, int quiet)
332{ 329{
333 return print_status(init_d, quiet, pidofproc(init_d->pidfile, init_d->pathname, NULL)); 330 return print_status(init_d, quiet,
331 pidofproc(init_d->pidfile, init_d->pathname, NULL));
334} 332}
335 333
336 334
337int default_show_info(struct init_d_handle_s *init_d, int just_checking) 335int default_show_info(struct init_d_handle_s *init_d, int just_checking)
338{ 336{
339 bb_printf("%s", init_d->info); 337 bb_printf("%s", init_d->info);
340 return INIT_D_OK; 338 return INIT_D_OK;
341} 339}
342 340
343 341
344int no_stop(struct init_d_handle_s *init_d, int just_checking) 342int no_stop(struct init_d_handle_s *init_d, int just_checking)
345{ 343{
346 return INIT_D_ERROR_NOT_IMPLEMENTED; 344 return INIT_D_ERROR_NOT_IMPLEMENTED;
347} 345}
348 346
349 347
350int no_reload(struct init_d_handle_s *init_d, int just_checking) 348int no_reload(struct init_d_handle_s *init_d, int just_checking)
351{ 349{
352 return INIT_D_ERROR_NOT_IMPLEMENTED; 350 return INIT_D_ERROR_NOT_IMPLEMENTED;
353} 351}
354 352
355 353
356int no_status(struct init_d_handle_s *init_d, int quiet) 354int no_status(struct init_d_handle_s *init_d, int quiet)
357{ 355{
358 return INIT_D_ERROR_NOT_IMPLEMENTED; 356 return INIT_D_ERROR_NOT_IMPLEMENTED;
359} 357}
360 358
361 359
362int do_init_from_main(int argc, char **argv, struct init_d_handle_s *init_d) 360int do_init_from_main(int argc, char **argv, struct init_d_handle_s *init_d)
363{ 361{
364 return do_init(init_d, (argc > 1) ? argv[1] : NULL); 362 read_sysconfig("/etc/runlevels.conf");
363 return do_init(init_d, (argc > 1) ? argv[1] : NULL);
365} 364}
366 365
367 366
368int do_init(struct init_d_handle_s *init_d, const char *command) 367int do_init(struct init_d_handle_s *init_d, const char *command)
369{ 368{
370 int i; 369 int i;
371 int status = INIT_D_ERROR_NOT_IMPLEMENTED; 370 int status = INIT_D_ERROR_NOT_IMPLEMENTED;
372 char *original_pidfile = init_d->pidfile; 371 char *original_pidfile = init_d->pidfile;
373 372 char *sysconfig;
374 if (init_d->start == NULL) init_d->start = &default_start; 373
375 if (init_d->stop == NULL) init_d->stop = &default_stop; 374 if (init_d->start == NULL)
376 if (init_d->restart == NULL) init_d->restart = &default_restart; 375 init_d->start = &default_start;
377 if (init_d->try_restart == NULL) init_d->try_restart = &default_try_restart; 376 if (init_d->stop == NULL)
378 if (init_d->reload == NULL) init_d->reload = &default_reload; 377 init_d->stop = &default_stop;
379 if (init_d->force_reload == NULL) init_d->force_reload = &default_force_reload; 378 if (init_d->restart == NULL)
380 if (init_d->status == NULL) init_d->status = &default_status; 379 init_d->restart = &default_restart;
381 if (init_d->show_info == NULL) init_d->show_info = &default_show_info; 380 if (init_d->try_restart == NULL)
382 if (init_d->basename == NULL) init_d->basename = bb_get_last_path_component(init_d->pathname); 381 init_d->try_restart = &default_try_restart;
383 if (init_d->pathname == NULL) init_d->pathname = init_d->basename; 382 if (init_d->reload == NULL)
384 if (init_d->args == NULL) init_d->args = ""; 383 init_d->reload = &default_reload;
385 if (init_d->pidfile == NULL) bb_xasprintf(&(init_d->pidfile), "/var/run/%s.pid", init_d->basename); 384 if (init_d->force_reload == NULL)
386 if (init_d->info == NULL) init_d->info = ""; 385 init_d->force_reload = &default_force_reload;
387 386 if (init_d->status == NULL)
388 if (command == NULL) 387 init_d->status = &default_status;
389 command = commands[2]; // Default to restart. 388 if (init_d->show_info == NULL)
390 389 init_d->show_info = &default_show_info;
391 for (i = 0; commands[i] != 0; i++) 390 if (init_d->basename == NULL)
392 { 391 init_d->basename = bb_get_last_path_component(init_d->pathname);
393 if (strcmp(commands[i], command ) == 0) 392 if (init_d->pathname == NULL)
394 { 393 init_d->pathname = init_d->basename;
395 switch (i) 394 if (init_d->args == NULL)
396 { 395 init_d->args = "";
397 case 0 : status = (init_d->start)(init_d, 0); break; 396 if (init_d->pidfile == NULL)
398 case 1 : status = (init_d->stop)(init_d, 0); break; 397 bb_xasprintf(&(init_d->pidfile), "/var/run/%s.pid", init_d->basename);
399 case 2 : status = (init_d->restart)(init_d, 0); break; 398 if (init_d->info == NULL)
400 case 3 : status = (init_d->try_restart)(init_d, 0); break; 399 init_d->info = "";
401 case 4 : status = (init_d->reload)(init_d, 0); break; 400
402 case 5 : status = (init_d->force_reload)(init_d, 0); break; 401 bb_xasprintf(&sysconfig, "/etc/sysconfig/%s", init_d->basename);
403 case 6 : status = (init_d->status)(init_d, 1); break; 402 read_sysconfig(sysconfig);
404 case 7 : status = (init_d->show_info)(init_d, 0); break; 403
405 } 404 if (command == NULL)
406 break; 405 command = commands[2]; // Default to restart.
406
407 for (i = 0; commands[i] != 0; i++) {
408 if (strcmp(commands[i], command) == 0) {
409 switch (i) {
410 case 0:
411 status = (init_d->start) (init_d, 0);
412 break;
413 case 1:
414 status = (init_d->stop) (init_d, 0);
415 break;
416 case 2:
417 status = (init_d->restart) (init_d, 0);
418 break;
419 case 3:
420 status = (init_d->try_restart) (init_d, 0);
421 break;
422 case 4:
423 status = (init_d->reload) (init_d, 0);
424 break;
425 case 5:
426 status = (init_d->force_reload) (init_d, 0);
427 break;
428 case 6:
429 status = (init_d->status) (init_d, 1);
430 break;
431 case 7:
432 status = (init_d->show_info) (init_d, 0);
433 break;
434 }
435 break;
436 }
407 } 437 }
408 }
409 438
410 if (original_pidfile == NULL) 439 free(sysconfig);
411 free(init_d->pidfile); 440 if (original_pidfile == NULL)
412 return status; 441 free(init_d->pidfile);
442 return status;
413} 443}
414 444
415 445
416static int init_script(char *script, char *command) 446static int init_script(char *script, char *command)
417{ 447{
418 int status = INIT_D_ERROR_NOT_IMPLEMENTED; 448 int status = INIT_D_ERROR_NOT_IMPLEMENTED;
419 449
420 bb_printf("%c%s %s ... ", toupper(command[0]), &command[1], script); 450 bb_printf("%c%s %s ... ", toupper(command[0]), &command[1], script);
421 fflush(stdout); 451 fflush(stdout);
422 doit(0, "/etc/init.d/%s %s", script, command); 452 doit(0, "/etc/init.d/%s %s", script, command);
423 status = errno; 453 status = errno;
424 if (strcmp("status", command) != 0) 454 if (strcmp("status", command) != 0) {
425 { 455 bb_printf("\t\t");
426 bb_printf("\t\t"); 456 switch (status) {
427 switch (status) 457 case INIT_D_OK:
428 { 458 bb_printf("OK");
429 case INIT_D_OK : bb_printf("OK"); break; 459 break;
430 case INIT_D_ERROR_NOT_IMPLEMENTED : bb_printf("not implemented"); break; 460 case INIT_D_ERROR_NOT_IMPLEMENTED:
431 case INIT_D_ERROR_NOT_INSTALLED : bb_printf("not installed"); break; 461 bb_printf("not implemented");
432 case INIT_D_ERROR_NOT_CONFIGURED : bb_printf("not configured"); break; 462 break;
433 case INIT_D_ERROR_NOT_RUNNING : bb_printf("not running"); break; 463 case INIT_D_ERROR_NOT_INSTALLED:
434 case INIT_D_ERROR_GENERIC : bb_printf("failed"); break; 464 bb_printf("not installed");
435 case INIT_D_ERROR_ARGS : bb_printf("invalid arguments"); break; 465 break;
436 case INIT_D_ERROR_SECURITY : bb_printf("security failure"); break; 466 case INIT_D_ERROR_NOT_CONFIGURED:
437 default : bb_printf("Failed!"); break; 467 bb_printf("not configured");
468 break;
469 case INIT_D_ERROR_NOT_RUNNING:
470 bb_printf("not running");
471 break;
472 case INIT_D_ERROR_GENERIC:
473 bb_printf("failed");
474 break;
475 case INIT_D_ERROR_ARGS:
476 bb_printf("invalid arguments");
477 break;
478 case INIT_D_ERROR_SECURITY:
479 bb_printf("security failure");
480 break;
481 default:
482 bb_printf("Failed!");
483 break;
484 }
485 bb_printf("\n");
438 } 486 }
439 bb_printf("\n"); 487 return status;
440 }
441 return status;
442} 488}
443 489
444 490
445init_d_info_t *parse_init_info(char *info_text, char *name) 491init_d_info_t *parse_init_info(char *info_text, char *name)
446{ 492{
447 init_d_info_t *info = NULL; 493 init_d_info_t *info = NULL;
448 494
449 // if init info found 495 // if init info found
450 if ((info_text != NULL) && (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0)) 496 if ((info_text != NULL)
451 { 497 && (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) ==
452 if (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0) 498 0)) {
453 { 499 if (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0) {
454 int lastfound = -1; 500 int lastfound = -1;
455 char *strtok_line; 501 char *strtok_line;
456 char *line; 502 char *line;
457 char *linecopy; 503 char *linecopy;
458 504
459 info = (init_d_info_t *) xcalloc(1, sizeof(init_d_info_t)); 505 info = (init_d_info_t *) xcalloc(1, sizeof(init_d_info_t));
460 bb_xasprintf(&info->path, "%s", name); 506 bb_xasprintf(&info->path, "%s", name);
461 507
462//bb_printf("%s is an init script -%s", name, info_text); 508//bb_printf("%s is an init script -%s", name, info_text);
463//bb_printf("%s is an init script\n", name); 509//bb_printf("%s is an init script\n", name);
464 // parse info into structure 510 // parse info into structure
465 for (line = strtok_r(info_text, "\n\r", &strtok_line); line != NULL; line = strtok_r(NULL, "\n\r", &strtok_line)) 511 for (line = strtok_r(info_text, "\n\r", &strtok_line);
466 { 512 line != NULL; line = strtok_r(NULL, "\n\r", &strtok_line)) {
467 int count = 0; 513 int count = 0;
468 int found = -1; 514 int found = -1;
469 char *strtok_token; 515 char *strtok_token;
470 char *token; 516 char *token;
471 517
472 bb_xasprintf(&linecopy, "%s", line); 518 bb_xasprintf(&linecopy, "%s", line);
473 for (token = strtok_r(line, " \t", &strtok_token); token != NULL; token = strtok_r(NULL, " \t", &strtok_token)) 519 for (token = strtok_r(line, " \t", &strtok_token);
474 { 520 token != NULL;
475 switch (count++) 521 token = strtok_r(NULL, " \t", &strtok_token)) {
476 { 522 switch (count++) {
477 case 0 : break; /* Ignore the "#". */ 523 case 0:
524 break; /* Ignore the "#". */
525
526 case 1:
527 {
528 int j;
478 529
479 case 1 : 530 for (j = 1; INFOS[j] != NULL; j++) {
480 {
481 int j;
482 for (j = 1; INFOS[j] != NULL; j++)
483 {
484//bb_printf("%s = %s %s\n", linecopy, &(INFOS[j][1]), token); 531//bb_printf("%s = %s %s\n", linecopy, &(INFOS[j][1]), token);
485 if (strncmp(&(INFOS[j][1]), linecopy, strlen(&(INFOS[j][1])) - 1) == 0) 532 if (strncmp
486 { 533 (&(INFOS[j][1]), linecopy,
487 found = j - 1; 534 strlen(&(INFOS[j][1])) - 1) == 0) {
488 break; 535 found = j - 1;
489 } 536 break;
490 } 537 }
491 break; 538 }
492 } 539 break;
493 540 }
494 default :
495 {
496 int multi = 1;
497 int string = 1;
498 void **kludge = (void **)info;
499
500 switch (found)
501 {
502 case 5 : /* INIT_D_DSTART */ string = 0; break;
503 case 6 : /* INIT_D_DSTOP */ string = 0; break;
504 case 7 : /* INIT_D_SDESC */ multi = 0; break;
505 case 8 : /* INIT_D_DESC */ multi = 0; break;
506 case 10 : /* INIT_D_CONT */
507 case 11 : /* INIT_D_CONT2 */ multi = 0; found = lastfound; break;
508 case 12 : /* INIT_D_END */ found = -1; break;
509 }
510
511 if (found != -1)
512 {
513 void *temp = kludge[found];
514
515 if (multi == 1)
516 {
517 int size = info->sizes[found];
518 541
519 info->sizes[found]++; 542 default:
543 {
544 int multi = 1;
545 int string = 1;
546 void **kludge = (void **) info;
547
548 switch (found) {
549 case 5: /* INIT_D_DSTART */
550 string = 0;
551 break;
552 case 6: /* INIT_D_DSTOP */
553 string = 0;
554 break;
555 case 7: /* INIT_D_SDESC */
556 multi = 0;
557 break;
558 case 8: /* INIT_D_DESC */
559 multi = 0;
560 break;
561 case 10: /* INIT_D_CONT */
562 case 11: /* INIT_D_CONT2 */
563 multi = 0;
564 found = lastfound;
565 break;
566 case 12: /* INIT_D_END */
567 found = -1;
568 break;
569 }
570
571 if (found != -1) {
572 void *temp = kludge[found];
573
574 if (multi == 1) {
575 int size = info->sizes[found];
576
577 info->sizes[found]++;
520// not LSB, but SuSE does it 578// not LSB, but SuSE does it
521if (token[0] == '$') 579 if (token[0] == '$')
522 token = &token[1]; 580 token = &token[1];
523// not LSB, but SuSE does it 581// not LSB, but SuSE does it
524if (strncmp(token, "boot.", 5) == 0) 582 if (strncmp(token, "boot.", 5) == 0)
525 token = &token[5]; 583 token = &token[5];
526 if (temp != NULL) 584 if (temp != NULL)
527 kludge[found] = xrealloc(kludge[found], sizeof (char **) * (size + 1)); 585 kludge[found] =
528 else 586 xrealloc(kludge[found],
529 kludge[found] = xcalloc(1, sizeof (char **)); 587 sizeof(char **) * (size +
530 if (string == 1) 588 1));
531 bb_xasprintf(&((char **) kludge[found])[size], "%s", token); 589 else
532 else 590 kludge[found] =
533 { 591 xcalloc(1, sizeof(char **));
592 if (string == 1)
593 bb_xasprintf(&((char **) kludge[found])
594 [size], "%s", token);
595 else {
534// not LSB, but SuSE does it 596// not LSB, but SuSE does it
535if (token[0] == 'B') 597 if (token[0] == 'B') {
536{ 598 token[0] = '5';
537 token[0] = '5'; 599 kludge[found] =
538 kludge[found] = xrealloc(kludge[found], sizeof (char **) * (10 + 1)); 600 xrealloc(kludge[found],
539 ((int *) kludge[found])[0] = 1; 601 sizeof(char **) * (10 +
540 ((int *) kludge[found])[1] = 2; 602 1));
541 ((int *) kludge[found])[2] = 3; 603 ((int *) kludge[found])[0] = 1;
542 ((int *) kludge[found])[3] = 4; 604 ((int *) kludge[found])[1] = 2;
543 size = 4; 605 ((int *) kludge[found])[2] = 3;
544 info->sizes[found] = 5; 606 ((int *) kludge[found])[3] = 4;
545} 607 size = 4;
608 info->sizes[found] = 5;
609 }
546// not LSB, but SuSE does it 610// not LSB, but SuSE does it
547if (token[0] == 'S') 611 if (token[0] == 'S')
548 token[0] = '1'; 612 token[0] = '1';
549 ((int *) kludge[found])[size] = atoi(token); 613 ((int *) kludge[found])[size] =
550 } 614 atoi(token);
551 temp = NULL; 615 }
552 } 616 temp = NULL;
553 else 617 } else {
554 { 618 if (string == 1) {
555 if (string == 1) 619 if (kludge[found] == NULL)
556 { 620 bb_xasprintf((char **) &kludge[found],
557 if (kludge[found] == NULL) 621 "%s", token);
558 bb_xasprintf((char **) &kludge[found], "%s", token); 622 else
559 else 623 bb_xasprintf((char **) &kludge[found],
560 bb_xasprintf((char **) &kludge[found], "%s %s", (char *) kludge[found], token); 624 "%s %s",
561 } 625 (char *) kludge[found],
562 else 626 token);
563 { 627 } else {
564// Should never happen. int value = atoi(token); 628// Should never happen. int value = atoi(token);
565 temp = NULL; 629 temp = NULL;
566 } 630 }
631 }
632
633 if (temp != NULL)
634 free(temp);
635 }
636 lastfound = found;
637
638 break;
639 }
640 }
567 } 641 }
568
569 if (temp != NULL)
570 free(temp);
571 }
572 lastfound = found;
573
574 break;
575 } 642 }
576 }
577 }
578 }
579 643
580 644
581#if 0 645#if 0
582{ 646 {
583 int k; 647 int k;
584 648
585 bb_printf("SCRIPT %s path %s\n", name, info->path); 649 bb_printf("SCRIPT %s path %s\n", name, info->path);
586// bb_printf("%s sizes ", name); 650// bb_printf("%s sizes ", name);
587// for(k = 0; k < 10; k++) 651// for(k = 0; k < 10; k++)
588// bb_printf("%d ", info->sizes[k]); 652// bb_printf("%d ", info->sizes[k]);
589// bb_printf("\n"); 653// bb_printf("\n");
590 if (info->provides != NULL) 654 if (info->provides != NULL) {
591 { 655 bb_printf("%s provides ", name);
592 bb_printf("%s provides ", name); 656 for (k = 0; k < info->sizes[0]; k++)
593 for(k = 0; k < info->sizes[0]; k++) 657 bb_printf("%s ", info->provides[k]);
594 bb_printf("%s ", info->provides[k]); 658 bb_printf("\n");
595 bb_printf("\n"); 659 }
596 } 660 if (info->reqstart != NULL) {
597 if (info->reqstart != NULL) 661 bb_printf("%s reqstart ", name);
598 { 662 for (k = 0; k < info->sizes[1]; k++)
599 bb_printf("%s reqstart ", name); 663 bb_printf("%s ", info->reqstart[k]);
600 for(k = 0; k < info->sizes[1]; k++) 664 bb_printf("\n");
601 bb_printf("%s ", info->reqstart[k]); 665 }
602 bb_printf("\n"); 666 if (info->reqstop != NULL) {
603 } 667 bb_printf("%s reqstop ", name);
604 if (info->reqstop != NULL) 668 for (k = 0; k < info->sizes[2]; k++)
605 { 669 bb_printf("%s ", info->reqstop[k]);
606 bb_printf("%s reqstop ", name); 670 bb_printf("\n");
607 for(k = 0; k < info->sizes[2]; k++) 671 }
608 bb_printf("%s ", info->reqstop[k]);
609 bb_printf("\n");
610 }
611 672
612 if (info->shouldstart != NULL) 673 if (info->shouldstart != NULL) {
613 { 674 bb_printf("%s shouldstart ", name);
614 bb_printf("%s shouldstart ", name); 675 for (k = 0; k < info->sizes[3]; k++)
615 for(k = 0; k < info->sizes[3]; k++) 676 bb_printf("%s ", info->shouldstart[k]);
616 bb_printf("%s ", info->shouldstart[k]); 677 bb_printf("\n");
617 bb_printf("\n"); 678 }
618 } 679 if (info->shouldstop != NULL) {
619 if (info->shouldstop != NULL) 680 bb_printf("%s shouldstop ", name);
620 { 681 for (k = 0; k < info->sizes[4]; k++)
621 bb_printf("%s shouldstop ", name); 682 bb_printf("%s ", info->shouldstop[k]);
622 for(k = 0; k < info->sizes[4]; k++) 683 bb_printf("\n");
623 bb_printf("%s ", info->shouldstop[k]); 684 }
624 bb_printf("\n");
625 }
626 685
627 if (info->defstart != NULL) 686 if (info->defstart != NULL) {
628 { 687 bb_printf("%s defstart ", name);
629 bb_printf("%s defstart ", name); 688 for (k = 0; k < info->sizes[5]; k++)
630 for(k = 0; k < info->sizes[5]; k++) 689 bb_printf("%d ", info->defstart[k]);
631 bb_printf("%d ", info->defstart[k]); 690 bb_printf("\n");
632 bb_printf("\n"); 691 }
633 } 692 if (info->defstop != NULL) {
634 if (info->defstop != NULL) 693 bb_printf("%s defstop ", name);
635 { 694 for (k = 0; k < info->sizes[6]; k++)
636 bb_printf("%s defstop ", name); 695 bb_printf("%d ", info->defstop[k]);
637 for(k = 0; k < info->sizes[6]; k++) 696 bb_printf("\n");
638 bb_printf("%d ", info->defstop[k]); 697 }
639 bb_printf("\n"); 698 if (info->shortdesc != NULL)
640 } 699 bb_printf("%s shortdes %s\n", name, info->shortdesc);
641 if (info->shortdesc != NULL) 700 if (info->desc != NULL)
642 bb_printf("%s shortdes %s\n", name, info->shortdesc); 701 bb_printf("%s descript %s\n", name, info->desc);
643 if (info->desc != NULL) 702 bb_printf("\n");
644 bb_printf("%s descript %s\n", name, info->desc); 703 }
645 bb_printf("\n");
646}
647#endif 704#endif
648 705
649 // if database of runlevels per script includes overrides 706 // if database of runlevels per script includes overrides
650 // change info structure accordingly 707 // change info structure accordingly
708 }
651 } 709 }
652 }
653 710
654 return info; 711 return info;
655} 712}
656 713
657 714
658char *get_init_info(char *pathname) 715char *get_init_info(char *pathname)
659{ 716{
660 struct stat script_stat; 717 struct stat script_stat;
661 char *info_text = NULL; 718 char *info_text = NULL;
662 char *base_name = bb_get_last_path_component(pathname); 719 char *base_name = bb_get_last_path_component(pathname);
663 720
664 721
665//bb_printf("CHECKING %s, ", pathname); 722//bb_printf("CHECKING %s, ", pathname);
666 // ignore rc, rcS, directories, non executables 723 // ignore rc, rcS, directories, non executables
667 if ((strcmp(base_name, "rc") != 0) && 724 if ((strcmp(base_name, "rc") != 0) &&
668 (strcmp(base_name, "rcS") != 0) && 725 (strcmp(base_name, "rcS") != 0) &&
669 (stat(pathname, &script_stat) == 0)) 726 (stat(pathname, &script_stat) == 0)) {
670 { 727 if ((!S_ISDIR(script_stat.st_mode)) &&
671 if ((!S_ISDIR(script_stat.st_mode)) && 728 S_ISREG(script_stat.st_mode) &&
672 S_ISREG(script_stat.st_mode) && 729 ((script_stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)) {
673 ((script_stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0 ))
674 {
675//bb_printf("maybe init script, "); 730//bb_printf("maybe init script, ");
676 // script info 731 // script info
677 if ((info_text == NULL) || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) != 0)) 732 if ((info_text == NULL)
678 bb_xasprintf(&info_text, "%s", doit(REDIR | QUIET, "%s info", pathname)); 733 || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1)
734 != 0))
735 bb_xasprintf(&info_text, "%s",
736 doit(REDIR | QUIET, "%s info", pathname));
679//bb_printf("INFO = %s\n", info_text); 737//bb_printf("INFO = %s\n", info_text);
680 738
681 // if not proper response 739 // if not proper response
682 if ((info_text == NULL) || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) != 0)) 740 if ((info_text == NULL)
683 { 741 || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1)
684 int count = 1; 742 != 0)) {
685 int found = -1; 743 int count = 1;
686 char *line; 744 int found = -1;
687 FILE *contents; 745 char *line;
746 FILE *contents;
688 747
689//bb_printf("search for INFO, "); 748//bb_printf("search for INFO, ");
690 // search script for init info 749 // search script for init info
691 info_text = (char *) xmalloc(sizeof (char) * 256 * 64); 750 info_text = (char *) xmalloc(sizeof(char) * 256 * 64);
692 info_text[0] = '\n'; 751 info_text[0] = '\n';
693 info_text[1] = '\0'; 752 info_text[1] = '\0';
694 contents = fopen(pathname, "r"); 753 contents = fopen(pathname, "r");
695 if (contents != NULL) 754 if (contents != NULL) {
696 { 755 do {
697 do 756 line = fgets(&info_text[count], 255, contents);
698 { 757 if (line != NULL) {
699 line = fgets(&info_text[count], 255, contents); 758 line--;
700 if (line != NULL) 759 if ((found == -1)
701 { 760 &&
702 line--; 761 (strncmp
703 if ((found == -1) && (strncmp(line, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0)) 762 (line, INIT_D_BEGIN,
704 found = 0; 763 strlen(INIT_D_BEGIN) - 1) == 0))
705 764 found = 0;
706 if (found != -1) 765
707 { 766 if (found != -1) {
708 767
709 if (strncmp(line, INIT_D_CUSTOM, strlen(INIT_D_CUSTOM)) != 0) 768 if (strncmp
710 { 769 (line, INIT_D_CUSTOM,
711 if (strncmp(line, INIT_D_END, strlen(INIT_D_END) - 1) == 0) 770 strlen(INIT_D_CUSTOM)) != 0) {
712 { 771 if (strncmp
772 (line, INIT_D_END,
773 strlen(INIT_D_END) - 1) == 0) {
713//bb_printf("INFO found, "); 774//bb_printf("INFO found, ");
714 line = NULL; 775 line = NULL;
715 found = 64 + 1; 776 found = 64 + 1;
716 } 777 } else {
717 else 778 int cont = 0;
718 { 779
719 int cont = 0; 780 if (strncmp
720 781 (line, INIT_D_CONT,
721 if (strncmp(line, INIT_D_CONT, strlen(INIT_D_CONT)) == 0) 782 strlen(INIT_D_CONT)) == 0)
722 cont = 1; 783 cont = 1;
723 if (strncmp(line, INIT_D_CONT2, strlen(INIT_D_CONT2)) == 0) 784 if (strncmp
724 cont = 1; 785 (line, INIT_D_CONT2,
725 if (cont == 1) 786 strlen(INIT_D_CONT2)) == 0)
726 { 787 cont = 1;
788 if (cont == 1) {
727//bb_printf("\n\n\nCONT found%s\n\n\n, ", line); 789//bb_printf("\n\n\nCONT found%s\n\n\n, ", line);
728 info_text[count - 1] = ' '; 790 info_text[count - 1] = ' ';
729 info_text[count] = ' '; 791 info_text[count] = ' ';
730 } 792 }
731 793
732 found++; 794 found++;
733 count += strlen(line) - 1; 795 count += strlen(line) - 1;
734 if (info_text[count - 1] != '\n') 796 if (info_text[count - 1] != '\n') {
735 { 797 info_text[count++] = '\n';
736 info_text[count++] = '\n';
737// Should seek until the next \n, 798// Should seek until the next \n,
738 } 799 }
739 } 800 }
740 info_text[count] = '\0'; 801 info_text[count] = '\0';
802 }
803 }
804 }
805 } while ((line != NULL) && (found < 64));
806
807 fclose(contents);
741 } 808 }
742 }
743 } 809 }
744 } while ((line != NULL) && (found < 64));
745
746 fclose(contents);
747 } 810 }
748 }
749 } 811 }
750 }
751//bb_printf("\n"); 812//bb_printf("\n");
752 813
753 return info_text; 814 return info_text;
754} 815}
755 816
756 817
757llist_t *get_scripts(void) 818llist_t *get_scripts(void)
758{ 819{
759 llist_t *result = NULL; 820 llist_t *result = NULL;
760 DIR *initd = opendir("/etc/init.d"); 821 DIR *initd = opendir("/etc/init.d");
761 822
762 if (initd != NULL) 823 if (initd != NULL) {
763 { 824 struct dirent *script;
764 struct dirent *script; 825
765 826 // foreach ls /etc/init.d
766 // foreach ls /etc/init.d 827 while ((script = readdir(initd)) != NULL) {
767 while ((script = readdir(initd)) != NULL) 828 char *info_text = NULL;
768 { 829 char *pathname = NULL;
769 char *info_text = NULL; 830 init_d_info_t *info = NULL;
770 char *pathname = NULL; 831
771 init_d_info_t *info = NULL; 832 bb_xasprintf(&pathname, "/etc/init.d/%s", script->d_name);
772 833 info_text = get_init_info(pathname);
773 bb_xasprintf(&pathname, "/etc/init.d/%s", script->d_name); 834 info = parse_init_info(info_text, script->d_name);
774 info_text = get_init_info(pathname); 835 if (info)
775 info = parse_init_info(info_text, script->d_name); 836 result = llist_add_to(result, (char *) info);
776 if (info) 837
777 result = llist_add_to(result, (char *) info); 838 free(info_text);
778 839 }
779 free(info_text); 840 closedir(initd);
780 }
781 closedir(initd);
782 } 841 }
783 842
784 return result; 843 return result;
785} 844}
786 845
787 846
788llist_t *sort_scripts(llist_t *unsorted) 847llist_t *sort_scripts(llist_t * unsorted, init_d_info_t *for_script)
789{ 848{
790// Should do something with info->shouldstart's 849// Should do something with info->shouldstart's
791 int count_moves = 0; 850 int count_moves = 0;
792 // all scripts start in unsorted list
793 llist_t *sorted = NULL;
794 llist_t *current = unsorted;
795 llist_t *previous = NULL;
796
797 // pull out those with no deps and create a sorted list for each
798 while (current)
799 {
800 init_d_info_t *info = (init_d_info_t *) current->data;
801
802 if (info->reqstart == NULL)
803 {
804 llist_t *new_list = NULL;
805 new_list = llist_add_to_end(new_list, (char *) info);
806 sorted = llist_add_to_end(sorted, (char *) new_list);
807 current = llist_delete(&unsorted, previous, current);
808 }
809 else
810 {
811 previous = current;
812 current = current->link;
813 }
814 }
815 851
816 do 852 // all scripts start in unsorted list
817 { 853 llist_t *sorted = NULL;
818 count_moves = 0; 854 llist_t *current = unsorted;
819 current = unsorted; 855 llist_t *previous = NULL;
820 previous = NULL;
821 // foreach in unsorted list
822 while (current)
823 {
824 int moved = 0;
825 init_d_info_t *info = (init_d_info_t *) current->data;
826 856
827 if (info->reqstart != NULL) 857 // pull out those with no deps and create a sorted list for each
828 { 858 while (current) {
829 int k; 859 init_d_info_t *info = (init_d_info_t *) current->data;
830 llist_t *current_sort = sorted;
831 short done[info->sizes[1]];
832 860
833 // foreach sorted list 861 if (info->reqstart == NULL) {
834 while (current_sort) 862 llist_t *new_list = NULL;
835 {
836 llist_t *current_list = (llist_t *) current_sort->data;
837 863
838 // if ALL deps are in sorted list move script to end of sorted list 864 new_list = llist_add_to_end(new_list, (char *) info);
839 for(k = 0; k < info->sizes[1]; k++) 865 sorted = llist_add_to_end(sorted, (char *) new_list);
840 done[k] = 0; 866 current = llist_delete(&unsorted, previous, current);
841 while (current_list) 867 } else {
842 { 868 previous = current;
843 init_d_info_t *this_info = (init_d_info_t *) current_list->data; 869 current = current->link;
844 870 }
845 for(k = 0; k < info->sizes[1]; k++) 871 }
846 {
847 int i;
848 char *needs = info->reqstart[k];
849 872
850 if (done[k] == 0) 873 do {
851 { 874 count_moves = 0;
875 current = unsorted;
876 previous = NULL;
877 // foreach in unsorted list
878 while (current) {
879 int moved = 0;
880 init_d_info_t *info = (init_d_info_t *) current->data;
881
882 if (info->reqstart != NULL) {
883 int k;
884 llist_t *current_sort = sorted;
885 short done[info->sizes[1]];
886
887 // foreach sorted list
888 while (current_sort) {
889 llist_t *current_list = (llist_t *) current_sort->data;
890
891 // if ALL deps are in sorted list move script to end of sorted list
892 for (k = 0; k < info->sizes[1]; k++)
893 done[k] = 0;
894 while (current_list) {
895 init_d_info_t *this_info =
896 (init_d_info_t *) current_list->data;
897
898 for (k = 0; k < info->sizes[1]; k++) {
899 int i;
900 char *needs = info->reqstart[k];
901
902 if (done[k] == 0) {
852//bb_printf("%s NEEDS %s - ", info->path, needs); 903//bb_printf("%s NEEDS %s - ", info->path, needs);
853 for(i = 0; i < this_info->sizes[0]; i++) 904 for (i = 0; i < this_info->sizes[0]; i++) {
854 {
855//bb_printf("%s ", this_info->provides[i]); 905//bb_printf("%s ", this_info->provides[i]);
856 if (strcmp(this_info->provides[i], needs) == 0) 906 if (strcmp(this_info->provides[i], needs)
857 { 907 == 0) {
858 done[k] = 1; 908 done[k] = 1;
859 break; 909 break;
860 } 910 }
861 } 911 }
862//bb_printf("\n"); 912//bb_printf("\n");
863 } 913 }
914 }
915 current_list = current_list->link;
916 }
917
918 moved = 1;
919 for (k = 0; k < info->sizes[1]; k++) {
920 if (done[k] == 0) {
921 moved = 0;
922 break;
923 }
924 }
925 if (moved == 1) {
926 llist_t *list = (llist_t *) current_sort->data;
927
928 llist_add_to_end(list, (char *) info);
929 current = llist_delete(&unsorted, previous, current);
930 moved = 1;
931 count_moves++;
932 current_sort = NULL;
933 } else
934 current_sort = current_sort->link;
935 }
864 } 936 }
865 current_list = current_list->link;
866 }
867 937
868 moved = 1; 938 if (moved == 0) {
869 for(k = 0; k < info->sizes[1]; k++) 939 previous = current;
870 { 940 current = current->link;
871 if (done[k] == 0)
872 {
873 moved = 0;
874 break;
875 } 941 }
876 }
877 if (moved == 1)
878 {
879 llist_t *list = (llist_t *) current_sort->data;
880 llist_add_to_end(list, (char *) info);
881 current = llist_delete(&unsorted, previous, current);
882 moved = 1;
883 count_moves++;
884 current_sort = NULL;
885 }
886 else
887 current_sort = current_sort->link;
888 } 942 }
889 } 943 } while (count_moves != 0);
890 944 // until no more moves happen
891 if (moved == 0) 945
892 { 946
893 previous = current; 947 do {
894 current = current->link; 948 count_moves = 0;
895 } 949 current = unsorted;
896 } 950 previous = NULL;
897 } while (count_moves != 0); 951 // foreach in unsorted list
898 // until no more moves happen 952 while (current) {
899 953 int moved = 1;
900 954 init_d_info_t *info = (init_d_info_t *) current->data;
901 do 955 short done[info->sizes[1]];
902 { 956
903 count_moves = 0; 957 if (info->reqstart != NULL) {
904 current = unsorted; 958 int k;
905 previous = NULL; 959 llist_t *current_sortof = sorted;
906 // foreach in unsorted list 960
907 while (current) 961 // if ALL deps are in sorted lists
908 { 962 for (k = 0; k < info->sizes[1]; k++)
909 int moved = 1; 963 done[k] = 0;
910 init_d_info_t *info = (init_d_info_t *) current->data; 964 while ((moved == 1) && (current_sortof != NULL)) {
911 short done[info->sizes[1]]; 965 llist_t *current_listof =
912 966 (llist_t *) current_sortof->data;
913 if (info->reqstart != NULL) 967
914 { 968 while (current_listof) {
915 int k; 969 init_d_info_t *this_info =
916 llist_t *current_sortof = sorted; 970 (init_d_info_t *) current_listof->data;
917 971
918 // if ALL deps are in sorted lists 972 for (k = 0; k < info->sizes[1]; k++) {
919 for(k = 0; k < info->sizes[1]; k++) 973 int i;
920 done[k] = 0; 974 char *needs = info->reqstart[k];
921 while ((moved == 1) && (current_sortof != NULL)) 975
922 { 976 if (done[k] == 0) {
923 llist_t *current_listof = (llist_t *) current_sortof->data;
924
925 while (current_listof)
926 {
927 init_d_info_t *this_info = (init_d_info_t *) current_listof->data;
928
929 for(k = 0; k < info->sizes[1]; k++)
930 {
931 int i;
932 char *needs = info->reqstart[k];
933
934 if (done[k] == 0)
935 {
936//bb_printf("%s NEEDS %s - ", info->path, needs); 977//bb_printf("%s NEEDS %s - ", info->path, needs);
937 for(i = 0; i < this_info->sizes[0]; i++) 978 for (i = 0; i < this_info->sizes[0]; i++) {
938 {
939//bb_printf("%s ", this_info->provides[i]); 979//bb_printf("%s ", this_info->provides[i]);
940 if (strcmp(this_info->provides[i], needs) == 0) 980 if (strcmp(this_info->provides[i], needs)
941 { 981 == 0) {
942 done[k] = 1; 982 done[k] = 1;
943 break; 983 break;
944 } 984 }
945 } 985 }
946//bb_printf("\n"); 986//bb_printf("\n");
947 } 987 }
948 } 988 }
949 current_listof = current_listof->link; 989 current_listof = current_listof->link;
950 } 990 }
951 current_sortof = current_sortof->link; 991 current_sortof = current_sortof->link;
952 } 992 }
953
954 moved = 1;
955 for(k = 0; k < info->sizes[1]; k++)
956 {
957 if (done[k] == 0)
958 {
959 moved = 0;
960 break;
961 }
962 }
963 993
964 if (moved == 1) 994 moved = 1;
965 { 995 for (k = 0; k < info->sizes[1]; k++) {
966 // create a merged list for script 996 if (done[k] == 0) {
967 llist_t *current_sort = sorted; 997 moved = 0;
968 llist_t *new_list = NULL; 998 break;
969 new_list = llist_add_to_end(new_list, (char *) info); 999 }
970 count_moves++; 1000 }
971
972 // foreach sorted | merged list
973 while (current_sort)
974 {
975 int found = 0;
976 llist_t *current_list = (llist_t *) current_sort->data;
977
978 // if A dep is in s|m add s|m to end of new merged list & continue with next s|m
979 while (current_list)
980 {
981 init_d_info_t *this_info = (init_d_info_t *) current_list->data;
982 1001
983 for(k = 0; k < info->sizes[1]; k++) 1002 if (moved == 1) {
984 { 1003 // create a merged list for script
985 int i; 1004 llist_t *current_sort = sorted;
986 char *needs = info->reqstart[k]; 1005 llist_t *new_list = NULL;
1006
1007 new_list = llist_add_to_end(new_list, (char *) info);
1008 count_moves++;
1009
1010 // foreach sorted | merged list
1011 while (current_sort) {
1012 int found = 0;
1013 llist_t *current_list =
1014 (llist_t *) current_sort->data;
1015
1016 // if A dep is in s|m add s|m to end of new merged list & continue with next s|m
1017 while (current_list) {
1018 init_d_info_t *this_info =
1019 (init_d_info_t *) current_list->data;
1020
1021 for (k = 0; k < info->sizes[1]; k++) {
1022 int i;
1023 char *needs = info->reqstart[k];
1024
1025 for (i = 0; i < this_info->sizes[0]; i++) {
1026 if (strcmp(this_info->provides[i], needs)
1027 == 0) {
1028 found = 1;
1029 break;
1030 }
1031 }
1032 if (found == 1)
1033 break;
1034 }
1035 if (found == 1) {
1036 init_d_info_t *new_info =
1037 (init_d_info_t *) xcalloc(1,
1038 sizeof
1039 (init_d_info_t));
1040 new_info->start = current_sort;
1041 new_list =
1042 llist_add_to_end(new_list,
1043 (char *) new_info);
1044 current_list = NULL;
1045 } else
1046 current_list = current_list->link;
1047 }
1048
1049 current_sort = current_sort->link;
1050 }
987 1051
988 for(i = 0; i < this_info->sizes[0]; i++) 1052 sorted = llist_add_to_end(sorted, (char *) new_list);
989 { 1053 current = llist_delete(&unsorted, previous, current);
990 if (strcmp(this_info->provides[i], needs) == 0)
991 {
992 found = 1;
993 break;
994 }
995 } 1054 }
996 if (found == 1)
997 break;
998 }
999 if (found == 1)
1000 {
1001 init_d_info_t *new_info = (init_d_info_t *) xcalloc(1, sizeof(init_d_info_t));
1002 new_info->start = current_sort;
1003 new_list = llist_add_to_end(new_list, (char *) new_info);
1004 current_list = NULL;
1005 }
1006 else
1007 current_list = current_list->link;
1008 } 1055 }
1009 1056
1010 current_sort = current_sort->link; 1057 if (moved == 0) {
1011 } 1058 previous = current;
1012 1059 current = current->link;
1013 sorted = llist_add_to_end(sorted, (char *) new_list); 1060 }
1014 current = llist_delete(&unsorted, previous, current);
1015 } 1061 }
1016 } 1062 } while (count_moves != 0);
1017 1063 // until no more creates happen
1018 if (moved == 0)
1019 {
1020 previous = current;
1021 current = current->link;
1022 }
1023 }
1024 } while (count_moves != 0);
1025 // until no more creates happen
1026 1064
1027 1065
1028 // unsorted list now contains unsatisfied and circular dependencies 1066 // unsorted list now contains unsatisfied and circular dependencies
1029 // complain if not empty. 1067 // complain if not empty.
1030 if (unsorted != NULL) 1068 if (unsorted != NULL) {
1031 { 1069 bb_printf
1032 bb_printf("\nWARNING, the following init scripts have unresolved or circular dependencies -\n"); 1070 ("\nWARNING, the following init scripts have unresolved or circular dependencies -\n");
1033 current = unsorted; 1071 current = unsorted;
1034 1072
1035 while (current) 1073 while (current) {
1036 { 1074 init_d_info_t *info = (init_d_info_t *) current->data;
1037 init_d_info_t *info = (init_d_info_t *) current->data;
1038 1075
1039 bb_printf("%s\n", info->path); 1076 bb_printf("%s\n", info->path);
1040 current = current->link; 1077 current = current->link;
1041#if 0 1078#if 0
1042{ 1079 {
1043 int k; 1080 int k;
1044 1081
1045 bb_printf("SCRIPT %s - ", info->path); 1082 bb_printf("SCRIPT %s - ", info->path);
1046 if (info->defstart != NULL) 1083 if (info->defstart != NULL) {
1047 { 1084 bb_printf("\t\t ");
1048 bb_printf("\t\t "); 1085 for (k = 0; k < info->sizes[5]; k++)
1049 for(k = 0; k < info->sizes[5]; k++) 1086 bb_printf("%d ", info->defstart[k]);
1050 bb_printf("%d ", info->defstart[k]); 1087// bb_printf("\n");
1051// bb_printf("\n"); 1088 }
1052 } 1089 if (info->provides != NULL) {
1053 if (info->provides != NULL) 1090 bb_printf("\t\t ");
1054 { 1091 for (k = 0; k < info->sizes[0]; k++)
1055 bb_printf("\t\t "); 1092 bb_printf("%s ", info->provides[k]);
1056 for(k = 0; k < info->sizes[0]; k++) 1093// bb_printf("\n");
1057 bb_printf("%s ", info->provides[k]); 1094 }
1058// bb_printf("\n"); 1095 if (info->reqstart != NULL) {
1059 } 1096 bb_printf("\n\t ");
1060 if (info->reqstart != NULL) 1097 for (k = 0; k < info->sizes[1]; k++)
1061 { 1098 bb_printf("%s ", info->reqstart[k]);
1062 bb_printf("\n\t "); 1099// bb_printf("\n");
1063 for(k = 0; k < info->sizes[1]; k++) 1100 }
1064 bb_printf("%s ", info->reqstart[k]); 1101 bb_printf("\n");
1065// bb_printf("\n"); 1102 }
1066 }
1067 bb_printf("\n");
1068}
1069#endif 1103#endif
1104 }
1105 bb_printf("\n");
1070 } 1106 }
1071 bb_printf("\n");
1072 }
1073 1107
1074 return sorted; 1108 return sorted;
1075} 1109}
1076 1110
1077 1111
1078static void call_scripts(llist_t *sorted, char *command, int oldlevel, int level) 1112static void call_scripts(llist_t * sorted, char *command, int oldlevel,
1113 int level)
1079{ 1114{
1080 // call init_script(script, command) for each script in each list in created order 1115 // call init_script(script, command) for each script in each list in created order
1081 llist_t *current_sort = sorted; 1116 llist_t *current_sort = sorted;
1082 1117
1083 while (current_sort) 1118 while (current_sort) {
1084 { 1119 llist_t *current_list = (llist_t *) current_sort->data;
1085 llist_t *current_list = (llist_t *) current_sort->data;
1086 1120
1087//bb_printf("\nLIST\n"); 1121//bb_printf("\nLIST\n");
1088 while (current_list) 1122 while (current_list) {
1089 { 1123 init_d_info_t *info = (init_d_info_t *) current_list->data;
1090 init_d_info_t *info = (init_d_info_t *) current_list->data; 1124
1091 1125 if (info->path != NULL) {
1092 if (info->path != NULL) 1126 if (info->defstart != NULL) {
1093 { 1127 int k;
1094 if (info->defstart != NULL) 1128 int found = 0;
1095 { 1129
1096 int k; 1130 // if info->DefaultStart includes level
1097 int found = 0; 1131 for (k = 0; k < info->sizes[5]; k++) {
1098 1132 if (info->defstart[k] == level) {
1099 // if info->DefaultStart includes level 1133 found = 1;
1100 for(k = 0; k < info->sizes[5]; k++) 1134 break;
1101 { 1135 }
1102 if (info->defstart[k] == level) 1136 }
1103 { 1137 // if info->DefaultStart does not include previous level
1104 found = 1; 1138 for (k = 0; k < info->sizes[5]; k++) {
1105 break; 1139 if (info->defstart[k] == oldlevel) {
1106 } 1140 found = 0;
1107 } 1141 break;
1108 // if info->DefaultStart does not include previous level 1142 }
1109 for(k = 0; k < info->sizes[5]; k++) 1143 }
1110 { 1144 // add info structure to list
1111 if (info->defstart[k] == oldlevel) 1145 if (found == 1)
1112 { 1146 init_script(info->path, command);
1113 found = 0; 1147 }
1114 break;
1115 }
1116 }
1117 // add info structure to list
1118 if (found == 1)
1119 init_script(info->path, command);
1120 }
1121
1122#if 0 1148#if 0
1123{ 1149 {
1124 int k; 1150 int k;
1125 1151
1126 bb_printf("SCRIPT %s - ", info->path); 1152 bb_printf("SCRIPT %s - ", info->path);
1127 if (info->defstart != NULL) 1153 if (info->defstart != NULL) {
1128 { 1154 bb_printf("\t\t ");
1129 bb_printf("\t\t "); 1155 for (k = 0; k < info->sizes[5]; k++)
1130 for(k = 0; k < info->sizes[5]; k++) 1156 bb_printf("%d ", info->defstart[k]);
1131 bb_printf("%d ", info->defstart[k]); 1157// bb_printf("\n");
1132// bb_printf("\n"); 1158 }
1133 } 1159 if (info->provides != NULL) {
1134 if (info->provides != NULL) 1160 bb_printf("\t\t ");
1135 { 1161 for (k = 0; k < info->sizes[0]; k++)
1136 bb_printf("\t\t "); 1162 bb_printf("%s ", info->provides[k]);
1137 for(k = 0; k < info->sizes[0]; k++) 1163// bb_printf("\n");
1138 bb_printf("%s ", info->provides[k]); 1164 }
1139// bb_printf("\n"); 1165 if (info->reqstart != NULL) {
1140 } 1166 bb_printf("\n\t ");
1141 if (info->reqstart != NULL) 1167 for (k = 0; k < info->sizes[1]; k++)
1142 { 1168 bb_printf("%s ", info->reqstart[k]);
1143 bb_printf("\n\t "); 1169// bb_printf("\n");
1144 for(k = 0; k < info->sizes[1]; k++) 1170 }
1145 bb_printf("%s ", info->reqstart[k]); 1171 bb_printf("\n");
1146// bb_printf("\n"); 1172 }
1147 }
1148 bb_printf("\n");
1149}
1150#endif 1173#endif
1151 } 1174 }
1152 current_list = current_list->link; 1175 current_list = current_list->link;
1176 }
1177 current_sort = current_sort->link;
1153 } 1178 }
1154 current_sort = current_sort->link;
1155 }
1156} 1179}
1157 1180
1158 1181
1159int run_level(char *level) 1182static int run_level(char *level)
1160{ 1183{
1161 int oldlevel = 0; 1184 int oldlevel = 0;
1162 int newlevel = atoi(level); 1185 int newlevel = atoi(level);
1163 char *temp; 1186 char *temp;
1164 llist_t *sorted = NULL; 1187 llist_t *sorted = NULL;
1165 llist_t *reversed = NULL; 1188 llist_t *reversed = NULL;
1166 llist_t *current_sort = NULL; 1189 llist_t *current_sort = NULL;
1167 1190
1168 bb_printf("\n\nSwitching to run level %d", newlevel); 1191 bb_printf("\n\nSwitching to run level %d", newlevel);
1169 1192
1170 // get previous run level 1193 // get previous run level
1171 temp = quick_read("/var/lib/misc/runlevel"); 1194 temp = quick_read("/var/lib/misc/runlevel");
1172 if (temp != NULL) 1195 if (temp != NULL) {
1173 { 1196 oldlevel = atoi(temp);
1174 oldlevel = atoi(temp); 1197 if (oldlevel < 1)
1175 if (oldlevel < 0) 1198 oldlevel = 1;
1176 oldlevel = 1; 1199 if ((oldlevel == 6) || (oldlevel > 9))
1177 if (oldlevel > 6) 1200 oldlevel = 5;
1178 oldlevel = 5; 1201 bb_printf(" from run level %d", oldlevel);
1179 bb_printf(" from run level %d", oldlevel); 1202 free(temp);
1180 free(temp); 1203 }
1181 } 1204 bb_printf(".\n\n");
1182 bb_printf(".\n\n");
1183 1205
1184 // get scripts and sort dependencies, careful with circular dependencies 1206 // get scripts and sort dependencies, careful with circular dependencies
1185 sorted = sort_scripts(get_scripts()); 1207 sorted = sort_scripts(get_scripts(), NULL);
1186 1208
1187 // reverse 1209 // reverse
1188 current_sort = sorted; 1210 current_sort = sorted;
1189 while (current_sort) 1211 while (current_sort) {
1190 { 1212 llist_t *current_list = (llist_t *) current_sort->data;
1191 llist_t *current_list = (llist_t *) current_sort->data; 1213 llist_t *new_list = NULL;
1192 llist_t *new_list = NULL;
1193 1214
1194 while (current_list) 1215 while (current_list) {
1195 { 1216 new_list = llist_add_to(new_list, current_list->data);
1196 new_list = llist_add_to(new_list, current_list->data); 1217 current_list = current_list->link;
1197 current_list = current_list->link; 1218 }
1219 reversed = llist_add_to(reversed, (char *) new_list);
1220 current_sort = current_sort->link;
1198 } 1221 }
1199 reversed = llist_add_to(reversed, (char *) new_list);
1200 current_sort = current_sort->link;
1201 }
1202 1222
1203 // call "stop" for each script 1223 // call "stop" for each script
1204 bb_printf("\n"); 1224 bb_printf("\n");
1205 call_scripts(reversed, "stop", newlevel, oldlevel); 1225 call_scripts(reversed, "stop", newlevel, oldlevel);
1206 1226
1207 // call "start" for each script 1227 // call "start" for each script
1208 bb_printf("\n"); 1228 bb_printf("\n");
1209 call_scripts(sorted, "start", oldlevel, newlevel); 1229 call_scripts(sorted, "start", oldlevel, newlevel);
1210// free all infos 1230// free all infos
1211 1231
1212 // set previous run level to new run level 1232 // set previous run level to new run level
1213 quick_write("/var/lib/misc/runlevel", "%d", newlevel); 1233 quick_write("/var/lib/misc/runlevel", "%d", newlevel);
1214 1234
1215 1235
1216// Later, optionally call them in parallel when possible. 1236// Later, optionally call them in parallel when possible.
1217 1237
1218 1238
1219// Later, add a database of runlevels per script and allow editing them - 1239// Later, add a database of runlevels per script and allow editing them -
1220// rc network --runlevels 3 4 5 1240// rc network -l 3 4 5
1221// cat /etc/runlevels.conf 1241// cat /etc/runlevels.conf
1222// runlevel="3" 1242// runlevel="3"
1223// runlevel3="multi user with network." 1243// runlevel_3="multi user with network."
1224// runlevel4="multi user with network and twin." 1244// runlevel_4="multi user with network and twin."
1225// runlevel5="multi user with network and X." 1245// runlevel_5="multi user with network and X."
1226// local_fs="1 2 3 4 5" 1246// runlevel_local_fs="1 2 3 4 5"
1227// network="3 4 5" 1247// runlevel_network="3 4 5"
1228// script1="2 3 5" 1248// runlevel_script1="2 3 5"
1229// script1="3 5" 1249// runlevel_script1="3 5"
1230// rc network --runlevels 1250// rc network -l
1231// 3 4 5 1251// 3 4 5
1232// rc network --runlevels -v 1252// rc network -lv
1233// The "network" service will be active during these run levels : 1253// The "network" service will be active during these run levels :
1234// 3 - multi user with network. 1254// 3 - multi user with network.
1235// 4 - multi user with network and twin. 1255// 4 - multi user with network and twin.
1236// 5 - multi user with network and X. 1256// 5 - multi user with network and X.
1237 1257
1238 return EXIT_SUCCESS; 1258 return EXIT_SUCCESS;
1259}
1260
1261
1262static void print_levels(char *script, char *levels, int verbose)
1263{
1264 if (verbose) {
1265 char *token;
1266 char *strtok_temp;
1267
1268 bb_printf("The \"%s\" service will be active during these run levels :\n", script);
1269
1270 for (token = strtok_r(levels, " \t\n\r", &strtok_temp); token != NULL; token = strtok_r(NULL, " \t\n\r", &strtok_temp)) {
1271 char *env;
1272
1273 bb_xasprintf(&env, "runlevel_%s", token);
1274 bb_printf("%s - %s\n", token, getenv(env));
1275 }
1276 } else {
1277 bb_printf("%s\n", levels);
1278 }
1279}
1280
1281
1282static int show_run_levels(char *script, int verbose)
1283{
1284 int result = EXIT_FAILURE;
1285
1286 char *info_text = NULL;
1287 char *pathname = NULL;
1288 init_d_info_t *info = NULL;
1289//bb_printf("SHOW levels for %s\n", script);
1290
1291 bb_xasprintf(&pathname, "/etc/init.d/%s", script);
1292 info_text = get_init_info(pathname);
1293 info = parse_init_info(info_text, script);
1294 if (info) {
1295 char *env;
1296 char *levels;
1297
1298 result = EXIT_SUCCESS;
1299 bb_xasprintf(&env, "runlevel_%s", script);
1300 levels = getenv(env);
1301 if (levels)
1302 print_levels(script, levels, verbose);
1303 else {
1304 int k;
1305 RESERVE_CONFIG_BUFFER(temp, PATH_MAX);
1306
1307 temp[0] = '\0';
1308 if (info->defstart != NULL) {
1309 for (k = 0; k < info->sizes[5]; k++)
1310 snprintf(temp, PATH_MAX, "%s%d ", temp, info->defstart[k]);
1311 }
1312
1313 print_levels(script, temp, verbose);
1314
1315 RELEASE_CONFIG_BUFFER(temp);
1316 }
1317 }
1318
1319 free(info);
1320 free(info_text);
1321 free(pathname);
1322
1323 return result;
1324}
1325
1326
1327static int edit_run_levels(char *script, char *levels, int verbose)
1328{
1329 int result = 0;
1330bb_printf("CHANGE levels for %s to %s\n", script, levels);
1331 return result;
1239} 1332}
1240 1333
1241 1334
@@ -1243,29 +1336,69 @@ int run_level(char *level)
1243 * rc 1336 * rc
1244 * rc 1 1337 * rc 1
1245 * rc network start 1338 * rc network start
1246 * rc network --runlevels 1339 * rc network -l
1247 * rc network --runlevels -v 1340 * rc network -lv
1248 * rc network --runlevels 3 4 5 1341 * rc network -l 3 4 5
1249 */ 1342 */
1250 1343
1251int rc_main(int argc, char **argv) 1344int rc_main(int argc, char **argv)
1252{ 1345{
1253 switch (argc) 1346 int opt;
1254 { 1347 int levels = 0, verbose = 0;
1255 case 0 : 1348
1256 case 1 : 1349 while ((opt = getopt(argc, argv, "lv")) > 0) {
1257 { 1350 switch (opt) {
1258 return run_level(quick_read("/etc/runlevel")); 1351 case 'l':
1352 levels = 1;
1353 break;
1354
1355 case 'v':
1356 verbose = 1;
1357 break;
1358
1359 default:
1360 bb_show_usage();
1361 }
1259 } 1362 }
1260 case 2 : return run_level(argv[1]); 1363
1261 case 3 : 1364 read_sysconfig("/etc/runlevels.conf");
1262 { 1365 argc -= optind - 1;
1366 argv += optind - 1;
1367
1368 if (levels) {
1369 switch (argc) {
1370 case 0:
1371 case 1:
1372 {
1373 return INIT_D_ERROR_NOT_IMPLEMENTED;
1374 }
1375 case 2:
1376 {
1377 return show_run_levels(argv[1], verbose);
1378 }
1379 default:
1380 {
1381 return edit_run_levels(argv[1], argv_cat(argc - 1, &argv[1]), verbose);
1382 }
1383 }
1384 } else {
1385 switch (argc) {
1386 case 0:
1387 case 1:
1388 {
1389 return run_level(quick_read("/etc/runlevel"));
1390 }
1391 case 2:
1392 return run_level(argv[1]);
1393 case 3:
1394 {
1263// Should take care of dependencies for argv[1] script. 1395// Should take care of dependencies for argv[1] script.
1264 return init_script(argv[1], argv[2]); 1396 return init_script(argv[1], argv[2]);
1265 } 1397 }
1266 default : 1398 default:
1267 { 1399 {
1268 return INIT_D_ERROR_NOT_IMPLEMENTED; 1400 return INIT_D_ERROR_NOT_IMPLEMENTED;
1401 }
1402 }
1269 } 1403 }
1270 }
1271} 1404}
diff --git a/urunlevel/runlevel/remote_fs.c b/urunlevel/runlevel/remote_fs.c
index 6da11f5..ab659a4 100644
--- a/urunlevel/runlevel/remote_fs.c
+++ b/urunlevel/runlevel/remote_fs.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -31,53 +34,51 @@ static int status(struct init_d_handle_s *, int);
31static int stop(struct init_d_handle_s *, int); 34static int stop(struct init_d_handle_s *, int);
32 35
33 36
34static init_d_handle_t my_commands = 37static init_d_handle_t my_commands = {
35{ 38 &start,
36 &start, 39 &stop,
37 &stop, 40 NULL,
38 NULL, 41 NULL,
39 NULL, 42 &no_reload,
40 &no_reload, 43 NULL,
41 NULL, 44 &status,
42 &status, 45 NULL,
43 NULL, 46 "remote_fs",
44 "remote_fs", 47 NULL,
45 NULL, 48 NULL,
46 NULL, 49 NULL,
47 NULL, 50 INIT_D_BEGIN
48 INIT_D_BEGIN \ 51 INIT_D_PROV "$remote_fs"
49 INIT_D_PROV "$remote_fs" \ 52 INIT_D_RSTART "$network"
50 INIT_D_RSTART "$network" \ 53 INIT_D_SSTART "nfs smbfs codafs"
51 INIT_D_SSTART "nfs smbfs codafs" \ 54 INIT_D_DSTART "3 4 5"
52 INIT_D_DSTART "3 4 5" \ 55 INIT_D_DSTOP "0 1 2 6"
53 INIT_D_DSTOP "0 1 2 6" \ 56 INIT_D_SDESC "Mount all remote file systems."
54 INIT_D_SDESC "Mount all remote file systems." \ 57 INIT_D_DESC "Mount all remote file systems. Actually, this is just a"
55 INIT_D_DESC "Mount all remote file systems. Actually, this is just a" \ 58 INIT_D_CONT "dummy that depends on all the init scripts that could"
56 INIT_D_CONT "dummy that depends on all the init scripts that could" \ 59 INIT_D_CONT "possibly mount remote file systems." INIT_D_END
57 INIT_D_CONT "possibly mount remote file systems." \
58 INIT_D_END
59}; 60};
60 61
61 62
62int remote_fs_main(int argc, char **argv) 63int remote_fs_main(int argc, char **argv)
63{ 64{
64 return do_init_from_main(argc, argv, &my_commands); 65 return do_init_from_main(argc, argv, &my_commands);
65} 66}
66 67
67 68
68static int start(struct init_d_handle_s *init_d, int just_checking) 69static int start(struct init_d_handle_s *init_d, int just_checking)
69{ 70{
70 return INIT_D_OK; 71 return INIT_D_OK;
71} 72}
72 73
73 74
74static int status(struct init_d_handle_s *init_d, int quiet) 75static int status(struct init_d_handle_s *init_d, int quiet)
75{ 76{
76 return print_status(init_d, quiet, INIT_D_STATUS_OK); 77 return print_status(init_d, quiet, INIT_D_STATUS_OK);
77} 78}
78 79
79 80
80static int stop(struct init_d_handle_s *init_d, int just_checking) 81static int stop(struct init_d_handle_s *init_d, int just_checking)
81{ 82{
82 return INIT_D_OK; 83 return INIT_D_OK;
83} 84}
diff --git a/urunlevel/runlevel/remove_initd.c b/urunlevel/runlevel/remove_initd.c
index 1224b03..1adda10 100644
--- a/urunlevel/runlevel/remove_initd.c
+++ b/urunlevel/runlevel/remove_initd.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -20,6 +23,7 @@
20 * 23 *
21 */ 24 */
22 25
26#include <string.h>
23#include <unistd.h> 27#include <unistd.h>
24 28
25#include "busybox.h" 29#include "busybox.h"
@@ -28,11 +32,103 @@
28 32
29int remove_initd_main(int argc, char **argv) 33int remove_initd_main(int argc, char **argv)
30{ 34{
31 llist_t *sorted = NULL; 35 int result = EXIT_FAILURE;
32 llist_t *unsorted = get_scripts(); 36
37 argv += optind;
38 if (!*argv)
39 bb_show_usage();
40 else {
41 int in_init = 0;
42 llist_t *current = NULL;
43 llist_t *previous = NULL;
44 llist_t *unsorted = get_scripts();
45 init_d_info_t *info = NULL;
46 char *info_text = NULL;
47 char *pathname = NULL;
48 RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
49
50 bb_xasprintf(&pathname, "%s", *argv);
51 if ((*argv)[0] != '/') {
52 char *cwd = xgetcwd(NULL);
53
54 if (cwd) {
55 free(pathname);
56 bb_xasprintf(&pathname, "%s/%s", cwd, *argv);
57 }
58 }
59
60 if (realpath(pathname, resolved_path) != NULL) {
61 if (strncmp("/etc/init.d/", resolved_path, 12) == 0)
62 in_init = 1;
63 } else {
64 bb_perror_msg("%s", pathname);
65 }
66
67 info_text = get_init_info(pathname);
68 info = parse_init_info(info_text, bb_get_last_path_component(pathname));
69
70 current = unsorted;
71 while (current) {
72 init_d_info_t *this_one = (init_d_info_t *) current->data;
73
74 if (strcmp(this_one->path, info->path) == 0) {
75 current = llist_delete(&unsorted, previous, current);
76 break;
77 }
78 previous = current;
79 current = current->link;
80 }
81
82 sort_scripts(unsorted, NULL);
83 result = EXIT_SUCCESS;
84 current = unsorted;
85 while (current) {
86 int k;
87 init_d_info_t *this_one = (init_d_info_t *) current->data;
88
89 if (this_one) {
90 for (k = 0; k < info->sizes[0]; k++) {
91 int i;
92
93 for (i = 0; i < this_one->sizes[1]; i++) {
94 if (strcmp(this_one->reqstart[i], info->provides[k]) == 0) {
95 result = EXIT_FAILURE;
96 bb_error_msg("%s is required by %s.", pathname, this_one->path);
97 break;
98 }
99 }
100 if (result == EXIT_FAILURE)
101 break;
102 }
103 }
104
105 current = current->link;
106 }
107
108 /* This is not LSB compliant, the LSB package manager is supposed to remove it, but...
109 * We may have created it, so we should remove it.
110 * LSB says that init.d scripts are "configuration files", I disagree, they are executables.
111 * LSB further says that config files are left behind after package removal. This is a
112 * contradiction with "package manager is supposed to remove it".
113 *
114 * Safest thing to do is zap it.
115 */
116 if ((in_init) && (result == EXIT_SUCCESS)) {
117 free(info_text);
118 bb_xasprintf(&info_text, "/etc/init.d/%s", bb_get_last_path_component(pathname));
119 remove_file(info_text, FILEUTILS_FORCE);
120 }
121
122 if (result == EXIT_FAILURE)
123 bb_error_msg("Unable to remove the %s init.d script.", pathname);
124
125#ifdef CONFIG_FEATURE_CLEAN_UP
126 RELEASE_CONFIG_BUFFER(resolved_path);
127#endif
128 free(info);
129 free(pathname);
130 free(info_text);
131 }
33 132
34// Should remove this script from unsorted. 133 return result;
35 sorted = sort_scripts(unsorted);
36// Should return 1 if there are unsatisfied dependencies if this is removed.
37 return EXIT_SUCCESS;
38} 134}
diff --git a/urunlevel/runlevel/runlevel.patch b/urunlevel/runlevel/runlevel.patch
new file mode 100644
index 0000000..c000944
--- /dev/null
+++ b/urunlevel/runlevel/runlevel.patch
@@ -0,0 +1,533 @@
1diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/Makefile busybox-1.00/Makefile
2--- busybox-1.00-original/Makefile 2004-10-08 17:45:08.000000000 +1000
3+++ busybox-1.00/Makefile 2005-03-12 00:58:35.000000000 +1000
4@@ -40,9 +40,9 @@
5 include $(top_builddir)/Rules.mak
6
7 DIRS:=applets archival archival/libunarchive coreutils console-tools \
8- debianutils editors findutils init miscutils modutils networking \
9+ debianutils editors findutils init miscutils modutils my_linux networking \
10 networking/libiproute networking/udhcp procps loginutils shell \
11- sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
12+ sysklogd runlevel util-linux libpwdgrp coreutils/libcoreutils libbb
13
14 SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
15
16diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/include/applets.h busybox-1.00/include/applets.h
17--- busybox-1.00-original/include/applets.h 2004-08-27 09:01:34.000000000 +1000
18+++ busybox-1.00/include/applets.h 2005-03-14 09:37:26.000000000 +1000
19@@ -75,6 +75,18 @@
20 #ifdef CONFIG_BASENAME
21 APPLET(basename, basename_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
22 #endif
23+#ifdef CONFIG_BOOT_NAMED
24+ APPLET(boot_named, boot_named_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
25+#endif
26+#ifdef CONFIG_BOOT_PORTMAP
27+ APPLET(boot_portmap, boot_portmap_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
28+#endif
29+#ifdef CONFIG_BOOT_SYSLOG
30+ APPLET(boot_syslog, boot_syslog_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
31+#endif
32+#ifdef CONFIG_BOOT_TIME
33+ APPLET(boot_time, boot_time_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
34+#endif
35 #ifdef CONFIG_BUNZIP2
36 APPLET(bunzip2, bunzip2_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
37 #endif
38@@ -226,6 +238,9 @@
39 #ifdef CONFIG_GETOPT
40 APPLET(getopt, getopt_main, _BB_DIR_BIN, _BB_SUID_NEVER)
41 #endif
42+#ifdef CONFIG_GETPKG
43+ APPLET(getpkg, getpkg_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
44+#endif
45 #ifdef CONFIG_GETTY
46 APPLET(getty, getty_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
47 #endif
48@@ -289,6 +304,9 @@
49 #ifdef CONFIG_INSTALL
50 APPLET(install, install_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
51 #endif
52+#ifdef CONFIG_INSTALL_INITD
53+ APPLET(install_initd, install_initd_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
54+#endif
55 #ifdef CONFIG_IP
56 APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER)
57 #endif
58@@ -313,6 +331,9 @@
59 #ifdef CONFIG_KILLALL
60 APPLET(killall, kill_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
61 #endif
62+#ifdef CONFIG_KILLPROC
63+ APPLET(killproc, killproc_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
64+#endif
65 #ifdef CONFIG_KLOGD
66 APPLET(klogd, klogd_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
67 #endif
68@@ -328,6 +349,9 @@
69 #ifdef CONFIG_FEATURE_INITRD
70 APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT, _BB_SUID_NEVER)
71 #endif
72+#ifdef CONFIG_LINUXRC
73+ APPLET(linuxrc, linuxrc_main, _BB_DIR_ROOT, _BB_SUID_NEVER)
74+#endif
75 #ifdef CONFIG_LN
76 APPLET(ln, ln_main, _BB_DIR_BIN, _BB_SUID_NEVER)
77 #endif
78@@ -337,6 +361,18 @@
79 #ifdef CONFIG_LOADKMAP
80 APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
81 #endif
82+#ifdef CONFIG_LOCAL_FS
83+ APPLET(local_fs, local_fs_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
84+#endif
85+#ifdef CONFIG_LOG_FAILURE_MSG
86+ APPLET(log_failure_msg, log_failure_msg_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
87+#endif
88+#ifdef CONFIG_LOG_SUCCESS_MSG
89+ APPLET(log_success_msg, log_success_msg_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
90+#endif
91+#ifdef CONFIG_LOG_WARNING_MSG
92+ APPLET(log_warning_msg, log_warning_msg_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
93+#endif
94 #ifdef CONFIG_LOGGER
95 APPLET(logger, logger_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
96 #endif
97@@ -361,6 +397,9 @@
98 #ifdef CONFIG_MAKEDEVS
99 APPLET(makedevs, makedevs_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
100 #endif
101+#ifdef CONFIG_MAN
102+ APPLET(man, man_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
103+#endif
104 #ifdef CONFIG_MD5SUM
105 APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
106 #endif
107@@ -379,6 +418,9 @@
108 #ifdef CONFIG_MKNOD
109 APPLET(mknod, mknod_main, _BB_DIR_BIN, _BB_SUID_NEVER)
110 #endif
111+#ifdef CONFIG_MKROOTFS
112+ APPLET(mkrootfs, mkrootfs_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
113+#endif
114 #ifdef CONFIG_MKSWAP
115 APPLET(mkswap, mkswap_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
116 #endif
117@@ -412,6 +454,9 @@
118 #ifdef CONFIG_NETSTAT
119 APPLET(netstat, netstat_main, _BB_DIR_BIN, _BB_SUID_NEVER)
120 #endif
121+#ifdef CONFIG_NETWORK
122+ APPLET(network, network_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
123+#endif
124 #ifdef CONFIG_NSLOOKUP
125 APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
126 #endif
127@@ -430,6 +475,9 @@
128 #ifdef CONFIG_PIDOF
129 APPLET(pidof, pidof_main, _BB_DIR_BIN, _BB_SUID_NEVER)
130 #endif
131+#ifdef CONFIG_PIDOFPROC
132+ APPLET(pidofproc, pidofproc_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
133+#endif
134 #ifdef CONFIG_PING
135 APPLET(ping, ping_main, _BB_DIR_BIN, _BB_SUID_MAYBE)
136 #endif
137@@ -454,6 +502,12 @@
138 #ifdef CONFIG_PWD
139 APPLET(pwd, pwd_main, _BB_DIR_BIN, _BB_SUID_NEVER)
140 #endif
141+#ifdef CONFIG_RC
142+ APPLET(rc, rc_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
143+#endif
144+#ifdef CONFIG_RCS
145+ APPLET(rcS, rcS_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
146+#endif
147 #ifdef CONFIG_RDATE
148 APPLET(rdate, rdate_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
149 #endif
150@@ -466,6 +520,12 @@
151 #ifdef CONFIG_REBOOT
152 APPLET(reboot, reboot_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
153 #endif
154+#ifdef CONFIG_REMOTE_FS
155+ APPLET(remote_fs, remote_fs_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
156+#endif
157+#ifdef CONFIG_REMOVE_INITD
158+ APPLET(remove_initd, remove_initd_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
159+#endif
160 #ifdef CONFIG_RENICE
161 APPLET(renice, renice_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
162 #endif
163@@ -526,6 +586,9 @@
164 #ifdef CONFIG_START_STOP_DAEMON
165 APPLET_ODDNAME("start-stop-daemon", start_stop_daemon_main, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon)
166 #endif
167+#ifdef CONFIG_START_DAEMON
168+ APPLET(start_daemon, start_daemon_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
169+#endif
170 #ifdef CONFIG_STRINGS
171 APPLET(strings, strings_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
172 #endif
173@@ -598,6 +661,9 @@
174 #ifdef CONFIG_UDHCPC
175 APPLET(udhcpc, udhcpc_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
176 #endif
177+#ifdef CONFIG_UDHCPC_SCRIPT
178+ APPLET(udhcpc_script, udhcpc_script_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
179+#endif
180 #ifdef CONFIG_UDHCPD
181 APPLET(udhcpd, udhcpd_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
182 #endif
183diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/include/usage.h busybox-1.00/include/usage.h
184--- busybox-1.00-original/include/usage.h 2004-09-15 02:23:56.000000000 +1000
185+++ busybox-1.00/include/usage.h 2005-03-14 09:37:34.000000000 +1000
186@@ -89,6 +89,43 @@
187 "$ basename /foo/bar.txt .txt\n" \
188 "bar"
189
190+
191+#define boot_named_trivial_usage \
192+ "start | stop | restart | try-restart | reload | force-reload | status | info"
193+#define boot_named_full_usage \
194+ "LSB compliant named init.d script."
195+#define boot_named_example_usage \
196+ "$ boot_named start\n" \
197+ "Start boot_named ... OK\n"
198+
199+
200+#define boot_portmap_trivial_usage \
201+ "start | stop | restart | try-restart | reload | force-reload | status | info"
202+#define boot_portmap_full_usage \
203+ "LSB compliant portmap init.d script."
204+#define boot_portmap_example_usage \
205+ "$ boot_portmap start\n" \
206+ "Start boot_portmap ... OK\n"
207+
208+
209+#define boot_syslog_trivial_usage \
210+ "start | stop | restart | try-restart | reload | force-reload | status | info"
211+#define boot_syslog_full_usage \
212+ "LSB compliant syslog init.d script."
213+#define boot_syslog_example_usage \
214+ "$ boot_syslog start\n" \
215+ "Start boot_syslog ... OK\n"
216+
217+
218+#define boot_time_trivial_usage \
219+ "start | stop | restart | try-restart | reload | force-reload | status | info"
220+#define boot_time_full_usage \
221+ "LSB compliant time init.d script."
222+#define boot_time_example_usage \
223+ "$ boot_time start\n" \
224+ "Start boot_time ... OK\n"
225+
226+
227 #define bunzip2_trivial_usage \
228 "[OPTION]... [FILE]"
229 #define bunzip2_full_usage \
230@@ -768,6 +805,23 @@
231 " esac\n" \
232 "done\n"
233
234+
235+#define getpkg_trivial_usage \
236+ "[-afk] [PACKAGE] {[URL] | [DIR]}"
237+#define getpkg_full_usage \
238+ "Install a Trinux PACKAGE from a FILE or an URL ." \
239+ "\t-a,\t\tget all packages\n" \
240+ "\t-f,\t\tpackage file, no need to download\n" \
241+ "\t-k,\t\tkernel package"
242+#define getpkg_example_usage \
243+ "$ getpkg\n" \
244+ "$ getpkg -a\n" \
245+ "$ getpkg -f name\n" \
246+ "$ getpkg -fk name /media/cdrom/trinux/pkg\n" \
247+ "$ getpkg -k name\n" \
248+ "$ getpkg name http://www.trinux.org/pkg/\n"
249+
250+
251 #define getty_trivial_usage \
252 "[OPTIONS]... baud_rate,... line [termtype]"
253 #define getty_full_usage \
254@@ -1299,6 +1353,15 @@
255 "\t-p\tpreserve date\n" \
256 "\t-s\tstrip symbol tables"
257
258+
259+#define install_initd_trivial_usage \
260+ "FILE"
261+#define install_initd_full_usage \
262+ "LSB compliant install_initd init.d script installer."
263+#define install_initd_example_usage \
264+ "$ install_initd /etc/init.d/init_script\n"
265+
266+
267 #define ip_trivial_usage \
268 "[ OPTIONS ] { address | link | route | tunnel } { COMMAND | help }"
269 #define ip_full_usage \
270@@ -1391,6 +1454,16 @@
271 #define killall_example_usage \
272 "$ killall apache\n"
273
274+#define killproc_trivial_usage \
275+ "[OPTION] COMMAND [SIGNAL]"
276+#define killproc_full_usage \
277+ "LSB compliant killproc daemon killer." \
278+ "\n\nOptions:"\
279+ "\n\t-p <pid-file>\t\t\tload pid using a pid-file"
280+#define killproc_example_usage \
281+ "$ killproc daemon_proggy\n"
282+
283+
284 #define klogd_trivial_usage \
285 "[-c n] [-n]"
286 #define klogd_full_usage \
287@@ -1407,6 +1480,14 @@
288 "$ length Hello\n" \
289 "5\n"
290
291+#define linuxrc_trivial_usage \
292+ ""
293+#define linuxrc_full_usage \
294+ "linuxrc pre boot."
295+#define linuxrc_example_usage \
296+ "$ linuxrc\n"
297+
298+
299 #define ln_trivial_usage \
300 "[OPTION] TARGET... LINK_NAME|DIRECTORY"
301 #define ln_full_usage \
302@@ -1435,6 +1516,39 @@
303 #define loadkmap_example_usage \
304 "$ loadkmap < /etc/i18n/lang-keymap\n"
305
306+#define local_fs_trivial_usage \
307+ "start | stop | restart | try-restart | reload | force-reload | status | info"
308+#define local_fs_full_usage \
309+ "LSB compliant local_fs init.d script."
310+#define local_fs_example_usage \
311+ "$ local_fs start\n" \
312+ "Start local_fs ... OK\n"
313+
314+
315+#define log_failure_msg_trivial_usage \
316+ "MESSAGE"
317+#define log_failure_msg_full_usage \
318+ "LSB compliant log_failure_msg."
319+#define log_failure_msg_example_usage \
320+ "$ log_failure_msg "It be broke!"\n"
321+
322+
323+#define log_success_msg_trivial_usage \
324+ "MESSAGE"
325+#define log_success_msg_full_usage \
326+ "LSB compliant log_success_msg."
327+#define log_success_msg_example_usage \
328+ "$ log_success_msg "It worked."\n"
329+
330+
331+#define log_warning_msg_trivial_usage \
332+ "MESSAGE"
333+#define log_warning_msg_full_usage \
334+ "LSB compliant log_warning_msg."
335+#define log_warning_msg_example_usage \
336+ "$ log_warning_msg "It might be broke."\n"
337+
338+
339 #define logger_trivial_usage \
340 "[OPTION]... [MESSAGE]"
341 #define logger_full_usage \
342@@ -1570,6 +1684,14 @@
343 "# makedevs /dev/hda b 3 0 0 8 s\n" \
344 "[creates hda,hda1-hda8]\n"
345
346+#define man_trivial_usage \
347+ "[NAME]"
348+#define man_full_usage \
349+ "Show documentation for Trinux software."
350+#define man_example_usage \
351+ "$ man basics\n"
352+
353+
354 #ifdef CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
355 #define USAGE_MD5_SHA1_SUM_CHECK(a) a
356 #else
357@@ -1652,6 +1774,15 @@
358 "$ mknod /dev/fd0 b 2 0\n" \
359 "$ mknod -m 644 /tmp/pipe p\n"
360
361+
362+#define mkrootfs_trivial_usage \
363+ "[-c filename] [PATH]"
364+#define mkrootfs_full_usage \
365+ "Creates all the directories, devices, files, and links needed for a root file system."
366+#define mkrootfs_example_usage \
367+ "$ mkrootfs /\n"
368+
369+
370 #define mkswap_trivial_usage \
371 "[-c] [-v0|-v1] device [block-count]"
372 #define mkswap_full_usage \
373@@ -1813,6 +1944,16 @@
374 "\t-w raw sockets\n" \
375 "\t-x unix sockets"
376
377+
378+#define network_trivial_usage \
379+ "start | stop | restart | try-restart | reload | force-reload | status | info"
380+#define network_full_usage \
381+ "LSB compliant network init.d script."
382+#define network_example_usage \
383+ "$ network start\n" \
384+ "Start network ... OK\n"
385+
386+
387 #define nslookup_trivial_usage \
388 "[HOST] [SERVER]"
389 #define nslookup_full_usage \
390@@ -1875,6 +2016,16 @@
391 "$ pidof init\n" \
392 "1\n"
393
394+#define pidofproc_trivial_usage \
395+ "[OPTION] COMMAND"
396+#define pidofproc_full_usage \
397+ "LSB compliant pidofproc daemon checker." \
398+ "\n\nOptions:"\
399+ "\n\t-p <pid-file>\t\t\tsave or load pid using a pid-file"
400+#define pidofproc_example_usage \
401+ "$ pidofproc daemon_proggy\n"
402+
403+
404 #ifndef CONFIG_FEATURE_FANCY_PING
405 #define ping_trivial_usage "host"
406 #define ping_full_usage "Send ICMP ECHO_REQUEST packets to network hosts"
407@@ -1977,6 +2128,33 @@
408 "$ pwd\n" \
409 "/root\n"
410
411+#define rc_trivial_usage \
412+ "[RUNLEVEL] | COMMAND [start | stop | restart | try-restart | reload | force-reload | status | info] [OPTIONS]"
413+#define rc_full_usage \
414+ "LSB compliant runlevel controller."
415+#define rc_example_usage \
416+ "$ rc\n" \
417+ "$ rc 5\n" \
418+ "$ rc network start\n" \
419+ "Start network ... OK\n" \
420+ "$ rc network --runlevels\n" \
421+ "3 4 5\n" \
422+ "$ rc network --runlevels -v\n" \
423+ "The \"network\" service will be active during these runlevels :\n" \
424+ "3 - multi user with network.\n" \
425+ "4 - multi user with network and twin.\n" \
426+ "5 - multi user with networkand X.\n" \
427+ "$ rc network --runlevels 3 4 5\n"
428+
429+
430+#define rcS_trivial_usage \
431+ ""
432+#define rcS_full_usage \
433+ "sysinit for inittab."
434+#define rcS_example_usage \
435+ "$ rcS\n"
436+
437+
438 #define rdate_trivial_usage \
439 "[-sp] HOST"
440 #define rdate_full_usage \
441@@ -2002,6 +2180,23 @@
442 "Options:\n" \
443 "\t-d\t\tdelay interval for rebooting."
444
445+#define remote_fs_trivial_usage \
446+ "start | stop | restart | try-restart | reload | force-reload | status | info"
447+#define remote_fs_full_usage \
448+ "LSB compliant remote_fs init.d script."
449+#define remote_fs_example_usage \
450+ "$ remote_fs start\n" \
451+ "Start remote_fs ... OK\n"
452+
453+
454+#define remove_initd_trivial_usage \
455+ "FILE"
456+#define remove_initd_full_usage \
457+ "LSB compliant remove_initd init.d script removal."
458+#define remove_initd_example_usage \
459+ "$ remove_initd /etc/init.d/init_script\n"
460+
461+
462 #define renice_trivial_usage \
463 "priority pid [pid ...]"
464 #define renice_full_usage \
465@@ -2212,6 +2407,18 @@
466 "e\n" \
467 "f\n"
468
469+#define start_daemon_trivial_usage \
470+ "[OPTIONS]... COMMAND [ARGS...]"
471+#define start_daemon_full_usage \
472+ "LSB compliant start_daemon daemon starter."\
473+ "\n\nOptions:"\
474+ "\n\t-f\t\t\tforce a start if already running"\
475+ "\n\t-n <nicelevel>\t\t\tnice level"\
476+ "\n\t-p <pid-file>\t\t\tsave or load pid using a pid-file"
477+#define start_daemon_example_usage \
478+ "$ start_daemon -p /var/run/daemon_proggy.pid daemon_proggy --foo blah\n"
479+
480+
481 #define start_stop_daemon_trivial_usage \
482 "[OPTIONS] [--start|--stop] ... [-- arguments...]\n"
483 #define start_stop_daemon_full_usage \
484@@ -2625,6 +2832,11 @@
485 "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
486 "\t-v,\t--version\tDisplay version"
487
488+#define udhcpc_script_trivial_usage \
489+ "[ACTION]"
490+#define udhcpc_script_full_usage \
491+ "Should only be called by udhcpc."
492+
493 #define udhcpd_trivial_usage \
494 "[configfile]\n" \
495
496diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/networking/udhcp/dhcpc.h busybox-1.00/networking/udhcp/dhcpc.h
497--- busybox-1.00-original/networking/udhcp/dhcpc.h 2004-01-31 09:45:12.000000000 +1000
498+++ busybox-1.00/networking/udhcp/dhcpc.h 2005-03-12 04:12:30.000000000 +1000
499@@ -2,7 +2,8 @@
500 #ifndef _DHCPC_H
501 #define _DHCPC_H
502
503-#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
504+//#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
505+#define DEFAULT_SCRIPT "/sbin/udhcpc_script"
506
507 /* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */
508 #include "libbb_udhcp.h"
509diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/networking/udhcp/libbb_udhcp.h busybox-1.00/networking/udhcp/libbb_udhcp.h
510--- busybox-1.00-original/networking/udhcp/libbb_udhcp.h 2004-05-19 19:18:04.000000000 +1000
511+++ busybox-1.00/networking/udhcp/libbb_udhcp.h 2005-03-12 04:07:27.000000000 +1000
512@@ -5,7 +5,8 @@
513
514 #ifdef CONFIG_INSTALL_NO_USR
515 #undef DEFAULT_SCRIPT
516-#define DEFAULT_SCRIPT "/share/udhcpc/default.script"
517+//#define DEFAULT_SCRIPT "/share/udhcpc/default.script"
518+#define DEFAULT_SCRIPT "/sbin/udhcpc_script"
519 #endif
520
521 #ifndef _LIBBB_UDHCP_H
522diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/sysdeps/linux/Config.in busybox-1.00/sysdeps/linux/Config.in
523--- busybox-1.00-original/sysdeps/linux/Config.in 2004-05-25 21:30:22.000000000 +1000
524+++ busybox-1.00/sysdeps/linux/Config.in 2005-03-12 00:47:43.000000000 +1000
525@@ -223,6 +223,8 @@
526 source debianutils/Config.in
527 source editors/Config.in
528 source findutils/Config.in
529+source my_linux/Config.in
530+source runlevel/Config.in
531 source init/Config.in
532 source loginutils/Config.in
533 source miscutils/Config.in
diff --git a/urunlevel/runlevel/runlevels.conf b/urunlevel/runlevel/runlevels.conf
new file mode 100644
index 0000000..87afe22
--- /dev/null
+++ b/urunlevel/runlevel/runlevels.conf
@@ -0,0 +1,17 @@
1runlevel="3"
2
3runlevel_0="halt."
4runlevel_1="single user."
5runlevel_2="multi user with no network."
6runlevel_3="multi user with network."
7runlevel_4="multi user with network and twin."
8runlevel_5="multi user with network and X."
9runlevel_6="reboot."
10runlevel_7="multi user with network and ggi, DirectFB, or SDL."
11runlevel_8="multi user with network and 3D."
12runlevel_9="node for cluster, render farm, or compile farm."
13
14#runlevel_local_fs="1 2 3 4 5"
15#runlevel_network="3 4 5"
16#runlevel_script1="2 3 5"
17#runlevel_script1="3 5"
diff --git a/urunlevel/runlevel/start_daemon.c b/urunlevel/runlevel/start_daemon.c
index ba922fa..6bd0b2f 100644
--- a/urunlevel/runlevel/start_daemon.c
+++ b/urunlevel/runlevel/start_daemon.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Clean room implementation of LSB init.d specs.
7 * I didn't steal any of this, honest B-).
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -31,40 +34,39 @@
31#include "lib_init_d.h" 34#include "lib_init_d.h"
32 35
33 36
34int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args) 37int start_daemon(int force, int nice_level, char *pidfile, char *pathname,
38 char *args)
35{ 39{
36 int status = 0; 40 int status = pidofproc(pidfile, pathname, NULL);
37 status = pidofproc(pidfile, pathname, NULL); 41
38 42 if ((status != INIT_D_STATUS_OK) || (force)) {
39 if ((status != INIT_D_STATUS_OK) || (force)) 43 char *pids = NULL;
40 { 44 char *strtok_temp;
41 char *pids = NULL; 45
42 char *strtok_temp; 46 doit(DAEMON, "start-stop-daemon -Sbmp %s -x %s -- %s", pidfile,
43 47 pathname, args);
44 doit(DAEMON, "start-stop-daemon -Sbmp %s -x %s -- %s", pidfile, pathname, args); 48// Should poll /proc/pid/... instead
45sleep(1); 49 sleep(1);
46 status = pidofproc(pidfile, pathname, &pids); 50 status = pidofproc(pidfile, pathname, &pids);
47 if ((status == INIT_D_STATUS_OK) && (nice_level)) 51 if ((status == INIT_D_STATUS_OK) && (nice_level)) {
48 { 52 int i;
49 int i; 53 char *pid;
50 char *pid; 54
51 55 pid = strtok_r(pids, " ", &strtok_temp);
52 pid = strtok_r(pids, " ", &strtok_temp); 56 for (i = 0; pid != NULL; i++) {
53 for (i = 0; pid != NULL; i++) 57 int ps = atoi(pid);
54 { 58 int oldp;
55 int ps = atoi(pid); 59
56 int oldp; 60 errno = 0;
57 61 oldp = getpriority(PRIO_PROCESS, ps);
58 errno = 0; 62 if (errno == 0)
59 oldp = getpriority(PRIO_PROCESS, ps); 63 setpriority(PRIO_PROCESS, ps, oldp + nice_level);
60 if (errno == 0) 64 pid = strtok_r(NULL, " ", &strtok_temp);
61 setpriority(PRIO_PROCESS, ps, oldp + nice_level); 65 }
62 pid = strtok_r(NULL, " ", &strtok_temp); 66 }
63 }
64 } 67 }
65 }
66 68
67 return status; 69 return status;
68} 70}
69 71
70 72
@@ -83,71 +85,63 @@ start_daemon [-f] [-n nicelevel] [-p pidfile] pathname [args]
83*/ 85*/
84 86
85 87
88 /* getopt not used, because I don't think it can handle [args] */
86int start_daemon_main(int argc, char **argv) 89int start_daemon_main(int argc, char **argv)
87{ 90{
88 int result = EXIT_FAILURE; 91 int result = EXIT_FAILURE;
89 int force = 0; 92 int force = 0;
90 int nice_level = 0; 93 int nice_level = 0;
91 char *pidfile = NULL; 94 char *pidfile = NULL;
92 char *pathname = NULL; 95 char *pathname = NULL;
93 char *args = NULL; 96 char *args = NULL;
94 int i; 97 int i;
95 98
96 for (i = 1; i < argc; i++) 99 for (i = 1; i < argc; i++) {
97 { 100 char *p = argv[i];
98 char *p = argv[i]; 101
99 102 if (*p == '-') {
100 if (*p == '-') 103 while (*(++p)) {
101 { 104 switch (*p) {
102 while (*(++p)) 105 case 'f':
103 { 106 force = 1;
104 switch (*p) 107 break;
105 { 108
106 case 'f' : 109 case 'n':
107 force = 1; 110 if ((++i) < argc)
108 break; 111 nice_level = atoi(argv[i]);
109 112 else
110 case 'n' : 113 bb_show_usage();
111 if ((++i) < argc) 114 break;
112 nice_level = atoi(argv[i]); 115
113 else 116 case 'p':
114 bb_show_usage(); 117 if ((++i) < argc)
115 break; 118 pidfile = argv[i];
116 119 else
117 case 'p' : 120 bb_show_usage();
118 if ((++i) < argc) 121 break;
119 pidfile = argv[i]; 122
120 else 123 default:
121 bb_show_usage(); 124 bb_show_usage();
125 }
126 }
127 } else if (pathname == NULL) {
128 pathname = p;
122 break; 129 break;
123 130 } else
124 default:
125 bb_show_usage(); 131 bb_show_usage();
126 }
127 }
128 }
129 else if (pathname == NULL)
130 {
131 pathname = p;
132 break;
133 } 132 }
134 else
135 bb_show_usage();
136 }
137 133
138 if (pathname == NULL) 134 if (pathname == NULL)
139 bb_show_usage(); 135 bb_show_usage();
140 136
141 if (i < argc) 137 if (i < argc)
142 args = argv_cat(argc - i, &argv[i]); 138 args = argv_cat(argc - i, &argv[i]);
143 139
144//bb_printf("ARGS - |%s|%s|%d|%d|%s\n", pidfile, pathname, force, nice_level, args); 140//bb_printf("ARGS - |%s|%s|%d|%d|%s\n", pidfile, pathname, force, nice_level, args);
145 result = start_daemon(force, nice_level, pidfile, pathname, args); 141 result = start_daemon(force, nice_level, pidfile, pathname, args);
146 142
147 if (args != NULL) 143 if (args != NULL)
148 free(args); 144 free(args);
149 145
150 return result; 146 return result;
151} 147}
152
153
diff --git a/urunlevel/runlevel/sysconfig/cron b/urunlevel/runlevel/sysconfig/cron
new file mode 100644
index 0000000..f5edf96
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/cron
@@ -0,0 +1,98 @@
1## Path: System/Cron
2## Description: days to keep old files in tmp-dirs, 0 to disable
3## Type: integer
4## Default: 0
5## Config:
6#
7# cron.daily can check for old files in tmp-dirs. It will delete all files
8# not accessed for more than MAX_DAYS_IN_TMP. If MAX_DAYS_IN_TMP is not set
9# or set to 0, this feature will be disabled.
10#
11MAX_DAYS_IN_TMP="7"
12
13## Type: integer
14## Default: 0
15#
16# see MAX_DAYS_IN_TMP. This allows to specify another frequency for
17# a second set of directories.
18#
19MAX_DAYS_IN_LONG_TMP="7"
20
21## Type: string
22## Default: "/tmp"
23#
24# This variable contains a list of directories, in which old files are to
25# be searched and deleted. The frequency is determined by MAX_DAYS_IN_TMP
26#
27TMP_DIRS_TO_CLEAR="/tmp"
28
29## Type: string
30## Default: ""
31#
32# This variable contains a list of directories, in which old files are to
33# be searched and deleted. The frequency is determined by MAX_DAYS_IN_LONG_TMP
34# If cleaning of /var/tmp is wanted add it here.
35#
36LONG_TMP_DIRS_TO_CLEAR="/var/tmp"
37
38## Type: string
39## Default: root
40#
41# In OWNER_TO_KEEP_IN_TMP, you can specify, whose files shall not be deleted.
42#
43OWNER_TO_KEEP_IN_TMP="root"
44
45## Type: string
46## Default: no
47#
48# "Set this to "yes" to entirely remove (rm -rf) all files and subdirectories
49# from the temporary directories defined in TMP_DIRS_TO_CLEAR on bootup.
50# Please note, that this feature ignores OWNER_TO_KEEP_IN_TMP - all files will
51# be removed without exception."
52#
53# If this is set to a list of directories (i.e. starts with a "/"), these
54# directories will be cleared instead of those listed in TMP_DIRS_TO_CLEAR.
55# This can be used to clear directories at boot as well as clearing unused
56# files out of other directories.
57#
58CLEAR_TMP_DIRS_AT_BOOTUP="no"
59## Path: System/Cron/Man
60## Description: cron configuration for man utility
61## Type: yesno
62## Default: yes
63#
64# Should mandb and whatis be recreated by cron.daily ("yes" or "no")
65#
66REINIT_MANDB="yes"
67
68## Type: yesno
69## Default: yes
70#
71# Should old preformatted man pages (in /var/catman) be deleted? (yes/no)
72#
73DELETE_OLD_CATMAN="yes"
74
75## Type: integer
76## Default: 7
77#
78# How long should old preformatted man pages be kept before deletion? (days)
79#
80CATMAN_ATIME="7"
81## Path: System/Cron
82## Description: Deleting core files
83## Type: yesno
84## Default: no
85#
86# Should old corefiles they be deleted? ("yes" or "no")
87# If set to 'no', cron.daily will tell you if it finds old core files.
88# NOTE: This feature requires RUN_UPDATEDB to be set to "yes"
89# and the package with locate (findutils-locate) to be installed.
90#
91DELETE_OLD_CORE="yes"
92
93## Type: integer
94## Default: 7
95#
96# Maximum age of core files (in days)
97#
98MAX_DAYS_FOR_CORE="7"
diff --git a/urunlevel/runlevel/sysconfig/named b/urunlevel/runlevel/sysconfig/named
new file mode 100644
index 0000000..3ffb1cf
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/named
@@ -0,0 +1,65 @@
1## Path: Network/DNS/Name Server
2## Description: Names server settings
3
4## Type: yesno
5## Default: yes
6## ServiceRestart: lwresd,named
7#
8# Shall the DNS server 'named' or the LightWeight RESolver Daemon, lwresd run
9# in the chroot jail?
10#
11# Each time you start one of the daemons with the init script, /etc/named.conf,
12# /etc/named.conf.include, /etc/rndc.key, and all files listed in
13# NAMED_CONF_INCLUDE_FILES will be copied relative to /var/lib/named.
14#
15# The pid file will be in /var/lib/named/var/run/named/ and named named.pid
16# or lwresd.pid.
17#
18NAMED_RUN_CHROOTED="yes"
19
20## Type: string
21## Default: ""
22## ServiceRestart: lwresd,named
23#
24# Additional arguments when starting the name daemon with the init script
25# /etc/init.d/named or rcnamed.
26#
27# For example "-n 2" to use two CPUs if named is unable to determine the
28# number of available CPUs.
29#
30# See man 8 named for all available commandline options.
31#
32# "-t /var/lib/named/var" is added if NAMED_RUN_CHROOTED is set to yes.
33#
34# "-u named" is used in any case by the init script to run the named daemon as
35# user 'named' after completing privileged operations.
36#
37NAMED_ARGS=""
38## Type: string
39## Default: ""
40## ServiceReload: named
41#
42# All mentioned config files will be copied relativ to /var/lib/named/, when
43# 'named' is started in the chroot jail.
44#
45# /etc/named.conf and /etc/rndc.key are always copied. Also all files from
46# include statements in named.conf.
47#
48# Filenames can be relative to /etc/named.d/.
49#
50# Please take care of the order if one file needs a setting of another.
51#
52# Example: "/etc/named-dhcpd.key ldap.dump rndc-access.conf"
53#
54NAMED_CONF_INCLUDE_FILES="/etc/named.d/zones.conf"
55
56## Type: string
57## Default: "createNamedConfInclude"
58## ServiceReload: named
59#
60# Programms to be executed each time the DNS server 'named' is started or
61# reloaded.
62#
63# Filenames can be relative to /usr/share/bind/.
64#
65NAMED_INITIALIZE_SCRIPTS="createNamedConfInclude"
diff --git a/urunlevel/runlevel/sysconfig/network b/urunlevel/runlevel/sysconfig/network
new file mode 100644
index 0000000..3c175bb
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/network
@@ -0,0 +1,5 @@
1HOSTNAME="matrix-RAD"
2
3tcp_syn_retries="7"
4#ip_forward="1"
5icmp_echo_ignore_all="1"
diff --git a/urunlevel/runlevel/sysconfig/syslog b/urunlevel/runlevel/sysconfig/syslog
new file mode 100644
index 0000000..8b7f24c
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/syslog
@@ -0,0 +1,102 @@
1## Path: System/Logging
2## Description: System logging
3## Type: list(0,1,2,3,4,5,6,7)
4## Default: 1
5## Config: ""
6## ServiceRestart: syslog
7#
8# Default loglevel for klogd
9#
10KERNEL_LOGLEVEL=1
11
12## Type: string
13## Default: ""
14## Config: ""
15## ServiceRestart: syslog
16#
17# if not empty: parameters for syslogd
18# for example SYSLOGD_PARAMS="-r -s my.dom.ain"
19#
20SYSLOGD_PARAMS=""
21
22## Type: string
23## Default: -2
24## Config: ""
25## ServiceRestart: syslog
26#
27# if not empty: parameters for klogd
28# for example KLOGD_PARAMS="-2" for clean oops lines
29#
30KLOGD_PARAMS="-2"
31
32## Type: list(syslogd,syslog-ng)
33## Default: syslogd
34## Config: syslog-ng
35## Command: /sbin/rcsyslog restart
36## PreSaveCommand: /sbin/rcsyslog status && /sbin/rcsyslog stop
37#
38# The name of the syslog daemon used as
39# syslog service: "syslogd", "syslog-ng"
40#
41SYSLOG_DAEMON="syslogd"
42
43## Type: string
44## Default: "/var/lib/ntp/dev/log"
45## Config: syslog-ng
46## ServiceRestart: syslog
47#
48# The filename mentioned here will be added with the "-a ..." option as
49# additional socket via SYSLOGD_PARAMS when syslogd is started.
50#
51# This additional socket is needed in case that syslogd is restarted. Otherwise
52# a chrooted 'ntpd' won't be able to continue logging.
53#
54SYSLOGD_ADDITIONAL_SOCKET_NTP="/var/lib/ntp/dev/log"
55## Type: string
56## Default: "/var/lib/named/dev/log"
57## ServiceRestart: syslog
58## Config: syslog-ng
59#
60# The filename mentioned here will be added with the "-a ..." option as
61# additional socket via SYSLOGD_PARAMS when syslogd is started.
62#
63# This additional socket is needed in case that syslogd is restarted. Otherwise
64# a chrooted 'named' or 'lwresd' won't be able to continue logging.
65#
66SYSLOGD_ADDITIONAL_SOCKET_NAMED="/var/lib/named/dev/log"
67## Type: string
68## Default: "/var/lib/dhcp/dev/log"
69## ServiceRestart: syslog
70## Config: syslog-ng
71#
72# The filename mentioned here will be added with the "-a ..." option as
73# additional socket via SYSLOGD_PARAMS when syslogd is started.
74#
75# This additional socket is needed in case that syslogd is restarted. Otherwise
76# a chrooted dhcpd won't be able to continue logging.
77#
78SYSLOGD_ADDITIONAL_SOCKET_DHCP="/var/lib/dhcp/dev/log"
79## Type: string
80## Default: "/var/lib/frox/dev/log"
81## ServiceRestart: syslog
82## Config: syslog-ng
83#
84# The filename mentioned here will be added as "-a ..." to SYSLOGD_PARAMS when
85# syslogd is started.
86#
87# This additional socket is needed in case that syslogd is restarted. Otherwise
88# a chrooted frox won't be able to continue logging.
89#
90SYSLOGD_ADDITIONAL_SOCKET_FROX="/var/lib/frox/dev/log"
91## Type: string
92## Default: "/var/lib/stunnel/dev/log"
93## ServiceRestart: syslog
94## Config: syslog-ng
95#
96# The filename mentioned here will be added as "-a ..." to SYSLOGD_PARAMS when
97# syslogd is started.
98#
99# This additional socket is needed in case that syslogd is restarted. Otherwise
100# a chrooted stunnel won't be able to continue logging.
101#
102SYSLOGD_ADDITIONAL_SOCKET_STUNNEL="/var/lib/stunnel/dev/log"
diff --git a/urunlevel/runlevel/sysconfig/time b/urunlevel/runlevel/sysconfig/time
new file mode 100644
index 0000000..4d8ef66
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/time
@@ -0,0 +1,18 @@
1## Path: System/Environment/Clock
2## Description: Information about your timezone and time
3## Type: string
4## ServiceRestart: boot.clock
5#
6# Set to "-u" if your system clock is set to UTC, and to "--localtime"
7# if your clock runs that way.
8#
9HWCLOCK="-u"
10
11## Type: string(Europe/Berlin,Europe/London,Europe/Paris)
12## ServiceRestart: boot.clock
13#
14# Timezone (e.g. CET)
15# (this will set /usr/lib/zoneinfo/localtime)
16#
17TIMEZONE="Australia/Queensland"
18DEFAULT_TIMEZONE="Europe/London"
diff --git a/urunlevel/runlevel/sysconfig/ulimit b/urunlevel/runlevel/sysconfig/ulimit
new file mode 100644
index 0000000..4b5de8b
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/ulimit
@@ -0,0 +1,253 @@
1## Path System/Limits
2## Description: Set single process limits (memory, CPU, core ...)
3## Command: killall mingetty
4#
5# Both hard and soft limits may be set. Soft limits are enough if you
6# trust the users. Then, the soft limits may protect your machine
7# against suffering too much from an application leaking memory.
8# If you don't trust your users, you may use hard limits to prevent
9# the amount of harm they can do to the machine. Note that this is
10# only partially effective: Memory limits are per process, not per
11# user.
12# A setting of 0 will skip the adjustment of the particular limit
13# (except for core file sizes), thus the default will remain in
14# place, which is "unlimited" for most limits. If a value is unset,
15# no adjustment will be made either.
16# The memory sizes are percentages, the other values are absolute
17# numbers.
18# Note that the limits only get effective after a session is
19# restarted by init. Thus exiting mingetty (^D on console login)
20# or changing runlevel to 3 and back to 5 for xdm is needed.
21# Rebooting helps as well, of course.
22#
23## Type: integer(0:99)
24## Default: 0
25#
26# Limit the amount of virtual memory a single process may allocate.
27# Hard limit: Can not be increased by non-root.
28# This value corresponds to ulimit -Hv
29# Parameter is in percent of virtual (phys+swap) memory, 0 means
30# no adjustment (unlimited).
31#
32HARDVIRTUALLIMIT=0
33
34## Type: integer(0:99)
35## Default: 80
36#
37# Limit the amount of virtual memory a single process may allocate.
38# Soft limit: Can be increased by non-root up to the hard limit.
39# This value corresponds to ulimit -Sv
40# Parameter is in percent of virtual (phys+swap) memory, 0 means
41# no adjustment (unlimited).
42#
43SOFTVIRTUALLIMIT=80
44
45## Type: integer(0:99)
46## Default: 0
47#
48# Limit the amount of resident memory a single process may occupy.
49# The process virtual memory can grow larger than this limit, but
50# it can not get more resident memory.
51# Hard limit: Can not be increased by non-root.
52# This value corresponds to ulimit -Hm
53# Parameter is in percent of physical memory, 0 means no adjustment
54# (unlimited).
55#
56HARDRESIDENTLIMIT=0
57
58## Type: integer(0:99)
59## Default: 85
60#
61# Limit the amount of resident memory a single process may occupy.
62# The process virtual memory can grow larger than this limit, but
63# it can not get more resident memory.
64# Soft limit: Can be increased by non-root up to the hard limit.
65# This value corresponds to ulimit -Sm
66# Parameter is in percent of physical memory, 0 means no adjustment
67# (unlimited).
68#
69SOFTRESIDENTLIMIT=85
70
71## Type: integer(0:99)
72## Default: 0
73#
74# Limit the size of the stack that a single process may allocate.
75# Normally, it should be enough to limit virtual and resident size.
76# Note that with NPTL, the stack limit determines the stack SIZE
77# of multithreaded programs and should thus better not be set.
78# Hard limit: Can not be increased by non-root.
79# This value corresponds to ulimit -Hs
80# Parameter is in percent of physical memory, 0 means no adjustment
81# (unlimited).
82#
83HARDSTACKLIMIT=0
84
85## Type: integer(0:99)
86## Default: 0
87#
88# Limit the size of the stack that a single process may allocate.
89# Normally, it should be enough to limit virtual and resident size.
90# Note that with NPTL, the stack limit determines the stack SIZE
91# of multithreaded programs and should thus better not be set.
92# Soft limit: Can be increased by non-root up to the hard limit.
93# This value corresponds to ulimit -Ss
94# Parameter is in percent of physical memory, 0 means no adjustment
95# (unlimited).
96#
97SOFTSTACKLIMIT=0
98
99## Type: integer(0:99)
100## Default: 0
101#
102# Limit the size of the data segment that a single process may allocate.
103# Normally, it should be enough to limit virtual and resident size.
104# Hard limit: Can not be increased by non-root.
105# This value corresponds to ulimit -Hd
106# Parameter is in percent of physical memory, 0 means no adjustment
107# (unlimited).
108#
109HARDDATALIMIT=0
110
111## Type: integer(0:99)
112## Default: 0
113#
114# Limit the size of the data segment that a single process may allocate.
115# Normally, it should be enough to limit virtual and resident size.
116# Soft limit: Can be increased by non-root up to the hard limit.
117# This value corresponds to ulimit -Sd
118# Parameter is in percent of physical memory, 0 means no adjustment
119# (unlimited).
120#
121SOFTDATALIMIT=0
122
123## Type: integer(0:99)
124## Default: 42
125#
126# Limit the size of the memory that a single process may lock in
127# physical memory (thus preventing it to be swapped out).
128# Hard limit: Can not be increased by non-root.
129# This value corresponds to ulimit -Hl
130# Parameter is in percent of physical memory, 0 means no adjustment
131# (unlimited).
132#
133HARDLOCKLIMIT=0
134
135## Type: integer(0:99)
136## Default: 42
137#
138# Limit the size of the memory that a single process may lock in
139# physical memory (thus preventing it to be swapped out).
140# Soft limit: Can be increased by non-root up to the hard limit.
141# This value corresponds to ulimit -Sl
142# Parameter is in percent of physical memory, 0 means no adjustment
143# (unlimited).
144#
145SOFTLOCKLIMIT=0
146
147## Type: integer
148## Default: 0
149#
150# Limit the amount of CPU time for a single process.
151# Should not normally be set to non-zero values.
152# Hard limit: Process will be killed.
153# Corresponds to ulimit -Ht.
154# Parameter is in seconds, 0 means no adjustment (unlimited).
155#
156HARDCPULIMIT=0
157
158## Type: integer
159## Default: 0
160#
161# Limit the amount of CPU time for a single process.
162# Should not normally be set to non-zero values.
163# Soft limit: Process will be sent SIGXCPU.
164# Corresponds to ulimit -St.
165# Parameter is in seconds, 0 means no adjustment (unlimited).
166#
167SOFTCPULIMIT=0
168
169## Type: integer
170## Default: 8192
171#
172# Limit the amount of file descriptors that a process
173# may have open at any time. Linux default is 1024.
174# Hard limit: Can not be increased by non-root.
175# Corresponds to ulimit -Hn.
176# 0 means no adjustment (system default: 1024).
177#
178HARDFDLIMIT=8192
179
180## Type: integer
181## Default: 1024
182#
183# Limit the amount of file descriptors that a process
184# may have open at any time. Linux default is 1024.
185# Soft limit: Can be increased by non-root up to the hard limit.
186# Corresponds to ulimit -Sn.
187# 0 means no adjustment (system default: 1024).
188#
189SOFTFDLIMIT=1024
190
191## Type: string
192## Default: "unlimited"
193#
194# Limit the size of core dump files. 0 turns them off.
195# Hard limit: Can not be increased by non-root.
196# Corresponds to ulimit -Hc.
197# Parameter is in blocks (1k), 0 means turning core files off.
198#
199HARDCORELIMIT="unlimited"
200
201## Type: string
202## Default: "0"
203#
204# Limit the size of core dump files. 0 turns them off.
205# Soft limit: Can be increased by non-root up to the hard limit.
206# Corresponds to ulimit -Sc.
207# Parameter is in blocks (1k), 0 means turning core files off.
208#
209SOFTCORELIMIT="0"
210
211## Type: string
212## Default: "unlimited"
213#
214# Limit the size of files a user may create.
215# Hard limit: Can not be increased by non-root.
216# Corresponds to ulimit -Hf.
217# Parameter is in blocks (1k), 0 means no adjustment (unlimited).
218#
219HARDFILESZLIMIT="unlimited"
220
221## Type: string
222## Default: "unlimited"
223#
224# Limit the size of files a user may create.
225# Soft limit: Can be increased by non-root up to the hard limit.
226# Corresponds to ulimit -Sf.
227# Parameter is in blocks (1k), 0 means no adjustment (unlimited).
228#
229SOFTFILESZLIMIT="unlimited"
230
231## Type: string
232## Default: "0"
233#
234# Limit the number of processes that a single user may have at the
235# same time.
236# Hard limit: Can not be increased by non-root.
237# Corresponds to ulimit -Hu.
238# 0 means no adjustment (system default is a few thousands, exact
239# value depends on the architecture).
240#
241HARDPROCESSLIMIT="0"
242
243## Type: string
244## Default: "0"
245#
246# Limit the number of processes that a single user may have at the
247# same time.
248# Soft limit: Can be increased by non-root up to the hard limit.
249# Corresponds to ulimit -Su.
250# 0 means no adjustment (system default is a few thousands, exact
251# value depends on the architecture).
252#
253SOFTPROCESSLIMIT="0"
diff --git a/urunlevel/runlevel/sysconfig/xntp b/urunlevel/runlevel/sysconfig/xntp
new file mode 100644
index 0000000..8423af0
--- /dev/null
+++ b/urunlevel/runlevel/sysconfig/xntp
@@ -0,0 +1,38 @@
1## Path: Network/NTP
2## Description: Network Time Protocol (NTP) server settings
3## Type: string
4## Default: AUTO-2
5## ServiceRestart: xntpd
6#
7# Usually it's a good idea to get the current time and date
8# from some other ntp server, before the local xntpd is started.
9# - Set XNTPD_INITIAL_NTPDATE="AUTO" to query ALL servers listed
10# in the configuration file (/etc/ntp.conf).
11# - Set XNTPD_INITIAL_NTPDATE="AUTO-{NUMBER}" to query the first {NUMBER}
12# servers listed in the configuration file. E.g. "AUTO-2".
13# Otherwise provide a space-separated list of ntp servers to query, or
14# set XNTPD_INITIAL_NTPDATE="" to do no initial query at all.
15#
16XNTPD_INITIAL_NTPDATE="AUTO-2"
17
18## Type: string
19## Default: "-u ntp"
20#
21# Additional arguments when starting ntpd. The most
22# important ones would be
23# -u user[:group] to make xntpd run as a user (group) other than root.
24#
25XNTPD_OPTIONS="-u ntp"
26
27## Type: yesno
28## Default: yes
29## ServiceRestart: xntpd
30#
31# Shall the time server ntpd run in the chroot jail /var/lib/ntp?
32#
33# Each time you start ntpd with the init script, /etc/ntp.conf will be
34# copied to /var/lib/ntp/etc/.
35#
36# The pid file will be in /var/lib/ntp/var/run/ntpd.pid.
37#
38XNTPD_RUN_CHROOTED="yes"
diff --git a/urunlevel/runlevel/udhcpc_script.c b/urunlevel/runlevel/udhcpc_script.c
index 5d5f592..afacd2f 100644
--- a/urunlevel/runlevel/udhcpc_script.c
+++ b/urunlevel/runlevel/udhcpc_script.c
@@ -1,8 +1,10 @@
1/* 1/*
2 * Mini udhcpc_script implementation for busybox. 2 * Mini udhcpc default.script implementation for busybox.
3 * 3 *
4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au 4 * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au
5 * 5 *
6 * Originally based on code from Trinux.
7 *
6 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * 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 10 * the Free Software Foundation; either version 2 of the License, or
@@ -30,162 +32,169 @@
30 32
31static void printit(char *name, char *description, char *value) 33static void printit(char *name, char *description, char *value)
32{ 34{
33 if (value != NULL) 35 if (value != NULL)
34 bb_printf("%s=%s\t\t- %s\n", name, value, description); 36 bb_printf("%s=%s\t\t- %s\n", name, value, description);
35} 37}
36 38
39
40 /* no options, no getopt */
37int udhcpc_script_main(int argc, char **argv) 41int udhcpc_script_main(int argc, char **argv)
38{ 42{
39 argv += optind; 43 argv += optind;
40 44
41#if 0 45#if 0
42 printit("action", "What action the script should perform", *argv); 46 printit("action", "What action the script should perform", *argv);
43 printit("HOME", "The set $HOME env or '/'", getenv("HOME")); 47 printit("HOME", "The set $HOME env or '/'", getenv("HOME"));
44 printit("PATH", "the set $PATH env or '/bin:/usr/bin:/sbin:/usr/sbin'", getenv("PATH")); 48 printit("PATH", "the set $PATH env or '/bin:/usr/bin:/sbin:/usr/sbin'",
45 printit("interface", "The interface this was obtained on", getenv("interface")); 49 getenv("PATH"));
46 printit("ip", "The obtained IP", getenv("ip")); 50 printit("interface", "The interface this was obtained on",
47 printit("mask", "The number of bits in the netmask (ie: 24)", getenv("mask")); 51 getenv("interface"));
48 printit("siaddr", "The bootp next server option", getenv("siaddr")); 52 printit("ip", "The obtained IP", getenv("ip"));
49 printit("sname", "The bootp server name option", getenv("sname")); 53 printit("mask", "The number of bits in the netmask (ie: 24)",
50 printit("boot_file", "The bootp boot file option", getenv("boot_file")); 54 getenv("mask"));
51 printit("subnet", "The assigend subnet mask", getenv("subnet")); 55 printit("siaddr", "The bootp next server option", getenv("siaddr"));
52 printit("timezone", "Offset in seconds from UTC", getenv("timezone")); 56 printit("sname", "The bootp server name option", getenv("sname"));
53 printit("router", "A list of routers", getenv("router")); 57 printit("boot_file", "The bootp boot file option", getenv("boot_file"));
54 printit("timesvr", "A list of time servers", getenv("timesvr")); 58 printit("subnet", "The assigend subnet mask", getenv("subnet"));
55 printit("namesvr", "A list of IEN 116 name servers", getenv("namesvr")); 59 printit("timezone", "Offset in seconds from UTC", getenv("timezone"));
56 printit("dns", "A list of DNS server", getenv("dns")); 60 printit("router", "A list of routers", getenv("router"));
57 printit("logsvr", "A list of MIT-LCS UDP log servers", getenv("logsvr")); 61 printit("timesvr", "A list of time servers", getenv("timesvr"));
58 printit("cookiesvr", "A list of RFC 865 cookie servers", getenv("cookiesvr")); 62 printit("namesvr", "A list of IEN 116 name servers", getenv("namesvr"));
59 printit("lprsvr", "A list of LPR servers", getenv("lprsvr")); 63 printit("dns", "A list of DNS server", getenv("dns"));
60 printit("hostname", "The assigned hostname", getenv("hostname")); 64 printit("logsvr", "A list of MIT-LCS UDP log servers", getenv("logsvr"));
61 printit("bootsize", "The length in 512 octect blocks of the bootfile", getenv("bootsize")); 65 printit("cookiesvr", "A list of RFC 865 cookie servers",
62 printit("domain", "The domain name of the network", getenv("domain")); 66 getenv("cookiesvr"));
63 printit("swapsvr", "The IP address of the client's swap server", getenv("swapsvr")); 67 printit("lprsvr", "A list of LPR servers", getenv("lprsvr"));
64 printit("rootpath", "The path name of the client's root disk", getenv("rootpath")); 68 printit("hostname", "The assigned hostname", getenv("hostname"));
65 printit("ipttl", "The TTL to use for this network", getenv("ipttl")); 69 printit("bootsize", "The length in 512 octect blocks of the bootfile",
66 printit("mtu", "The MTU to use for this network", getenv("mtu")); 70 getenv("bootsize"));
67 printit("broadcast", "The broadcast address for this network", getenv("broadcast")); 71 printit("domain", "The domain name of the network", getenv("domain"));
68 printit("ntpsrv", "A list of NTP servers", getenv("ntpsrv")); 72 printit("swapsvr", "The IP address of the client's swap server",
69 printit("wins", "A list of WINS servers", getenv("wins")); 73 getenv("swapsvr"));
70 printit("lease", "The lease time, in seconds", getenv("lease")); 74 printit("rootpath", "The path name of the client's root disk",
71 printit("dhcptype", "DHCP message type (safely ignored)", getenv("dhcptype")); 75 getenv("rootpath"));
72 printit("serverid", "The IP of the server", getenv("serverid")); 76 printit("ipttl", "The TTL to use for this network", getenv("ipttl"));
73 printit("message", "Reason for a DHCPNAK", getenv("message")); 77 printit("mtu", "The MTU to use for this network", getenv("mtu"));
74 printit("tftp", "The TFTP server name", getenv("tftp")); 78 printit("broadcast", "The broadcast address for this network",
75 printit("bootfile", "The bootfile name", getenv("bootfile")); 79 getenv("broadcast"));
80 printit("ntpsrv", "A list of NTP servers", getenv("ntpsrv"));
81 printit("wins", "A list of WINS servers", getenv("wins"));
82 printit("lease", "The lease time, in seconds", getenv("lease"));
83 printit("dhcptype", "DHCP message type (safely ignored)",
84 getenv("dhcptype"));
85 printit("serverid", "The IP of the server", getenv("serverid"));
86 printit("message", "Reason for a DHCPNAK", getenv("message"));
87 printit("tftp", "The TFTP server name", getenv("tftp"));
88 printit("bootfile", "The bootfile name", getenv("bootfile"));
76#endif 89#endif
77 90
78 if (!*argv) 91 if (!*argv)
79 bb_printf("Error: should be called from udhcpc\n"); 92 bb_printf("Error: should be called from udhcpc\n");
80 else 93 else {
81 { 94 char *interface = getenv("interface");
82 char *interface = getenv("interface");
83 95
84 if (strcmp(*argv, "deconfig") == 0) 96 read_sysconfig("/etc/sysconfig/network");
85 { 97 if (strcmp(*argv, "deconfig") == 0) {
86#ifdef CONFIG_FEATURE_IFUPDOWN_IP 98#ifdef CONFIG_FEATURE_IFUPDOWN_IP
87 doit(QUIET, "ip route flush dev %s", interface); 99 doit(QUIET, "ip route flush dev %s", interface);
88 doit(QUIET, "ip addr flush dev %s", interface); 100 doit(QUIET, "ip addr flush dev %s", interface);
89 doit(QUIET, "ip link set %s up", interface); 101 doit(QUIET, "ip link set %s up", interface);
90#else 102#else
91 errno = 0; 103 errno = 0;
92 while (errno == 0) 104 while (errno == 0)
93 doit(QUIET, "route del default gw 0.0.0.0 dev %s", interface); 105 doit(QUIET, "route del default gw 0.0.0.0 dev %s", interface);
94 doit(QUIET, "ifconfig %s 0.0.0.0", interface); 106 doit(QUIET, "ifconfig %s 0.0.0.0", interface);
95#endif 107#endif
96 } 108 } else if (strcmp(*argv, "nak") == 0)
97 else if (strcmp(*argv, "nak") == 0) 109 bb_printf("udhcpc received a NAK: %s\n", getenv("message"));
98 bb_printf("udhcpc received a NAK: %s\n", getenv("message")); 110 else if ((strcmp(*argv, "bound") == 0)
99 else if ((strcmp(*argv, "bound") == 0) || (strcmp(*argv, "renew") == 0)) 111 || (strcmp(*argv, "renew") == 0)) {
100 { 112 const char *RESOLV_CONF = "/etc/resolv.conf";
101 const char *RESOLV_CONF = "/etc/resolv.conf"; 113 char *broadcast = getenv("broadcast");
102 char *broadcast = getenv("broadcast"); 114 char *subnet = getenv("subnet");
103 char *subnet = getenv("subnet"); 115 char *mask = getenv("mask");
104 char *mask = getenv("mask"); 116 char *ip = getenv("ip");
105 char *ip = getenv("ip"); 117 char *hostname = getenv("hostname");
106 char *hostname = getenv("hostname"); 118 char *domain = getenv("domain");
107 char *domain = getenv("domain"); 119 char *router = getenv("router");
108 char *router = getenv("router"); 120 char *dns = getenv("dns");
109 char *dns = getenv("dns"); 121 char *siaddr = getenv("siaddr");
110 char *siaddr = getenv("siaddr"); 122 char *tftp = getenv("tftp");
111 char *tftp = getenv("tftp"); 123 char *BROADCAST = "";
112 char *BROADCAST = ""; 124 char *NETMASK = "";
113 char *NETMASK = ""; 125 char *MASK = "";
114 char *MASK = ""; 126 char *HOSTNAME = 0;
115 char *HOSTNAME = 0; 127 int i, metric = 0;
116 int i, metric = 0; 128 char *token;
117 char *token; 129 char *strtok_temp;
118 char *strtok_temp; 130
119 131 if (broadcast != 0)
120 if (broadcast != 0) 132 bb_xasprintf(&BROADCAST, "broadcast %s", broadcast);
121 bb_xasprintf(&BROADCAST, "broadcast %s", broadcast); 133 if (subnet != 0)
122 if (subnet != 0) 134 bb_xasprintf(&NETMASK, "netmask %s", subnet);
123 bb_xasprintf(&NETMASK, "netmask %s", subnet); 135 if (mask != 0)
124 if (mask != 0) 136 bb_xasprintf(&MASK, "/%s", mask);
125 bb_xasprintf(&MASK, "/%s", mask); 137 if (hostname != 0)
126 if (hostname != 0) 138 bb_xasprintf(&HOSTNAME, "/%s", hostname);
127 bb_xasprintf(&HOSTNAME, "/%s", hostname);
128#ifdef CONFIG_FEATURE_IFUPDOWN_IP 139#ifdef CONFIG_FEATURE_IFUPDOWN_IP
129 doit(0, "ip addr add %s%s %s dev %s", ip, MASK, BROADCAST, interface); 140 doit(0, "ip addr add %s%s %s dev %s", ip, MASK, BROADCAST,
130 doit(0, "ip link set %s up", interface); 141 interface);
142 doit(0, "ip link set %s up", interface);
131#else 143#else
132 doit(0, "/sbin/ifconfig %s %s %s %s", interface, ip, BROADCAST, NETMASK); 144 doit(0, "/sbin/ifconfig %s %s %s %s", interface, ip, BROADCAST,
145 NETMASK);
133#endif 146#endif
134 if (router != 0) 147 if (router != 0) {
135 { 148 token = strtok_r(router, " ,\t\r\n", &strtok_temp);
136 token = strtok_r(router, " ,\t\r\n", &strtok_temp); 149 for (i = 0; token != NULL; i++) {
137 for (i = 0; token != NULL; i++)
138 {
139#ifdef CONFIG_FEATURE_IFUPDOWN_IP 150#ifdef CONFIG_FEATURE_IFUPDOWN_IP
140 doit(0, "ip route add to default via %s dev %s", token, interface, metric++); 151 doit(0, "ip route add to default via %s dev %s", token,
152 interface, metric++);
141#else 153#else
142 doit(0, "route add default gw %s dev %s metric %d", token, interface, metric++); 154 doit(0, "route add default gw %s dev %s metric %d", token,
155 interface, metric++);
143#endif 156#endif
144 token = strtok_r(NULL, " ,\t\r\n", &strtok_temp); 157 token = strtok_r(NULL, " ,\t\r\n", &strtok_temp);
145 } 158 }
146 } 159 }
147 160
148 doit(0, "echo -n > %s", RESOLV_CONF); 161 doit(0, "echo -n > %s", RESOLV_CONF);
149 if (domain != 0) 162 if (domain != 0)
150 doit(0, "echo \"search %s\" > %s", domain, RESOLV_CONF); 163 doit(0, "echo \"search %s\" > %s", domain, RESOLV_CONF);
151 164
152 token = strtok_r(dns, " \r\n", &strtok_temp); 165 token = strtok_r(dns, " \r\n", &strtok_temp);
153 for (i = 0; token != NULL; i++) 166 for (i = 0; token != NULL; i++) {
154 { 167 doit(0, "echo \"nameserver %s\" >> %s", token, RESOLV_CONF);
155 doit(0, "echo \"nameserver %s\" >> %s", token, RESOLV_CONF); 168
156 169 token = strtok_r(NULL, " \r\n", &strtok_temp);
157 token = strtok_r(NULL, " \r\n", &strtok_temp); 170 }
158 } 171
159 172 if (HOSTNAME == 0) {
160 if (HOSTNAME == 0) 173 bb_xasprintf(&HOSTNAME, doit(REDIR, "nslookup %s | grep -v default | grep Name | cut -d\":\" -f2 | tr -d ' ' | tail -n 1", ip));
161 { 174 if ((HOSTNAME == 0) && (getenv("HOSTNAME") != NULL))
162 bb_xasprintf(&HOSTNAME, doit(REDIR, "nslookup %s | grep -v default | grep Name | cut -d\":\" -f2 | tr -d ' ' | tail -n 1", ip)); 175 HOSTNAME = getenv("HOSTNAME");
163 if ((HOSTNAME == 0) && (stat("/var/lib/my_linux/config/hostname", &path_stat) == 0)) 176 if (HOSTNAME == 0)
164 HOSTNAME = quick_read("/var/lib/my_linux/config/hostname"); 177 HOSTNAME = "my_linux";
165 if (HOSTNAME == 0) 178 }
166 HOSTNAME = "my_linux"; 179 doit(0, "hostname %s", HOSTNAME);
167 }
168 doit(0, "hostname %s", HOSTNAME);
169// Should remove old entry 180// Should remove old entry
170 doit(0, "echo \"%s %s\" >> /etc/hosts", ip, HOSTNAME); 181 doit(0, "echo \"%s %s\" >> /etc/hosts", ip, HOSTNAME);
171 182
172// Should dump these in a per interface file 183// Should dump these in a per interface file
173 if (siaddr != NULL) 184 if (siaddr != NULL)
174 quick_write("/var/lib/network/nfsaddr", siaddr); 185 quick_write("/var/lib/network/nfsaddr", siaddr);
175 if (tftp != NULL) 186 if (tftp != NULL)
176 quick_write("/var/lib/network/tftpaddr", tftp); 187 quick_write("/var/lib/network/tftpaddr", tftp);
177 188
178 /* This is what the network init script is waiting for. */ 189 /* This is what the network init script is waiting for. */
179 quick_write("/var/lib/network/ipaddr", ip); 190 quick_write("/var/lib/network/ipaddr", ip);
180 bb_printf("IP %s HOSTNAME %s\n", ip, HOSTNAME); 191 bb_printf("IP %s HOSTNAME %s\n", ip, HOSTNAME);
181 192
182 free(HOSTNAME); 193 free(HOSTNAME);
183 } 194 } else {
184 else 195 bb_printf("Huh?\n");
185 { 196 }
186 bb_printf("Huh?\n");
187 } 197 }
188 }
189 198
190 return EXIT_SUCCESS; 199 return EXIT_SUCCESS;
191} 200}
diff --git a/urunlevel/runlevel/ugly_stick b/urunlevel/runlevel/ugly_stick
new file mode 100644
index 0000000..bba6433
--- /dev/null
+++ b/urunlevel/runlevel/ugly_stick
@@ -0,0 +1,6 @@
1#! /bin/sh
2
3pushd ..
4indent runlevel/*.c runlevel/*.h my_linux/*.c my_linux/*.h
5rm -f runlevel/*.c~ runlevel/*.h~ my_linux/*.c~ my_linux/*.h~
6popd
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/LICENSE b/urunlevel/runlevel/urunlevel.sourceforge.net/LICENSE
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/LICENSE
@@ -0,0 +1,340 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Library General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License
307 along with this program; if not, write to the Free Software
308 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
310
311Also add information on how to contact you by electronic and paper mail.
312
313If the program is interactive, make it output a short notice like this
314when it starts in an interactive mode:
315
316 Gnomovision version 69, Copyright (C) year name of author
317 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 This is free software, and you are welcome to redistribute it
319 under certain conditions; type `show c' for details.
320
321The hypothetical commands `show w' and `show c' should show the appropriate
322parts of the General Public License. Of course, the commands you use may
323be called something other than `show w' and `show c'; they could even be
324mouse-clicks or menu items--whatever suits your program.
325
326You should also get your employer (if you work as a programmer) or your
327school, if any, to sign a "copyright disclaimer" for the program, if
328necessary. Here is a sample; alter the names:
329
330 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
333 <signature of Ty Coon>, 1 April 1989
334 Ty Coon, President of Vice
335
336This General Public License does not permit incorporating your program into
337proprietary programs. If your program is a subroutine library, you may
338consider it more useful to permit linking proprietary applications with the
339library. If this is what you want to do, use the GNU Library General
340Public License instead of this License.
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/DONE.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/DONE.shtml
new file mode 100644
index 0000000..360a15c
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/DONE.shtml
@@ -0,0 +1,13 @@
1<!--#set var="title" value="DONE" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4This is a temporary holding area for <A HREF="TODO.shtml">TODO</A> items that are now DONE.
5Since I tend to write a large amount of descriptive text for TODO items, it is
6useful to use that as the starting point for documenting them once they are
7DONE. However, until I pull my finger out, the relevant text will just be cut
8and pasted into here. Note that some items that have not been DONE may get
9dragged into here, they will get dragged back when I pull my finger out. Also
10note that the DONE item may differ from the TODO item, but the documentation here
11will reflect the TODO item.
12 </P>
13<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/TODO.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/TODO.shtml
new file mode 100644
index 0000000..c95c898
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/TODO.shtml
@@ -0,0 +1,8 @@
1<!--#set var="title" value="TODO" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4The following is some developer notes on what needs to be done to the entire
5system. Note that I may have done some of these already, and forgotten to update
6the document.<BR><BR>
7
8<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/coding.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/coding.shtml
new file mode 100644
index 0000000..490cbd6
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/coding.shtml
@@ -0,0 +1,13 @@
1<!--#set var="title" value="coding standards" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4Since this is a collection af busybox applets, the <A HREF="http://www.busybox.net/">Busybox</A> style guide will be
5followed.<BR><BR>
6
7Personally, I don't like the style chosen by the busybox authors, but I'm
8flexible enough to write in any style. There is a runlevel/ugly_stick
9script that will convert all runlevel and my_linux source code to busybox
10style, via the busybox supplied .indent.pro file. When we say "hit it
11with the ugly stick" we mean "use the runlevel/ugly_stick script".
12 </P>
13<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/design.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/design.shtml
new file mode 100644
index 0000000..428883f
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/design.shtml
@@ -0,0 +1,5 @@
1<!--#set var="title" value="Design" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4 </P>
5<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/index.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/index.shtml
new file mode 100644
index 0000000..597e9cc
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/index.shtml
@@ -0,0 +1,17 @@
1<!--#set var="title" value="Documentation for coders" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4"Technique?" said the programmer turning from his terminal, "What I follow
5is Tao -- beyond all technique! When I first began to program I would see
6before me the whole problem in one mass. After three years I no longer saw
7this mass. Instead, I used subroutines. But now I see nothing. My whole
8being exists in a formless void. My senses are idle. My spirit, free to
9work without plan, follows its own instinct. In short, my program writes
10itself. True, sometimes there are difficult problems. I see them coming, I
11slow down, I watch silently. Then I change a single line of code and the
12difficulties vanish like puffs of idle smoke. I then compile the program.
13I sit still and let the joy of the work fill my being. I close my eyes for
14a moment and then log off."<BR><BR>
15(From the fortune program.)
16 </P>
17<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/keywords.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/keywords.shtml
new file mode 100644
index 0000000..a00dde2
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/keywords.shtml
@@ -0,0 +1,18 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3 <HEAD>
4 <TITLE>matrix-RAD - <!--#echo var="title" --></TITLE>
5 </HEAD>
6<!--#include virtual="../header.inc" -->
7 <P Align="CENTER">
8 <A HREF="people.shtml">The people</A> &nbsp
9 <A HREF="coding.shtml">Coding standards</A> &nbsp
10 <A HREF="design.shtml">Design</A> &nbsp
11 <A HREF="TODO.shtml">TODO</A> &nbsp
12 <A HREF="DONE.shtml">DONE</A> &nbsp
13 </P>
14 <P Align="CENTER">
15 <A HREF="api/" TARGET="_top">API</A> &nbsp
16 </P>
17 <HR WIDTH="50%">
18 <H3 ALIGN="CENTER"><!--#echo var="title" --></H3>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coders/people.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/people.shtml
new file mode 100644
index 0000000..54458c8
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coders/people.shtml
@@ -0,0 +1,9 @@
1<!--#set var="title" value="coders" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4<A HREF="../dvs1.shtml">onefang</A> wrote most of the code and documentation. He is
5the code nazi. I, me, my, etc usually refers to him.<BR><BR>
6
7AKA onefang, dvs1, the DVS one, Digital Polyglot, and David Seikel (but only if you have to).
8 </P>
9<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/coming.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/coming.shtml
new file mode 100644
index 0000000..0b48d6c
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/coming.shtml
@@ -0,0 +1,13 @@
1<!--#set var="title" value="What's coming?" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4These are the immeadiate plans, more or less in order.
5 </P>
6 <HR WIDTH="50%">
7 <H3 ALIGN="CENTER">More documentation.</H3>
8 <P>
9The first import of the code into CVS included the typical amount of
10documentation included with early versions of open source projects. This
11will be corrected soon.
12 </P>
13<!--#include virtual="footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/crontab.in b/urunlevel/runlevel/urunlevel.sourceforge.net/crontab.in
new file mode 100644
index 0000000..8535bb4
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/crontab.in
@@ -0,0 +1 @@
42 * * * * ~/fetch-html.sh
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/crontab.sh b/urunlevel/runlevel/urunlevel.sourceforge.net/crontab.sh
new file mode 100644
index 0000000..6fb8bfb
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/crontab.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2
3crontab -r
4crontab ~/crontab.in
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/fetch-html.sh b/urunlevel/runlevel/urunlevel.sourceforge.net/fetch-html.sh
new file mode 100644
index 0000000..1eb55bd
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/fetch-html.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2
3# crontab -e
4# 42 * * * * ~/fetch-html.sh
5
6/usr/bin/wget -q -O ~/project.tmp http://sourceforge.net/export/projhtml.php?group_id=133645&mode=full&no_table=1 >/dev/null
7/bin/mv ~/project.tmp ~/project.inc
8
9/usr/bin/wget -q -O ~/news.tmp http://sourceforge.net/export/projnews.php?group_id=133645&limit=10&flat=0&show_summaries=1 >/dev/null
10/bin/mv ~/news.tmp ~/news.inc
11
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/footer.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/footer.shtml
new file mode 100644
index 0000000..648eded
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/footer.shtml
@@ -0,0 +1,10 @@
1 <P ALIGN="CENTRE">
2 <A HREF="http://sourceforge.net/"><IMG SRC="http://sourceforge.net/sflogo.php?group_id=133645&amp;type=6" BORDER="0" ALT="SourceForge.net Logo"/></A><BR>
3 <A HREF="http://sourceforge.net/projects/urunlevel/">Sourceforge project site.</A>
4 </P>
5 <H6>
6 <!--#config timefmt="%F" -->
7 <P>This file was last modified on <!--#echo var="LAST_MODIFIED" --></P>
8 </H6>
9 </FONT>
10 </BODY>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/footer_line.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/footer_line.shtml
new file mode 100644
index 0000000..d731304
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/footer_line.shtml
@@ -0,0 +1,10 @@
1 <HR WIDTH="50%">
2 <P ALIGN="CENTRE">
3 <A HREF="http://sourceforge.net/"><IMG SRC="http://sourceforge.net/sflogo.php?group_id=133645&amp;type=6" BORDER="0" ALT="SourceForge.net Logo"/></A>
4 </P>
5 <H6>
6 <!--#config timefmt="%F" -->
7 <P>This file was last modified on <!--#echo var="LAST_MODIFIED" --></P>
8 </H6>
9 </FONT>
10 </BODY>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/header.inc b/urunlevel/runlevel/urunlevel.sourceforge.net/header.inc
new file mode 100644
index 0000000..4fc6edd
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/header.inc
@@ -0,0 +1,2 @@
1 <BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#60FF90" ALINK="#FFFFFF" VLINK="#609060" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
2 <FONT face="helvetica, arial, sans-serif">
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/home.inc b/urunlevel/runlevel/urunlevel.sourceforge.net/home.inc
new file mode 100644
index 0000000..c86507d
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/home.inc
@@ -0,0 +1,40 @@
1 <H1 ALIGN="CENTER">Micro runlevel</H1>
2 <P ALIGN="CENTER">Zen programming is not a spectator sport.</P>
3 <P>
4Clean room implementation of runlevel/init.d/SYS V init applets for
5busybox, aiming for LSB compliance.<BR><BR>
6
7<A HREF="http://www.busybox.net/">Busybox</A> currently has no support for runlevels
8and init.d scripts, also known as the SYS V init system. My software
9adds that support as standard busybox applets written in the C langauge. <BR><BR>
10
11I am aiming for <A HREF="http://www.linuxbase.org/">LSB</A> compliance, so Linux is
12the supported platform, but I have no objections to making sure it works
13on other busybox supported platforms. This was in fact written to the
14LSB specs, with no reference to the source code of similar systems. Any
15LSB compliant init.d script will be compatible with this. All the
16support programs and functions mentioned in the LSB spec are provided as
17part of this system. Other support programs and functions that I have
18found useful will be provided. Example init.d "scripts", written in C,
19are also included, especially all the system scripts that LSB requires
20distros to provide.<BR><BR>
21
22I am writing this as part of a Linux distro that I am building. One of
23the design criterea for this distro is to boot as fast as possible.
24Typicall Linux boots involve a lot of shell scripts, which are typically
25a lot slower than C. Most of these shell scripts are part of the SYS V
26init process. By writing this in C, writing init scripts themselves in
27C, and writing as much support stuff in C as possible, I am able to make
28a major improvement in boot speed.<BR><BR>
29
30Features -
31<UL>
32<LI>Small, like all busybox applets.</LI>
33<LI>Fast, the main reason for writing it.</LI>
34<LI>Intelligent, LSB requires an init system to determine dependencies and
35run the init scripts in the correct order.</LI>
36</UL>
37Busybox does not include named and portmap applets, so boot_named.c and
38boot_portmap.c should be considered as examples. Skeleton is also an
39example.
40 </P>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/home.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/home.shtml
new file mode 100644
index 0000000..f353c54
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/home.shtml
@@ -0,0 +1,9 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3 <HEAD>
4 <TITLE>Micro runlevel</TITLE>
5 </HEAD>
6 <!--#include virtual="header.inc" -->
7 <!--#include virtual="home.inc" -->
8 <!--#include virtual="footer.shtml" -->
9</HTML>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1.gif
new file mode 100644
index 0000000..dd31299
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1space.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1space.gif
new file mode 100644
index 0000000..076c753
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1space.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/bug.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/bug.png
new file mode 100644
index 0000000..9c8229d
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/bug.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/cvs16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/cvs16b.png
new file mode 100644
index 0000000..3a1ffcf
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/cvs16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/docman16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/docman16b.png
new file mode 100644
index 0000000..bcb7104
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/docman16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1-smile_mini.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1-smile_mini.gif
new file mode 100644
index 0000000..59d5b55
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1-smile_mini.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1.xface b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1.xface
new file mode 100644
index 0000000..ec452fd
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1.xface
@@ -0,0 +1,3 @@
1X-Face: 17(@/;MHtUp:15TJeNpoH<hE>YY\;dv"PCEs%.Yi6m8DA$.(x)PQO&lQbJ(wJ\DQx}prw4L
2 Cb7=oS}uC:&7>fVw-z!x1fdWS8@^nmcZ<?@9vp0/)Qc0w([!OD&uuW9EtHKFTUd|mdX#VD0)q$[+*+
3 *N:8!otYu~ijb"RN+19]5bQqf+Aj0I{ebAMjB8%@u,hHV4Igc048]H8gi1iYGgKt}A!i+iyfvCU[c>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_XFace.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_XFace.gif
new file mode 100644
index 0000000..025ac44
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_XFace.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_mini.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_mini.gif
new file mode 100644
index 0000000..0c9a7f1
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_mini.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/ftp16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/ftp16b.png
new file mode 100644
index 0000000..32b700e
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/ftp16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/mail16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/mail16b.png
new file mode 100644
index 0000000..3b9c4a4
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/mail16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix-RAD.jpg b/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix-RAD.jpg
new file mode 100644
index 0000000..8c1abdf
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix-RAD.jpg
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix.gif
new file mode 100644
index 0000000..72c7f63
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/mock_dave_icon.trans.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/mock_dave_icon.trans.gif
new file mode 100644
index 0000000..dbe9b38
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/mock_dave_icon.trans.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/notes16.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/notes16.png
new file mode 100644
index 0000000..8d0c968
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/notes16.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/taskman16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/taskman16b.png
new file mode 100644
index 0000000..53f56c0
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/taskman16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/title.png b/urunlevel/runlevel/urunlevel.sourceforge.net/images/title.png
new file mode 100644
index 0000000..79d976f
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/title.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/trans.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/trans.gif
new file mode 100644
index 0000000..9af12f3
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/trans.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/undercon.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/undercon.gif
new file mode 100644
index 0000000..833d40c
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/undercon.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/images/wait.gif b/urunlevel/runlevel/urunlevel.sourceforge.net/images/wait.gif
new file mode 100644
index 0000000..8e9c6f9
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/images/wait.gif
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/index.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/index.shtml
new file mode 100644
index 0000000..02734ac
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/index.shtml
@@ -0,0 +1,16 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
2 "http://www.w3.org/TR/html4/frameset.dtd">
3<HTML>
4 <HEAD>
5 <TITLE>Micro runlevel</TITLE>
6 </HEAD>
7 <FRAMESET cols="*, 660" border="0" bordercolor="#000000">
8 <FRAME NAME= "LEFT" src="navigation.shtml" bordercolor="#000000" noresize scrolling="yes">
9 <FRAME NAME= "RIGHT" src="home.shtml" bordercolor="#000000" noresize scrolling="yes">
10 </FRAMESET>
11 <NOFRAMES>
12 <!--#include virtual="header.inc" -->
13 <!--#include virtual="home.inc" -->
14 <!--#include virtual="footer.shtml" -->
15 </NOFRAMES>
16</HTML>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/keywords.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/keywords.shtml
new file mode 100644
index 0000000..86d3cfb
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/keywords.shtml
@@ -0,0 +1,16 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3 <HEAD>
4 <TITLE>Micro runlevel - <!--#echo var="title" --></TITLE>
5 </HEAD>
6<!--#include virtual="header.inc" -->
7 <H4 ALIGN="CENTER">
8 <P ALIGN="CENTER">Clean room LSB init.d applets for busybox.</P>
9 </H4>
10 <P Align="CENTER">
11 </P>
12 <P Align="CENTER">
13 <A HREF="navigation.shtml">Navigation links</A>
14 </P>
15 <HR WIDTH="50%">
16 <H3 ALIGN="CENTER"><!--#echo var="title" --></H3>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/navigation.inc b/urunlevel/runlevel/urunlevel.sourceforge.net/navigation.inc
new file mode 100644
index 0000000..d19efbe
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/navigation.inc
@@ -0,0 +1,43 @@
1 <H2 ALIGN="CENTER">Micro runlevel</H2>
2 <P ALIGN="CENTER">Clean room LSB init.d applets for busybox.</P>
3
4 <A HREF="index.shtml" TARGET="RIGHT">What is Micro runlevel?</A><BR>
5 <A HREF="news.shtml" TARGET="RIGHT">What's new?</A><BR>
6 <A HREF="coming.shtml" TARGET="RIGHT">What's coming?</A><BR>
7 <A HREF="http://www.fsf.org/licensing/licenses/gpl.html" TARGET="_TOP">Open Source license.</A><BR>
8 <A HREF="coders/index.shtml" TARGET="RIGHT">Documentation for coders.</A><BR>
9 <A HREF="testers/index.shtml" TARGET="RIGHT">Documentation for testers.</A><BR><BR>
10 Downloads<UL>
11 <LI><A HREF="../urunlevel_STABLE.tar.bz2">Stable release</A></LI>
12 <LI><A HREF="../urunlevel.tar.bz2">Unstable snapshot</A></LI>
13 </UL>
14 LSB init.d applets<UL>
15 <LI><A HREF="coders/rc.shtml" TARGET="RIGHT">rc - runlevel controller</A></LI>
16 <LI><A HREF="coders/pidofproc.shtml" TARGET="RIGHT">pidofproc</A></LI>
17 <LI><A HREF="coders/start-daemon.shtml" TARGET="RIGHT">start-daemon</A></LI>
18 <LI><A HREF="coders/killproc.shtml" TARGET="RIGHT">killproc</A></LI>
19 <LI><A HREF="coders/log_failure_msg.shtml" TARGET="RIGHT">log_failure_msg</A></LI>
20 <LI><A HREF="coders/log_success_msg.shtml" TARGET="RIGHT">log_success_msg</A></LI>
21 <LI><A HREF="coders/log_warning_msg.shtml" TARGET="RIGHT">log_warning_msg</A></LI>
22 </UL>
23 Support applets<UL>
24 <LI><A HREF="coders/install_initd.shtml" TARGET="RIGHT">install_initd</A></LI>
25 <LI><A HREF="coders/remove_initd.shtml" TARGET="RIGHT">remove_initd</A></LI>
26 </UL>
27 Example applets<UL>
28 <LI><A HREF="coders/boot_named.shtml" TARGET="RIGHT">boot_named</A></LI>
29 <LI><A HREF="coders/boot_portmap.shtml" TARGET="RIGHT">boot_portmap</A></LI>
30 <LI><A HREF="coders/boot_syslog.shtml" TARGET="RIGHT">boot_syslog</A></LI>
31 <LI><A HREF="coders/boot_time.shtml" TARGET="RIGHT">boot_time</A></LI>
32 <LI><A HREF="coders/local_fs.shtml" TARGET="RIGHT">local_fs</A></LI>
33 <LI><A HREF="coders/network.shtml" TARGET="RIGHT">network</A></LI>
34 <LI><A HREF="coders/remote_fs.shtml" TARGET="RIGHT">remote_fs</A></LI>
35 <LI><A HREF="coders/udhcpc_script.shtml" TARGET="RIGHT">udhcpc_script</A></LI>
36 </UL>
37 My LInux applets<UL>
38 <LI><A HREF="coders/rcS.shtml" TARGET="RIGHT">rcS</A></LI>
39 <LI><A HREF="coders/linuxrc.shtml" TARGET="RIGHT">linuxrc</A></LI>
40 <LI><A HREF="coders/mkrootfs.shtml" TARGET="RIGHT">mkrootfs</A></LI>
41 <LI><A HREF="coders/getpkg.shtml" TARGET="RIGHT">getpkg</A></LI>
42 </UL>
43 <hr noshade="noshade" size="1"> \ No newline at end of file
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/navigation.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/navigation.shtml
new file mode 100644
index 0000000..38c78e8
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/navigation.shtml
@@ -0,0 +1,11 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
2 "http://www.w3.org/TR/html4/frameset.dtd">
3<HTML>
4 <HEAD>
5 <TITLE>Micro runlevel</TITLE>
6 </HEAD>
7<!--#include virtual="header.inc" -->
8<!--#include virtual="navigation.inc" -->
9<!--#include virtual="project.inc" -->
10<!--#include virtual="footer.shtml" -->
11</HTML>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/news.inc b/urunlevel/runlevel/urunlevel.sourceforge.net/news.inc
new file mode 100644
index 0000000..14b2bd1
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/news.inc
@@ -0,0 +1 @@
<html><head></head><body><h3>No News Items Found</h3><div align="center"><a href="http://sourceforge.net/news/?group_id=133645">[News archive]</a></div></body></html> \ No newline at end of file
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/news.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/news.shtml
new file mode 100644
index 0000000..a332b6e
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/news.shtml
@@ -0,0 +1,7 @@
1<!--#set var="title" value="What's new?" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4See the coders <A HREF="coders/DONE.shtml">DONE</A> document for some very recent news.
5 </P>
6<!--#include virtual="news.inc" -->
7<!--#include virtual="footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/project.inc b/urunlevel/runlevel/urunlevel.sourceforge.net/project.inc
new file mode 100644
index 0000000..5c7fa34
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/project.inc
@@ -0,0 +1,24 @@
1<html><head></head><body><a href="http://sourceforge.net/tracker/?group_id=133645"><img src="projhtml.php_files/taskman16b.png" alt="Tracker" border="0" height="20" width="20"> Tracker</a><p>
2 &nbsp;-&nbsp;<a href="http://sourceforge.net/tracker/?atid=727887&amp;group_id=133645&amp;func=browse">Bugs</a>
3 ( <b>0 open / 0 total</b> )<br>Bug Tracking System</p><p>
4 &nbsp;-&nbsp;<a href="http://sourceforge.net/tracker/?atid=727888&amp;group_id=133645&amp;func=browse">Support Requests</a>
5 ( <b>0 open / 0 total</b> )<br>Tech Support Tracking System</p><p>
6 &nbsp;-&nbsp;<a href="http://sourceforge.net/tracker/?atid=727889&amp;group_id=133645&amp;func=browse">Patches</a>
7 ( <b>0 open / 0 total</b> )<br>Patch Tracking System</p><p>
8 &nbsp;-&nbsp;<a href="http://sourceforge.net/tracker/?atid=727890&amp;group_id=133645&amp;func=browse">Feature Requests</a>
9 ( <b>0 open / 0 total</b> )<br>Feature Request Tracking System
10
11 </p><hr noshade="noshade" size="1"><a href="http://sourceforge.net/forum/?group_id=133645"><img src="projhtml.php_files/notes16.png" alt="Forums" border="0" height="20" width="20">&nbsp;Forums</a> ( <b>0</b> messages in <b>0</b> forums )
12
13
14 <hr noshade="noshade" size="1"><a href="http://sourceforge.net/docman/?group_id=133645"><img src="projhtml.php_files/docman16b.png" alt="Docs" border="0" height="20" width="20">&nbsp;Doc&nbsp;Manager</a>
15
16 <hr noshade="noshade" size="1"><a href="http://sourceforge.net/mail/?group_id=133645"><img src="projhtml.php_files/mail16b.png" alt="Mail Lists" border="0" height="20" width="20">&nbsp;Mailing&nbsp;Lists</a> ( <b>0</b> mailing lists )
17
18 <hr noshade="noshade" size="1"><a href="http://sourceforge.net/project/screenshots.php?group_id=133645"><img src="projhtml.php_files/notes16.png" alt="Screenshots" border="0" height="20" width="20">&nbsp;Screenshots</a>
19
20 <hr noshade="noshade" size="1"><a href="http://sourceforge.net/pm/?group_id=133645"><img src="projhtml.php_files/taskman16b.png" alt="Tasks" border="0" height="20" width="20">&nbsp;Task&nbsp;Manager</a><br><i>There are no public subprojects available</i>
21
22 <hr noshade="noshade" size="1"><a href="http://sourceforge.net/cvs/?group_id=133645"><img src="projhtml.php_files/cvs16b.png" alt="CVS" border="0" height="20" width="20">&nbsp;CVS&nbsp;Tree</a> ( <b></b> commits, <b></b> adds ) <a href="http://sourceforge.net/project/stats/?group_id=133645#stats_notice"><img src="projhtml.php_files/bug.png" alt="known bug" border="0" height="25" width="25"></a>
23
24 <hr noshade="noshade" size="1"><a href="http://sourceforge.net/project/showfiles.php?group_id=133645"><img src="projhtml.php_files/ftp16b.png" alt="FTP" border="0" height="20" width="20">&nbsp;Released&nbsp;Files</a></body></html> \ No newline at end of file
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/bug.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/bug.png
new file mode 100644
index 0000000..9c8229d
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/bug.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/cvs16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/cvs16b.png
new file mode 100644
index 0000000..3a1ffcf
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/cvs16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/docman16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/docman16b.png
new file mode 100644
index 0000000..bcb7104
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/docman16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/ftp16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/ftp16b.png
new file mode 100644
index 0000000..32b700e
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/ftp16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/mail16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/mail16b.png
new file mode 100644
index 0000000..3b9c4a4
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/mail16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/notes16.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/notes16.png
new file mode 100644
index 0000000..8d0c968
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/notes16.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/taskman16b.png b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/taskman16b.png
new file mode 100644
index 0000000..53f56c0
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/taskman16b.png
Binary files differ
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/testers/TODO.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/TODO.shtml
new file mode 100644
index 0000000..27a9004
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/TODO.shtml
@@ -0,0 +1,5 @@
1<!--#set var="title" value="TODO" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4 </P>
5<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/testers/index.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/index.shtml
new file mode 100644
index 0000000..676bcbf
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/index.shtml
@@ -0,0 +1,28 @@
1<!--#set var="title" value="Documentation for testers" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4 A novice asked the Master: "Here is a programmer that never designs,
5documents, or tests his programs. Yet all who know him consider him one of
6the best programmers in the world. Why is this?"
7 The Master replies: "That programmer has mastered the Tao. He has
8gone beyond the need for design; he does not become angry when the system
9crashes, but accepts the universe without concern. He has gone beyond the
10need for documentation; he no longer cares if anyone else sees his code. He
11has gone beyond the need for testing; each of his programs are perfect within
12themselves, serene and elegant, their purpose self-evident. Truly, he has
13entered the mystery of the Tao."<BR>
14 -- Geoffrey James, "The Tao of Programming"<BR><BR>
15
16I went on to test the program in every way I could devise. I strained it to
17expose its weaknesses. I ran it for high-mass stars and low-mass stars, for
18stars born exceedingly hot and those born relatively cold. I ran it assuming
19the superfluid currents beneath the crust to be absent -- not because I wanted
20to know the answer, but because I had developed an intuitive feel for the
21answer in this particular case. Finally I got a run in which the computer
22showed the pulsar's temperature to be less than absolute zero. I had found
23an error. I chased down the error and fixed it. Now I had improved the
24program to the point where it would not run at all.<BR>
25 -- George Greenstein, "Frozen Star:<BR>
26 Of Pulsars, Black Holes and the Fate of Stars"<BR><BR>
27 </P>
28<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/testers/keywords.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/keywords.shtml
new file mode 100644
index 0000000..3e354a3
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/keywords.shtml
@@ -0,0 +1,13 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3 <HEAD>
4 <TITLE>Micro runlevel - <!--#echo var="title" --></TITLE>
5 </HEAD>
6<!--#include virtual="../header.inc" -->
7 <HR WIDTH="50%">
8 <H3 ALIGN="CENTER"><!--#echo var="title" --></H3>
9 <P Align="CENTER">
10 <A HREF="people.shtml">The people</A> &nbsp
11 <A HREF="method.shtml">The method</A> &nbsp
12 <A HREF="TODO.shtml">TODO</A> &nbsp
13 </P>
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/testers/method.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/method.shtml
new file mode 100644
index 0000000..6f9d102
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/method.shtml
@@ -0,0 +1,7 @@
1<!--#set var="title" value="testers" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4To be written, for now just go nuts on it and report bugs in the <A HREF="http://lists.sourceforge.net/mailman/listinfo/urunlevel-development" TARGET="RIGHT">urunlevel-development</A>
5mailing list.
6 </P>
7<!--#include virtual="../footer_line.shtml" -->
diff --git a/urunlevel/runlevel/urunlevel.sourceforge.net/testers/people.shtml b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/people.shtml
new file mode 100644
index 0000000..6daf11c
--- /dev/null
+++ b/urunlevel/runlevel/urunlevel.sourceforge.net/testers/people.shtml
@@ -0,0 +1,9 @@
1<!--#set var="title" value="testers" -->
2<!--#include virtual="keywords.shtml" -->
3 <P>
4The only tester at the moment is me (onefang), and programmers are not the best
5choice for properly testing their own work. So, we are desperately in need
6of real testers. This is where ordinary computer users can contribute to
7Micro runlevel.
8 </P>
9<!--#include virtual="../footer_line.shtml" -->