From 9f23832b7e53b0b8ccc7b1a8f9c79a8568315744 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 31 Mar 2005 05:37:25 +0000 Subject: Added patch files and web site. --- urunlevel/runlevel/Changelog | 19 + urunlevel/runlevel/Config.in | 74 +- urunlevel/runlevel/INSTALL | 14 + urunlevel/runlevel/LICENSE | 340 ++++ urunlevel/runlevel/README | 10 +- urunlevel/runlevel/TODO | 55 +- urunlevel/runlevel/apply_patch | 9 + urunlevel/runlevel/boot_named.c | 47 +- urunlevel/runlevel/boot_portmap.c | 70 +- urunlevel/runlevel/boot_syslog.c | 69 +- urunlevel/runlevel/boot_time.c | 58 +- urunlevel/runlevel/diff_excludes | 14 + urunlevel/runlevel/install_initd.c | 91 +- urunlevel/runlevel/killproc.c | 173 +- urunlevel/runlevel/lib_init_d.c | 721 ++++--- urunlevel/runlevel/lib_init_d.h | 39 +- urunlevel/runlevel/local_fs.c | 238 ++- urunlevel/runlevel/log_failure_msg.c | 20 +- urunlevel/runlevel/log_success_msg.c | 20 +- urunlevel/runlevel/log_warning_msg.c | 20 +- urunlevel/runlevel/make_patch | 10 + urunlevel/runlevel/network.c | 176 +- urunlevel/runlevel/pidofproc.c | 217 +-- urunlevel/runlevel/rc.c | 2013 +++++++++++--------- urunlevel/runlevel/remote_fs.c | 59 +- urunlevel/runlevel/remove_initd.c | 108 +- urunlevel/runlevel/runlevel.patch | 533 ++++++ urunlevel/runlevel/runlevels.conf | 17 + urunlevel/runlevel/start_daemon.c | 168 +- urunlevel/runlevel/sysconfig/cron | 98 + urunlevel/runlevel/sysconfig/named | 65 + urunlevel/runlevel/sysconfig/network | 5 + urunlevel/runlevel/sysconfig/syslog | 102 + urunlevel/runlevel/sysconfig/time | 18 + urunlevel/runlevel/sysconfig/ulimit | 253 +++ urunlevel/runlevel/sysconfig/xntp | 38 + urunlevel/runlevel/udhcpc_script.c | 281 +-- urunlevel/runlevel/ugly_stick | 6 + .../runlevel/urunlevel.sourceforge.net/LICENSE | 340 ++++ .../urunlevel.sourceforge.net/coders/DONE.shtml | 13 + .../urunlevel.sourceforge.net/coders/TODO.shtml | 8 + .../urunlevel.sourceforge.net/coders/coding.shtml | 13 + .../urunlevel.sourceforge.net/coders/design.shtml | 5 + .../urunlevel.sourceforge.net/coders/index.shtml | 17 + .../coders/keywords.shtml | 18 + .../urunlevel.sourceforge.net/coders/people.shtml | 9 + .../urunlevel.sourceforge.net/coming.shtml | 13 + .../runlevel/urunlevel.sourceforge.net/crontab.in | 1 + .../runlevel/urunlevel.sourceforge.net/crontab.sh | 4 + .../urunlevel.sourceforge.net/fetch-html.sh | 11 + .../urunlevel.sourceforge.net/footer.shtml | 10 + .../urunlevel.sourceforge.net/footer_line.shtml | 10 + .../runlevel/urunlevel.sourceforge.net/header.inc | 2 + .../runlevel/urunlevel.sourceforge.net/home.inc | 40 + .../runlevel/urunlevel.sourceforge.net/home.shtml | 9 + .../urunlevel.sourceforge.net/images/1x1.gif | Bin 0 -> 35 bytes .../urunlevel.sourceforge.net/images/1x1space.gif | Bin 0 -> 43 bytes .../urunlevel.sourceforge.net/images/bug.png | Bin 0 -> 1050 bytes .../urunlevel.sourceforge.net/images/cvs16b.png | Bin 0 -> 549 bytes .../urunlevel.sourceforge.net/images/docman16b.png | Bin 0 -> 530 bytes .../images/dvs1-smile_mini.gif | Bin 0 -> 1172 bytes .../urunlevel.sourceforge.net/images/dvs1.xface | 3 + .../images/dvs1_XFace.gif | Bin 0 -> 332 bytes .../urunlevel.sourceforge.net/images/dvs1_mini.gif | Bin 0 -> 1404 bytes .../urunlevel.sourceforge.net/images/ftp16b.png | Bin 0 -> 431 bytes .../urunlevel.sourceforge.net/images/mail16b.png | Bin 0 -> 587 bytes .../images/matrix-RAD.jpg | Bin 0 -> 69182 bytes .../urunlevel.sourceforge.net/images/matrix.gif | Bin 0 -> 43463 bytes .../images/mock_dave_icon.trans.gif | Bin 0 -> 1609 bytes .../urunlevel.sourceforge.net/images/notes16.png | Bin 0 -> 253 bytes .../images/taskman16b.png | Bin 0 -> 598 bytes .../urunlevel.sourceforge.net/images/title.png | Bin 0 -> 99911 bytes .../urunlevel.sourceforge.net/images/trans.gif | Bin 0 -> 886 bytes .../urunlevel.sourceforge.net/images/undercon.gif | Bin 0 -> 1133 bytes .../urunlevel.sourceforge.net/images/wait.gif | Bin 0 -> 2329 bytes .../runlevel/urunlevel.sourceforge.net/index.shtml | 16 + .../urunlevel.sourceforge.net/keywords.shtml | 16 + .../urunlevel.sourceforge.net/navigation.inc | 43 + .../urunlevel.sourceforge.net/navigation.shtml | 11 + .../runlevel/urunlevel.sourceforge.net/news.inc | 1 + .../runlevel/urunlevel.sourceforge.net/news.shtml | 7 + .../runlevel/urunlevel.sourceforge.net/project.inc | 24 + .../projhtml.php_files/bug.png | Bin 0 -> 1050 bytes .../projhtml.php_files/cvs16b.png | Bin 0 -> 549 bytes .../projhtml.php_files/docman16b.png | Bin 0 -> 530 bytes .../projhtml.php_files/ftp16b.png | Bin 0 -> 431 bytes .../projhtml.php_files/mail16b.png | Bin 0 -> 587 bytes .../projhtml.php_files/notes16.png | Bin 0 -> 253 bytes .../projhtml.php_files/taskman16b.png | Bin 0 -> 598 bytes .../urunlevel.sourceforge.net/testers/TODO.shtml | 5 + .../urunlevel.sourceforge.net/testers/index.shtml | 28 + .../testers/keywords.shtml | 13 + .../urunlevel.sourceforge.net/testers/method.shtml | 7 + .../urunlevel.sourceforge.net/testers/people.shtml | 9 + 94 files changed, 4812 insertions(+), 2162 deletions(-) create mode 100644 urunlevel/runlevel/Changelog create mode 100644 urunlevel/runlevel/INSTALL create mode 100644 urunlevel/runlevel/LICENSE create mode 100644 urunlevel/runlevel/apply_patch create mode 100644 urunlevel/runlevel/diff_excludes create mode 100644 urunlevel/runlevel/make_patch create mode 100644 urunlevel/runlevel/runlevel.patch create mode 100644 urunlevel/runlevel/runlevels.conf create mode 100644 urunlevel/runlevel/sysconfig/cron create mode 100644 urunlevel/runlevel/sysconfig/named create mode 100644 urunlevel/runlevel/sysconfig/network create mode 100644 urunlevel/runlevel/sysconfig/syslog create mode 100644 urunlevel/runlevel/sysconfig/time create mode 100644 urunlevel/runlevel/sysconfig/ulimit create mode 100644 urunlevel/runlevel/sysconfig/xntp create mode 100644 urunlevel/runlevel/ugly_stick create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/LICENSE create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/DONE.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/TODO.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/coding.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/design.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/index.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/keywords.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coders/people.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/coming.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/crontab.in create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/crontab.sh create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/fetch-html.sh create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/footer.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/footer_line.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/header.inc create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/home.inc create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/home.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1space.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/bug.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/cvs16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/docman16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1-smile_mini.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1.xface create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_XFace.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_mini.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/ftp16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/mail16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix-RAD.jpg create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/mock_dave_icon.trans.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/notes16.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/taskman16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/title.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/trans.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/undercon.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/images/wait.gif create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/index.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/keywords.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/navigation.inc create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/navigation.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/news.inc create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/news.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/project.inc create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/bug.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/cvs16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/docman16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/ftp16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/mail16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/notes16.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/taskman16b.png create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/testers/TODO.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/testers/index.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/testers/keywords.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/testers/method.shtml create mode 100644 urunlevel/runlevel/urunlevel.sourceforge.net/testers/people.shtml 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 @@ +--------------------- +Date: 2005/03/19 03:40:00 +Author: onefang +Log: +Updated various Config.in's to reflect some of the dependencies. + +--------------------- +Date: 2005/03/19 03:42:00 +Author: onefang +Log: +Finished install_initd and remove_initd. + +--------------------- +Date: 2005/03/19 05:18:00 +Author: onefang +Log: +Implemented sysconfig file support. +Update boot_syslog, network, and udhcpc_script to suit. + 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" config CONFIG_BOOT_NAMED bool "boot_named" - default y + default n help An implementation of LSB $named. config CONFIG_BOOT_PORTMAP bool "boot_portmap" - default y + default n help An implementation of LSB $. config CONFIG_BOOT_SYSLOG bool "boot_syslog" - default y + default n help An implementation of LSB $syslog. config CONFIG_BOOT_TIME bool "boot_time" - default y + default n help An implementation of LSB $time. config CONFIG_INSTALL_INITD bool "install_initd" - default y + default n help An implementation of install_initd. -config CONFIG_KILLPROC +if CONFIG_RC + config CONFIG_KILLPROC + default y + comment "killproc (forced enabled for use with rc)" +endif +if !CONFIG_RC + config CONFIG_KILLPROC bool "killproc" default y help An implementation of killproc. +endif config CONFIG_LOCAL_FS bool "local_fs" - default y + default n help A $local_fs boot script. -config CONFIG_LOG_FAILURE_MSG +if CONFIG_RC + config CONFIG_LOG_FAILURE_MSG + default y + comment "log_failure_msg (forced enabled for use with rc)" +endif +if !CONFIG_RC + config CONFIG_LOG_FAILURE_MSG bool "log_failure_msg" default y help An implementation of log_failure_msg. +endif -config CONFIG_LOG_SUCCESS_MSG +if CONFIG_RC + config CONFIG_LOG_SUCCESS_MSG + default y + comment "log_success_msg (forced enabled for use with rc)" +endif +if !CONFIG_RC + config CONFIG_LOG_SUCCESS_MSG bool "log_success_msg" default y help An implementation of log_success_msg. +endif -config CONFIG_LOG_WARNING_MSG +if CONFIG_RC + config CONFIG_LOG_WARNING_MSG + default y + comment "log_warning_msg (forced enabled for use with rc)" +endif +if !CONFIG_RC + config CONFIG_LOG_WARNING_MSG bool "log_warning_msg" default y help An implementation of log_warning_msg. +endif config CONFIG_NETWORK bool "network" - default y + default n help A $network boot script. -config CONFIG_PIDOFPROC +if CONFIG_RC + config CONFIG_PIDOFPROC + default y + comment "pidofproc (forced enabled for use with rc)" +endif +if !CONFIG_RC + config CONFIG_PIDOFPROC bool "pidofproc" default y help An implementation of pidofproc. +endif config CONFIG_RC bool "rc" @@ -85,25 +120,32 @@ config CONFIG_RC config CONFIG_REMOTE_FS bool "remote_fs" - default y + default n help A $remote_fs boot script. config CONFIG_REMOVE_INITD bool "remove_initd" - default y + default n help An implementation of remove_initd. -config CONFIG_START_DAEMON +if CONFIG_RC + config CONFIG_START_DAEMON + default y + comment "start_daemon (forced enabled for use with rc)" +endif +if !CONFIG_RC + config CONFIG_START_DAEMON bool "start_daemon" default y help An implementation of start_daemon. +endif config CONFIG_UDHCPC_SCRIPT bool "udhcpc_script" - default y + default n help An implementation of udhcpc.script. 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 @@ +Download busybox-1.00.tar.bz2. + +Unpack it. + +Copy this directory (runlevel) and the my_linux directory into the busybox-1.00 +directory. + +Change to the busybox-1.00/runlevel directory. + +Run the apply_patch script. + +The apply_patch script will run "make oldconfig" for you. + +Follow 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 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public 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 @@ -Busybox does not include named and portmap applets, so boot_named.c and -boot_portmap.c should be considered as examples. Skeleton is also an example. +Clean room implementation of runlevel/init.d/SYS V init applets for +busybox, aiming for LSB compliance. +Busybox currently has no support for runlevels +and init.d scripts, also known as the SYS V init system. Micro runlevel +adds that support as standard busybox applets written in the C langauge. + +Most of the documentation is in the urunlevel.sourceforge.net directory, +which 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 @@ -+ LSB niceness -* LSB compliance ! fix bug -$ store config info in - - kernel command line - boot://bootrc - /etc/sysconfig/* syslog network/config network/routes - - if (stat("/var/lib/my_linux/config/ipfwd", &path_stat) == 0) - if (stat("/var/lib/my_linux/config/noping", &path_stat) == 0) - /var/lib/my_linux/config/hostname - hostname - /var/lib/my_linux/config/loghost - syslogd remote host +* LSB compliance ++ LSB niceness review init.d script dependencies @@ -21,35 +12,33 @@ $ store config info in - portmap - network named - network and syslog -$ write a proper network & friends - add fsck support to local_fs and linuxrc - local_fs should only umount things it mounted -! try to detect ext3 before mount whinges -! redirect console to some other VT - +* add database editing command to rc * do something with info->shouldstart's in rc + rc foo start - start dependencies of foo first + rc foo stop - stop things dependent on foo first -* add a database of runlevels per script -* add database editing and reporting commands to rc - -* finish install_initd & remove_initd -$ finish boot_syslog -$ finish boot_time ++ dependencies should be per runlevel as well. + I don't think LSB explicitly requires this, but it makes sense. + OTOH, there is much that could go wrong with a dependency script, + so how paranoid do we want to be? + #ifdef CONFIG_FEATURE_RUNLEVEL_PARANOID ! double check status functions - -+ write init_d_from_script -+ rewrite skeleton to use initd_from_script - ! pidofproc needs to check the name of the proc as well as the pid in /proc/$pid remove start_daemon's reliance on start-stop-daemon ! remove need for sleep(1) in start_daemon + + finish boot_time + write a proper network & friends + add fsck support to local_fs and linuxrc + local_fs should only umount things it mounted +! try to detect ext3 before mount whinges +! redirect console to some other VT + ++ write init_d_from_script ++ rewrite skeleton to use initd_from_script ! fix forking, daemon begat's daemon, and daemonic hell breaks loose. My doit() is probably to blame. + #ifdef CONFIG_FEATURE_CLEAN_UP + replace some doit's with C code + force enable of remaining doit's - on boot - hard link /linuxrc to /bin/busybox - turn makefs into a full blown applet - CONFIG_FEATURE_FULL_LSB - permissions for files - move cron out of rcS - + hit it with the ugly_stick 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 @@ +#! /bin/sh + +pushd .. +make clean +patch -ufp1 status)(init_d, 0); + int status = (init_d->status) (init_d, 0); + const char *state = "/var/run/portmap.state"; - if (status == INIT_D_STATUS_OK) - { - doit(0, "pmap_dump > %s", state); - status = default_restart(init_d, 0); - doit(0, "pmap_set < %s", state); - remove_file(state, FILEUTILS_FORCE); - } - else - status = default_restart(init_d, 0); - return status; + if (status == INIT_D_STATUS_OK) { + doit(0, "pmap_dump > %s", state); + status = default_restart(init_d, 0); + doit(0, "pmap_set < %s", state); + remove_file(state, FILEUTILS_FORCE); + } else + status = default_restart(init_d, 0); + return status; } 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 @@ * * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au * + * Originally based on code from Trinux. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -29,51 +31,46 @@ static int start(struct init_d_handle_s *, int); -static init_d_handle_t my_commands = -{ - &start, - NULL, - NULL, - NULL, - &no_reload, - NULL, - NULL, - NULL, - "boot_syslogd", - "/sbin/syslogd", - "-n", - NULL, - INIT_D_BEGIN \ - INIT_D_PROV "$syslog" \ - INIT_D_RSTART "$local_fs $time" \ - INIT_D_SSTART "$network" \ - INIT_D_DSTART "1 2 3 4 5" \ - INIT_D_DSTOP "0 6" \ - INIT_D_SDESC "System logger." \ - INIT_D_DESC "System logger." \ - INIT_D_END +static init_d_handle_t my_commands = { + &start, + NULL, + NULL, + NULL, + &no_reload, + NULL, + NULL, + NULL, + "syslog", + "/sbin/syslogd", + "-n", + NULL, + INIT_D_BEGIN + INIT_D_PROV "$syslog" + INIT_D_RSTART "$local_fs $time" + INIT_D_SSTART "$network" + INIT_D_DSTART "1 2 3 4 5" + INIT_D_DSTOP "0 6" + INIT_D_SDESC "System logger." INIT_D_DESC "System logger." INIT_D_END }; int boot_syslog_main(int argc, char **argv) { - return do_init_from_main(argc, argv, &my_commands); + return do_init_from_main(argc, argv, &my_commands); } static int start(struct init_d_handle_s *init_d, int just_checking) { -/* -#LOGHOST=`cat /var/lib/my_linux/config/loghost 2> /dev/null` -#if [ "$LOGHOST" ] -#then -# if [ "$LOGHOST" = "prompt" ] -# then -# echo -n "Enter syslog server: " -# read $LOGHOST -# fi -# $REMOTELOG = "-R $LOGHOST" -#fi -*/ + char *LOGHOST = getenv("SYSLOGD_LOGHOST"); + + if (LOGHOST && (LOGHOST[0] != '\0')) { + char *temp; /* Being paranoid here, probably. */ + + bb_xasprintf(&temp, "%s", init_d->args); + bb_xasprintf(&(init_d->args), "%s -R %s", temp, LOGHOST); + free(temp); + } + return default_start(init_d, 0); } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -31,35 +34,34 @@ static int status(struct init_d_handle_s *, int); static int stop(struct init_d_handle_s *, int); -static init_d_handle_t my_commands = -{ - &start, - &stop, - NULL, - NULL, - &no_reload, - NULL, - &status, - NULL, - "boot_time", - NULL, - NULL, - NULL, - INIT_D_BEGIN \ - INIT_D_PROV "$time" \ - INIT_D_DSTART "1 2 3 4 5" \ - INIT_D_DSTOP "0 6" \ - INIT_D_SDESC "Set the system time." \ - INIT_D_DESC "Set the system time, maybe from the hardware clock," \ - INIT_D_CONT "maybe from the network via NTP or DATE." \ - INIT_D_END +static init_d_handle_t my_commands = { + &start, + &stop, + NULL, + NULL, + &no_reload, + NULL, + &status, + NULL, + "time", + NULL, + NULL, + NULL, + INIT_D_BEGIN + INIT_D_PROV "$time" + INIT_D_DSTART "1 2 3 4 5" + INIT_D_DSTOP "0 6" + INIT_D_SDESC "Set the system time." + INIT_D_DESC "Set the system time, maybe from the hardware clock," + INIT_D_CONT "maybe from the network via NTP or DATE." INIT_D_END }; + // INIT_D_SSTART "$network" \ int boot_time_main(int argc, char **argv) { - return do_init_from_main(argc, argv, &my_commands); + return do_init_from_main(argc, argv, &my_commands); } @@ -67,22 +69,22 @@ static int start(struct init_d_handle_s *init_d, int just_checking) { // Should check if we need to NTP or whatever // Should check for -l/-u - doit(0, "/sbin/hwclock -su"); + doit(0, "/sbin/hwclock -su"); // Should check errno and convert into INIT_D_ERROR_? - return INIT_D_OK; + return INIT_D_OK; } static int status(struct init_d_handle_s *init_d, int quiet) { - return print_status(init_d, quiet, INIT_D_STATUS_OK); + return print_status(init_d, quiet, INIT_D_STATUS_OK); } static int stop(struct init_d_handle_s *init_d, int just_checking) { // Should check for -l/-u - doit(0, "/sbin/hwclock -wu"); + doit(0, "/sbin/hwclock -wu"); // Should check errno and convert into INIT_D_ERROR_? - return INIT_D_OK; + return INIT_D_OK; } 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 @@ +config.h +.config +.config.cmd +.depend +conf +mconf +mkdep +lex.zconf.c +lkc_defs.h +zconf.tab.c +zconf.tab.h +gzip.c +runlevel +my_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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -20,6 +23,7 @@ * */ +#include #include #include "busybox.h" @@ -28,21 +32,74 @@ int install_initd_main(int argc, char **argv) { - llist_t *sorted = NULL; - llist_t *unsorted = get_scripts(); -// char *info_text = NULL; -// char *pathname = NULL; -// init_d_info_t *info = NULL; - -// bb_xasprintf(&pathname, "/etc/init.d/%s", script->d_name); -// info_text = get_init_info(pathname); -// info = parse_init_info(info_text, script->d_name); -// if (info) -// result = llist_add_to(result, (char *) info); - - sorted = sort_scripts(unsorted); -// Should return 1 if this script is in unsorted. - -// free(info_text); - return EXIT_SUCCESS; + int result = EXIT_FAILURE; + + argv += optind; + if (!*argv) + bb_show_usage(); + else { + int in_init = 0; + llist_t *current = NULL; + llist_t *unsorted = get_scripts(); + init_d_info_t *info = NULL; + char *info_text = NULL; + char *pathname = NULL; + RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX); + + bb_xasprintf(&pathname, "%s", *argv); + if ((*argv)[0] != '/') { + char *cwd = xgetcwd(NULL); + + if (cwd) { + free(pathname); + bb_xasprintf(&pathname, "%s/%s", cwd, *argv); + } + } + + if (realpath(pathname, resolved_path) != NULL) { + if (strncmp("/etc/init.d/", resolved_path, 12) == 0) + in_init = 1; + } else { + bb_perror_msg("%s", pathname); + } + + if (!in_init) { + bb_xasprintf(&info_text, "/etc/init.d/%s", bb_get_last_path_component(pathname)); + symlink(pathname, info_text); + free(info_text); + } + + info_text = get_init_info(pathname); + info = parse_init_info(info_text, bb_get_last_path_component(pathname)); + + sort_scripts(unsorted, info); + current = unsorted; + result = EXIT_SUCCESS; + while (current) { + init_d_info_t *this_one = (init_d_info_t *) current->data; + + if (this_one) { + if (strcmp(this_one->path, info->path) == 0) { + result = EXIT_FAILURE; + free(info_text); + bb_xasprintf(&info_text, "/etc/init.d/%s", bb_get_last_path_component(pathname)); + remove_file(info_text, FILEUTILS_FORCE); + break; + } + } + current = current->link; + } + + if (result == EXIT_FAILURE) + bb_error_msg("Unable to install the %s init.d script.", pathname); + +#ifdef CONFIG_FEATURE_CLEAN_UP + RELEASE_CONFIG_BUFFER(resolved_path); +#endif + free(info); + free(pathname); + free(info_text); + } + + return result; } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * + * Clean room implementation of LSB init.d specs. + * A tiny bit was stolen from procps/kill.c in busybox. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -31,61 +35,53 @@ int killproc(char *pidfile, char *pathname, int my_signal) { - char *pids = NULL; - int status = pidofproc(pidfile, pathname, &pids); + char *pids = NULL; + int status = pidofproc(pidfile, pathname, &pids); + + if (status == INIT_D_STATUS_OK) { + int i; + char *pid; + char *strtok_temp; + + pid = strtok_r(pids, " ", &strtok_temp); + for (i = 0; pid != NULL; i++) { + int pid_num; + + if (!isdigit(*pid)) + bb_error_msg("Bad PID '%s'", pid); + pid_num = strtol(pid, NULL, 0); + if (my_signal != 0) { + if (kill(pid_num, my_signal) != 0) + bb_perror_msg("Could not kill pid '%d'", pid_num); + } else { + if (kill(pid_num, SIGTERM) != 0) + bb_perror_msg("Could not kill pid '%d'", pid_num); + sleep(1); + status = pidofproc(pidfile, pathname, &pids); + if (status == INIT_D_STATUS_OK) { + sleep(5); + status = pidofproc(pidfile, pathname, &pids); + if (status == INIT_D_STATUS_OK) { + if (kill(pid_num, SIGKILL) != 0) + bb_perror_msg("Could not kill pid '%d'", pid_num); + } + } + } + + pid = strtok_r(NULL, " ", &strtok_temp); + } - if (status == INIT_D_STATUS_OK) - { - int i; - char *pid; - char *strtok_temp; - - pid = strtok_r(pids, " ", &strtok_temp); - for (i = 0; pid != NULL; i++) - { - int pid_num; - - if (!isdigit(*pid)) - bb_error_msg( "Bad PID '%s'", pid); - pid_num = strtol(pid, NULL, 0); - if (my_signal != 0) - { - if (kill(pid_num, my_signal) != 0) - bb_perror_msg( "Could not kill pid '%d'", pid_num); - } - else - { - if (kill(pid_num, SIGTERM) != 0) - bb_perror_msg( "Could not kill pid '%d'", pid_num); - sleep(1); status = pidofproc(pidfile, pathname, &pids); - if (status == INIT_D_STATUS_OK) - { - sleep(5); - status = pidofproc(pidfile, pathname, &pids); - if (status == INIT_D_STATUS_OK) - { - if (kill(pid_num, SIGKILL) != 0) - bb_perror_msg( "Could not kill pid '%d'", pid_num); - } + if (status == INIT_D_STATUS_DEAD_PID) { + if (pidfile != NULL) + remove_file(pidfile, FILEUTILS_FORCE); + status = INIT_D_STATUS_NOT_RUNNING; } - } - - pid = strtok_r(NULL, " ", &strtok_temp); - } - - status = pidofproc(pidfile, pathname, &pids); - if (status == INIT_D_STATUS_DEAD_PID) - { - if (pidfile != NULL) - remove_file(pidfile, FILEUTILS_FORCE); - status = INIT_D_STATUS_NOT_RUNNING; + if ((my_signal == 0) && (status == INIT_D_STATUS_NOT_RUNNING)) + status = INIT_D_STATUS_OK; } - if ((my_signal == 0) && (status == INIT_D_STATUS_NOT_RUNNING)) - status = INIT_D_STATUS_OK; - } - return status; + return status; } @@ -111,52 +107,45 @@ killproc [-p pidfile] pathname [signal] */ + /* getopt not used, because I don't think it can handle [signal] */ int killproc_main(int argc, char **argv) { - int i; - int my_signal = 0; - char *pidfile = NULL; - char *pathname = NULL; - char *signame = NULL; - - for (i = 1; i < argc; i++) - { - char *p = argv[i]; - - if (*p == '-') - { - p++; - if (*p == 'p') - { - if ((i + 1) < argc) - pidfile = argv[++i]; + int i; + int my_signal = 0; + char *pidfile = NULL; + char *pathname = NULL; + char *signame = NULL; + + for (i = 1; i < argc; i++) { + char *p = argv[i]; + + if (*p == '-') { + p++; + if (*p == 'p') { + if ((i + 1) < argc) + pidfile = argv[++i]; + else + bb_show_usage(); + } else + signame = &argv[i][1]; + } else if (pathname == NULL) + pathname = p; + else if (signame == NULL) + signame = p; else - bb_show_usage(); - } - else - signame = &argv[i][1]; - } - else if (pathname == NULL) - pathname = p; - else if (signame == NULL) - signame = p; - else - bb_show_usage(); - } - - if (pathname == NULL) - bb_show_usage(); - - if (signame != NULL) - { - u_signal_names(signame, &my_signal, 1); - if (my_signal == 0) - { - log_failure_msg("unknown signal."); - bb_show_usage(); + bb_show_usage(); } - } + if (pathname == NULL) + bb_show_usage(); + + if (signame != NULL) { + u_signal_names(signame, &my_signal, 1); + if (my_signal == 0) { + log_failure_msg("unknown signal."); + bb_show_usage(); + } + } //bb_printf("ARGS - %s %s %d = %s\n", pidfile, pathname, my_signal, u_signal_names(NULL, &signal, 1)); - return killproc(pidfile, pathname, my_signal); + return killproc(pidfile, pathname, my_signal); } 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 @@ /* * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au * + * llist_add_to_end() lifted whole from busybox networking/ifupdown.c, + * so it should probably be in libbb. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -26,237 +29,235 @@ #include #include #include -#include /* for uname(2) */ +#include /* for uname(2) */ #include "busybox.h" #include "lib_init_d.h" +const static nodes_t nodes[] = { + {"hda", S_IFBLK, 3, 0, 0}, + {"hdb", S_IFBLK, 3, 64, 0}, + {"hdc", S_IFBLK, 22, 0, 0}, + {"hdd", S_IFBLK, 22, 64, 0}, + {"ram", S_IFBLK, 1, 0, 9}, + {"fd", S_IFBLK, 2, 0, 1}, + {"loop", S_IFBLK, 7, 0, 63}, + {"cloop", S_IFBLK, 240, 0, 7}, + {"vcs", S_IFBLK, 7, 0, 9}, + {"vcsa", S_IFBLK, 7, 0, 9}, + {0, 0, 0, 0, 0} +}; + + static char *shell = 0; struct stat path_stat; char *argv_cat(int argc, char **argv) { - int i; - int length = 1; - char *message = NULL; - - for (i = 0; i < argc; i++) - length += strlen(argv[i]); - message = (char *) xmalloc(sizeof (char) * length); - - if (message != NULL) - { - message[0] = '\0'; - for (i = 1; i < argc; i++) - { - strcat(message, argv[i]); - if (i < (argc - 1)) - strcat(message, " "); + int i; + int length = 1; + char *message = NULL; + + for (i = 0; i < argc; i++) + length += strlen(argv[i]) + 1; + message = (char *) xmalloc(sizeof(char) * length); + + if (message != NULL) { + message[0] = '\0'; + for (i = 1; i < argc; i++) { + /* These strcat's are not dangerous, since we checked sizes above. */ + strcat(message, argv[i]); + if (i < (argc - 1)) + strcat(message, " "); + } } - } - return message; + return message; } char *big_chomp(char *s) { - char *lc = index(s, '\n'); + char *lc = index(s, '\n'); - if(lc) - *lc = '\0'; - return s; + if (lc) + *lc = '\0'; + return s; } +/* I found out that networking/ifupdown.c has a similar function + * with an identical name AFTER I wrote this. + */ char *doit(int mode, char *command, ...) { - int buffsize = 63; - char *buffer = NULL; - int dataPipe[2] = { -1, -1 }; - int statusPipe[2] = { -1, -1 }; - int n; - pid_t pid = 0; - volatile int vfork_exec_errno = 0; - char **args; - char *commandBuffer; - - if (mode & DAEMON) - mode |= FORK | QUIET; - - va_list p; - int r; - - va_start(p, command); - r = vasprintf(&commandBuffer, command, p); - va_end(p); - - if (r < 0) - bb_perror_msg_and_die("doit"); - - if (shell == 0) - { - shell = getenv("SHELL"); - if (shell == 0) - shell = "/bin/sh"; - } - - args = (char **) xmalloc (sizeof (char *) * 4); - n = 0; - args[n++] = shell; - args[n++] = "-c"; - if (mode & QUIET) - bb_xasprintf(&(args[n++]), "%s 2>/dev/null", commandBuffer); - else - args[n++] = commandBuffer; - args[n++] = 0; - - if (!(mode & NOFORK)) - { - if (!(mode & DAEMON)) - { - if (pipe(dataPipe) < 0 || pipe(statusPipe) < 0) - bb_perror_msg("Failed to create pipe"); - signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ - } -// pid = vfork(); - pid = fork(); - } - if (pid == 0) /* child */ - { - if ((!(mode & NOFORK)) && (!(mode & NOFORK))) - { - close(STDIN_FILENO); - dup2(dataPipe[1], STDOUT_FILENO); - dup2(dataPipe[1], STDERR_FILENO); - close(dataPipe[0]); - close(statusPipe[0]); - fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */ + int buffsize = 63; + char *buffer = NULL; + int dataPipe[2] = { -1, -1 }; + int statusPipe[2] = { -1, -1 }; + int n; + pid_t pid = 0; + volatile int vfork_exec_errno = 0; + char **args; + char *commandBuffer; + + if (mode & DAEMON) + mode |= FORK | QUIET; + + va_list p; + int r; + + va_start(p, command); + r = vasprintf(&commandBuffer, command, p); + va_end(p); + + if (r < 0) + bb_perror_msg_and_die("doit"); + + if (shell == 0) { + shell = getenv("SHELL"); + if (shell == 0) + shell = "/bin/sh"; } - if ((mode & DAEMON)) - { - if (!(mode & NOFORK)) - { - close(dataPipe[1]); - close(statusPipe[1]); - close(STDOUT_FILENO); - close(STDERR_FILENO); - } - daemon(1, 0); - } - errno = 0; - execvp(shell, (char **) args ); - - vfork_exec_errno = errno; - if (!(mode & NOFORK)) - close(statusPipe[1]); - _exit(-1); - } - else if (pid > 0) /* parent */ - { - close(dataPipe[1]); - close(statusPipe[1]); - - while (1) - { - char buf; - - n = read(statusPipe[0], &buf, 1); - - if ((n < 0) && ((errno == EAGAIN) || (errno == EINTR)) && !(mode & FORK)) - continue; /* try it again */ - else if (n == 0 && vfork_exec_errno != 0) - { - errno = vfork_exec_errno; - bb_perror_msg("Could not exec process"); - } - break; + args = (char **) xmalloc(sizeof(char *) * 4); + n = 0; + args[n++] = shell; + args[n++] = "-c"; + if (mode & QUIET) + bb_xasprintf(&(args[n++]), "%s 2>/dev/null", commandBuffer); + else + args[n++] = commandBuffer; + args[n++] = 0; + + if (!(mode & NOFORK)) { + if (!(mode & DAEMON)) { + if (pipe(dataPipe) < 0 || pipe(statusPipe) < 0) + bb_perror_msg("Failed to create pipe"); + signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ + } +// pid = vfork(); + pid = fork(); } - close(statusPipe[0]); - - if (buffer == NULL) - buffer = (char *) xcalloc(buffsize + 1, sizeof (char)); - - if ((mode & FORK) == 0) - { - ssize_t cc; - struct pollfd poller[1]; + if (pid == 0) { /* child */ + if ((!(mode & NOFORK)) && (!(mode & NOFORK))) { + close(STDIN_FILENO); + dup2(dataPipe[1], STDOUT_FILENO); + dup2(dataPipe[1], STDERR_FILENO); + close(dataPipe[0]); + close(statusPipe[0]); + fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */ + } - poller[0].fd = dataPipe[0]; - poller[0].events = POLLIN | POLLPRI; - poller[0].revents = 0; + if ((mode & DAEMON)) { + if (!(mode & NOFORK)) { + close(dataPipe[1]); + close(statusPipe[1]); + close(STDOUT_FILENO); + close(STDERR_FILENO); + } + daemon(1, 0); + } + errno = 0; + execvp(shell, (char **) args); - n = 0; - while (1) - { - if ((buffsize - n) <= 0) - { - int i; + vfork_exec_errno = errno; + if (!(mode & NOFORK)) + close(statusPipe[1]); + _exit(-1); + } else if (pid > 0) { /* parent */ + close(dataPipe[1]); + close(statusPipe[1]); - buffsize += buffsize; - buffer = xrealloc(buffer, sizeof(char) * (buffsize + 1)); - for (i = n; i <= buffsize; i++) - buffer[i] = '\0'; - } + while (1) { + char buf; - errno = 0; - cc = poll(poller, 1, 1010); /* network sleeps for 1000 between '.' outputs */ - if (cc > 0) - cc = read(dataPipe[0], &buffer[n], buffsize - n); + n = read(statusPipe[0], &buf, 1); - if (cc < 0) - { - if (errno == EINTR) - continue; - if (errno == EAGAIN) - continue; + if ((n < 0) && ((errno == EAGAIN) || (errno == EINTR)) + && !(mode & FORK)) + continue; /* try it again */ + else if (n == 0 && vfork_exec_errno != 0) { + errno = vfork_exec_errno; + bb_perror_msg("Could not exec process"); + } break; } - else if (cc == 0) - break; + close(statusPipe[0]); + + if (buffer == NULL) + buffer = (char *) xcalloc(buffsize + 1, sizeof(char)); + + if ((mode & FORK) == 0) { + ssize_t cc; + struct pollfd poller[1]; + + poller[0].fd = dataPipe[0]; + poller[0].events = POLLIN | POLLPRI; + poller[0].revents = 0; + + n = 0; + while (1) { + if ((buffsize - n) <= 0) { + int i; + + buffsize += buffsize; + buffer = xrealloc(buffer, sizeof(char) * (buffsize + 1)); + for (i = n; i <= buffsize; i++) + buffer[i] = '\0'; + } + + errno = 0; + cc = poll(poller, 1, 1010); /* network sleeps for 1000 between '.' outputs */ + if (cc > 0) + cc = read(dataPipe[0], &buffer[n], buffsize - n); + + if (cc < 0) { + if (errno == EINTR) + continue; + if (errno == EAGAIN) + continue; + break; + } else if (cc == 0) + break; + + if ((mode & (QUIET | REDIR)) == 0) + bb_printf(&buffer[n]); + n += cc; + } + } - if ((mode & (QUIET | REDIR)) == 0) - bb_printf(&buffer[n]); - n += cc; - } + if (mode & REDIR) + chomp(buffer); + } else { + bb_perror_msg("Failed to fork process"); } - if (mode & REDIR) - chomp(buffer); - } - else - { - bb_perror_msg("Failed to fork process"); - } - - n = 0; - if (pid) - { - close(dataPipe[0]); - - if ((mode & FORK) == 0) - { - if (waitpid(pid, &n, 0) == -1) - bb_printf("Couldn't wait?"); + n = 0; + if (pid) { + close(dataPipe[0]); + + if ((mode & FORK) == 0) { + if (waitpid(pid, &n, 0) == -1) + bb_printf("Couldn't wait?"); + } + if (WIFEXITED(n)) + n = WEXITSTATUS(n); + else + n = -1; } - if (WIFEXITED(n)) - n = WEXITSTATUS(n); - else - n = -1; - } - free(args); - free(commandBuffer); - errno = n; - return buffer; + free(args); + free(commandBuffer); + errno = n; + return buffer; } #ifdef RUNLEVEL_LIST // From ifupdown, so it should probably be in libbb. -llist_t *llist_add_to_end(llist_t *list_head, char *data) +llist_t *llist_add_to_end(llist_t * list_head, char *data) { llist_t *new_item, *tmp, *prev; @@ -266,160 +267,270 @@ llist_t *llist_add_to_end(llist_t *list_head, char *data) prev = NULL; tmp = list_head; - while(tmp) - { - prev = tmp; - tmp = tmp->link; + while (tmp) { + prev = tmp; + tmp = tmp->link; } if (prev) - prev->link = new_item; + prev->link = new_item; else - list_head = new_item; + list_head = new_item; - return(list_head); + return (list_head); } #endif -llist_t *llist_delete(llist_t **head, llist_t *previous, llist_t *current) +llist_t *llist_delete(llist_t ** head, llist_t * previous, llist_t * current) { - if (previous == NULL) - { - *head = current->link; - free(current); - current = *head; - } - else - { - previous->link = current->link; - free(current); - current = previous->link; - } - - return current; + if (previous == NULL) { + *head = current->link; + free(current); + current = *head; + } else { + previous->link = current->link; + free(current); + current = previous->link; + } + + return current; } -void make_disk(char *token, const nodes_t *nodes) +void make_disk(char *token) { - int i; - char temp[32]; - - for (i = 0; nodes[i].name != 0; i++) - { - if (strncmp(nodes[i].name, token, 3) == 0) - { - int m = atoi(&token[3]); - sprintf(temp, "/dev/%s", token); - mknod(temp, nodes[i].mode, makedev(nodes[i].major, nodes[i].minor + m)); - break; + int i; + + RESERVE_CONFIG_BUFFER(temp, PATH_MAX); + + if (nodes == NULL) + return; + + for (i = 0; nodes[i].name != NULL; i++) { + if (strncmp(nodes[i].name, token, 3) == 0) { + int m = atoi(&token[3]); + + snprintf(temp, PATH_MAX, "/dev/%s", token); + mknod(temp, nodes[i].mode, + makedev(nodes[i].major, nodes[i].minor + m)); + break; + } } - } - sprintf(temp, "/media/%s", token); - bb_make_directory(temp, -1l, FILEUTILS_RECUR); + snprintf(temp, PATH_MAX, "/media/%s", token); + bb_make_directory(temp, -1l, FILEUTILS_RECUR); + RELEASE_CONFIG_BUFFER(temp); } void make_ram_disk(int size, int number, char *place, int TMPFS) { - if (size > 0) - { - char *place2; - - bb_printf( "Creating ramdisk at %s\n", place); - bb_xasprintf(&place2, "%s2", place); - if (copy_file(place, place2, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0) - remove_file(place, FILEUTILS_RECUR | FILEUTILS_FORCE); - bb_make_directory (place, -1l, 0); - if (TMPFS) - quick_mount("tmpfs", "/dev/null", place, "-n -o size=%i", size * 1024); - else - { - doit(QUIET, "mkfs.minix /dev/ram%i %i", number, size); - quick_mount("minix", "", "", "/dev/ram%i %s", number, place); + if (size > 0) { + char *place2; + + bb_printf("Creating ramdisk at %s\n", place); + bb_xasprintf(&place2, "%s2", place); + if (copy_file + (place, place2, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0) + remove_file(place, FILEUTILS_RECUR | FILEUTILS_FORCE); + bb_make_directory(place, -1l, 0); + if (TMPFS) + quick_mount("tmpfs", "/dev/null", place, "-n -o size=%i", + size * 1024); + else { + doit(QUIET, "mkfs.minix /dev/ram%i %i", number, size); + quick_mount("minix", "", "", "/dev/ram%i %s", number, place); + } + if (copy_file + (place2, place, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0) + remove_file(place2, FILEUTILS_RECUR | FILEUTILS_FORCE); + free(place2); } - if (copy_file(place2, place, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0) - remove_file(place2, FILEUTILS_RECUR | FILEUTILS_FORCE); - free(place2); - } } void quick_mount(char *type, char *device, char *path, char *data, ...) { - char *dataBuffer; - va_list p; - int r; - - va_start(p, data); - r = vasprintf(&dataBuffer, data, p); - va_end(p); - if (r < 0) - bb_perror_msg("quick_mount"); - else - { - doit(QUIET, "busybox mount -t %s %s %s %s", type, device, path, dataBuffer); - } - - free(dataBuffer); + char *dataBuffer; + va_list p; + int r; + + va_start(p, data); + r = vasprintf(&dataBuffer, data, p); + va_end(p); + if (r < 0) + bb_perror_msg("quick_mount"); + else { + doit(QUIET, "busybox mount -t %s %s %s %s", type, device, path, + dataBuffer); + } + + free(dataBuffer); } char *quick_read(char *filename) { - char *result = NULL; - - if (stat(filename, &path_stat) == 0) - { -// if (S_ISREG(path_stat.st_mode)) - { - int ifd; - ssize_t size = path_stat.st_size; - - if (size <= 0) - size = 1024; - result = (char *) xmalloc (sizeof (char) * size + 1); - if ((ifd = open(filename, O_RDONLY)) < 0) - bb_perror_msg("%s", filename); - else - { - ssize_t total = bb_full_read(ifd, result, size); -// result[path_stat.st_size] = '\0'; - result[total] = '\0'; - if (close (ifd) < 0) - bb_perror_msg("%s", filename); - } + char *result = NULL; + + if (stat(filename, &path_stat) == 0) { +// if (S_ISREG(path_stat.st_mode)) + { + int ifd; + ssize_t size = path_stat.st_size; + + if (size <= 0) + size = 1024; + result = (char *) xmalloc(sizeof(char) * size + 1); + if ((ifd = open(filename, O_RDONLY)) < 0) + bb_perror_msg("%s", filename); + else { + ssize_t total = bb_full_read(ifd, result, size); + +// result[path_stat.st_size] = '\0'; + result[total] = '\0'; + if (close(ifd) < 0) + bb_perror_msg("%s", filename); + } + } } - } - return result; + return result; } void quick_write(const char *filename, const char *data, ...) { - char *dataBuffer; - va_list p; - int r; - - va_start(p, data); - r = vasprintf(&dataBuffer, data, p); - va_end(p); - if (r >= 0) - { - int ofd; - - if ((ofd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) - bb_perror_msg("%s", filename); - else - { - r = bb_full_write(ofd, dataBuffer, r); - if (close (ofd) < 0) - bb_perror_msg("%s", filename); + char *dataBuffer; + va_list p; + int r; + + va_start(p, data); + r = vasprintf(&dataBuffer, data, p); + va_end(p); + if (r >= 0) { + int ofd; + + if ((ofd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) + bb_perror_msg("%s", filename); + else { + r = bb_full_write(ofd, dataBuffer, r); + if (close(ofd) < 0) + bb_perror_msg("%s", filename); + } + } + if (r < 0) + bb_perror_msg("quick_write"); + + free(dataBuffer); +} + + +void read_sysconfig(char *sysconfig) +{ + if (sysconfig == NULL) + sysconfig = "/bootconfig"; + if (stat(sysconfig, &path_stat) == 0) { + char *line; + FILE *contents; + + contents = fopen(sysconfig, "r"); + if (contents != NULL) { + char *buffer = (char *) xmalloc(sizeof(char) * 256); + +//bb_printf("Parsing configuration.\n"); + do { + line = fgets(buffer, 255, contents); + set_sysconfig_env(buffer); + } while (line != NULL); + } + } +} + + +void set_sysconfig_env(char *token) +{ + int i; + char *eq = NULL; + char *ha = NULL; + char quote = 0; + + if (token == NULL) + return; + trim(token); + if (token[0] == '\0') + return; + for (i = 0; token[i] != '\0'; i++) { + switch (token[i]) { + case '=': + if (quote == 0) { + if (eq == NULL) + eq = &token[i]; + } + break; + case '#': + if (quote == 0) { + if (ha == NULL) + ha = &token[i]; + } + break; + + case '"': + if (quote == 0) { + quote = '"'; + if (eq) { + *eq = '\0'; + eq = &token[i]; + } + } + else if (quote == '"') { + quote = 0; + token[i] = '\0'; + } + break; + + case '\'': + if (quote == 0) { + quote = '\''; + if (eq) { + *eq = '\0'; + eq = &token[i]; + } + } + else if (quote == '\'') { + quote = 0; + token[i] = '\0'; + } + break; + } } - } - if (r < 0) - bb_perror_msg("quick_write"); - free(dataBuffer); + if (eq == NULL) + return; + + if ((eq != token) && (ha != token)) { + char *name = (char *) xmalloc(sizeof(char) * (i + 5)); + + if (eq != NULL) + *eq = '\0'; + if (ha != NULL) + *ha = '\0'; + sprintf(name, "%s", token); + trim(name); + if (name[0] != '\0') { + if (eq != NULL) { + // Don't override previously set env. + if (getenv(name) == NULL) { + setenv(name, &eq[1], 1); + } + } else { + setenv(name, "", 1); + } + } + free(name); +// if (eq != NULL) +// *eq = '='; +// if (ha != NULL) +// *ha = '#'; + } } + 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 { char **reqstop; char **shouldstart; char **shouldstop; - int *defstart; - int *defstop; + int *defstart; + int *defstop; char *shortdesc; char *desc; char *comment; @@ -69,14 +69,14 @@ typedef struct init_d_info_s { */ typedef struct init_d_handle_s { - int (*start)(struct init_d_handle_s *, int); - int (*stop)(struct init_d_handle_s *, int); - int (*restart)(struct init_d_handle_s *, int); - int (*try_restart)(struct init_d_handle_s *, int); - int (*reload)(struct init_d_handle_s *, int); - int (*force_reload)(struct init_d_handle_s *, int); - int (*status)(struct init_d_handle_s *, int); - int (*show_info)(struct init_d_handle_s *, int); + int (*start) (struct init_d_handle_s *, int); + int (*stop) (struct init_d_handle_s *, int); + int (*restart) (struct init_d_handle_s *, int); + int (*try_restart) (struct init_d_handle_s *, int); + int (*reload) (struct init_d_handle_s *, int); + int (*force_reload) (struct init_d_handle_s *, int); + int (*status) (struct init_d_handle_s *, int); + int (*show_info) (struct init_d_handle_s *, int); char *basename; char *pathname; char *args; @@ -142,7 +142,8 @@ int print_status(struct init_d_handle_s *init_d, int quiet, int status); /* * /lib/lsb/init-functions */ -int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args); +int start_daemon(int force, int nice_level, char *pidfile, char *pathname, + char *args); int killproc(char *pidfile, char *pathname, int my_signal); int checkpid(char *pid); int pidofproc(char *pidfile, char *pathname, char **pids); @@ -154,7 +155,7 @@ void log_warning_msg(char *message); init_d_info_t *parse_init_info(char *info_text, char *name); char *get_init_info(char *pathname); llist_t *get_scripts(void); -llist_t *sort_scripts(llist_t *unsorted); +llist_t *sort_scripts(llist_t * unsorted, init_d_info_t *for_script); #define REDIR 1 @@ -166,8 +167,7 @@ llist_t *sort_scripts(llist_t *unsorted); extern struct stat path_stat; -typedef struct nodes_s -{ +typedef struct nodes_s { const char *name; mode_t mode; int major; @@ -186,17 +186,20 @@ char *doit(int mode, char *command, ...); #endif #ifdef RUNLEVEL_LIST // From ifupdown, so it should probably be in libbb. -llist_t *llist_add_to_end(llist_t *list_head, char *data); +llist_t *llist_add_to_end(llist_t * list_head, char *data); #else -extern llist_t *llist_add_to_end(llist_t *list_head, char *data); +extern llist_t *llist_add_to_end(llist_t * list_head, char *data); #endif -llist_t *llist_delete(llist_t **unsorted, llist_t *previous, llist_t *current); -void make_disk(char *token, const nodes_t *nodes); +llist_t *llist_delete(llist_t ** unsorted, llist_t * previous, + llist_t * current); +void make_disk(char *token); void make_ram_disk(int size, int number, char *place, int TMPFS); void quick_mount(char *type, char *device, char *path, char *data, ...); char *quick_read(char *filename); void quick_write(const char *filename, const char *data, ...); +void read_sysconfig(char *sysconfig); +void set_sysconfig_env(char *token); #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 @@ * * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au * + * Originally based on code from Trinux. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -27,62 +29,44 @@ #include "lib_init_d.h" -const static nodes_t nodes[] = -{ - {"hda", S_IFBLK, 3, 0, 0}, - {"hdb", S_IFBLK, 3, 64, 0}, - {"hdc", S_IFBLK, 22, 0, 0}, - {"hdd", S_IFBLK, 22, 64, 0}, - {"ram", S_IFBLK, 1, 0, 9}, - {"fd", S_IFBLK, 2, 0, 1}, - {"loop", S_IFBLK, 7, 0,63}, - {"cloop", S_IFBLK, 240, 0, 7}, - {"vcs", S_IFBLK, 7, 0, 9}, - {"vcsa", S_IFBLK, 7, 0, 9}, - {0, 0, 0, 0, 0} -}; - - static int start(struct init_d_handle_s *, int); static int status(struct init_d_handle_s *, int); static int stop(struct init_d_handle_s *, int); -static init_d_handle_t my_commands = -{ - &start, - &stop, - NULL, - NULL, - &no_reload, - NULL, - &status, - NULL, - "local_fs", - NULL, - NULL, - NULL, - INIT_D_BEGIN \ - INIT_D_PROV "$local_fs" \ - INIT_D_DSTART "1 2 3 4 5" \ - INIT_D_DSTOP "0 6" \ - INIT_D_SDESC "Mount all local file systems." \ - INIT_D_DESC "Mount all local file systems." \ - INIT_D_CONT "Including any left over partitions not otherwise mounted." \ - INIT_D_END +static init_d_handle_t my_commands = { + &start, + &stop, + NULL, + NULL, + &no_reload, + NULL, + &status, + NULL, + "local_fs", + NULL, + NULL, + NULL, + INIT_D_BEGIN + INIT_D_PROV "$local_fs" + INIT_D_DSTART "1 2 3 4 5" + INIT_D_DSTOP "0 6" + INIT_D_SDESC "Mount all local file systems." + INIT_D_DESC "Mount all local file systems." + INIT_D_CONT + "Including any left over partitions not otherwise mounted." INIT_D_END }; -static const char *i386_sys_types[] = -{ -// " 0Empty", -// " 1fat", -// " 4fat", -// " 6fat", -// " bvfat", +static const char *i386_sys_types[] = { +// " 0Empty", +// " 1fat", +// " 4fat", +// " 6fat", +// " bvfat", " cvfat", -// " evfat", -// " fvfat", +// " evfat", +// " fvfat", "80minix", "81minix", "82swap", @@ -94,98 +78,98 @@ static const char *i386_sys_types[] = int local_fs_main(int argc, char **argv) { - return do_init_from_main(argc, argv, &my_commands); + return do_init_from_main(argc, argv, &my_commands); } static int start(struct init_d_handle_s *init_d, int just_checking) { - int i; - char *CMDLINE = 0; - char *ROOT = 0; - char *CDEV = 0; - char *FDEV = 0; - char *token; - char *strtok_temp; - -sleep(5); // delay it for testing purposes + int i; + char *CMDLINE = 0; + char *ROOT = 0; + char *CDEV = 0; + char *FDEV = 0; + char *token; + char *strtok_temp; + + sleep(5); // delay it for testing purposes // Should fsck all non root partitions first. - doit(0, "/bin/mount -a"); - bb_xasprintf(&CMDLINE, "%s", doit(REDIR, "cat /proc/cmdline")); - for (token = strtok_r(CMDLINE, " \t\n\r", &strtok_temp); token != NULL; token = strtok_r(NULL, " \t\n\r", &strtok_temp)) - { - if (strncmp(token, "ROOT=", 5) == 0) - ROOT = &token[5]; - } - - bb_xasprintf(&CDEV, "%s", doit(REDIR, "dmesg | grep D-ROM | grep hd | cut -d: -f1 | sort | uniq")); - - bb_xasprintf(&FDEV, "%s %s", doit(REDIR, "dmesg | grep -v LDM | grep \"^ [sh]d[a-f]\" | cut -d':' -f2 | sort | uniq"), (CDEV != 0) ? CDEV : ""); - token = strtok_r(FDEV, " \r\n", &strtok_temp); - for (i = 0; token != NULL; i++) - { - if (strlen(token) > 2) - make_disk(token, nodes); - token = strtok_r(NULL, " \r\n", &strtok_temp); - } - - bb_xasprintf(&FDEV, "%s", doit(REDIR, "fdisk -l | grep \"^/dev/\" | cut -b6-10,52-55")); - token = strtok_r(FDEV, "\r\n", &strtok_temp); - for (i = 0; token != NULL; i++) - { - int j; - int found = 0; - char *type = &token[6]; - token[4] = '\0'; - for (j = 0; i386_sys_types[j] != 0; j++) - { - if (strncmp(i386_sys_types[j], type, 2) == 0) - { - char *DEV = 0; - char *MOUNT = 0; - char *TYPE = 0; - - bb_xasprintf(&DEV, "/dev/%s", token); - bb_xasprintf(&MOUNT, "/media/%s", token); - bb_xasprintf(&TYPE, "%s", &i386_sys_types[j][2]); - found = 1; - if (strncmp(&i386_sys_types[j][2], "swap", 4) == 0) - { - doit(QUIET, "mkswap %s", DEV); - doit(QUIET, "swapon %s", DEV); - } - else - { + doit(0, "/bin/mount -a"); + bb_xasprintf(&CMDLINE, "%s", doit(REDIR, "cat /proc/cmdline")); + for (token = strtok_r(CMDLINE, " \t\n\r", &strtok_temp); token != NULL; + token = strtok_r(NULL, " \t\n\r", &strtok_temp)) { + if (strncmp(token, "ROOT=", 5) == 0) + ROOT = &token[5]; + } + + bb_xasprintf(&CDEV, "%s", + doit(REDIR, + "dmesg | grep D-ROM | grep hd | cut -d: -f1 | sort | uniq")); + + bb_xasprintf(&FDEV, "%s %s", + doit(REDIR, + "dmesg | grep -v LDM | grep \"^ [sh]d[a-f]\" | cut -d':' -f2 | sort | uniq"), + (CDEV != 0) ? CDEV : ""); + token = strtok_r(FDEV, " \r\n", &strtok_temp); + for (i = 0; token != NULL; i++) { + if (strlen(token) > 2) + make_disk(token); + token = strtok_r(NULL, " \r\n", &strtok_temp); + } + + bb_xasprintf(&FDEV, "%s", + doit(REDIR, + "fdisk -l | grep \"^/dev/\" | cut -b6-10,52-55")); + token = strtok_r(FDEV, "\r\n", &strtok_temp); + for (i = 0; token != NULL; i++) { + int j; + int found = 0; + char *type = &token[6]; + + token[4] = '\0'; + for (j = 0; i386_sys_types[j] != 0; j++) { + if (strncmp(i386_sys_types[j], type, 2) == 0) { + char *DEV = 0; + char *MOUNT = 0; + char *TYPE = 0; + + bb_xasprintf(&DEV, "/dev/%s", token); + bb_xasprintf(&MOUNT, "/media/%s", token); + bb_xasprintf(&TYPE, "%s", &i386_sys_types[j][2]); + found = 1; + if (strncmp(&i386_sys_types[j][2], "swap", 4) == 0) { + doit(QUIET, "mkswap %s", DEV); + doit(QUIET, "swapon %s", DEV); + } else { // Should not mount it if it is already mounted. - if ((ROOT == 0) || strcmp(ROOT, DEV) != 0) /* Don't try to remount ROOT, */ - { - make_disk(token, nodes); - quick_mount(TYPE, DEV, MOUNT, "-o ro"); -// quick_mount("auto", DEV, MOUNT, "-o ro"); - } + if ((ROOT == 0) || strcmp(ROOT, DEV) != 0) { /* Don't try to remount ROOT, */ + make_disk(token); + quick_mount(TYPE, DEV, MOUNT, "-o ro"); +// quick_mount("auto", DEV, MOUNT, "-o ro"); + } + } + + break; + } } +// if (found == 0) +// bb_printf(" %s - unknown\n", token); - break; - } + token = strtok_r(NULL, "\r\n", &strtok_temp); } -// if (found == 0) -// bb_printf(" %s - unknown\n", token); - - token = strtok_r(NULL, "\r\n", &strtok_temp); - } - - free(FDEV); - free(CDEV); - free(ROOT); - free(CMDLINE); - - return INIT_D_OK; + + free(FDEV); + free(CDEV); + free(ROOT); + free(CMDLINE); + + return INIT_D_OK; } static int status(struct init_d_handle_s *init_d, int quiet) { - return print_status(init_d, quiet, INIT_D_STATUS_OK); + return print_status(init_d, quiet, INIT_D_STATUS_OK); } @@ -193,7 +177,7 @@ static int stop(struct init_d_handle_s *init_d, int just_checking) { // Should only umount things we mounted in the first place. // Same for swap - doit(0, "/sbin/swapoff -a"); - doit(0, "/bin/umount -a -r"); - return INIT_D_OK; + doit(0, "/sbin/swapoff -a"); + doit(0, "/bin/umount -a -r"); + return INIT_D_OK; } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -28,7 +31,7 @@ void log_failure_msg(char *message) { - bb_perror_msg("Failure - %s\n", message); + bb_error_msg("Failure - %s\n", message); } @@ -41,14 +44,13 @@ log_failure_msg "message" int log_failure_msg_main(int argc, char **argv) { - char *message = argv_cat(argc, argv); + char *message = argv_cat(argc, argv); - if (message != NULL) - { - log_failure_msg(message); + if (message != NULL) { + log_failure_msg(message); - free(message); - return EXIT_SUCCESS; - } - return EXIT_FAILURE; + free(message); + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -28,7 +31,7 @@ void log_success_msg(char *message) { - bb_printf("Success - %s\n", message); + bb_printf("Success - %s\n", message); } @@ -41,14 +44,13 @@ log_success_msg "message" int log_success_msg_main(int argc, char **argv) { - char *message = argv_cat(argc, argv); + char *message = argv_cat(argc, argv); - if (message != NULL) - { - log_success_msg(message); + if (message != NULL) { + log_success_msg(message); - free(message); - return EXIT_SUCCESS; - } - return EXIT_FAILURE; + free(message); + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -28,7 +31,7 @@ void log_warning_msg(char *message) { - bb_perror_msg("Warning - %s\n", message); + bb_error_msg("Warning - %s\n", message); } @@ -41,14 +44,13 @@ log_warning_msg "message" int log_warning_msg_main(int argc, char **argv) { - char *message = argv_cat(argc, argv); + char *message = argv_cat(argc, argv); - if (message != NULL) - { - log_warning_msg(message); + if (message != NULL) { + log_warning_msg(message); - free(message); - return EXIT_SUCCESS; - } - return EXIT_FAILURE; + free(message); + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } 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 @@ +#! /bin/sh + +pushd .. +make clean +pushd .. +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original busybox-1.00 >busybox-1.00/runlevel/runlevel.patch +# This is needed to support My Linux, and no one wants that. +#diff -urN busybox-1.00-original/archival/gzip.c busybox-1.00/archival/gzip.c >busybox-1.00/my_linux/my_linux.patch +popd +popd 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 @@ * * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au * + * Originally based on code from Trinux. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * 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); static int stop(struct init_d_handle_s *, int); -static init_d_handle_t my_commands = -{ - &start, - &stop, - NULL, - NULL, - NULL, - NULL, - &status, - NULL, - "network", - NULL, - NULL, - NULL, - INIT_D_BEGIN \ - INIT_D_PROV "$network" \ - INIT_D_RSTART "$syslog" \ - INIT_D_DSTART "3 4 5" \ - INIT_D_DSTOP "0 1 2 6" \ - INIT_D_SDESC "Basic network setup" \ - INIT_D_DESC "Configures all your network interfaces," \ - INIT_D_CONT "brings them all up and sets up routing." \ - INIT_D_CONT "Also configures things like port forwarding," \ - INIT_D_CONT "hostnames, etc." \ - INIT_D_END +static init_d_handle_t my_commands = { + &start, + &stop, + NULL, + NULL, + NULL, + NULL, + &status, + NULL, + "network", + NULL, + NULL, + NULL, + INIT_D_BEGIN + INIT_D_PROV "$network" + INIT_D_RSTART "$syslog" + INIT_D_DSTART "3 4 5" + INIT_D_DSTOP "0 1 2 6" + INIT_D_SDESC "Basic network setup" + INIT_D_DESC "Configures all your network interfaces," + INIT_D_CONT "brings them all up and sets up routing." + INIT_D_CONT "Also configures things like port forwarding," + INIT_D_CONT "hostnames, etc." INIT_D_END }; int network_main(int argc, char **argv) { - return do_init_from_main(argc, argv, &my_commands); + return do_init_from_main(argc, argv, &my_commands); } static int start(struct init_d_handle_s *init_d, int just_checking) { - int i; - int my_status = (init_d->status)(init_d, 0); - char *IPADDR = 0; - - if (my_status == INIT_D_STATUS_NOT_RUNNING) - { - my_status = INIT_D_ERROR_NOT_RUNNING; -// if (stat("/proc/net/pnp", &path_stat) == 0) -// copy_file("/proc/net/pnp", "/etc/resolv.conf", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS); - - fflush(stdout); - doit(QUIET, "ifup -af"); - for (i = 20; stat("/var/lib/network/ipaddr", &path_stat) != 0; i--) - { - bb_printf("."); - fflush(stdout); - sleep(2); - if (i <= 0) - { - bb_printf(" timeout."); - break; - } - } - - if (stat("/var/lib/network/ipaddr", &path_stat) == 0) - IPADDR = quick_read("/var/lib/network/ipaddr"); - - if ((IPADDR != 0) && (IPADDR[0] != '\0')) - { - if (stat("/proc/sys/net/ipv4/tcp_syn_retries", &path_stat) == 0) - quick_write("/proc/sys/net/ipv4/tcp_syn_retries", "7"); - if (stat("/var/lib/my_linux/config/ipfwd", &path_stat) == 0) - { - bb_printf("Enabling IP forwarding\n"); - quick_write("/proc/sys/net/ipv4/ip_forward", "1"); - } - if (stat("/var/lib/my_linux/config/noping", &path_stat) == 0) - quick_write("/proc/sys/net/ipv4/icmp_echo_ignore_all", "1"); - my_status = INIT_D_OK; - } - else - my_status = INIT_D_ERROR_GENERIC; - - free(IPADDR); - } - else - my_status = INIT_D_OK; - - return my_status; + int i; + int my_status = (init_d->status) (init_d, 0); + char *IPADDR = 0; + + if (my_status == INIT_D_STATUS_NOT_RUNNING) { + my_status = INIT_D_ERROR_NOT_RUNNING; +// if (stat("/proc/net/pnp", &path_stat) == 0) +// copy_file("/proc/net/pnp", "/etc/resolv.conf", FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS); + + fflush(stdout); + doit(QUIET, "ifup -af"); + for (i = 20; stat("/var/lib/network/ipaddr", &path_stat) != 0; i--) { + bb_printf("."); + fflush(stdout); + sleep(2); + if (i <= 0) { + bb_printf(" timeout."); + break; + } + } + + if (stat("/var/lib/network/ipaddr", &path_stat) == 0) + IPADDR = quick_read("/var/lib/network/ipaddr"); + + if ((IPADDR != 0) && (IPADDR[0] != '\0')) { + char *tcp_syn_retries = getenv("tcp_syn_retries"); + char *ip_forward = getenv("ip_forward"); + char *icmp_echo_ignore_all = getenv("icmp_echo_ignore_all"); + + if (tcp_syn_retries) + quick_write("/proc/sys/net/ipv4/tcp_syn_retries", tcp_syn_retries); + if (ip_forward) { + bb_printf("Enabling IP forwarding\n"); + quick_write("/proc/sys/net/ipv4/ip_forward", ip_forward); + } + if (icmp_echo_ignore_all) + quick_write("/proc/sys/net/ipv4/icmp_echo_ignore_all", icmp_echo_ignore_all); + my_status = INIT_D_OK; + } else + my_status = INIT_D_ERROR_GENERIC; + + free(IPADDR); + } else + my_status = INIT_D_OK; + + return my_status; } static int status(struct init_d_handle_s *init_d, int quiet) { - int my_status = INIT_D_STATUS_NOT_RUNNING; - char *ip = NULL; + int my_status = INIT_D_STATUS_NOT_RUNNING; + char *ip = NULL; - bb_xasprintf(&ip, "%s", doit(REDIR, "ip -o addr | grep lo: | cut -d\" \" -f3 | cut -d\",\" -f2")); - if ((ip != NULL) && (strncmp("UP", ip, 2) == 0)) - my_status = INIT_D_STATUS_OK; + bb_xasprintf(&ip, "%s", + doit(REDIR, + "ip -o addr | grep lo: | cut -d\" \" -f3 | cut -d\",\" -f2")); + if ((ip != NULL) && (strncmp("UP", ip, 2) == 0)) + my_status = INIT_D_STATUS_OK; - return print_status(init_d, quiet, my_status); + return print_status(init_d, quiet, my_status); } static int stop(struct init_d_handle_s *init_d, int just_checking) { - int my_status = default_stop(init_d, 1); - - if (my_status == INIT_D_ERROR_JUST_RUNNING) - { - doit(QUIET, "ifdown -af"); - my_status = INIT_D_OK; - } - return my_status; + int my_status = default_stop(init_d, 1); + + if (my_status == INIT_D_ERROR_JUST_RUNNING) { + doit(QUIET, "ifdown -af"); + my_status = INIT_D_OK; + } + return my_status; } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -30,112 +33,104 @@ int checkpid(char *pid) { - int found = 0; - char proc[132]; - - sprintf(proc, "/proc/%s", pid); - if (stat(proc, &path_stat) == 0) - { - char *state = NULL; - - sprintf(proc, "/proc/%s/stat", pid); - state = quick_read(proc); - if (state != NULL) - { - /* Read and interpret the third space seperated field (State - DRSW = OK - ZX = DEAD_PID - T = STOPPED) */ - if (state[0] != '\0') - { - while (*state != ' ') state++; - while (*state == ' ') state++; - while (*state != ' ') state++ + int found = 0; + + RESERVE_CONFIG_BUFFER(proc, PATH_MAX); + + snprintf(proc, PATH_MAX, "/proc/%s", pid); + if (stat(proc, &path_stat) == 0) { + char *state = NULL; + + snprintf(proc, PATH_MAX, "/proc/%s/stat", pid); + state = quick_read(proc); + if (state != NULL) { + /* Read and interpret the third space seperated field (State - DRSW = OK - ZX = DEAD_PID - T = STOPPED) */ + if (state[0] != '\0') { + while ((*state != ' ') && (*state != '\0')) + state++; + while (*state == ' ') + state++; + while ((*state != ' ') && (*state != '\0')) + state++ // Should compare the name while scanning this. - ; - while (*state == ' ') state++; - switch (*state) - { - case 'D' : - case 'R' : - case 'S' : - case 'W' : - case 'T' : /* Until proven otherwise, I'm assuming this means OK. */ - found = 1; - } - } - } - else /* Paranoid fallbacks. */ - { - sprintf(proc, "/proc/%s/exe", pid); - if (stat(proc, &path_stat) == 0) - { + ; + while (*state == ' ') + state++; + switch (*state) { + case 'D': + case 'R': + case 'S': + case 'W': + case 'T': /* Until proven otherwise, I'm assuming this means OK. */ + found = 1; + } + } + } else { /* Paranoid fallbacks. */ + + snprintf(proc, PATH_MAX, "/proc/%s/exe", pid); + if (stat(proc, &path_stat) == 0) { // Should check that it is a link to our executable. - found = 1; - } - else - { - sprintf(proc, "/proc/%s/cmdline", pid); - if (stat(proc, &path_stat) == 0) - { + found = 1; + } else { + snprintf(proc, PATH_MAX, "/proc/%s/cmdline", pid); + if (stat(proc, &path_stat) == 0) { // Should compare the name. - found = 1; + found = 1; + } + } } - } + } - - } - return found; + RELEASE_CONFIG_BUFFER(proc); + return found; } int pidofproc(char *pidfile, char *pathname, char **pids) { - int status = INIT_D_STATUS_UNKNOWN; - char *our_pidfile = pidfile; - char *our_pids = NULL; + int status = INIT_D_STATUS_UNKNOWN; + char *our_pidfile = pidfile; + char *our_pids = NULL; - if (our_pidfile == NULL) - bb_xasprintf(&our_pidfile, "/var/run/%s.pid", bb_get_last_path_component(pathname)); + if (our_pidfile == NULL) + bb_xasprintf(&our_pidfile, "/var/run/%s.pid", + bb_get_last_path_component(pathname)); - our_pids = quick_read(our_pidfile); + our_pids = quick_read(our_pidfile); - if (our_pids != NULL) - { - int i; - char *pid; - char *strtok_temp; + if (our_pids != NULL) { + int i; + char *pid; + char *strtok_temp; - status = INIT_D_STATUS_DEAD_PID; - if (pids != NULL) - { - (*pids) = (char *) xmalloc(sizeof (char) * strlen(our_pids) + 1); - (*pids)[0] = '\0'; - } - - pid = strtok_r(our_pids, " \n\r", &strtok_temp); - for (i = 0; pid != NULL; i++) - { - if (checkpid(pid)) - { - if (pids != NULL) - { - strcat(*pids, pid); - strcat(*pids, " "); + status = INIT_D_STATUS_DEAD_PID; + if (pids != NULL) { + (*pids) = (char *) xmalloc(sizeof(char) * strlen(our_pids) + 1); + (*pids)[0] = '\0'; } - status = INIT_D_STATUS_OK; - } - pid = strtok_r(NULL, " \n\r", &strtok_temp); - } + pid = strtok_r(our_pids, " \n\r", &strtok_temp); + for (i = 0; pid != NULL; i++) { + if (checkpid(pid)) { + if (pids != NULL) { + strcat(*pids, pid); + strcat(*pids, " "); + } + status = INIT_D_STATUS_OK; + } + + pid = strtok_r(NULL, " \n\r", &strtok_temp); + } - free(our_pids); - } - else - status = INIT_D_STATUS_NOT_RUNNING; + free(our_pids); + } else + status = INIT_D_STATUS_NOT_RUNNING; - if (pidfile == NULL) - free(our_pidfile); + if (pidfile == NULL) + free(our_pidfile); - return status; + return status; } @@ -154,39 +149,31 @@ pidofproc [-p pidfile] pathname running and not 0 otherwise. */ -static const struct option long_options[] = -{ - { "pidfile", 1, NULL, 'p' }, - { 0, 0, 0, 0 } -}; - int pidofproc_main(int argc, char **argv) { - int result = EXIT_FAILURE; - char *pidfile = NULL; - char *pids = NULL; - int opt; - - while ((opt = getopt_long (argc, argv, "p:", long_options, NULL)) > 0) - { - switch (opt) - { - case 'p': - pidfile = optarg; - break; - - default: - bb_show_usage(); + int result = EXIT_FAILURE; + char *pidfile = NULL; + char *pids = NULL; + int opt; + + while ((opt = getopt(argc, argv, "p:")) > 0) { + switch (opt) { + case 'p': + pidfile = optarg; + break; + + default: + bb_show_usage(); + } } - } - /* We require exactly one argument: the path name */ - if (optind != (argc - 1)) - bb_show_usage(); + /* We require exactly one argument: the path name */ + if (optind != (argc - 1)) + bb_show_usage(); - result = pidofproc(pidfile, argv[optind], &pids); - if (pids != NULL) - bb_printf("%s\n", pids); + result = pidofproc(pidfile, argv[optind], &pids); + if (pids != NULL) + bb_printf("%s\n", pids); - return result; + return result; } 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 @@ /* - * Mini rc implementation for busybox. + * init.d runlevel implementation for busybox. * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -33,1209 +36,1299 @@ #include "lib_init_d.h" -const static char *commands[] = -{ - "start", - "stop", - "restart", - "try-restart", - "reload", - "force-reload", - "status", - "info", - NULL +const static char *commands[] = { + "start", + "stop", + "restart", + "try-restart", + "reload", + "force-reload", + "status", + "info", + NULL }; -const static char *INFOS[] = -{ - INIT_D_BEGIN, - INIT_D_PROV, - INIT_D_RSTART, - INIT_D_RSTOP, - INIT_D_SSTART, - INIT_D_SSTOP, - INIT_D_DSTART, - INIT_D_DSTOP, - INIT_D_SDESC, - INIT_D_DESC, - INIT_D_COMMENT, - INIT_D_CONT, - INIT_D_CONT2, - INIT_D_END, - NULL +const static char *INFOS[] = { + INIT_D_BEGIN, + INIT_D_PROV, + INIT_D_RSTART, + INIT_D_RSTOP, + INIT_D_SSTART, + INIT_D_SSTOP, + INIT_D_DSTART, + INIT_D_DSTOP, + INIT_D_SDESC, + INIT_D_DESC, + INIT_D_COMMENT, + INIT_D_CONT, + INIT_D_CONT2, + INIT_D_END, + NULL }; int default_start(struct init_d_handle_s *init_d, int just_checking) { - int status = (init_d->status)(init_d, 0); + int status = (init_d->status) (init_d, 0); - switch (status) - { - case INIT_D_STATUS_OK : + switch (status) { + case INIT_D_STATUS_OK: { - status = INIT_D_OK; - break; + status = INIT_D_OK; + break; } - case INIT_D_STATUS_DEAD_PID : + case INIT_D_STATUS_DEAD_PID: { - log_warning_msg("Stale pid file exists!"); - status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. - break; + log_warning_msg("Stale pid file exists!"); + status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. + break; } - case INIT_D_STATUS_DEAD_LOCK : + case INIT_D_STATUS_DEAD_LOCK: { - log_warning_msg("Stale lock file exists!"); - status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. - break; + log_warning_msg("Stale lock file exists!"); + status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. + break; } - case INIT_D_STATUS_NOT_RUNNING : + case INIT_D_STATUS_NOT_RUNNING: { - struct stat script_stat; - - if (stat(init_d->pathname, &script_stat) == 0) - { - if (just_checking) - status = INIT_D_ERROR_JUST_NOT_RUNNING; - else - status = start_daemon(0, 0, init_d->pidfile, init_d->pathname, init_d->args); - } - else - status = INIT_D_ERROR_NOT_INSTALLED; - break; + struct stat script_stat; + + if (stat(init_d->pathname, &script_stat) == 0) { + if (just_checking) + status = INIT_D_ERROR_JUST_NOT_RUNNING; + else + status = + start_daemon(0, 0, init_d->pidfile, init_d->pathname, + init_d->args); + } else + status = INIT_D_ERROR_NOT_INSTALLED; + break; } - - default : + + default: { - status = INIT_D_ERROR_GENERIC; - break; + status = INIT_D_ERROR_GENERIC; + break; + } } - } - return status; + return status; } int default_stop(struct init_d_handle_s *init_d, int just_checking) { - int status = (init_d->status)(init_d, 0); + int status = (init_d->status) (init_d, 0); - switch (status) - { - case INIT_D_STATUS_OK : + switch (status) { + case INIT_D_STATUS_OK: { - if (just_checking) - status = INIT_D_ERROR_JUST_RUNNING; - else - status = killproc(init_d->pidfile, init_d->pathname, 0); - break; + if (just_checking) + status = INIT_D_ERROR_JUST_RUNNING; + else + status = killproc(init_d->pidfile, init_d->pathname, 0); + break; } - case INIT_D_STATUS_DEAD_PID : + case INIT_D_STATUS_DEAD_PID: { - log_warning_msg("Stale pid file exists!"); - status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. - break; + log_warning_msg("Stale pid file exists!"); + status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. + break; } - case INIT_D_STATUS_DEAD_LOCK : + case INIT_D_STATUS_DEAD_LOCK: { - log_warning_msg("Stale lock file exists!"); - status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. - break; + log_warning_msg("Stale lock file exists!"); + status = INIT_D_ERROR_GENERIC; // LSB is not clear on what to return, but this is an error condition. + break; } - case INIT_D_STATUS_NOT_RUNNING : + case INIT_D_STATUS_NOT_RUNNING: { - status = INIT_D_OK; - break; + status = INIT_D_OK; + break; } - - default : + + default: { - status = INIT_D_ERROR_GENERIC; - break; + status = INIT_D_ERROR_GENERIC; + break; + } } - } - return status; + return status; } int default_restart(struct init_d_handle_s *init_d, int just_checking) { - int status = (init_d->status)(init_d, 0); + int status = (init_d->status) (init_d, 0); - switch (status) - { - case INIT_D_STATUS_OK : + switch (status) { + case INIT_D_STATUS_OK: { - status = (init_d->stop)(init_d, just_checking); - if ((status == INIT_D_OK) || (status == INIT_D_ERROR_NOT_RUNNING)) - status = INIT_D_STATUS_NOT_RUNNING; - else - status = INIT_D_STATUS_UNKNOWN; - break; + status = (init_d->stop) (init_d, just_checking); + if ((status == INIT_D_OK) || (status == INIT_D_ERROR_NOT_RUNNING)) + status = INIT_D_STATUS_NOT_RUNNING; + else + status = INIT_D_STATUS_UNKNOWN; + break; } - - case INIT_D_STATUS_DEAD_PID : + + case INIT_D_STATUS_DEAD_PID: { - log_warning_msg("Stale pid file exists!"); - break; + log_warning_msg("Stale pid file exists!"); + break; } - case INIT_D_STATUS_DEAD_LOCK : + case INIT_D_STATUS_DEAD_LOCK: { - log_warning_msg("Stale lock file exists!"); - break; + log_warning_msg("Stale lock file exists!"); + break; } - } - if (status == INIT_D_STATUS_NOT_RUNNING) - status = (init_d->start)(init_d, just_checking); - else - status = INIT_D_ERROR_GENERIC; + } + if (status == INIT_D_STATUS_NOT_RUNNING) + status = (init_d->start) (init_d, just_checking); + else + status = INIT_D_ERROR_GENERIC; - return status; + return status; } int default_try_restart(struct init_d_handle_s *init_d, int just_checking) { - int status = (init_d->status)(init_d, 0); + int status = (init_d->status) (init_d, 0); - switch (status) - { - case INIT_D_STATUS_OK : + switch (status) { + case INIT_D_STATUS_OK: { - status = (init_d->stop)(init_d, just_checking); - if (status == INIT_D_OK) - status = (init_d->start)(init_d, just_checking); - 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. */ - status = INIT_D_OK; - break; + status = (init_d->stop) (init_d, just_checking); + if (status == INIT_D_OK) + status = (init_d->start) (init_d, just_checking); + 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. */ + status = INIT_D_OK; + break; } - - case INIT_D_STATUS_NOT_RUNNING : /* I think this is what LSB 8.2.61 means. */ - { /* If try-restart was meant to start a stopped service, then it would be no different from restart. - * LSB 8.2.42-44 may have some bearing on this, but the english is broken, rendering it unintelligable. - * OTH, try-restart is optional, so a broken implentation is no problem B-). - * OTGH, our force-reload uses this as it's fallback position. - */ - status = INIT_D_OK; - break; + + case INIT_D_STATUS_NOT_RUNNING: /* I think this is what LSB 8.2.61 means. */ + { /* If try-restart was meant to start a stopped service, then it would be no different from restart. + * LSB 8.2.42-44 may have some bearing on this, but the english is broken, rendering it unintelligable. + * OTH, try-restart is optional, so a broken implentation is no problem B-). + * OTGH, our force-reload uses this as it's fallback position. + */ + status = INIT_D_OK; + break; } - default : + default: { - status = INIT_D_ERROR_GENERIC; + status = INIT_D_ERROR_GENERIC; + } } - } - return status; + return status; } int default_reload(struct init_d_handle_s *init_d, int just_checking) { - return INIT_D_ERROR_NOT_IMPLEMENTED; + return INIT_D_ERROR_NOT_IMPLEMENTED; } int sighup_reload(struct init_d_handle_s *init_d, int just_checking) { - int status = (init_d->status)(init_d, 0); + int status = (init_d->status) (init_d, 0); - switch (status) - { - case INIT_D_STATUS_OK : + switch (status) { + case INIT_D_STATUS_OK: { - if (just_checking) - status = INIT_D_ERROR_JUST_RUNNING; - else - status = killproc(init_d->pidfile, init_d->pathname, SIGHUP); - break; + if (just_checking) + status = INIT_D_ERROR_JUST_RUNNING; + else + status = killproc(init_d->pidfile, init_d->pathname, SIGHUP); + break; } - case INIT_D_STATUS_NOT_RUNNING : + case INIT_D_STATUS_NOT_RUNNING: { - status = INIT_D_ERROR_NOT_RUNNING; - break; + status = INIT_D_ERROR_NOT_RUNNING; + break; } - default : + default: { - status = INIT_D_ERROR_GENERIC; - break; + status = INIT_D_ERROR_GENERIC; + break; + } } - } - return status; + return status; } int default_force_reload(struct init_d_handle_s *init_d, int just_checking) { - int status = (init_d->reload)(init_d, just_checking); + int status = (init_d->reload) (init_d, just_checking); - if (status == INIT_D_ERROR_NOT_IMPLEMENTED) - status = (init_d->try_restart)(init_d, just_checking); + if (status == INIT_D_ERROR_NOT_IMPLEMENTED) + status = (init_d->try_restart) (init_d, just_checking); - return status; + return status; } int print_status(struct init_d_handle_s *init_d, int quiet, int status) { - if (quiet) - switch (status) - { - case INIT_D_STATUS_OK : - { - bb_printf("%s is running.\n", init_d->basename); - break; - } + if (quiet) + switch (status) { + case INIT_D_STATUS_OK: + { + bb_printf("%s is running.\n", init_d->basename); + break; + } - case INIT_D_STATUS_DEAD_PID : - { - bb_printf("%s is not running, but there is a stale %s.\n", init_d->basename, init_d->pidfile); - break; - } + case INIT_D_STATUS_DEAD_PID: + { + bb_printf("%s is not running, but there is a stale %s.\n", + init_d->basename, init_d->pidfile); + break; + } - case INIT_D_STATUS_DEAD_LOCK : - { - bb_printf("%s is not running, but there is a stale lock file.\n", init_d->basename); - break; - } + case INIT_D_STATUS_DEAD_LOCK: + { + bb_printf("%s is not running, but there is a stale lock file.\n", + init_d->basename); + break; + } - case INIT_D_STATUS_NOT_RUNNING : - { - bb_printf("%s is not running.\n", init_d->basename); - break; - } - - default : - { - bb_printf("The status of %s is not known.\n", init_d->basename); - break; - } - } + case INIT_D_STATUS_NOT_RUNNING: + { + bb_printf("%s is not running.\n", init_d->basename); + break; + } - return status; + default: + { + bb_printf("The status of %s is not known.\n", init_d->basename); + break; + } + } + + return status; } int default_status(struct init_d_handle_s *init_d, int quiet) { - return print_status(init_d, quiet, pidofproc(init_d->pidfile, init_d->pathname, NULL)); + return print_status(init_d, quiet, + pidofproc(init_d->pidfile, init_d->pathname, NULL)); } int default_show_info(struct init_d_handle_s *init_d, int just_checking) { - bb_printf("%s", init_d->info); - return INIT_D_OK; + bb_printf("%s", init_d->info); + return INIT_D_OK; } int no_stop(struct init_d_handle_s *init_d, int just_checking) { - return INIT_D_ERROR_NOT_IMPLEMENTED; + return INIT_D_ERROR_NOT_IMPLEMENTED; } int no_reload(struct init_d_handle_s *init_d, int just_checking) { - return INIT_D_ERROR_NOT_IMPLEMENTED; + return INIT_D_ERROR_NOT_IMPLEMENTED; } int no_status(struct init_d_handle_s *init_d, int quiet) { - return INIT_D_ERROR_NOT_IMPLEMENTED; + return INIT_D_ERROR_NOT_IMPLEMENTED; } int do_init_from_main(int argc, char **argv, struct init_d_handle_s *init_d) { - return do_init(init_d, (argc > 1) ? argv[1] : NULL); + read_sysconfig("/etc/runlevels.conf"); + return do_init(init_d, (argc > 1) ? argv[1] : NULL); } int do_init(struct init_d_handle_s *init_d, const char *command) { - int i; - int status = INIT_D_ERROR_NOT_IMPLEMENTED; - char *original_pidfile = init_d->pidfile; - - if (init_d->start == NULL) init_d->start = &default_start; - if (init_d->stop == NULL) init_d->stop = &default_stop; - if (init_d->restart == NULL) init_d->restart = &default_restart; - if (init_d->try_restart == NULL) init_d->try_restart = &default_try_restart; - if (init_d->reload == NULL) init_d->reload = &default_reload; - if (init_d->force_reload == NULL) init_d->force_reload = &default_force_reload; - if (init_d->status == NULL) init_d->status = &default_status; - if (init_d->show_info == NULL) init_d->show_info = &default_show_info; - if (init_d->basename == NULL) init_d->basename = bb_get_last_path_component(init_d->pathname); - if (init_d->pathname == NULL) init_d->pathname = init_d->basename; - if (init_d->args == NULL) init_d->args = ""; - if (init_d->pidfile == NULL) bb_xasprintf(&(init_d->pidfile), "/var/run/%s.pid", init_d->basename); - if (init_d->info == NULL) init_d->info = ""; - - if (command == NULL) - command = commands[2]; // Default to restart. - - for (i = 0; commands[i] != 0; i++) - { - if (strcmp(commands[i], command ) == 0) - { - switch (i) - { - case 0 : status = (init_d->start)(init_d, 0); break; - case 1 : status = (init_d->stop)(init_d, 0); break; - case 2 : status = (init_d->restart)(init_d, 0); break; - case 3 : status = (init_d->try_restart)(init_d, 0); break; - case 4 : status = (init_d->reload)(init_d, 0); break; - case 5 : status = (init_d->force_reload)(init_d, 0); break; - case 6 : status = (init_d->status)(init_d, 1); break; - case 7 : status = (init_d->show_info)(init_d, 0); break; - } - break; + int i; + int status = INIT_D_ERROR_NOT_IMPLEMENTED; + char *original_pidfile = init_d->pidfile; + char *sysconfig; + + if (init_d->start == NULL) + init_d->start = &default_start; + if (init_d->stop == NULL) + init_d->stop = &default_stop; + if (init_d->restart == NULL) + init_d->restart = &default_restart; + if (init_d->try_restart == NULL) + init_d->try_restart = &default_try_restart; + if (init_d->reload == NULL) + init_d->reload = &default_reload; + if (init_d->force_reload == NULL) + init_d->force_reload = &default_force_reload; + if (init_d->status == NULL) + init_d->status = &default_status; + if (init_d->show_info == NULL) + init_d->show_info = &default_show_info; + if (init_d->basename == NULL) + init_d->basename = bb_get_last_path_component(init_d->pathname); + if (init_d->pathname == NULL) + init_d->pathname = init_d->basename; + if (init_d->args == NULL) + init_d->args = ""; + if (init_d->pidfile == NULL) + bb_xasprintf(&(init_d->pidfile), "/var/run/%s.pid", init_d->basename); + if (init_d->info == NULL) + init_d->info = ""; + + bb_xasprintf(&sysconfig, "/etc/sysconfig/%s", init_d->basename); + read_sysconfig(sysconfig); + + if (command == NULL) + command = commands[2]; // Default to restart. + + for (i = 0; commands[i] != 0; i++) { + if (strcmp(commands[i], command) == 0) { + switch (i) { + case 0: + status = (init_d->start) (init_d, 0); + break; + case 1: + status = (init_d->stop) (init_d, 0); + break; + case 2: + status = (init_d->restart) (init_d, 0); + break; + case 3: + status = (init_d->try_restart) (init_d, 0); + break; + case 4: + status = (init_d->reload) (init_d, 0); + break; + case 5: + status = (init_d->force_reload) (init_d, 0); + break; + case 6: + status = (init_d->status) (init_d, 1); + break; + case 7: + status = (init_d->show_info) (init_d, 0); + break; + } + break; + } } - } - if (original_pidfile == NULL) - free(init_d->pidfile); - return status; + free(sysconfig); + if (original_pidfile == NULL) + free(init_d->pidfile); + return status; } static int init_script(char *script, char *command) { - int status = INIT_D_ERROR_NOT_IMPLEMENTED; - - bb_printf("%c%s %s ... ", toupper(command[0]), &command[1], script); - fflush(stdout); - doit(0, "/etc/init.d/%s %s", script, command); - status = errno; - if (strcmp("status", command) != 0) - { - bb_printf("\t\t"); - switch (status) - { - case INIT_D_OK : bb_printf("OK"); break; - case INIT_D_ERROR_NOT_IMPLEMENTED : bb_printf("not implemented"); break; - case INIT_D_ERROR_NOT_INSTALLED : bb_printf("not installed"); break; - case INIT_D_ERROR_NOT_CONFIGURED : bb_printf("not configured"); break; - case INIT_D_ERROR_NOT_RUNNING : bb_printf("not running"); break; - case INIT_D_ERROR_GENERIC : bb_printf("failed"); break; - case INIT_D_ERROR_ARGS : bb_printf("invalid arguments"); break; - case INIT_D_ERROR_SECURITY : bb_printf("security failure"); break; - default : bb_printf("Failed!"); break; + int status = INIT_D_ERROR_NOT_IMPLEMENTED; + + bb_printf("%c%s %s ... ", toupper(command[0]), &command[1], script); + fflush(stdout); + doit(0, "/etc/init.d/%s %s", script, command); + status = errno; + if (strcmp("status", command) != 0) { + bb_printf("\t\t"); + switch (status) { + case INIT_D_OK: + bb_printf("OK"); + break; + case INIT_D_ERROR_NOT_IMPLEMENTED: + bb_printf("not implemented"); + break; + case INIT_D_ERROR_NOT_INSTALLED: + bb_printf("not installed"); + break; + case INIT_D_ERROR_NOT_CONFIGURED: + bb_printf("not configured"); + break; + case INIT_D_ERROR_NOT_RUNNING: + bb_printf("not running"); + break; + case INIT_D_ERROR_GENERIC: + bb_printf("failed"); + break; + case INIT_D_ERROR_ARGS: + bb_printf("invalid arguments"); + break; + case INIT_D_ERROR_SECURITY: + bb_printf("security failure"); + break; + default: + bb_printf("Failed!"); + break; + } + bb_printf("\n"); } - bb_printf("\n"); - } - return status; + return status; } init_d_info_t *parse_init_info(char *info_text, char *name) { - init_d_info_t *info = NULL; + init_d_info_t *info = NULL; - // if init info found - if ((info_text != NULL) && (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0)) - { - if (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0) - { - int lastfound = -1; - char *strtok_line; - char *line; - char *linecopy; + // if init info found + if ((info_text != NULL) + && (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == + 0)) { + if (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0) { + int lastfound = -1; + char *strtok_line; + char *line; + char *linecopy; - info = (init_d_info_t *) xcalloc(1, sizeof(init_d_info_t)); - bb_xasprintf(&info->path, "%s", name); + info = (init_d_info_t *) xcalloc(1, sizeof(init_d_info_t)); + bb_xasprintf(&info->path, "%s", name); //bb_printf("%s is an init script -%s", name, info_text); //bb_printf("%s is an init script\n", name); - // parse info into structure - for (line = strtok_r(info_text, "\n\r", &strtok_line); line != NULL; line = strtok_r(NULL, "\n\r", &strtok_line)) - { - int count = 0; - int found = -1; - char *strtok_token; - char *token; - - bb_xasprintf(&linecopy, "%s", line); - for (token = strtok_r(line, " \t", &strtok_token); token != NULL; token = strtok_r(NULL, " \t", &strtok_token)) - { - switch (count++) - { - case 0 : break; /* Ignore the "#". */ + // parse info into structure + for (line = strtok_r(info_text, "\n\r", &strtok_line); + line != NULL; line = strtok_r(NULL, "\n\r", &strtok_line)) { + int count = 0; + int found = -1; + char *strtok_token; + char *token; + + bb_xasprintf(&linecopy, "%s", line); + for (token = strtok_r(line, " \t", &strtok_token); + token != NULL; + token = strtok_r(NULL, " \t", &strtok_token)) { + switch (count++) { + case 0: + break; /* Ignore the "#". */ + + case 1: + { + int j; - case 1 : - { - int j; - for (j = 1; INFOS[j] != NULL; j++) - { + for (j = 1; INFOS[j] != NULL; j++) { //bb_printf("%s = %s %s\n", linecopy, &(INFOS[j][1]), token); - if (strncmp(&(INFOS[j][1]), linecopy, strlen(&(INFOS[j][1])) - 1) == 0) - { - found = j - 1; - break; - } - } - break; - } - - default : - { - int multi = 1; - int string = 1; - void **kludge = (void **)info; - - switch (found) - { - case 5 : /* INIT_D_DSTART */ string = 0; break; - case 6 : /* INIT_D_DSTOP */ string = 0; break; - case 7 : /* INIT_D_SDESC */ multi = 0; break; - case 8 : /* INIT_D_DESC */ multi = 0; break; - case 10 : /* INIT_D_CONT */ - case 11 : /* INIT_D_CONT2 */ multi = 0; found = lastfound; break; - case 12 : /* INIT_D_END */ found = -1; break; - } - - if (found != -1) - { - void *temp = kludge[found]; - - if (multi == 1) - { - int size = info->sizes[found]; + if (strncmp + (&(INFOS[j][1]), linecopy, + strlen(&(INFOS[j][1])) - 1) == 0) { + found = j - 1; + break; + } + } + break; + } - info->sizes[found]++; + default: + { + int multi = 1; + int string = 1; + void **kludge = (void **) info; + + switch (found) { + case 5: /* INIT_D_DSTART */ + string = 0; + break; + case 6: /* INIT_D_DSTOP */ + string = 0; + break; + case 7: /* INIT_D_SDESC */ + multi = 0; + break; + case 8: /* INIT_D_DESC */ + multi = 0; + break; + case 10: /* INIT_D_CONT */ + case 11: /* INIT_D_CONT2 */ + multi = 0; + found = lastfound; + break; + case 12: /* INIT_D_END */ + found = -1; + break; + } + + if (found != -1) { + void *temp = kludge[found]; + + if (multi == 1) { + int size = info->sizes[found]; + + info->sizes[found]++; // not LSB, but SuSE does it -if (token[0] == '$') - token = &token[1]; + if (token[0] == '$') + token = &token[1]; // not LSB, but SuSE does it -if (strncmp(token, "boot.", 5) == 0) - token = &token[5]; - if (temp != NULL) - kludge[found] = xrealloc(kludge[found], sizeof (char **) * (size + 1)); - else - kludge[found] = xcalloc(1, sizeof (char **)); - if (string == 1) - bb_xasprintf(&((char **) kludge[found])[size], "%s", token); - else - { + if (strncmp(token, "boot.", 5) == 0) + token = &token[5]; + if (temp != NULL) + kludge[found] = + xrealloc(kludge[found], + sizeof(char **) * (size + + 1)); + else + kludge[found] = + xcalloc(1, sizeof(char **)); + if (string == 1) + bb_xasprintf(&((char **) kludge[found]) + [size], "%s", token); + else { // not LSB, but SuSE does it -if (token[0] == 'B') -{ - token[0] = '5'; - kludge[found] = xrealloc(kludge[found], sizeof (char **) * (10 + 1)); - ((int *) kludge[found])[0] = 1; - ((int *) kludge[found])[1] = 2; - ((int *) kludge[found])[2] = 3; - ((int *) kludge[found])[3] = 4; - size = 4; - info->sizes[found] = 5; -} + if (token[0] == 'B') { + token[0] = '5'; + kludge[found] = + xrealloc(kludge[found], + sizeof(char **) * (10 + + 1)); + ((int *) kludge[found])[0] = 1; + ((int *) kludge[found])[1] = 2; + ((int *) kludge[found])[2] = 3; + ((int *) kludge[found])[3] = 4; + size = 4; + info->sizes[found] = 5; + } // not LSB, but SuSE does it -if (token[0] == 'S') - token[0] = '1'; - ((int *) kludge[found])[size] = atoi(token); - } - temp = NULL; - } - else - { - if (string == 1) - { - if (kludge[found] == NULL) - bb_xasprintf((char **) &kludge[found], "%s", token); - else - bb_xasprintf((char **) &kludge[found], "%s %s", (char *) kludge[found], token); - } - else - { -// Should never happen. int value = atoi(token); - temp = NULL; - } + if (token[0] == 'S') + token[0] = '1'; + ((int *) kludge[found])[size] = + atoi(token); + } + temp = NULL; + } else { + if (string == 1) { + if (kludge[found] == NULL) + bb_xasprintf((char **) &kludge[found], + "%s", token); + else + bb_xasprintf((char **) &kludge[found], + "%s %s", + (char *) kludge[found], + token); + } else { +// Should never happen. int value = atoi(token); + temp = NULL; + } + } + + if (temp != NULL) + free(temp); + } + lastfound = found; + + break; + } + } } - - if (temp != NULL) - free(temp); - } - lastfound = found; - - break; } - } - } - } #if 0 -{ - int k; + { + int k; - bb_printf("SCRIPT %s path %s\n", name, info->path); + bb_printf("SCRIPT %s path %s\n", name, info->path); // bb_printf("%s sizes ", name); // for(k = 0; k < 10; k++) -// bb_printf("%d ", info->sizes[k]); +// bb_printf("%d ", info->sizes[k]); // bb_printf("\n"); - if (info->provides != NULL) - { - bb_printf("%s provides ", name); - for(k = 0; k < info->sizes[0]; k++) - bb_printf("%s ", info->provides[k]); - bb_printf("\n"); - } - if (info->reqstart != NULL) - { - bb_printf("%s reqstart ", name); - for(k = 0; k < info->sizes[1]; k++) - bb_printf("%s ", info->reqstart[k]); - bb_printf("\n"); - } - if (info->reqstop != NULL) - { - bb_printf("%s reqstop ", name); - for(k = 0; k < info->sizes[2]; k++) - bb_printf("%s ", info->reqstop[k]); - bb_printf("\n"); - } + if (info->provides != NULL) { + bb_printf("%s provides ", name); + for (k = 0; k < info->sizes[0]; k++) + bb_printf("%s ", info->provides[k]); + bb_printf("\n"); + } + if (info->reqstart != NULL) { + bb_printf("%s reqstart ", name); + for (k = 0; k < info->sizes[1]; k++) + bb_printf("%s ", info->reqstart[k]); + bb_printf("\n"); + } + if (info->reqstop != NULL) { + bb_printf("%s reqstop ", name); + for (k = 0; k < info->sizes[2]; k++) + bb_printf("%s ", info->reqstop[k]); + bb_printf("\n"); + } - if (info->shouldstart != NULL) - { - bb_printf("%s shouldstart ", name); - for(k = 0; k < info->sizes[3]; k++) - bb_printf("%s ", info->shouldstart[k]); - bb_printf("\n"); - } - if (info->shouldstop != NULL) - { - bb_printf("%s shouldstop ", name); - for(k = 0; k < info->sizes[4]; k++) - bb_printf("%s ", info->shouldstop[k]); - bb_printf("\n"); - } + if (info->shouldstart != NULL) { + bb_printf("%s shouldstart ", name); + for (k = 0; k < info->sizes[3]; k++) + bb_printf("%s ", info->shouldstart[k]); + bb_printf("\n"); + } + if (info->shouldstop != NULL) { + bb_printf("%s shouldstop ", name); + for (k = 0; k < info->sizes[4]; k++) + bb_printf("%s ", info->shouldstop[k]); + bb_printf("\n"); + } - if (info->defstart != NULL) - { - bb_printf("%s defstart ", name); - for(k = 0; k < info->sizes[5]; k++) - bb_printf("%d ", info->defstart[k]); - bb_printf("\n"); - } - if (info->defstop != NULL) - { - bb_printf("%s defstop ", name); - for(k = 0; k < info->sizes[6]; k++) - bb_printf("%d ", info->defstop[k]); - bb_printf("\n"); - } - if (info->shortdesc != NULL) - bb_printf("%s shortdes %s\n", name, info->shortdesc); - if (info->desc != NULL) - bb_printf("%s descript %s\n", name, info->desc); - bb_printf("\n"); -} + if (info->defstart != NULL) { + bb_printf("%s defstart ", name); + for (k = 0; k < info->sizes[5]; k++) + bb_printf("%d ", info->defstart[k]); + bb_printf("\n"); + } + if (info->defstop != NULL) { + bb_printf("%s defstop ", name); + for (k = 0; k < info->sizes[6]; k++) + bb_printf("%d ", info->defstop[k]); + bb_printf("\n"); + } + if (info->shortdesc != NULL) + bb_printf("%s shortdes %s\n", name, info->shortdesc); + if (info->desc != NULL) + bb_printf("%s descript %s\n", name, info->desc); + bb_printf("\n"); + } #endif - // if database of runlevels per script includes overrides - // change info structure accordingly + // if database of runlevels per script includes overrides + // change info structure accordingly + } } - } - return info; + return info; } char *get_init_info(char *pathname) { - struct stat script_stat; - char *info_text = NULL; - char *base_name = bb_get_last_path_component(pathname); + struct stat script_stat; + char *info_text = NULL; + char *base_name = bb_get_last_path_component(pathname); //bb_printf("CHECKING %s, ", pathname); - // ignore rc, rcS, directories, non executables - if ((strcmp(base_name, "rc") != 0) && - (strcmp(base_name, "rcS") != 0) && - (stat(pathname, &script_stat) == 0)) - { - if ((!S_ISDIR(script_stat.st_mode)) && - S_ISREG(script_stat.st_mode) && - ((script_stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0 )) - { + // ignore rc, rcS, directories, non executables + if ((strcmp(base_name, "rc") != 0) && + (strcmp(base_name, "rcS") != 0) && + (stat(pathname, &script_stat) == 0)) { + if ((!S_ISDIR(script_stat.st_mode)) && + S_ISREG(script_stat.st_mode) && + ((script_stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)) { //bb_printf("maybe init script, "); - // script info - if ((info_text == NULL) || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) != 0)) - bb_xasprintf(&info_text, "%s", doit(REDIR | QUIET, "%s info", pathname)); + // script info + if ((info_text == NULL) + || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) + != 0)) + bb_xasprintf(&info_text, "%s", + doit(REDIR | QUIET, "%s info", pathname)); //bb_printf("INFO = %s\n", info_text); - // if not proper response - if ((info_text == NULL) || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) != 0)) - { - int count = 1; - int found = -1; - char *line; - FILE *contents; + // if not proper response + if ((info_text == NULL) + || (strncmp(info_text, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) + != 0)) { + int count = 1; + int found = -1; + char *line; + FILE *contents; //bb_printf("search for INFO, "); - // search script for init info - info_text = (char *) xmalloc(sizeof (char) * 256 * 64); - info_text[0] = '\n'; - info_text[1] = '\0'; - contents = fopen(pathname, "r"); - if (contents != NULL) - { - do - { - line = fgets(&info_text[count], 255, contents); - if (line != NULL) - { - line--; - if ((found == -1) && (strncmp(line, INIT_D_BEGIN, strlen(INIT_D_BEGIN) - 1) == 0)) - found = 0; - - if (found != -1) - { - - if (strncmp(line, INIT_D_CUSTOM, strlen(INIT_D_CUSTOM)) != 0) - { - if (strncmp(line, INIT_D_END, strlen(INIT_D_END) - 1) == 0) - { + // search script for init info + info_text = (char *) xmalloc(sizeof(char) * 256 * 64); + info_text[0] = '\n'; + info_text[1] = '\0'; + contents = fopen(pathname, "r"); + if (contents != NULL) { + do { + line = fgets(&info_text[count], 255, contents); + if (line != NULL) { + line--; + if ((found == -1) + && + (strncmp + (line, INIT_D_BEGIN, + strlen(INIT_D_BEGIN) - 1) == 0)) + found = 0; + + if (found != -1) { + + if (strncmp + (line, INIT_D_CUSTOM, + strlen(INIT_D_CUSTOM)) != 0) { + if (strncmp + (line, INIT_D_END, + strlen(INIT_D_END) - 1) == 0) { //bb_printf("INFO found, "); - line = NULL; - found = 64 + 1; - } - else - { - int cont = 0; - - if (strncmp(line, INIT_D_CONT, strlen(INIT_D_CONT)) == 0) - cont = 1; - if (strncmp(line, INIT_D_CONT2, strlen(INIT_D_CONT2)) == 0) - cont = 1; - if (cont == 1) - { + line = NULL; + found = 64 + 1; + } else { + int cont = 0; + + if (strncmp + (line, INIT_D_CONT, + strlen(INIT_D_CONT)) == 0) + cont = 1; + if (strncmp + (line, INIT_D_CONT2, + strlen(INIT_D_CONT2)) == 0) + cont = 1; + if (cont == 1) { //bb_printf("\n\n\nCONT found%s\n\n\n, ", line); - info_text[count - 1] = ' '; - info_text[count] = ' '; - } - - found++; - count += strlen(line) - 1; - if (info_text[count - 1] != '\n') - { - info_text[count++] = '\n'; + info_text[count - 1] = ' '; + info_text[count] = ' '; + } + + found++; + count += strlen(line) - 1; + if (info_text[count - 1] != '\n') { + info_text[count++] = '\n'; // Should seek until the next \n, - } - } - info_text[count] = '\0'; + } + } + info_text[count] = '\0'; + } + } + } + } while ((line != NULL) && (found < 64)); + + fclose(contents); } - } } - } while ((line != NULL) && (found < 64)); - - fclose(contents); } - } } - } //bb_printf("\n"); - return info_text; + return info_text; } llist_t *get_scripts(void) { - llist_t *result = NULL; - DIR *initd = opendir("/etc/init.d"); + llist_t *result = NULL; + DIR *initd = opendir("/etc/init.d"); - if (initd != NULL) - { - struct dirent *script; - - // foreach ls /etc/init.d - while ((script = readdir(initd)) != NULL) - { - char *info_text = NULL; - char *pathname = NULL; - init_d_info_t *info = NULL; - - bb_xasprintf(&pathname, "/etc/init.d/%s", script->d_name); - info_text = get_init_info(pathname); - info = parse_init_info(info_text, script->d_name); - if (info) - result = llist_add_to(result, (char *) info); - - free(info_text); - } - closedir(initd); + if (initd != NULL) { + struct dirent *script; + + // foreach ls /etc/init.d + while ((script = readdir(initd)) != NULL) { + char *info_text = NULL; + char *pathname = NULL; + init_d_info_t *info = NULL; + + bb_xasprintf(&pathname, "/etc/init.d/%s", script->d_name); + info_text = get_init_info(pathname); + info = parse_init_info(info_text, script->d_name); + if (info) + result = llist_add_to(result, (char *) info); + + free(info_text); + } + closedir(initd); } - return result; + return result; } -llist_t *sort_scripts(llist_t *unsorted) +llist_t *sort_scripts(llist_t * unsorted, init_d_info_t *for_script) { // Should do something with info->shouldstart's - int count_moves = 0; - // all scripts start in unsorted list - llist_t *sorted = NULL; - llist_t *current = unsorted; - llist_t *previous = NULL; - - // pull out those with no deps and create a sorted list for each - while (current) - { - init_d_info_t *info = (init_d_info_t *) current->data; - - if (info->reqstart == NULL) - { - llist_t *new_list = NULL; - new_list = llist_add_to_end(new_list, (char *) info); - sorted = llist_add_to_end(sorted, (char *) new_list); - current = llist_delete(&unsorted, previous, current); - } - else - { - previous = current; - current = current->link; - } - } + int count_moves = 0; - do - { - count_moves = 0; - current = unsorted; - previous = NULL; - // foreach in unsorted list - while (current) - { - int moved = 0; - init_d_info_t *info = (init_d_info_t *) current->data; + // all scripts start in unsorted list + llist_t *sorted = NULL; + llist_t *current = unsorted; + llist_t *previous = NULL; - if (info->reqstart != NULL) - { - int k; - llist_t *current_sort = sorted; - short done[info->sizes[1]]; + // pull out those with no deps and create a sorted list for each + while (current) { + init_d_info_t *info = (init_d_info_t *) current->data; - // foreach sorted list - while (current_sort) - { - llist_t *current_list = (llist_t *) current_sort->data; + if (info->reqstart == NULL) { + llist_t *new_list = NULL; - // if ALL deps are in sorted list move script to end of sorted list - for(k = 0; k < info->sizes[1]; k++) - done[k] = 0; - while (current_list) - { - init_d_info_t *this_info = (init_d_info_t *) current_list->data; - - for(k = 0; k < info->sizes[1]; k++) - { - int i; - char *needs = info->reqstart[k]; + new_list = llist_add_to_end(new_list, (char *) info); + sorted = llist_add_to_end(sorted, (char *) new_list); + current = llist_delete(&unsorted, previous, current); + } else { + previous = current; + current = current->link; + } + } - if (done[k] == 0) - { + do { + count_moves = 0; + current = unsorted; + previous = NULL; + // foreach in unsorted list + while (current) { + int moved = 0; + init_d_info_t *info = (init_d_info_t *) current->data; + + if (info->reqstart != NULL) { + int k; + llist_t *current_sort = sorted; + short done[info->sizes[1]]; + + // foreach sorted list + while (current_sort) { + llist_t *current_list = (llist_t *) current_sort->data; + + // if ALL deps are in sorted list move script to end of sorted list + for (k = 0; k < info->sizes[1]; k++) + done[k] = 0; + while (current_list) { + init_d_info_t *this_info = + (init_d_info_t *) current_list->data; + + for (k = 0; k < info->sizes[1]; k++) { + int i; + char *needs = info->reqstart[k]; + + if (done[k] == 0) { //bb_printf("%s NEEDS %s - ", info->path, needs); - for(i = 0; i < this_info->sizes[0]; i++) - { + for (i = 0; i < this_info->sizes[0]; i++) { //bb_printf("%s ", this_info->provides[i]); - if (strcmp(this_info->provides[i], needs) == 0) - { - done[k] = 1; - break; - } - } + if (strcmp(this_info->provides[i], needs) + == 0) { + done[k] = 1; + break; + } + } //bb_printf("\n"); - } + } + } + current_list = current_list->link; + } + + moved = 1; + for (k = 0; k < info->sizes[1]; k++) { + if (done[k] == 0) { + moved = 0; + break; + } + } + if (moved == 1) { + llist_t *list = (llist_t *) current_sort->data; + + llist_add_to_end(list, (char *) info); + current = llist_delete(&unsorted, previous, current); + moved = 1; + count_moves++; + current_sort = NULL; + } else + current_sort = current_sort->link; + } } - current_list = current_list->link; - } - moved = 1; - for(k = 0; k < info->sizes[1]; k++) - { - if (done[k] == 0) - { - moved = 0; - break; + if (moved == 0) { + previous = current; + current = current->link; } - } - if (moved == 1) - { - llist_t *list = (llist_t *) current_sort->data; - llist_add_to_end(list, (char *) info); - current = llist_delete(&unsorted, previous, current); - moved = 1; - count_moves++; - current_sort = NULL; - } - else - current_sort = current_sort->link; } - } - - if (moved == 0) - { - previous = current; - current = current->link; - } - } - } while (count_moves != 0); - // until no more moves happen - - - do - { - count_moves = 0; - current = unsorted; - previous = NULL; - // foreach in unsorted list - while (current) - { - int moved = 1; - init_d_info_t *info = (init_d_info_t *) current->data; - short done[info->sizes[1]]; - - if (info->reqstart != NULL) - { - int k; - llist_t *current_sortof = sorted; - - // if ALL deps are in sorted lists - for(k = 0; k < info->sizes[1]; k++) - done[k] = 0; - while ((moved == 1) && (current_sortof != NULL)) - { - llist_t *current_listof = (llist_t *) current_sortof->data; - - while (current_listof) - { - init_d_info_t *this_info = (init_d_info_t *) current_listof->data; - - for(k = 0; k < info->sizes[1]; k++) - { - int i; - char *needs = info->reqstart[k]; - - if (done[k] == 0) - { + } while (count_moves != 0); + // until no more moves happen + + + do { + count_moves = 0; + current = unsorted; + previous = NULL; + // foreach in unsorted list + while (current) { + int moved = 1; + init_d_info_t *info = (init_d_info_t *) current->data; + short done[info->sizes[1]]; + + if (info->reqstart != NULL) { + int k; + llist_t *current_sortof = sorted; + + // if ALL deps are in sorted lists + for (k = 0; k < info->sizes[1]; k++) + done[k] = 0; + while ((moved == 1) && (current_sortof != NULL)) { + llist_t *current_listof = + (llist_t *) current_sortof->data; + + while (current_listof) { + init_d_info_t *this_info = + (init_d_info_t *) current_listof->data; + + for (k = 0; k < info->sizes[1]; k++) { + int i; + char *needs = info->reqstart[k]; + + if (done[k] == 0) { //bb_printf("%s NEEDS %s - ", info->path, needs); - for(i = 0; i < this_info->sizes[0]; i++) - { + for (i = 0; i < this_info->sizes[0]; i++) { //bb_printf("%s ", this_info->provides[i]); - if (strcmp(this_info->provides[i], needs) == 0) - { - done[k] = 1; - break; - } - } + if (strcmp(this_info->provides[i], needs) + == 0) { + done[k] = 1; + break; + } + } //bb_printf("\n"); - } - } - current_listof = current_listof->link; - } - current_sortof = current_sortof->link; - } - - moved = 1; - for(k = 0; k < info->sizes[1]; k++) - { - if (done[k] == 0) - { - moved = 0; - break; - } - } + } + } + current_listof = current_listof->link; + } + current_sortof = current_sortof->link; + } - if (moved == 1) - { - // create a merged list for script - llist_t *current_sort = sorted; - llist_t *new_list = NULL; - new_list = llist_add_to_end(new_list, (char *) info); - count_moves++; - - // foreach sorted | merged list - while (current_sort) - { - int found = 0; - llist_t *current_list = (llist_t *) current_sort->data; - - // if A dep is in s|m add s|m to end of new merged list & continue with next s|m - while (current_list) - { - init_d_info_t *this_info = (init_d_info_t *) current_list->data; + moved = 1; + for (k = 0; k < info->sizes[1]; k++) { + if (done[k] == 0) { + moved = 0; + break; + } + } - for(k = 0; k < info->sizes[1]; k++) - { - int i; - char *needs = info->reqstart[k]; + if (moved == 1) { + // create a merged list for script + llist_t *current_sort = sorted; + llist_t *new_list = NULL; + + new_list = llist_add_to_end(new_list, (char *) info); + count_moves++; + + // foreach sorted | merged list + while (current_sort) { + int found = 0; + llist_t *current_list = + (llist_t *) current_sort->data; + + // if A dep is in s|m add s|m to end of new merged list & continue with next s|m + while (current_list) { + init_d_info_t *this_info = + (init_d_info_t *) current_list->data; + + for (k = 0; k < info->sizes[1]; k++) { + int i; + char *needs = info->reqstart[k]; + + for (i = 0; i < this_info->sizes[0]; i++) { + if (strcmp(this_info->provides[i], needs) + == 0) { + found = 1; + break; + } + } + if (found == 1) + break; + } + if (found == 1) { + init_d_info_t *new_info = + (init_d_info_t *) xcalloc(1, + sizeof + (init_d_info_t)); + new_info->start = current_sort; + new_list = + llist_add_to_end(new_list, + (char *) new_info); + current_list = NULL; + } else + current_list = current_list->link; + } + + current_sort = current_sort->link; + } - for(i = 0; i < this_info->sizes[0]; i++) - { - if (strcmp(this_info->provides[i], needs) == 0) - { - found = 1; - break; - } + sorted = llist_add_to_end(sorted, (char *) new_list); + current = llist_delete(&unsorted, previous, current); } - if (found == 1) - break; - } - if (found == 1) - { - init_d_info_t *new_info = (init_d_info_t *) xcalloc(1, sizeof(init_d_info_t)); - new_info->start = current_sort; - new_list = llist_add_to_end(new_list, (char *) new_info); - current_list = NULL; - } - else - current_list = current_list->link; } - current_sort = current_sort->link; - } - - sorted = llist_add_to_end(sorted, (char *) new_list); - current = llist_delete(&unsorted, previous, current); + if (moved == 0) { + previous = current; + current = current->link; + } } - } - - if (moved == 0) - { - previous = current; - current = current->link; - } - } - } while (count_moves != 0); - // until no more creates happen + } while (count_moves != 0); + // until no more creates happen - // unsorted list now contains unsatisfied and circular dependencies - // complain if not empty. - if (unsorted != NULL) - { - bb_printf("\nWARNING, the following init scripts have unresolved or circular dependencies -\n"); - current = unsorted; + // unsorted list now contains unsatisfied and circular dependencies + // complain if not empty. + if (unsorted != NULL) { + bb_printf + ("\nWARNING, the following init scripts have unresolved or circular dependencies -\n"); + current = unsorted; - while (current) - { - init_d_info_t *info = (init_d_info_t *) current->data; + while (current) { + init_d_info_t *info = (init_d_info_t *) current->data; - bb_printf("%s\n", info->path); - current = current->link; + bb_printf("%s\n", info->path); + current = current->link; #if 0 -{ - int k; - - bb_printf("SCRIPT %s - ", info->path); - if (info->defstart != NULL) - { - bb_printf("\t\t "); - for(k = 0; k < info->sizes[5]; k++) - bb_printf("%d ", info->defstart[k]); -// bb_printf("\n"); - } - if (info->provides != NULL) - { - bb_printf("\t\t "); - for(k = 0; k < info->sizes[0]; k++) - bb_printf("%s ", info->provides[k]); -// bb_printf("\n"); - } - if (info->reqstart != NULL) - { - bb_printf("\n\t "); - for(k = 0; k < info->sizes[1]; k++) - bb_printf("%s ", info->reqstart[k]); -// bb_printf("\n"); - } - bb_printf("\n"); -} + { + int k; + + bb_printf("SCRIPT %s - ", info->path); + if (info->defstart != NULL) { + bb_printf("\t\t "); + for (k = 0; k < info->sizes[5]; k++) + bb_printf("%d ", info->defstart[k]); +// bb_printf("\n"); + } + if (info->provides != NULL) { + bb_printf("\t\t "); + for (k = 0; k < info->sizes[0]; k++) + bb_printf("%s ", info->provides[k]); +// bb_printf("\n"); + } + if (info->reqstart != NULL) { + bb_printf("\n\t "); + for (k = 0; k < info->sizes[1]; k++) + bb_printf("%s ", info->reqstart[k]); +// bb_printf("\n"); + } + bb_printf("\n"); + } #endif + } + bb_printf("\n"); } - bb_printf("\n"); - } - return sorted; + return sorted; } -static void call_scripts(llist_t *sorted, char *command, int oldlevel, int level) +static void call_scripts(llist_t * sorted, char *command, int oldlevel, + int level) { - // call init_script(script, command) for each script in each list in created order - llist_t *current_sort = sorted; + // call init_script(script, command) for each script in each list in created order + llist_t *current_sort = sorted; - while (current_sort) - { - llist_t *current_list = (llist_t *) current_sort->data; + while (current_sort) { + llist_t *current_list = (llist_t *) current_sort->data; //bb_printf("\nLIST\n"); - while (current_list) - { - init_d_info_t *info = (init_d_info_t *) current_list->data; - - if (info->path != NULL) - { - if (info->defstart != NULL) - { - int k; - int found = 0; - - // if info->DefaultStart includes level - for(k = 0; k < info->sizes[5]; k++) - { - if (info->defstart[k] == level) - { - found = 1; - break; - } - } - // if info->DefaultStart does not include previous level - for(k = 0; k < info->sizes[5]; k++) - { - if (info->defstart[k] == oldlevel) - { - found = 0; - break; - } - } - // add info structure to list - if (found == 1) - init_script(info->path, command); - } - + while (current_list) { + init_d_info_t *info = (init_d_info_t *) current_list->data; + + if (info->path != NULL) { + if (info->defstart != NULL) { + int k; + int found = 0; + + // if info->DefaultStart includes level + for (k = 0; k < info->sizes[5]; k++) { + if (info->defstart[k] == level) { + found = 1; + break; + } + } + // if info->DefaultStart does not include previous level + for (k = 0; k < info->sizes[5]; k++) { + if (info->defstart[k] == oldlevel) { + found = 0; + break; + } + } + // add info structure to list + if (found == 1) + init_script(info->path, command); + } #if 0 -{ - int k; - - bb_printf("SCRIPT %s - ", info->path); - if (info->defstart != NULL) - { - bb_printf("\t\t "); - for(k = 0; k < info->sizes[5]; k++) - bb_printf("%d ", info->defstart[k]); -// bb_printf("\n"); - } - if (info->provides != NULL) - { - bb_printf("\t\t "); - for(k = 0; k < info->sizes[0]; k++) - bb_printf("%s ", info->provides[k]); -// bb_printf("\n"); - } - if (info->reqstart != NULL) - { - bb_printf("\n\t "); - for(k = 0; k < info->sizes[1]; k++) - bb_printf("%s ", info->reqstart[k]); -// bb_printf("\n"); - } - bb_printf("\n"); -} + { + int k; + + bb_printf("SCRIPT %s - ", info->path); + if (info->defstart != NULL) { + bb_printf("\t\t "); + for (k = 0; k < info->sizes[5]; k++) + bb_printf("%d ", info->defstart[k]); +// bb_printf("\n"); + } + if (info->provides != NULL) { + bb_printf("\t\t "); + for (k = 0; k < info->sizes[0]; k++) + bb_printf("%s ", info->provides[k]); +// bb_printf("\n"); + } + if (info->reqstart != NULL) { + bb_printf("\n\t "); + for (k = 0; k < info->sizes[1]; k++) + bb_printf("%s ", info->reqstart[k]); +// bb_printf("\n"); + } + bb_printf("\n"); + } #endif - } - current_list = current_list->link; + } + current_list = current_list->link; + } + current_sort = current_sort->link; } - current_sort = current_sort->link; - } } -int run_level(char *level) +static int run_level(char *level) { - int oldlevel = 0; - int newlevel = atoi(level); - char *temp; - llist_t *sorted = NULL; - llist_t *reversed = NULL; - llist_t *current_sort = NULL; - - bb_printf("\n\nSwitching to run level %d", newlevel); - - // get previous run level - temp = quick_read("/var/lib/misc/runlevel"); - if (temp != NULL) - { - oldlevel = atoi(temp); - if (oldlevel < 0) - oldlevel = 1; - if (oldlevel > 6) - oldlevel = 5; - bb_printf(" from run level %d", oldlevel); - free(temp); - } - bb_printf(".\n\n"); + int oldlevel = 0; + int newlevel = atoi(level); + char *temp; + llist_t *sorted = NULL; + llist_t *reversed = NULL; + llist_t *current_sort = NULL; + + bb_printf("\n\nSwitching to run level %d", newlevel); + + // get previous run level + temp = quick_read("/var/lib/misc/runlevel"); + if (temp != NULL) { + oldlevel = atoi(temp); + if (oldlevel < 1) + oldlevel = 1; + if ((oldlevel == 6) || (oldlevel > 9)) + oldlevel = 5; + bb_printf(" from run level %d", oldlevel); + free(temp); + } + bb_printf(".\n\n"); - // get scripts and sort dependencies, careful with circular dependencies - sorted = sort_scripts(get_scripts()); + // get scripts and sort dependencies, careful with circular dependencies + sorted = sort_scripts(get_scripts(), NULL); - // reverse - current_sort = sorted; - while (current_sort) - { - llist_t *current_list = (llist_t *) current_sort->data; - llist_t *new_list = NULL; + // reverse + current_sort = sorted; + while (current_sort) { + llist_t *current_list = (llist_t *) current_sort->data; + llist_t *new_list = NULL; - while (current_list) - { - new_list = llist_add_to(new_list, current_list->data); - current_list = current_list->link; + while (current_list) { + new_list = llist_add_to(new_list, current_list->data); + current_list = current_list->link; + } + reversed = llist_add_to(reversed, (char *) new_list); + current_sort = current_sort->link; } - reversed = llist_add_to(reversed, (char *) new_list); - current_sort = current_sort->link; - } - // call "stop" for each script - bb_printf("\n"); - call_scripts(reversed, "stop", newlevel, oldlevel); + // call "stop" for each script + bb_printf("\n"); + call_scripts(reversed, "stop", newlevel, oldlevel); - // call "start" for each script - bb_printf("\n"); - call_scripts(sorted, "start", oldlevel, newlevel); + // call "start" for each script + bb_printf("\n"); + call_scripts(sorted, "start", oldlevel, newlevel); // free all infos - // set previous run level to new run level - quick_write("/var/lib/misc/runlevel", "%d", newlevel); + // set previous run level to new run level + quick_write("/var/lib/misc/runlevel", "%d", newlevel); // Later, optionally call them in parallel when possible. // Later, add a database of runlevels per script and allow editing them - -// rc network --runlevels 3 4 5 +// rc network -l 3 4 5 // cat /etc/runlevels.conf // runlevel="3" -// runlevel3="multi user with network." -// runlevel4="multi user with network and twin." -// runlevel5="multi user with network and X." -// local_fs="1 2 3 4 5" -// network="3 4 5" -// script1="2 3 5" -// script1="3 5" -// rc network --runlevels +// runlevel_3="multi user with network." +// runlevel_4="multi user with network and twin." +// runlevel_5="multi user with network and X." +// runlevel_local_fs="1 2 3 4 5" +// runlevel_network="3 4 5" +// runlevel_script1="2 3 5" +// runlevel_script1="3 5" +// rc network -l // 3 4 5 -// rc network --runlevels -v +// rc network -lv // The "network" service will be active during these run levels : // 3 - multi user with network. // 4 - multi user with network and twin. // 5 - multi user with network and X. - return EXIT_SUCCESS; + return EXIT_SUCCESS; +} + + +static void print_levels(char *script, char *levels, int verbose) +{ + if (verbose) { + char *token; + char *strtok_temp; + + bb_printf("The \"%s\" service will be active during these run levels :\n", script); + + for (token = strtok_r(levels, " \t\n\r", &strtok_temp); token != NULL; token = strtok_r(NULL, " \t\n\r", &strtok_temp)) { + char *env; + + bb_xasprintf(&env, "runlevel_%s", token); + bb_printf("%s - %s\n", token, getenv(env)); + } + } else { + bb_printf("%s\n", levels); + } +} + + +static int show_run_levels(char *script, int verbose) +{ + int result = EXIT_FAILURE; + + char *info_text = NULL; + char *pathname = NULL; + init_d_info_t *info = NULL; +//bb_printf("SHOW levels for %s\n", script); + + bb_xasprintf(&pathname, "/etc/init.d/%s", script); + info_text = get_init_info(pathname); + info = parse_init_info(info_text, script); + if (info) { + char *env; + char *levels; + + result = EXIT_SUCCESS; + bb_xasprintf(&env, "runlevel_%s", script); + levels = getenv(env); + if (levels) + print_levels(script, levels, verbose); + else { + int k; + RESERVE_CONFIG_BUFFER(temp, PATH_MAX); + + temp[0] = '\0'; + if (info->defstart != NULL) { + for (k = 0; k < info->sizes[5]; k++) + snprintf(temp, PATH_MAX, "%s%d ", temp, info->defstart[k]); + } + + print_levels(script, temp, verbose); + + RELEASE_CONFIG_BUFFER(temp); + } + } + + free(info); + free(info_text); + free(pathname); + + return result; +} + + +static int edit_run_levels(char *script, char *levels, int verbose) +{ + int result = 0; +bb_printf("CHANGE levels for %s to %s\n", script, levels); + return result; } @@ -1243,29 +1336,69 @@ int run_level(char *level) * rc * rc 1 * rc network start - * rc network --runlevels - * rc network --runlevels -v - * rc network --runlevels 3 4 5 + * rc network -l + * rc network -lv + * rc network -l 3 4 5 */ int rc_main(int argc, char **argv) { - switch (argc) - { - case 0 : - case 1 : - { - return run_level(quick_read("/etc/runlevel")); + int opt; + int levels = 0, verbose = 0; + + while ((opt = getopt(argc, argv, "lv")) > 0) { + switch (opt) { + case 'l': + levels = 1; + break; + + case 'v': + verbose = 1; + break; + + default: + bb_show_usage(); + } } - case 2 : return run_level(argv[1]); - case 3 : - { + + read_sysconfig("/etc/runlevels.conf"); + argc -= optind - 1; + argv += optind - 1; + + if (levels) { + switch (argc) { + case 0: + case 1: + { + return INIT_D_ERROR_NOT_IMPLEMENTED; + } + case 2: + { + return show_run_levels(argv[1], verbose); + } + default: + { + return edit_run_levels(argv[1], argv_cat(argc - 1, &argv[1]), verbose); + } + } + } else { + switch (argc) { + case 0: + case 1: + { + return run_level(quick_read("/etc/runlevel")); + } + case 2: + return run_level(argv[1]); + case 3: + { // Should take care of dependencies for argv[1] script. - return init_script(argv[1], argv[2]); - } - default : - { - return INIT_D_ERROR_NOT_IMPLEMENTED; + return init_script(argv[1], argv[2]); + } + default: + { + return INIT_D_ERROR_NOT_IMPLEMENTED; + } + } } - } } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -31,53 +34,51 @@ static int status(struct init_d_handle_s *, int); static int stop(struct init_d_handle_s *, int); -static init_d_handle_t my_commands = -{ - &start, - &stop, - NULL, - NULL, - &no_reload, - NULL, - &status, - NULL, - "remote_fs", - NULL, - NULL, - NULL, - INIT_D_BEGIN \ - INIT_D_PROV "$remote_fs" \ - INIT_D_RSTART "$network" \ - INIT_D_SSTART "nfs smbfs codafs" \ - INIT_D_DSTART "3 4 5" \ - INIT_D_DSTOP "0 1 2 6" \ - INIT_D_SDESC "Mount all remote file systems." \ - INIT_D_DESC "Mount all remote file systems. Actually, this is just a" \ - INIT_D_CONT "dummy that depends on all the init scripts that could" \ - INIT_D_CONT "possibly mount remote file systems." \ - INIT_D_END +static init_d_handle_t my_commands = { + &start, + &stop, + NULL, + NULL, + &no_reload, + NULL, + &status, + NULL, + "remote_fs", + NULL, + NULL, + NULL, + INIT_D_BEGIN + INIT_D_PROV "$remote_fs" + INIT_D_RSTART "$network" + INIT_D_SSTART "nfs smbfs codafs" + INIT_D_DSTART "3 4 5" + INIT_D_DSTOP "0 1 2 6" + INIT_D_SDESC "Mount all remote file systems." + INIT_D_DESC "Mount all remote file systems. Actually, this is just a" + INIT_D_CONT "dummy that depends on all the init scripts that could" + INIT_D_CONT "possibly mount remote file systems." INIT_D_END }; int remote_fs_main(int argc, char **argv) { - return do_init_from_main(argc, argv, &my_commands); + return do_init_from_main(argc, argv, &my_commands); } static int start(struct init_d_handle_s *init_d, int just_checking) { - return INIT_D_OK; + return INIT_D_OK; } static int status(struct init_d_handle_s *init_d, int quiet) { - return print_status(init_d, quiet, INIT_D_STATUS_OK); + return print_status(init_d, quiet, INIT_D_STATUS_OK); } static int stop(struct init_d_handle_s *init_d, int just_checking) { - return INIT_D_OK; + return INIT_D_OK; } 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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -20,6 +23,7 @@ * */ +#include #include #include "busybox.h" @@ -28,11 +32,103 @@ int remove_initd_main(int argc, char **argv) { - llist_t *sorted = NULL; - llist_t *unsorted = get_scripts(); + int result = EXIT_FAILURE; + + argv += optind; + if (!*argv) + bb_show_usage(); + else { + int in_init = 0; + llist_t *current = NULL; + llist_t *previous = NULL; + llist_t *unsorted = get_scripts(); + init_d_info_t *info = NULL; + char *info_text = NULL; + char *pathname = NULL; + RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX); + + bb_xasprintf(&pathname, "%s", *argv); + if ((*argv)[0] != '/') { + char *cwd = xgetcwd(NULL); + + if (cwd) { + free(pathname); + bb_xasprintf(&pathname, "%s/%s", cwd, *argv); + } + } + + if (realpath(pathname, resolved_path) != NULL) { + if (strncmp("/etc/init.d/", resolved_path, 12) == 0) + in_init = 1; + } else { + bb_perror_msg("%s", pathname); + } + + info_text = get_init_info(pathname); + info = parse_init_info(info_text, bb_get_last_path_component(pathname)); + + current = unsorted; + while (current) { + init_d_info_t *this_one = (init_d_info_t *) current->data; + + if (strcmp(this_one->path, info->path) == 0) { + current = llist_delete(&unsorted, previous, current); + break; + } + previous = current; + current = current->link; + } + + sort_scripts(unsorted, NULL); + result = EXIT_SUCCESS; + current = unsorted; + while (current) { + int k; + init_d_info_t *this_one = (init_d_info_t *) current->data; + + if (this_one) { + for (k = 0; k < info->sizes[0]; k++) { + int i; + + for (i = 0; i < this_one->sizes[1]; i++) { + if (strcmp(this_one->reqstart[i], info->provides[k]) == 0) { + result = EXIT_FAILURE; + bb_error_msg("%s is required by %s.", pathname, this_one->path); + break; + } + } + if (result == EXIT_FAILURE) + break; + } + } + + current = current->link; + } + + /* This is not LSB compliant, the LSB package manager is supposed to remove it, but... + * We may have created it, so we should remove it. + * LSB says that init.d scripts are "configuration files", I disagree, they are executables. + * LSB further says that config files are left behind after package removal. This is a + * contradiction with "package manager is supposed to remove it". + * + * Safest thing to do is zap it. + */ + if ((in_init) && (result == EXIT_SUCCESS)) { + free(info_text); + bb_xasprintf(&info_text, "/etc/init.d/%s", bb_get_last_path_component(pathname)); + remove_file(info_text, FILEUTILS_FORCE); + } + + if (result == EXIT_FAILURE) + bb_error_msg("Unable to remove the %s init.d script.", pathname); + +#ifdef CONFIG_FEATURE_CLEAN_UP + RELEASE_CONFIG_BUFFER(resolved_path); +#endif + free(info); + free(pathname); + free(info_text); + } -// Should remove this script from unsorted. - sorted = sort_scripts(unsorted); -// Should return 1 if there are unsatisfied dependencies if this is removed. - return EXIT_SUCCESS; + return result; } 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 @@ +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/Makefile busybox-1.00/Makefile +--- busybox-1.00-original/Makefile 2004-10-08 17:45:08.000000000 +1000 ++++ busybox-1.00/Makefile 2005-03-12 00:58:35.000000000 +1000 +@@ -40,9 +40,9 @@ + include $(top_builddir)/Rules.mak + + DIRS:=applets archival archival/libunarchive coreutils console-tools \ +- debianutils editors findutils init miscutils modutils networking \ ++ debianutils editors findutils init miscutils modutils my_linux networking \ + networking/libiproute networking/udhcp procps loginutils shell \ +- sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb ++ sysklogd runlevel util-linux libpwdgrp coreutils/libcoreutils libbb + + SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) + +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/include/applets.h busybox-1.00/include/applets.h +--- busybox-1.00-original/include/applets.h 2004-08-27 09:01:34.000000000 +1000 ++++ busybox-1.00/include/applets.h 2005-03-14 09:37:26.000000000 +1000 +@@ -75,6 +75,18 @@ + #ifdef CONFIG_BASENAME + APPLET(basename, basename_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_BOOT_NAMED ++ APPLET(boot_named, boot_named_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_BOOT_PORTMAP ++ APPLET(boot_portmap, boot_portmap_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_BOOT_SYSLOG ++ APPLET(boot_syslog, boot_syslog_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_BOOT_TIME ++ APPLET(boot_time, boot_time_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_BUNZIP2 + APPLET(bunzip2, bunzip2_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -226,6 +238,9 @@ + #ifdef CONFIG_GETOPT + APPLET(getopt, getopt_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_GETPKG ++ APPLET(getpkg, getpkg_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_GETTY + APPLET(getty, getty_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif +@@ -289,6 +304,9 @@ + #ifdef CONFIG_INSTALL + APPLET(install, install_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_INSTALL_INITD ++ APPLET(install_initd, install_initd_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_IP + APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif +@@ -313,6 +331,9 @@ + #ifdef CONFIG_KILLALL + APPLET(killall, kill_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_KILLPROC ++ APPLET(killproc, killproc_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_KLOGD + APPLET(klogd, klogd_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif +@@ -328,6 +349,9 @@ + #ifdef CONFIG_FEATURE_INITRD + APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_LINUXRC ++ APPLET(linuxrc, linuxrc_main, _BB_DIR_ROOT, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_LN + APPLET(ln, ln_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif +@@ -337,6 +361,18 @@ + #ifdef CONFIG_LOADKMAP + APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_LOCAL_FS ++ APPLET(local_fs, local_fs_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_LOG_FAILURE_MSG ++ APPLET(log_failure_msg, log_failure_msg_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_LOG_SUCCESS_MSG ++ APPLET(log_success_msg, log_success_msg_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_LOG_WARNING_MSG ++ APPLET(log_warning_msg, log_warning_msg_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_LOGGER + APPLET(logger, logger_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -361,6 +397,9 @@ + #ifdef CONFIG_MAKEDEVS + APPLET(makedevs, makedevs_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_MAN ++ APPLET(man, man_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_MD5SUM + APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -379,6 +418,9 @@ + #ifdef CONFIG_MKNOD + APPLET(mknod, mknod_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_MKROOTFS ++ APPLET(mkrootfs, mkrootfs_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_MKSWAP + APPLET(mkswap, mkswap_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif +@@ -412,6 +454,9 @@ + #ifdef CONFIG_NETSTAT + APPLET(netstat, netstat_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_NETWORK ++ APPLET(network, network_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_NSLOOKUP + APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -430,6 +475,9 @@ + #ifdef CONFIG_PIDOF + APPLET(pidof, pidof_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_PIDOFPROC ++ APPLET(pidofproc, pidofproc_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_PING + APPLET(ping, ping_main, _BB_DIR_BIN, _BB_SUID_MAYBE) + #endif +@@ -454,6 +502,12 @@ + #ifdef CONFIG_PWD + APPLET(pwd, pwd_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_RC ++ APPLET(rc, rc_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_RCS ++ APPLET(rcS, rcS_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_RDATE + APPLET(rdate, rdate_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) + #endif +@@ -466,6 +520,12 @@ + #ifdef CONFIG_REBOOT + APPLET(reboot, reboot_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_REMOTE_FS ++ APPLET(remote_fs, remote_fs_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif ++#ifdef CONFIG_REMOVE_INITD ++ APPLET(remove_initd, remove_initd_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_RENICE + APPLET(renice, renice_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -526,6 +586,9 @@ + #ifdef CONFIG_START_STOP_DAEMON + APPLET_ODDNAME("start-stop-daemon", start_stop_daemon_main, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon) + #endif ++#ifdef CONFIG_START_DAEMON ++ APPLET(start_daemon, start_daemon_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_STRINGS + APPLET(strings, strings_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -598,6 +661,9 @@ + #ifdef CONFIG_UDHCPC + APPLET(udhcpc, udhcpc_main, _BB_DIR_SBIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_UDHCPC_SCRIPT ++ APPLET(udhcpc_script, udhcpc_script_main, _BB_DIR_SBIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_UDHCPD + APPLET(udhcpd, udhcpd_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER) + #endif +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/include/usage.h busybox-1.00/include/usage.h +--- busybox-1.00-original/include/usage.h 2004-09-15 02:23:56.000000000 +1000 ++++ busybox-1.00/include/usage.h 2005-03-14 09:37:34.000000000 +1000 +@@ -89,6 +89,43 @@ + "$ basename /foo/bar.txt .txt\n" \ + "bar" + ++ ++#define boot_named_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define boot_named_full_usage \ ++ "LSB compliant named init.d script." ++#define boot_named_example_usage \ ++ "$ boot_named start\n" \ ++ "Start boot_named ... OK\n" ++ ++ ++#define boot_portmap_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define boot_portmap_full_usage \ ++ "LSB compliant portmap init.d script." ++#define boot_portmap_example_usage \ ++ "$ boot_portmap start\n" \ ++ "Start boot_portmap ... OK\n" ++ ++ ++#define boot_syslog_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define boot_syslog_full_usage \ ++ "LSB compliant syslog init.d script." ++#define boot_syslog_example_usage \ ++ "$ boot_syslog start\n" \ ++ "Start boot_syslog ... OK\n" ++ ++ ++#define boot_time_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define boot_time_full_usage \ ++ "LSB compliant time init.d script." ++#define boot_time_example_usage \ ++ "$ boot_time start\n" \ ++ "Start boot_time ... OK\n" ++ ++ + #define bunzip2_trivial_usage \ + "[OPTION]... [FILE]" + #define bunzip2_full_usage \ +@@ -768,6 +805,23 @@ + " esac\n" \ + "done\n" + ++ ++#define getpkg_trivial_usage \ ++ "[-afk] [PACKAGE] {[URL] | [DIR]}" ++#define getpkg_full_usage \ ++ "Install a Trinux PACKAGE from a FILE or an URL ." \ ++ "\t-a,\t\tget all packages\n" \ ++ "\t-f,\t\tpackage file, no need to download\n" \ ++ "\t-k,\t\tkernel package" ++#define getpkg_example_usage \ ++ "$ getpkg\n" \ ++ "$ getpkg -a\n" \ ++ "$ getpkg -f name\n" \ ++ "$ getpkg -fk name /media/cdrom/trinux/pkg\n" \ ++ "$ getpkg -k name\n" \ ++ "$ getpkg name http://www.trinux.org/pkg/\n" ++ ++ + #define getty_trivial_usage \ + "[OPTIONS]... baud_rate,... line [termtype]" + #define getty_full_usage \ +@@ -1299,6 +1353,15 @@ + "\t-p\tpreserve date\n" \ + "\t-s\tstrip symbol tables" + ++ ++#define install_initd_trivial_usage \ ++ "FILE" ++#define install_initd_full_usage \ ++ "LSB compliant install_initd init.d script installer." ++#define install_initd_example_usage \ ++ "$ install_initd /etc/init.d/init_script\n" ++ ++ + #define ip_trivial_usage \ + "[ OPTIONS ] { address | link | route | tunnel } { COMMAND | help }" + #define ip_full_usage \ +@@ -1391,6 +1454,16 @@ + #define killall_example_usage \ + "$ killall apache\n" + ++#define killproc_trivial_usage \ ++ "[OPTION] COMMAND [SIGNAL]" ++#define killproc_full_usage \ ++ "LSB compliant killproc daemon killer." \ ++ "\n\nOptions:"\ ++ "\n\t-p \t\t\tload pid using a pid-file" ++#define killproc_example_usage \ ++ "$ killproc daemon_proggy\n" ++ ++ + #define klogd_trivial_usage \ + "[-c n] [-n]" + #define klogd_full_usage \ +@@ -1407,6 +1480,14 @@ + "$ length Hello\n" \ + "5\n" + ++#define linuxrc_trivial_usage \ ++ "" ++#define linuxrc_full_usage \ ++ "linuxrc pre boot." ++#define linuxrc_example_usage \ ++ "$ linuxrc\n" ++ ++ + #define ln_trivial_usage \ + "[OPTION] TARGET... LINK_NAME|DIRECTORY" + #define ln_full_usage \ +@@ -1435,6 +1516,39 @@ + #define loadkmap_example_usage \ + "$ loadkmap < /etc/i18n/lang-keymap\n" + ++#define local_fs_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define local_fs_full_usage \ ++ "LSB compliant local_fs init.d script." ++#define local_fs_example_usage \ ++ "$ local_fs start\n" \ ++ "Start local_fs ... OK\n" ++ ++ ++#define log_failure_msg_trivial_usage \ ++ "MESSAGE" ++#define log_failure_msg_full_usage \ ++ "LSB compliant log_failure_msg." ++#define log_failure_msg_example_usage \ ++ "$ log_failure_msg "It be broke!"\n" ++ ++ ++#define log_success_msg_trivial_usage \ ++ "MESSAGE" ++#define log_success_msg_full_usage \ ++ "LSB compliant log_success_msg." ++#define log_success_msg_example_usage \ ++ "$ log_success_msg "It worked."\n" ++ ++ ++#define log_warning_msg_trivial_usage \ ++ "MESSAGE" ++#define log_warning_msg_full_usage \ ++ "LSB compliant log_warning_msg." ++#define log_warning_msg_example_usage \ ++ "$ log_warning_msg "It might be broke."\n" ++ ++ + #define logger_trivial_usage \ + "[OPTION]... [MESSAGE]" + #define logger_full_usage \ +@@ -1570,6 +1684,14 @@ + "# makedevs /dev/hda b 3 0 0 8 s\n" \ + "[creates hda,hda1-hda8]\n" + ++#define man_trivial_usage \ ++ "[NAME]" ++#define man_full_usage \ ++ "Show documentation for Trinux software." ++#define man_example_usage \ ++ "$ man basics\n" ++ ++ + #ifdef CONFIG_FEATURE_MD5_SHA1_SUM_CHECK + #define USAGE_MD5_SHA1_SUM_CHECK(a) a + #else +@@ -1652,6 +1774,15 @@ + "$ mknod /dev/fd0 b 2 0\n" \ + "$ mknod -m 644 /tmp/pipe p\n" + ++ ++#define mkrootfs_trivial_usage \ ++ "[-c filename] [PATH]" ++#define mkrootfs_full_usage \ ++ "Creates all the directories, devices, files, and links needed for a root file system." ++#define mkrootfs_example_usage \ ++ "$ mkrootfs /\n" ++ ++ + #define mkswap_trivial_usage \ + "[-c] [-v0|-v1] device [block-count]" + #define mkswap_full_usage \ +@@ -1813,6 +1944,16 @@ + "\t-w raw sockets\n" \ + "\t-x unix sockets" + ++ ++#define network_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define network_full_usage \ ++ "LSB compliant network init.d script." ++#define network_example_usage \ ++ "$ network start\n" \ ++ "Start network ... OK\n" ++ ++ + #define nslookup_trivial_usage \ + "[HOST] [SERVER]" + #define nslookup_full_usage \ +@@ -1875,6 +2016,16 @@ + "$ pidof init\n" \ + "1\n" + ++#define pidofproc_trivial_usage \ ++ "[OPTION] COMMAND" ++#define pidofproc_full_usage \ ++ "LSB compliant pidofproc daemon checker." \ ++ "\n\nOptions:"\ ++ "\n\t-p \t\t\tsave or load pid using a pid-file" ++#define pidofproc_example_usage \ ++ "$ pidofproc daemon_proggy\n" ++ ++ + #ifndef CONFIG_FEATURE_FANCY_PING + #define ping_trivial_usage "host" + #define ping_full_usage "Send ICMP ECHO_REQUEST packets to network hosts" +@@ -1977,6 +2128,33 @@ + "$ pwd\n" \ + "/root\n" + ++#define rc_trivial_usage \ ++ "[RUNLEVEL] | COMMAND [start | stop | restart | try-restart | reload | force-reload | status | info] [OPTIONS]" ++#define rc_full_usage \ ++ "LSB compliant runlevel controller." ++#define rc_example_usage \ ++ "$ rc\n" \ ++ "$ rc 5\n" \ ++ "$ rc network start\n" \ ++ "Start network ... OK\n" \ ++ "$ rc network --runlevels\n" \ ++ "3 4 5\n" \ ++ "$ rc network --runlevels -v\n" \ ++ "The \"network\" service will be active during these runlevels :\n" \ ++ "3 - multi user with network.\n" \ ++ "4 - multi user with network and twin.\n" \ ++ "5 - multi user with networkand X.\n" \ ++ "$ rc network --runlevels 3 4 5\n" ++ ++ ++#define rcS_trivial_usage \ ++ "" ++#define rcS_full_usage \ ++ "sysinit for inittab." ++#define rcS_example_usage \ ++ "$ rcS\n" ++ ++ + #define rdate_trivial_usage \ + "[-sp] HOST" + #define rdate_full_usage \ +@@ -2002,6 +2180,23 @@ + "Options:\n" \ + "\t-d\t\tdelay interval for rebooting." + ++#define remote_fs_trivial_usage \ ++ "start | stop | restart | try-restart | reload | force-reload | status | info" ++#define remote_fs_full_usage \ ++ "LSB compliant remote_fs init.d script." ++#define remote_fs_example_usage \ ++ "$ remote_fs start\n" \ ++ "Start remote_fs ... OK\n" ++ ++ ++#define remove_initd_trivial_usage \ ++ "FILE" ++#define remove_initd_full_usage \ ++ "LSB compliant remove_initd init.d script removal." ++#define remove_initd_example_usage \ ++ "$ remove_initd /etc/init.d/init_script\n" ++ ++ + #define renice_trivial_usage \ + "priority pid [pid ...]" + #define renice_full_usage \ +@@ -2212,6 +2407,18 @@ + "e\n" \ + "f\n" + ++#define start_daemon_trivial_usage \ ++ "[OPTIONS]... COMMAND [ARGS...]" ++#define start_daemon_full_usage \ ++ "LSB compliant start_daemon daemon starter."\ ++ "\n\nOptions:"\ ++ "\n\t-f\t\t\tforce a start if already running"\ ++ "\n\t-n \t\t\tnice level"\ ++ "\n\t-p \t\t\tsave or load pid using a pid-file" ++#define start_daemon_example_usage \ ++ "$ start_daemon -p /var/run/daemon_proggy.pid daemon_proggy --foo blah\n" ++ ++ + #define start_stop_daemon_trivial_usage \ + "[OPTIONS] [--start|--stop] ... [-- arguments...]\n" + #define start_stop_daemon_full_usage \ +@@ -2625,6 +2832,11 @@ + "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ + "\t-v,\t--version\tDisplay version" + ++#define udhcpc_script_trivial_usage \ ++ "[ACTION]" ++#define udhcpc_script_full_usage \ ++ "Should only be called by udhcpc." ++ + #define udhcpd_trivial_usage \ + "[configfile]\n" \ + +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/networking/udhcp/dhcpc.h busybox-1.00/networking/udhcp/dhcpc.h +--- busybox-1.00-original/networking/udhcp/dhcpc.h 2004-01-31 09:45:12.000000000 +1000 ++++ busybox-1.00/networking/udhcp/dhcpc.h 2005-03-12 04:12:30.000000000 +1000 +@@ -2,7 +2,8 @@ + #ifndef _DHCPC_H + #define _DHCPC_H + +-#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script" ++//#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script" ++#define DEFAULT_SCRIPT "/sbin/udhcpc_script" + + /* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */ + #include "libbb_udhcp.h" +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/networking/udhcp/libbb_udhcp.h busybox-1.00/networking/udhcp/libbb_udhcp.h +--- busybox-1.00-original/networking/udhcp/libbb_udhcp.h 2004-05-19 19:18:04.000000000 +1000 ++++ busybox-1.00/networking/udhcp/libbb_udhcp.h 2005-03-12 04:07:27.000000000 +1000 +@@ -5,7 +5,8 @@ + + #ifdef CONFIG_INSTALL_NO_USR + #undef DEFAULT_SCRIPT +-#define DEFAULT_SCRIPT "/share/udhcpc/default.script" ++//#define DEFAULT_SCRIPT "/share/udhcpc/default.script" ++#define DEFAULT_SCRIPT "/sbin/udhcpc_script" + #endif + + #ifndef _LIBBB_UDHCP_H +diff -urNX busybox-1.00/runlevel/diff_excludes busybox-1.00-original/sysdeps/linux/Config.in busybox-1.00/sysdeps/linux/Config.in +--- busybox-1.00-original/sysdeps/linux/Config.in 2004-05-25 21:30:22.000000000 +1000 ++++ busybox-1.00/sysdeps/linux/Config.in 2005-03-12 00:47:43.000000000 +1000 +@@ -223,6 +223,8 @@ + source debianutils/Config.in + source editors/Config.in + source findutils/Config.in ++source my_linux/Config.in ++source runlevel/Config.in + source init/Config.in + source loginutils/Config.in + 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 @@ +runlevel="3" + +runlevel_0="halt." +runlevel_1="single user." +runlevel_2="multi user with no network." +runlevel_3="multi user with network." +runlevel_4="multi user with network and twin." +runlevel_5="multi user with network and X." +runlevel_6="reboot." +runlevel_7="multi user with network and ggi, DirectFB, or SDL." +runlevel_8="multi user with network and 3D." +runlevel_9="node for cluster, render farm, or compile farm." + +#runlevel_local_fs="1 2 3 4 5" +#runlevel_network="3 4 5" +#runlevel_script1="2 3 5" +#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 @@ * * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au * + * Clean room implementation of LSB init.d specs. + * I didn't steal any of this, honest B-). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -31,40 +34,39 @@ #include "lib_init_d.h" -int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args) +int start_daemon(int force, int nice_level, char *pidfile, char *pathname, + char *args) { - int status = 0; - status = pidofproc(pidfile, pathname, NULL); - - if ((status != INIT_D_STATUS_OK) || (force)) - { - char *pids = NULL; - char *strtok_temp; - - doit(DAEMON, "start-stop-daemon -Sbmp %s -x %s -- %s", pidfile, pathname, args); -sleep(1); - status = pidofproc(pidfile, pathname, &pids); - if ((status == INIT_D_STATUS_OK) && (nice_level)) - { - int i; - char *pid; - - pid = strtok_r(pids, " ", &strtok_temp); - for (i = 0; pid != NULL; i++) - { - int ps = atoi(pid); - int oldp; - - errno = 0; - oldp = getpriority(PRIO_PROCESS, ps); - if (errno == 0) - setpriority(PRIO_PROCESS, ps, oldp + nice_level); - pid = strtok_r(NULL, " ", &strtok_temp); - } + int status = pidofproc(pidfile, pathname, NULL); + + if ((status != INIT_D_STATUS_OK) || (force)) { + char *pids = NULL; + char *strtok_temp; + + doit(DAEMON, "start-stop-daemon -Sbmp %s -x %s -- %s", pidfile, + pathname, args); +// Should poll /proc/pid/... instead + sleep(1); + status = pidofproc(pidfile, pathname, &pids); + if ((status == INIT_D_STATUS_OK) && (nice_level)) { + int i; + char *pid; + + pid = strtok_r(pids, " ", &strtok_temp); + for (i = 0; pid != NULL; i++) { + int ps = atoi(pid); + int oldp; + + errno = 0; + oldp = getpriority(PRIO_PROCESS, ps); + if (errno == 0) + setpriority(PRIO_PROCESS, ps, oldp + nice_level); + pid = strtok_r(NULL, " ", &strtok_temp); + } + } } - } - return status; + return status; } @@ -83,71 +85,63 @@ start_daemon [-f] [-n nicelevel] [-p pidfile] pathname [args] */ + /* getopt not used, because I don't think it can handle [args] */ int start_daemon_main(int argc, char **argv) { - int result = EXIT_FAILURE; - int force = 0; - int nice_level = 0; - char *pidfile = NULL; - char *pathname = NULL; - char *args = NULL; - int i; - - for (i = 1; i < argc; i++) - { - char *p = argv[i]; - - if (*p == '-') - { - while (*(++p)) - { - switch (*p) - { - case 'f' : - force = 1; - break; - - case 'n' : - if ((++i) < argc) - nice_level = atoi(argv[i]); - else - bb_show_usage(); - break; - - case 'p' : - if ((++i) < argc) - pidfile = argv[i]; - else - bb_show_usage(); + int result = EXIT_FAILURE; + int force = 0; + int nice_level = 0; + char *pidfile = NULL; + char *pathname = NULL; + char *args = NULL; + int i; + + for (i = 1; i < argc; i++) { + char *p = argv[i]; + + if (*p == '-') { + while (*(++p)) { + switch (*p) { + case 'f': + force = 1; + break; + + case 'n': + if ((++i) < argc) + nice_level = atoi(argv[i]); + else + bb_show_usage(); + break; + + case 'p': + if ((++i) < argc) + pidfile = argv[i]; + else + bb_show_usage(); + break; + + default: + bb_show_usage(); + } + } + } else if (pathname == NULL) { + pathname = p; break; - - default: + } else bb_show_usage(); - } - } - } - else if (pathname == NULL) - { - pathname = p; - break; } - else - bb_show_usage(); - } - if (pathname == NULL) - bb_show_usage(); + if (pathname == NULL) + bb_show_usage(); - if (i < argc) - args = argv_cat(argc - i, &argv[i]); + if (i < argc) + args = argv_cat(argc - i, &argv[i]); //bb_printf("ARGS - |%s|%s|%d|%d|%s\n", pidfile, pathname, force, nice_level, args); - result = start_daemon(force, nice_level, pidfile, pathname, args); + result = start_daemon(force, nice_level, pidfile, pathname, args); - if (args != NULL) - free(args); + if (args != NULL) + free(args); - return result; + return result; } - - 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 @@ +## Path: System/Cron +## Description: days to keep old files in tmp-dirs, 0 to disable +## Type: integer +## Default: 0 +## Config: +# +# cron.daily can check for old files in tmp-dirs. It will delete all files +# not accessed for more than MAX_DAYS_IN_TMP. If MAX_DAYS_IN_TMP is not set +# or set to 0, this feature will be disabled. +# +MAX_DAYS_IN_TMP="7" + +## Type: integer +## Default: 0 +# +# see MAX_DAYS_IN_TMP. This allows to specify another frequency for +# a second set of directories. +# +MAX_DAYS_IN_LONG_TMP="7" + +## Type: string +## Default: "/tmp" +# +# This variable contains a list of directories, in which old files are to +# be searched and deleted. The frequency is determined by MAX_DAYS_IN_TMP +# +TMP_DIRS_TO_CLEAR="/tmp" + +## Type: string +## Default: "" +# +# This variable contains a list of directories, in which old files are to +# be searched and deleted. The frequency is determined by MAX_DAYS_IN_LONG_TMP +# If cleaning of /var/tmp is wanted add it here. +# +LONG_TMP_DIRS_TO_CLEAR="/var/tmp" + +## Type: string +## Default: root +# +# In OWNER_TO_KEEP_IN_TMP, you can specify, whose files shall not be deleted. +# +OWNER_TO_KEEP_IN_TMP="root" + +## Type: string +## Default: no +# +# "Set this to "yes" to entirely remove (rm -rf) all files and subdirectories +# from the temporary directories defined in TMP_DIRS_TO_CLEAR on bootup. +# Please note, that this feature ignores OWNER_TO_KEEP_IN_TMP - all files will +# be removed without exception." +# +# If this is set to a list of directories (i.e. starts with a "/"), these +# directories will be cleared instead of those listed in TMP_DIRS_TO_CLEAR. +# This can be used to clear directories at boot as well as clearing unused +# files out of other directories. +# +CLEAR_TMP_DIRS_AT_BOOTUP="no" +## Path: System/Cron/Man +## Description: cron configuration for man utility +## Type: yesno +## Default: yes +# +# Should mandb and whatis be recreated by cron.daily ("yes" or "no") +# +REINIT_MANDB="yes" + +## Type: yesno +## Default: yes +# +# Should old preformatted man pages (in /var/catman) be deleted? (yes/no) +# +DELETE_OLD_CATMAN="yes" + +## Type: integer +## Default: 7 +# +# How long should old preformatted man pages be kept before deletion? (days) +# +CATMAN_ATIME="7" +## Path: System/Cron +## Description: Deleting core files +## Type: yesno +## Default: no +# +# Should old corefiles they be deleted? ("yes" or "no") +# If set to 'no', cron.daily will tell you if it finds old core files. +# NOTE: This feature requires RUN_UPDATEDB to be set to "yes" +# and the package with locate (findutils-locate) to be installed. +# +DELETE_OLD_CORE="yes" + +## Type: integer +## Default: 7 +# +# Maximum age of core files (in days) +# +MAX_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 @@ +## Path: Network/DNS/Name Server +## Description: Names server settings + +## Type: yesno +## Default: yes +## ServiceRestart: lwresd,named +# +# Shall the DNS server 'named' or the LightWeight RESolver Daemon, lwresd run +# in the chroot jail? +# +# Each time you start one of the daemons with the init script, /etc/named.conf, +# /etc/named.conf.include, /etc/rndc.key, and all files listed in +# NAMED_CONF_INCLUDE_FILES will be copied relative to /var/lib/named. +# +# The pid file will be in /var/lib/named/var/run/named/ and named named.pid +# or lwresd.pid. +# +NAMED_RUN_CHROOTED="yes" + +## Type: string +## Default: "" +## ServiceRestart: lwresd,named +# +# Additional arguments when starting the name daemon with the init script +# /etc/init.d/named or rcnamed. +# +# For example "-n 2" to use two CPUs if named is unable to determine the +# number of available CPUs. +# +# See man 8 named for all available commandline options. +# +# "-t /var/lib/named/var" is added if NAMED_RUN_CHROOTED is set to yes. +# +# "-u named" is used in any case by the init script to run the named daemon as +# user 'named' after completing privileged operations. +# +NAMED_ARGS="" +## Type: string +## Default: "" +## ServiceReload: named +# +# All mentioned config files will be copied relativ to /var/lib/named/, when +# 'named' is started in the chroot jail. +# +# /etc/named.conf and /etc/rndc.key are always copied. Also all files from +# include statements in named.conf. +# +# Filenames can be relative to /etc/named.d/. +# +# Please take care of the order if one file needs a setting of another. +# +# Example: "/etc/named-dhcpd.key ldap.dump rndc-access.conf" +# +NAMED_CONF_INCLUDE_FILES="/etc/named.d/zones.conf" + +## Type: string +## Default: "createNamedConfInclude" +## ServiceReload: named +# +# Programms to be executed each time the DNS server 'named' is started or +# reloaded. +# +# Filenames can be relative to /usr/share/bind/. +# +NAMED_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 @@ +HOSTNAME="matrix-RAD" + +tcp_syn_retries="7" +#ip_forward="1" +icmp_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 @@ +## Path: System/Logging +## Description: System logging +## Type: list(0,1,2,3,4,5,6,7) +## Default: 1 +## Config: "" +## ServiceRestart: syslog +# +# Default loglevel for klogd +# +KERNEL_LOGLEVEL=1 + +## Type: string +## Default: "" +## Config: "" +## ServiceRestart: syslog +# +# if not empty: parameters for syslogd +# for example SYSLOGD_PARAMS="-r -s my.dom.ain" +# +SYSLOGD_PARAMS="" + +## Type: string +## Default: -2 +## Config: "" +## ServiceRestart: syslog +# +# if not empty: parameters for klogd +# for example KLOGD_PARAMS="-2" for clean oops lines +# +KLOGD_PARAMS="-2" + +## Type: list(syslogd,syslog-ng) +## Default: syslogd +## Config: syslog-ng +## Command: /sbin/rcsyslog restart +## PreSaveCommand: /sbin/rcsyslog status && /sbin/rcsyslog stop +# +# The name of the syslog daemon used as +# syslog service: "syslogd", "syslog-ng" +# +SYSLOG_DAEMON="syslogd" + +## Type: string +## Default: "/var/lib/ntp/dev/log" +## Config: syslog-ng +## ServiceRestart: syslog +# +# The filename mentioned here will be added with the "-a ..." option as +# additional socket via SYSLOGD_PARAMS when syslogd is started. +# +# This additional socket is needed in case that syslogd is restarted. Otherwise +# a chrooted 'ntpd' won't be able to continue logging. +# +SYSLOGD_ADDITIONAL_SOCKET_NTP="/var/lib/ntp/dev/log" +## Type: string +## Default: "/var/lib/named/dev/log" +## ServiceRestart: syslog +## Config: syslog-ng +# +# The filename mentioned here will be added with the "-a ..." option as +# additional socket via SYSLOGD_PARAMS when syslogd is started. +# +# This additional socket is needed in case that syslogd is restarted. Otherwise +# a chrooted 'named' or 'lwresd' won't be able to continue logging. +# +SYSLOGD_ADDITIONAL_SOCKET_NAMED="/var/lib/named/dev/log" +## Type: string +## Default: "/var/lib/dhcp/dev/log" +## ServiceRestart: syslog +## Config: syslog-ng +# +# The filename mentioned here will be added with the "-a ..." option as +# additional socket via SYSLOGD_PARAMS when syslogd is started. +# +# This additional socket is needed in case that syslogd is restarted. Otherwise +# a chrooted dhcpd won't be able to continue logging. +# +SYSLOGD_ADDITIONAL_SOCKET_DHCP="/var/lib/dhcp/dev/log" +## Type: string +## Default: "/var/lib/frox/dev/log" +## ServiceRestart: syslog +## Config: syslog-ng +# +# The filename mentioned here will be added as "-a ..." to SYSLOGD_PARAMS when +# syslogd is started. +# +# This additional socket is needed in case that syslogd is restarted. Otherwise +# a chrooted frox won't be able to continue logging. +# +SYSLOGD_ADDITIONAL_SOCKET_FROX="/var/lib/frox/dev/log" +## Type: string +## Default: "/var/lib/stunnel/dev/log" +## ServiceRestart: syslog +## Config: syslog-ng +# +# The filename mentioned here will be added as "-a ..." to SYSLOGD_PARAMS when +# syslogd is started. +# +# This additional socket is needed in case that syslogd is restarted. Otherwise +# a chrooted stunnel won't be able to continue logging. +# +SYSLOGD_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 @@ +## Path: System/Environment/Clock +## Description: Information about your timezone and time +## Type: string +## ServiceRestart: boot.clock +# +# Set to "-u" if your system clock is set to UTC, and to "--localtime" +# if your clock runs that way. +# +HWCLOCK="-u" + +## Type: string(Europe/Berlin,Europe/London,Europe/Paris) +## ServiceRestart: boot.clock +# +# Timezone (e.g. CET) +# (this will set /usr/lib/zoneinfo/localtime) +# +TIMEZONE="Australia/Queensland" +DEFAULT_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 @@ +## Path System/Limits +## Description: Set single process limits (memory, CPU, core ...) +## Command: killall mingetty +# +# Both hard and soft limits may be set. Soft limits are enough if you +# trust the users. Then, the soft limits may protect your machine +# against suffering too much from an application leaking memory. +# If you don't trust your users, you may use hard limits to prevent +# the amount of harm they can do to the machine. Note that this is +# only partially effective: Memory limits are per process, not per +# user. +# A setting of 0 will skip the adjustment of the particular limit +# (except for core file sizes), thus the default will remain in +# place, which is "unlimited" for most limits. If a value is unset, +# no adjustment will be made either. +# The memory sizes are percentages, the other values are absolute +# numbers. +# Note that the limits only get effective after a session is +# restarted by init. Thus exiting mingetty (^D on console login) +# or changing runlevel to 3 and back to 5 for xdm is needed. +# Rebooting helps as well, of course. +# +## Type: integer(0:99) +## Default: 0 +# +# Limit the amount of virtual memory a single process may allocate. +# Hard limit: Can not be increased by non-root. +# This value corresponds to ulimit -Hv +# Parameter is in percent of virtual (phys+swap) memory, 0 means +# no adjustment (unlimited). +# +HARDVIRTUALLIMIT=0 + +## Type: integer(0:99) +## Default: 80 +# +# Limit the amount of virtual memory a single process may allocate. +# Soft limit: Can be increased by non-root up to the hard limit. +# This value corresponds to ulimit -Sv +# Parameter is in percent of virtual (phys+swap) memory, 0 means +# no adjustment (unlimited). +# +SOFTVIRTUALLIMIT=80 + +## Type: integer(0:99) +## Default: 0 +# +# Limit the amount of resident memory a single process may occupy. +# The process virtual memory can grow larger than this limit, but +# it can not get more resident memory. +# Hard limit: Can not be increased by non-root. +# This value corresponds to ulimit -Hm +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +HARDRESIDENTLIMIT=0 + +## Type: integer(0:99) +## Default: 85 +# +# Limit the amount of resident memory a single process may occupy. +# The process virtual memory can grow larger than this limit, but +# it can not get more resident memory. +# Soft limit: Can be increased by non-root up to the hard limit. +# This value corresponds to ulimit -Sm +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +SOFTRESIDENTLIMIT=85 + +## Type: integer(0:99) +## Default: 0 +# +# Limit the size of the stack that a single process may allocate. +# Normally, it should be enough to limit virtual and resident size. +# Note that with NPTL, the stack limit determines the stack SIZE +# of multithreaded programs and should thus better not be set. +# Hard limit: Can not be increased by non-root. +# This value corresponds to ulimit -Hs +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +HARDSTACKLIMIT=0 + +## Type: integer(0:99) +## Default: 0 +# +# Limit the size of the stack that a single process may allocate. +# Normally, it should be enough to limit virtual and resident size. +# Note that with NPTL, the stack limit determines the stack SIZE +# of multithreaded programs and should thus better not be set. +# Soft limit: Can be increased by non-root up to the hard limit. +# This value corresponds to ulimit -Ss +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +SOFTSTACKLIMIT=0 + +## Type: integer(0:99) +## Default: 0 +# +# Limit the size of the data segment that a single process may allocate. +# Normally, it should be enough to limit virtual and resident size. +# Hard limit: Can not be increased by non-root. +# This value corresponds to ulimit -Hd +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +HARDDATALIMIT=0 + +## Type: integer(0:99) +## Default: 0 +# +# Limit the size of the data segment that a single process may allocate. +# Normally, it should be enough to limit virtual and resident size. +# Soft limit: Can be increased by non-root up to the hard limit. +# This value corresponds to ulimit -Sd +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +SOFTDATALIMIT=0 + +## Type: integer(0:99) +## Default: 42 +# +# Limit the size of the memory that a single process may lock in +# physical memory (thus preventing it to be swapped out). +# Hard limit: Can not be increased by non-root. +# This value corresponds to ulimit -Hl +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +HARDLOCKLIMIT=0 + +## Type: integer(0:99) +## Default: 42 +# +# Limit the size of the memory that a single process may lock in +# physical memory (thus preventing it to be swapped out). +# Soft limit: Can be increased by non-root up to the hard limit. +# This value corresponds to ulimit -Sl +# Parameter is in percent of physical memory, 0 means no adjustment +# (unlimited). +# +SOFTLOCKLIMIT=0 + +## Type: integer +## Default: 0 +# +# Limit the amount of CPU time for a single process. +# Should not normally be set to non-zero values. +# Hard limit: Process will be killed. +# Corresponds to ulimit -Ht. +# Parameter is in seconds, 0 means no adjustment (unlimited). +# +HARDCPULIMIT=0 + +## Type: integer +## Default: 0 +# +# Limit the amount of CPU time for a single process. +# Should not normally be set to non-zero values. +# Soft limit: Process will be sent SIGXCPU. +# Corresponds to ulimit -St. +# Parameter is in seconds, 0 means no adjustment (unlimited). +# +SOFTCPULIMIT=0 + +## Type: integer +## Default: 8192 +# +# Limit the amount of file descriptors that a process +# may have open at any time. Linux default is 1024. +# Hard limit: Can not be increased by non-root. +# Corresponds to ulimit -Hn. +# 0 means no adjustment (system default: 1024). +# +HARDFDLIMIT=8192 + +## Type: integer +## Default: 1024 +# +# Limit the amount of file descriptors that a process +# may have open at any time. Linux default is 1024. +# Soft limit: Can be increased by non-root up to the hard limit. +# Corresponds to ulimit -Sn. +# 0 means no adjustment (system default: 1024). +# +SOFTFDLIMIT=1024 + +## Type: string +## Default: "unlimited" +# +# Limit the size of core dump files. 0 turns them off. +# Hard limit: Can not be increased by non-root. +# Corresponds to ulimit -Hc. +# Parameter is in blocks (1k), 0 means turning core files off. +# +HARDCORELIMIT="unlimited" + +## Type: string +## Default: "0" +# +# Limit the size of core dump files. 0 turns them off. +# Soft limit: Can be increased by non-root up to the hard limit. +# Corresponds to ulimit -Sc. +# Parameter is in blocks (1k), 0 means turning core files off. +# +SOFTCORELIMIT="0" + +## Type: string +## Default: "unlimited" +# +# Limit the size of files a user may create. +# Hard limit: Can not be increased by non-root. +# Corresponds to ulimit -Hf. +# Parameter is in blocks (1k), 0 means no adjustment (unlimited). +# +HARDFILESZLIMIT="unlimited" + +## Type: string +## Default: "unlimited" +# +# Limit the size of files a user may create. +# Soft limit: Can be increased by non-root up to the hard limit. +# Corresponds to ulimit -Sf. +# Parameter is in blocks (1k), 0 means no adjustment (unlimited). +# +SOFTFILESZLIMIT="unlimited" + +## Type: string +## Default: "0" +# +# Limit the number of processes that a single user may have at the +# same time. +# Hard limit: Can not be increased by non-root. +# Corresponds to ulimit -Hu. +# 0 means no adjustment (system default is a few thousands, exact +# value depends on the architecture). +# +HARDPROCESSLIMIT="0" + +## Type: string +## Default: "0" +# +# Limit the number of processes that a single user may have at the +# same time. +# Soft limit: Can be increased by non-root up to the hard limit. +# Corresponds to ulimit -Su. +# 0 means no adjustment (system default is a few thousands, exact +# value depends on the architecture). +# +SOFTPROCESSLIMIT="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 @@ +## Path: Network/NTP +## Description: Network Time Protocol (NTP) server settings +## Type: string +## Default: AUTO-2 +## ServiceRestart: xntpd +# +# Usually it's a good idea to get the current time and date +# from some other ntp server, before the local xntpd is started. +# - Set XNTPD_INITIAL_NTPDATE="AUTO" to query ALL servers listed +# in the configuration file (/etc/ntp.conf). +# - Set XNTPD_INITIAL_NTPDATE="AUTO-{NUMBER}" to query the first {NUMBER} +# servers listed in the configuration file. E.g. "AUTO-2". +# Otherwise provide a space-separated list of ntp servers to query, or +# set XNTPD_INITIAL_NTPDATE="" to do no initial query at all. +# +XNTPD_INITIAL_NTPDATE="AUTO-2" + +## Type: string +## Default: "-u ntp" +# +# Additional arguments when starting ntpd. The most +# important ones would be +# -u user[:group] to make xntpd run as a user (group) other than root. +# +XNTPD_OPTIONS="-u ntp" + +## Type: yesno +## Default: yes +## ServiceRestart: xntpd +# +# Shall the time server ntpd run in the chroot jail /var/lib/ntp? +# +# Each time you start ntpd with the init script, /etc/ntp.conf will be +# copied to /var/lib/ntp/etc/. +# +# The pid file will be in /var/lib/ntp/var/run/ntpd.pid. +# +XNTPD_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 @@ /* - * Mini udhcpc_script implementation for busybox. + * Mini udhcpc default.script implementation for busybox. * * Copyright (C) 2004 by David Seikel won_fang@yahoo.com.au * + * Originally based on code from Trinux. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -30,162 +32,169 @@ static void printit(char *name, char *description, char *value) { - if (value != NULL) - bb_printf("%s=%s\t\t- %s\n", name, value, description); + if (value != NULL) + bb_printf("%s=%s\t\t- %s\n", name, value, description); } + + /* no options, no getopt */ int udhcpc_script_main(int argc, char **argv) { - argv += optind; + argv += optind; #if 0 - printit("action", "What action the script should perform", *argv); - printit("HOME", "The set $HOME env or '/'", getenv("HOME")); - printit("PATH", "the set $PATH env or '/bin:/usr/bin:/sbin:/usr/sbin'", getenv("PATH")); - printit("interface", "The interface this was obtained on", getenv("interface")); - printit("ip", "The obtained IP", getenv("ip")); - printit("mask", "The number of bits in the netmask (ie: 24)", getenv("mask")); - printit("siaddr", "The bootp next server option", getenv("siaddr")); - printit("sname", "The bootp server name option", getenv("sname")); - printit("boot_file", "The bootp boot file option", getenv("boot_file")); - printit("subnet", "The assigend subnet mask", getenv("subnet")); - printit("timezone", "Offset in seconds from UTC", getenv("timezone")); - printit("router", "A list of routers", getenv("router")); - printit("timesvr", "A list of time servers", getenv("timesvr")); - printit("namesvr", "A list of IEN 116 name servers", getenv("namesvr")); - printit("dns", "A list of DNS server", getenv("dns")); - printit("logsvr", "A list of MIT-LCS UDP log servers", getenv("logsvr")); - printit("cookiesvr", "A list of RFC 865 cookie servers", getenv("cookiesvr")); - printit("lprsvr", "A list of LPR servers", getenv("lprsvr")); - printit("hostname", "The assigned hostname", getenv("hostname")); - printit("bootsize", "The length in 512 octect blocks of the bootfile", getenv("bootsize")); - printit("domain", "The domain name of the network", getenv("domain")); - printit("swapsvr", "The IP address of the client's swap server", getenv("swapsvr")); - printit("rootpath", "The path name of the client's root disk", getenv("rootpath")); - printit("ipttl", "The TTL to use for this network", getenv("ipttl")); - printit("mtu", "The MTU to use for this network", getenv("mtu")); - printit("broadcast", "The broadcast address for this network", getenv("broadcast")); - printit("ntpsrv", "A list of NTP servers", getenv("ntpsrv")); - printit("wins", "A list of WINS servers", getenv("wins")); - printit("lease", "The lease time, in seconds", getenv("lease")); - printit("dhcptype", "DHCP message type (safely ignored)", getenv("dhcptype")); - printit("serverid", "The IP of the server", getenv("serverid")); - printit("message", "Reason for a DHCPNAK", getenv("message")); - printit("tftp", "The TFTP server name", getenv("tftp")); - printit("bootfile", "The bootfile name", getenv("bootfile")); + printit("action", "What action the script should perform", *argv); + printit("HOME", "The set $HOME env or '/'", getenv("HOME")); + printit("PATH", "the set $PATH env or '/bin:/usr/bin:/sbin:/usr/sbin'", + getenv("PATH")); + printit("interface", "The interface this was obtained on", + getenv("interface")); + printit("ip", "The obtained IP", getenv("ip")); + printit("mask", "The number of bits in the netmask (ie: 24)", + getenv("mask")); + printit("siaddr", "The bootp next server option", getenv("siaddr")); + printit("sname", "The bootp server name option", getenv("sname")); + printit("boot_file", "The bootp boot file option", getenv("boot_file")); + printit("subnet", "The assigend subnet mask", getenv("subnet")); + printit("timezone", "Offset in seconds from UTC", getenv("timezone")); + printit("router", "A list of routers", getenv("router")); + printit("timesvr", "A list of time servers", getenv("timesvr")); + printit("namesvr", "A list of IEN 116 name servers", getenv("namesvr")); + printit("dns", "A list of DNS server", getenv("dns")); + printit("logsvr", "A list of MIT-LCS UDP log servers", getenv("logsvr")); + printit("cookiesvr", "A list of RFC 865 cookie servers", + getenv("cookiesvr")); + printit("lprsvr", "A list of LPR servers", getenv("lprsvr")); + printit("hostname", "The assigned hostname", getenv("hostname")); + printit("bootsize", "The length in 512 octect blocks of the bootfile", + getenv("bootsize")); + printit("domain", "The domain name of the network", getenv("domain")); + printit("swapsvr", "The IP address of the client's swap server", + getenv("swapsvr")); + printit("rootpath", "The path name of the client's root disk", + getenv("rootpath")); + printit("ipttl", "The TTL to use for this network", getenv("ipttl")); + printit("mtu", "The MTU to use for this network", getenv("mtu")); + printit("broadcast", "The broadcast address for this network", + getenv("broadcast")); + printit("ntpsrv", "A list of NTP servers", getenv("ntpsrv")); + printit("wins", "A list of WINS servers", getenv("wins")); + printit("lease", "The lease time, in seconds", getenv("lease")); + printit("dhcptype", "DHCP message type (safely ignored)", + getenv("dhcptype")); + printit("serverid", "The IP of the server", getenv("serverid")); + printit("message", "Reason for a DHCPNAK", getenv("message")); + printit("tftp", "The TFTP server name", getenv("tftp")); + printit("bootfile", "The bootfile name", getenv("bootfile")); #endif - if (!*argv) - bb_printf("Error: should be called from udhcpc\n"); - else - { - char *interface = getenv("interface"); + if (!*argv) + bb_printf("Error: should be called from udhcpc\n"); + else { + char *interface = getenv("interface"); - if (strcmp(*argv, "deconfig") == 0) - { + read_sysconfig("/etc/sysconfig/network"); + if (strcmp(*argv, "deconfig") == 0) { #ifdef CONFIG_FEATURE_IFUPDOWN_IP - doit(QUIET, "ip route flush dev %s", interface); - doit(QUIET, "ip addr flush dev %s", interface); - doit(QUIET, "ip link set %s up", interface); + doit(QUIET, "ip route flush dev %s", interface); + doit(QUIET, "ip addr flush dev %s", interface); + doit(QUIET, "ip link set %s up", interface); #else - errno = 0; - while (errno == 0) - doit(QUIET, "route del default gw 0.0.0.0 dev %s", interface); - doit(QUIET, "ifconfig %s 0.0.0.0", interface); + errno = 0; + while (errno == 0) + doit(QUIET, "route del default gw 0.0.0.0 dev %s", interface); + doit(QUIET, "ifconfig %s 0.0.0.0", interface); #endif - } - else if (strcmp(*argv, "nak") == 0) - bb_printf("udhcpc received a NAK: %s\n", getenv("message")); - else if ((strcmp(*argv, "bound") == 0) || (strcmp(*argv, "renew") == 0)) - { - const char *RESOLV_CONF = "/etc/resolv.conf"; - char *broadcast = getenv("broadcast"); - char *subnet = getenv("subnet"); - char *mask = getenv("mask"); - char *ip = getenv("ip"); - char *hostname = getenv("hostname"); - char *domain = getenv("domain"); - char *router = getenv("router"); - char *dns = getenv("dns"); - char *siaddr = getenv("siaddr"); - char *tftp = getenv("tftp"); - char *BROADCAST = ""; - char *NETMASK = ""; - char *MASK = ""; - char *HOSTNAME = 0; - int i, metric = 0; - char *token; - char *strtok_temp; - - if (broadcast != 0) - bb_xasprintf(&BROADCAST, "broadcast %s", broadcast); - if (subnet != 0) - bb_xasprintf(&NETMASK, "netmask %s", subnet); - if (mask != 0) - bb_xasprintf(&MASK, "/%s", mask); - if (hostname != 0) - bb_xasprintf(&HOSTNAME, "/%s", hostname); + } else if (strcmp(*argv, "nak") == 0) + bb_printf("udhcpc received a NAK: %s\n", getenv("message")); + else if ((strcmp(*argv, "bound") == 0) + || (strcmp(*argv, "renew") == 0)) { + const char *RESOLV_CONF = "/etc/resolv.conf"; + char *broadcast = getenv("broadcast"); + char *subnet = getenv("subnet"); + char *mask = getenv("mask"); + char *ip = getenv("ip"); + char *hostname = getenv("hostname"); + char *domain = getenv("domain"); + char *router = getenv("router"); + char *dns = getenv("dns"); + char *siaddr = getenv("siaddr"); + char *tftp = getenv("tftp"); + char *BROADCAST = ""; + char *NETMASK = ""; + char *MASK = ""; + char *HOSTNAME = 0; + int i, metric = 0; + char *token; + char *strtok_temp; + + if (broadcast != 0) + bb_xasprintf(&BROADCAST, "broadcast %s", broadcast); + if (subnet != 0) + bb_xasprintf(&NETMASK, "netmask %s", subnet); + if (mask != 0) + bb_xasprintf(&MASK, "/%s", mask); + if (hostname != 0) + bb_xasprintf(&HOSTNAME, "/%s", hostname); #ifdef CONFIG_FEATURE_IFUPDOWN_IP - doit(0, "ip addr add %s%s %s dev %s", ip, MASK, BROADCAST, interface); - doit(0, "ip link set %s up", interface); + doit(0, "ip addr add %s%s %s dev %s", ip, MASK, BROADCAST, + interface); + doit(0, "ip link set %s up", interface); #else - doit(0, "/sbin/ifconfig %s %s %s %s", interface, ip, BROADCAST, NETMASK); + doit(0, "/sbin/ifconfig %s %s %s %s", interface, ip, BROADCAST, + NETMASK); #endif - if (router != 0) - { - token = strtok_r(router, " ,\t\r\n", &strtok_temp); - for (i = 0; token != NULL; i++) - { + if (router != 0) { + token = strtok_r(router, " ,\t\r\n", &strtok_temp); + for (i = 0; token != NULL; i++) { #ifdef CONFIG_FEATURE_IFUPDOWN_IP - doit(0, "ip route add to default via %s dev %s", token, interface, metric++); + doit(0, "ip route add to default via %s dev %s", token, + interface, metric++); #else - doit(0, "route add default gw %s dev %s metric %d", token, interface, metric++); + doit(0, "route add default gw %s dev %s metric %d", token, + interface, metric++); #endif - token = strtok_r(NULL, " ,\t\r\n", &strtok_temp); - } - } - - doit(0, "echo -n > %s", RESOLV_CONF); - if (domain != 0) - doit(0, "echo \"search %s\" > %s", domain, RESOLV_CONF); - - token = strtok_r(dns, " \r\n", &strtok_temp); - for (i = 0; token != NULL; i++) - { - doit(0, "echo \"nameserver %s\" >> %s", token, RESOLV_CONF); - - token = strtok_r(NULL, " \r\n", &strtok_temp); - } - - if (HOSTNAME == 0) - { - bb_xasprintf(&HOSTNAME, doit(REDIR, "nslookup %s | grep -v default | grep Name | cut -d\":\" -f2 | tr -d ' ' | tail -n 1", ip)); - if ((HOSTNAME == 0) && (stat("/var/lib/my_linux/config/hostname", &path_stat) == 0)) - HOSTNAME = quick_read("/var/lib/my_linux/config/hostname"); - if (HOSTNAME == 0) - HOSTNAME = "my_linux"; - } - doit(0, "hostname %s", HOSTNAME); + token = strtok_r(NULL, " ,\t\r\n", &strtok_temp); + } + } + + doit(0, "echo -n > %s", RESOLV_CONF); + if (domain != 0) + doit(0, "echo \"search %s\" > %s", domain, RESOLV_CONF); + + token = strtok_r(dns, " \r\n", &strtok_temp); + for (i = 0; token != NULL; i++) { + doit(0, "echo \"nameserver %s\" >> %s", token, RESOLV_CONF); + + token = strtok_r(NULL, " \r\n", &strtok_temp); + } + + if (HOSTNAME == 0) { + bb_xasprintf(&HOSTNAME, doit(REDIR, "nslookup %s | grep -v default | grep Name | cut -d\":\" -f2 | tr -d ' ' | tail -n 1", ip)); + if ((HOSTNAME == 0) && (getenv("HOSTNAME") != NULL)) + HOSTNAME = getenv("HOSTNAME"); + if (HOSTNAME == 0) + HOSTNAME = "my_linux"; + } + doit(0, "hostname %s", HOSTNAME); // Should remove old entry - doit(0, "echo \"%s %s\" >> /etc/hosts", ip, HOSTNAME); + doit(0, "echo \"%s %s\" >> /etc/hosts", ip, HOSTNAME); // Should dump these in a per interface file - if (siaddr != NULL) - quick_write("/var/lib/network/nfsaddr", siaddr); - if (tftp != NULL) - quick_write("/var/lib/network/tftpaddr", tftp); - - /* This is what the network init script is waiting for. */ - quick_write("/var/lib/network/ipaddr", ip); - bb_printf("IP %s HOSTNAME %s\n", ip, HOSTNAME); - - free(HOSTNAME); - } - else - { - bb_printf("Huh?\n"); + if (siaddr != NULL) + quick_write("/var/lib/network/nfsaddr", siaddr); + if (tftp != NULL) + quick_write("/var/lib/network/tftpaddr", tftp); + + /* This is what the network init script is waiting for. */ + quick_write("/var/lib/network/ipaddr", ip); + bb_printf("IP %s HOSTNAME %s\n", ip, HOSTNAME); + + free(HOSTNAME); + } else { + bb_printf("Huh?\n"); + } } - } - return EXIT_SUCCESS; + return EXIT_SUCCESS; } 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 @@ +#! /bin/sh + +pushd .. +indent runlevel/*.c runlevel/*.h my_linux/*.c my_linux/*.h +rm -f runlevel/*.c~ runlevel/*.h~ my_linux/*.c~ my_linux/*.h~ +popd 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 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public 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 @@ + + +

+This is a temporary holding area for TODO items that are now DONE. +Since I tend to write a large amount of descriptive text for TODO items, it is +useful to use that as the starting point for documenting them once they are +DONE. However, until I pull my finger out, the relevant text will just be cut +and pasted into here. Note that some items that have not been DONE may get +dragged into here, they will get dragged back when I pull my finger out. Also +note that the DONE item may differ from the TODO item, but the documentation here +will reflect the TODO item. +

+ 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 @@ + + +

+The following is some developer notes on what needs to be done to the entire +system. Note that I may have done some of these already, and forgotten to update +the document.

+ + 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 @@ + + +

+Since this is a collection af busybox applets, the Busybox style guide will be +followed.

+ +Personally, I don't like the style chosen by the busybox authors, but I'm +flexible enough to write in any style. There is a runlevel/ugly_stick +script that will convert all runlevel and my_linux source code to busybox +style, via the busybox supplied .indent.pro file. When we say "hit it +with the ugly stick" we mean "use the runlevel/ugly_stick script". +

+ 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 @@ + + +

+

+ 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 @@ + + +

+"Technique?" said the programmer turning from his terminal, "What I follow +is Tao -- beyond all technique! When I first began to program I would see +before me the whole problem in one mass. After three years I no longer saw +this mass. Instead, I used subroutines. But now I see nothing. My whole +being exists in a formless void. My senses are idle. My spirit, free to +work without plan, follows its own instinct. In short, my program writes +itself. True, sometimes there are difficult problems. I see them coming, I +slow down, I watch silently. Then I change a single line of code and the +difficulties vanish like puffs of idle smoke. I then compile the program. +I sit still and let the joy of the work fill my being. I close my eyes for +a moment and then log off."

+(From the fortune program.) +

+ 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 @@ + + + + matrix-RAD - <!--#echo var="title" --> + + +

+ The people   + Coding standards   + Design   + TODO   + DONE   +

+

+ API   +

+
+

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 @@ + + +

+onefang wrote most of the code and documentation. He is +the code nazi. I, me, my, etc usually refers to him.

+ +AKA onefang, dvs1, the DVS one, Digital Polyglot, and David Seikel (but only if you have to). +

+ 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 @@ + + +

+These are the immeadiate plans, more or less in order. +

+
+

More documentation.

+

+The first import of the code into CVS included the typical amount of +documentation included with early versions of open source projects. This +will be corrected soon. +

+ 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 @@ +#!/bin/sh + +crontab -r +crontab ~/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 @@ +#!/bin/sh + +# crontab -e +# 42 * * * * ~/fetch-html.sh + +/usr/bin/wget -q -O ~/project.tmp http://sourceforge.net/export/projhtml.php?group_id=133645&mode=full&no_table=1 >/dev/null +/bin/mv ~/project.tmp ~/project.inc + +/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 +/bin/mv ~/news.tmp ~/news.inc + 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 @@ +

+ SourceForge.net Logo
+ Sourceforge project site. +

+
+ +

This file was last modified on

+
+ + 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 @@ +
+

+ SourceForge.net Logo +

+
+ +

This file was last modified on

+
+ + 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 @@ + + 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 @@ +

Micro runlevel

+

Zen programming is not a spectator sport.

+

+Clean room implementation of runlevel/init.d/SYS V init applets for +busybox, aiming for LSB compliance.

+ +Busybox currently has no support for runlevels +and init.d scripts, also known as the SYS V init system. My software +adds that support as standard busybox applets written in the C langauge.

+ +I am aiming for LSB compliance, so Linux is +the supported platform, but I have no objections to making sure it works +on other busybox supported platforms. This was in fact written to the +LSB specs, with no reference to the source code of similar systems. Any +LSB compliant init.d script will be compatible with this. All the +support programs and functions mentioned in the LSB spec are provided as +part of this system. Other support programs and functions that I have +found useful will be provided. Example init.d "scripts", written in C, +are also included, especially all the system scripts that LSB requires +distros to provide.

+ +I am writing this as part of a Linux distro that I am building. One of +the design criterea for this distro is to boot as fast as possible. +Typicall Linux boots involve a lot of shell scripts, which are typically +a lot slower than C. Most of these shell scripts are part of the SYS V +init process. By writing this in C, writing init scripts themselves in +C, and writing as much support stuff in C as possible, I am able to make +a major improvement in boot speed.

+ +Features - +

    +
  • Small, like all busybox applets.
  • +
  • Fast, the main reason for writing it.
  • +
  • Intelligent, LSB requires an init system to determine dependencies and +run the init scripts in the correct order.
  • +
+Busybox does not include named and portmap applets, so boot_named.c and +boot_portmap.c should be considered as examples. Skeleton is also an +example. +

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 @@ + + + + Micro runlevel + + + + + 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/1x1space.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/bug.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/cvs16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/docman16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1-smile_mini.gif 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 @@ +X-Face: 17(@/;MHtUp:15TJeNpoHYY\;dv"PCEs%.Yi6m8DA$.(x)PQO&lQbJ(wJ\DQx}prw4L + Cb7=oS}uC:&7>fVw-z!x1fdWS8@^nmcZ 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_XFace.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/dvs1_mini.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/ftp16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/mail16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix-RAD.jpg 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/matrix.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/mock_dave_icon.trans.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/notes16.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/taskman16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/title.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/trans.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/undercon.gif 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/images/wait.gif 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 @@ + + + + Micro runlevel + + + + + + + <!--#include virtual="header.inc" --> + <!--#include virtual="home.inc" --> + <!--#include virtual="footer.shtml" --> + + 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 @@ + + + + Micro runlevel - <!--#echo var="title" --> + + +

+

Clean room LSB init.d applets for busybox.

+

+

+

+

+ Navigation links +

+
+

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 @@ +

Micro runlevel

+

Clean room LSB init.d applets for busybox.

+ + What is Micro runlevel?
+ What's new?
+ What's coming?
+ Open Source license.
+ Documentation for coders.
+ Documentation for testers.

+ Downloads + LSB init.d applets + Support applets + Example applets + My LInux applets +
\ 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 @@ + + + + Micro runlevel + + + + + + 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 @@ +

No News Items Found

\ 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 @@ + + +

+See the coders DONE document for some very recent news. +

+ + 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 @@ +Tracker Tracker

+  - Bugs + ( 0 open / 0 total )
Bug Tracking System

+  - Support Requests + ( 0 open / 0 total )
Tech Support Tracking System

+  - Patches + ( 0 open / 0 total )
Patch Tracking System

+  - Feature Requests + ( 0 open / 0 total )
Feature Request Tracking System + +


Forums Forums ( 0 messages in 0 forums ) + + +
Docs Doc Manager + +
Mail Lists Mailing Lists ( 0 mailing lists ) + +
Screenshots Screenshots + +
Tasks Task Manager
There are no public subprojects available + +
CVS CVS Tree ( commits, adds ) known bug + +
FTP Released Files \ 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/bug.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/cvs16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/docman16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/ftp16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/mail16b.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/notes16.png 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 Binary files /dev/null and b/urunlevel/runlevel/urunlevel.sourceforge.net/projhtml.php_files/taskman16b.png 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 @@ + + +

+

+ 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 @@ + + +

+ A novice asked the Master: "Here is a programmer that never designs, +documents, or tests his programs. Yet all who know him consider him one of +the best programmers in the world. Why is this?" + The Master replies: "That programmer has mastered the Tao. He has +gone beyond the need for design; he does not become angry when the system +crashes, but accepts the universe without concern. He has gone beyond the +need for documentation; he no longer cares if anyone else sees his code. He +has gone beyond the need for testing; each of his programs are perfect within +themselves, serene and elegant, their purpose self-evident. Truly, he has +entered the mystery of the Tao."
+ -- Geoffrey James, "The Tao of Programming"

+ +I went on to test the program in every way I could devise. I strained it to +expose its weaknesses. I ran it for high-mass stars and low-mass stars, for +stars born exceedingly hot and those born relatively cold. I ran it assuming +the superfluid currents beneath the crust to be absent -- not because I wanted +to know the answer, but because I had developed an intuitive feel for the +answer in this particular case. Finally I got a run in which the computer +showed the pulsar's temperature to be less than absolute zero. I had found +an error. I chased down the error and fixed it. Now I had improved the +program to the point where it would not run at all.
+ -- George Greenstein, "Frozen Star:
+ Of Pulsars, Black Holes and the Fate of Stars"

+

+ 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 @@ + + + + Micro runlevel - <!--#echo var="title" --> + + +
+

+

+ The people   + The method   + TODO   +

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 @@ + + +

+To be written, for now just go nuts on it and report bugs in the urunlevel-development +mailing list. +

+ 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 @@ + + +

+The only tester at the moment is me (onefang), and programmers are not the best +choice for properly testing their own work. So, we are desperately in need +of real testers. This is where ordinary computer users can contribute to +Micro runlevel. +

+ -- cgit v1.1