From 906caeb7ae90070e4c300161fbd4f14e8a492a6e Mon Sep 17 00:00:00 2001 From: silvan Date: Tue, 26 Apr 2011 12:26:24 +0200 Subject: [PATCH] First git commit --- COPYING | 340 +++++++++ ChangeLog | 756 ++++++++++++++++++++ Makefile | 100 +++ VERSION | 1 + etc/inittab | 51 ++ etc/modprobe.d/ipv6.conf | 2 + etc/modprobe.d/lp.conf | 1 + etc/modprobe.d/nouveau.conf | 1 + etc/modprobe.d/rt28xx.conf | 2 + etc/rc.d/init.d/checkfs | 90 +++ etc/rc.d/init.d/cleanfs | 52 ++ etc/rc.d/init.d/functions | 620 ++++++++++++++++ etc/rc.d/init.d/halt | 21 + etc/rc.d/init.d/loadmodules | 30 + etc/rc.d/init.d/localnet | 42 ++ etc/rc.d/init.d/mountfs | 67 ++ etc/rc.d/init.d/mountproc | 33 + etc/rc.d/init.d/network | 89 +++ etc/rc.d/init.d/network-functions | 159 ++++ etc/rc.d/init.d/random | 49 ++ etc/rc.d/init.d/rc | 143 ++++ etc/rc.d/init.d/rc.local | 6 + etc/rc.d/init.d/rc.sysinit | 104 +++ etc/rc.d/init.d/reboot | 23 + etc/rc.d/init.d/sendsignals | 35 + etc/rc.d/init.d/setclock | 44 ++ etc/rc.d/init.d/swap | 34 + etc/rc.d/init.d/sysctl | 14 + etc/rc.d/init.d/sysinit | 89 +++ etc/rc.d/init.d/template | 50 ++ etc/rc.d/rc0.d/K02setclock | 1 + etc/rc.d/rc0.d/K90random | 1 + etc/rc.d/rc0.d/K94sendsignals | 1 + etc/rc.d/rc0.d/K95mountfs | 1 + etc/rc.d/rc0.d/K96swap | 1 + etc/rc.d/rc0.d/K98localnet | 1 + etc/rc.d/rc0.d/K99halt | 1 + etc/rc.d/rc1.d/S13sysinit | 1 + etc/rc.d/rc2.d/S12random | 1 + etc/rc.d/rc2.d/S13sysinit | 1 + etc/rc.d/rc2.d/S99rc.local | 1 + etc/rc.d/rc3.d/S12random | 1 + etc/rc.d/rc3.d/S13sysinit | 1 + etc/rc.d/rc3.d/S99rc.local | 1 + etc/rc.d/rc4.d/S13sysinit | 1 + etc/rc.d/rc4.d/S99rc.local | 1 + etc/rc.d/rc5.d/S12random | 1 + etc/rc.d/rc5.d/S13sysinit | 1 + etc/rc.d/rc5.d/S99rc.local | 1 + etc/rc.d/rc6.d/K02setclock | 1 + etc/rc.d/rc6.d/K90random | 1 + etc/rc.d/rc6.d/K94sendsignals | 1 + etc/rc.d/rc6.d/K95mountfs | 1 + etc/rc.d/rc6.d/K96swap | 1 + etc/rc.d/rc6.d/K97network | 1 + etc/rc.d/rc6.d/K98localnet | 1 + etc/rc.d/rc6.d/K99reboot | 1 + etc/rc.d/rcsysinit.d/S10mountproc | 1 + etc/rc.d/rcsysinit.d/S20localnet | 1 + etc/rc.d/rcsysinit.d/S22sysctl | 1 + etc/rc.d/rcsysinit.d/S30loadmodules | 1 + etc/rc.d/rcsysinit.d/S45setclock | 1 + etc/rc.d/rcsysinit.d/S50checkfs | 1 + etc/rc.d/rcsysinit.d/S55mountfs | 1 + etc/rc.d/rcsysinit.d/S60cleanfs | 1 + etc/rc.d/rcsysinit.d/S75swap | 1 + etc/sysconfig/clock | 4 + etc/sysconfig/i18n | 0 etc/sysconfig/keyboard | 0 etc/sysconfig/network | 5 + etc/sysconfig/network-devices/ifdown | 1 + etc/sysconfig/network-devices/ifup | 1 + etc/sysconfig/network-devices/ifup-routes | 15 + etc/sysconfig/network-devices/ifup-wireless | 146 ++++ etc/sysconfig/proxy | 11 + etc/sysconfig/rc | 15 + etc/sysconfig/static-routes | 7 + etc/sysctl.conf | 39 + po/es.po | 48 ++ po/es.po~ | 30 + po/fr.po | 26 + po/it.po | 46 ++ sbin/depinit | 70 ++ sbin/ifdown | 29 + sbin/ifrestart | 11 + sbin/ifup | 77 ++ sbin/service | 43 ++ src/Makefile | 78 ++ src/Makefile.orig | 77 ++ src/consoletype.1 | 39 + src/consoletype.c | 66 ++ src/doexec.1 | 12 + src/doexec.c | 19 + src/fstab-decode.8 | 45 ++ src/fstab-decode.c | 86 +++ src/genhostid.1 | 12 + src/genhostid.c | 32 + src/getkey.1 | 80 +++ src/getkey.c | 135 ++++ src/initlog.1 | 87 +++ src/initlog.c | 446 ++++++++++++ src/initlog.c.orig | 446 ++++++++++++ src/initlog.conf | 23 + src/initlog.h | 20 + src/ipcalc.1 | 58 ++ src/ipcalc.c | 361 ++++++++++ src/minilogd.c | 187 +++++ src/netreport.1 | 22 + src/netreport.c | 66 ++ src/process.c | 324 +++++++++ src/process.h | 9 + src/usernetctl.8 | 39 + src/usernetctl.c | 238 ++++++ src/usleep.1 | 25 + src/usleep.c | 76 ++ var/init/deps.start.mk | 75 ++ var/init/deps.stop.mk | 54 ++ var/init/runlevel.mk | 195 +++++ 118 files changed, 7140 insertions(+) create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 Makefile create mode 100644 VERSION create mode 100644 etc/inittab create mode 100644 etc/modprobe.d/ipv6.conf create mode 100644 etc/modprobe.d/lp.conf create mode 100644 etc/modprobe.d/nouveau.conf create mode 100644 etc/modprobe.d/rt28xx.conf create mode 100755 etc/rc.d/init.d/checkfs create mode 100755 etc/rc.d/init.d/cleanfs create mode 100755 etc/rc.d/init.d/functions create mode 100755 etc/rc.d/init.d/halt create mode 100755 etc/rc.d/init.d/loadmodules create mode 100755 etc/rc.d/init.d/localnet create mode 100755 etc/rc.d/init.d/mountfs create mode 100755 etc/rc.d/init.d/mountproc create mode 100755 etc/rc.d/init.d/network create mode 100755 etc/rc.d/init.d/network-functions create mode 100755 etc/rc.d/init.d/random create mode 100755 etc/rc.d/init.d/rc create mode 100755 etc/rc.d/init.d/rc.local create mode 100755 etc/rc.d/init.d/rc.sysinit create mode 100755 etc/rc.d/init.d/reboot create mode 100755 etc/rc.d/init.d/sendsignals create mode 100755 etc/rc.d/init.d/setclock create mode 100755 etc/rc.d/init.d/swap create mode 100755 etc/rc.d/init.d/sysctl create mode 100755 etc/rc.d/init.d/sysinit create mode 100755 etc/rc.d/init.d/template create mode 120000 etc/rc.d/rc0.d/K02setclock create mode 120000 etc/rc.d/rc0.d/K90random create mode 120000 etc/rc.d/rc0.d/K94sendsignals create mode 120000 etc/rc.d/rc0.d/K95mountfs create mode 120000 etc/rc.d/rc0.d/K96swap create mode 120000 etc/rc.d/rc0.d/K98localnet create mode 120000 etc/rc.d/rc0.d/K99halt create mode 120000 etc/rc.d/rc1.d/S13sysinit create mode 120000 etc/rc.d/rc2.d/S12random create mode 120000 etc/rc.d/rc2.d/S13sysinit create mode 120000 etc/rc.d/rc2.d/S99rc.local create mode 120000 etc/rc.d/rc3.d/S12random create mode 120000 etc/rc.d/rc3.d/S13sysinit create mode 120000 etc/rc.d/rc3.d/S99rc.local create mode 120000 etc/rc.d/rc4.d/S13sysinit create mode 120000 etc/rc.d/rc4.d/S99rc.local create mode 120000 etc/rc.d/rc5.d/S12random create mode 120000 etc/rc.d/rc5.d/S13sysinit create mode 120000 etc/rc.d/rc5.d/S99rc.local create mode 120000 etc/rc.d/rc6.d/K02setclock create mode 120000 etc/rc.d/rc6.d/K90random create mode 120000 etc/rc.d/rc6.d/K94sendsignals create mode 120000 etc/rc.d/rc6.d/K95mountfs create mode 120000 etc/rc.d/rc6.d/K96swap create mode 120000 etc/rc.d/rc6.d/K97network create mode 120000 etc/rc.d/rc6.d/K98localnet create mode 120000 etc/rc.d/rc6.d/K99reboot create mode 120000 etc/rc.d/rcsysinit.d/S10mountproc create mode 120000 etc/rc.d/rcsysinit.d/S20localnet create mode 120000 etc/rc.d/rcsysinit.d/S22sysctl create mode 120000 etc/rc.d/rcsysinit.d/S30loadmodules create mode 120000 etc/rc.d/rcsysinit.d/S45setclock create mode 120000 etc/rc.d/rcsysinit.d/S50checkfs create mode 120000 etc/rc.d/rcsysinit.d/S55mountfs create mode 120000 etc/rc.d/rcsysinit.d/S60cleanfs create mode 120000 etc/rc.d/rcsysinit.d/S75swap create mode 100644 etc/sysconfig/clock create mode 100644 etc/sysconfig/i18n create mode 100644 etc/sysconfig/keyboard create mode 100644 etc/sysconfig/network create mode 120000 etc/sysconfig/network-devices/ifdown create mode 120000 etc/sysconfig/network-devices/ifup create mode 100644 etc/sysconfig/network-devices/ifup-routes create mode 100644 etc/sysconfig/network-devices/ifup-wireless create mode 100644 etc/sysconfig/proxy create mode 100644 etc/sysconfig/rc create mode 100644 etc/sysconfig/static-routes create mode 100644 etc/sysctl.conf create mode 100644 po/es.po create mode 100644 po/es.po~ create mode 100644 po/fr.po create mode 100644 po/it.po create mode 100644 sbin/depinit create mode 100644 sbin/ifdown create mode 100644 sbin/ifrestart create mode 100644 sbin/ifup create mode 100644 sbin/service create mode 100644 src/Makefile create mode 100644 src/Makefile.orig create mode 100644 src/consoletype.1 create mode 100644 src/consoletype.c create mode 100644 src/doexec.1 create mode 100644 src/doexec.c create mode 100644 src/fstab-decode.8 create mode 100644 src/fstab-decode.c create mode 100644 src/genhostid.1 create mode 100644 src/genhostid.c create mode 100644 src/getkey.1 create mode 100644 src/getkey.c create mode 100644 src/initlog.1 create mode 100644 src/initlog.c create mode 100644 src/initlog.c.orig create mode 100644 src/initlog.conf create mode 100644 src/initlog.h create mode 100644 src/ipcalc.1 create mode 100644 src/ipcalc.c create mode 100644 src/minilogd.c create mode 100644 src/netreport.1 create mode 100644 src/netreport.c create mode 100644 src/process.c create mode 100644 src/process.h create mode 100644 src/usernetctl.8 create mode 100644 src/usernetctl.c create mode 100644 src/usleep.1 create mode 100644 src/usleep.c create mode 100644 var/init/deps.start.mk create mode 100644 var/init/deps.stop.mk create mode 100644 var/init/runlevel.mk diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..b6f92f3 --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/ChangeLog b/ChangeLog new file mode 100644 index 0000000..14de9e9 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,756 @@ +Changes in version 1.5.0 20110406 +- Integrate patches by Dabive Madrisan for dash compatibility and cleanups: + * dash compatibility (functions,rc): sourced script with arguments + * dash compatibility (functions,rc): avoid non POSIX command "echo -e" + * halt, random, rc, and reboot: reworked + * dash compatibility (functions): fix kill invocations + * dash compatibility (rc): fix export command + * dash compatibility (network-functions): it's only used by guarddog-firsttime + * functions: syntax fixes for dash compatibility + * use /bin/sh instead of /bin/bash + * functions, network-functions: remove bashisms +- loadmodules: + * check if /proc/ide/hd[a-z] exits to remove a warning +-------------------------------------------------------------------------------- + +Changes in version 1.4.50 20110314 +- Integrate patches by Davide Madrisan: + * rc: do not use vector variables; rework and simplify code +- rc.sysinit: + * create /lib/modules/$KERNELVER if missing +- deps.start.mk: + * add NetworkManager and udev-post deps for messagebus and syslog +-------------------------------------------------------------------------------- + +Changes in version 1.4.49 20110210 +- rc.sysinit: + * early mount /proc to get cmdline if needed +-------------------------------------------------------------------------------- + +Changes in version 1.4.48 20110201 +- rc.sysinit, rc: + * remove use of obsolete /initrd; use /dev as temporary dir +- Integrate patches by Davide Madrisan: + * sysinit: fix execution of ldconfig; support 64bit architectures + * make sysinit dash compatible + * sysinit: remove unused variable KERNELMIN + * fix my mail address in several files +-------------------------------------------------------------------------------- + +Changes in version 1.4.47 20101219 +- runlevel.mk: + * move call to splash_comm_progress in block including functions file to avoid a missing function error +-------------------------------------------------------------------------------- + +Changes in version 1.4.46 20101116 +- modprobe.d: blacklist nouveau driver until it works (kernel >=2.6.35) +-------------------------------------------------------------------------------- + +Changes in version 1.4.45 20101112 +- rt28xx: blacklist rt2800pci and rt2800usb in favour of staging driver rt2860sta and rt2870sta +- functions: fix plymouthd path +-------------------------------------------------------------------------------- + +Changes in version 1.4.44 20101106 +- sysinit: run depmod -a insted of depmod -A to ensure that module deps are really updated +-------------------------------------------------------------------------------- + +Changes in version 1.4.43 20101102 +- added check for plymouth presence and don't use it if missing from system +-------------------------------------------------------------------------------- + +Changes in version 1.4.42 20100906 +- updated scripts to use plymouth instead of fbsplash +-------------------------------------------------------------------------------- + +Changes in version 1.4.41 20100625 +- mountfs: perform a safer umount by skipping umount of network and virtual filesystems +-------------------------------------------------------------------------------- + +Changes in version 1.4.40 20100622 +- modules.d: create pluggable directory for modules loading on boot; removed /etc/modules +-------------------------------------------------------------------------------- + +Changes in version 1.4.39 20100604 +- sysinit: fixed error in a check for /boot symlinks creation +- spanish translation updated +-------------------------------------------------------------------------------- + +Changes in version 1.4.38 20100528 +- checkfs: continue boot in case of operational, syntax, e2fsck error +-------------------------------------------------------------------------------- + +Changes in version 1.4.37 20100526 +- checkfs: + * continue booting in case of unfixable errors + * added splash messages +- rc: added splash message +- rc.sysinit: fix /initrd umount and log final copy from temporary folder +-------------------------------------------------------------------------------- + +Changes in version 1.4.36 20100521 +- sysinit: added support for no_auto_depmod and no_auto_ldconfig variables set in sysconfig/rc +- sysinit: don't display boot message if /boot kernel link are not created +-------------------------------------------------------------------------------- + +Changes in version 1.4.35 20100512 +- modprobe.d/ipv6.conf: added configuration to disable IPv6 by default +-------------------------------------------------------------------------------- + +Changes in version 1.4.34 20100401 +- rc: add support for multithread kernel option to set multithreaded init +-------------------------------------------------------------------------------- + +Changes in version 1.4.33 20100323 +- Makefile: add install-files target to allow initscripts installation without (obsolete?) tools +-------------------------------------------------------------------------------- + +Changes in version 1.4.32 20100312 +- checkfs: reboot without requesting to press enter when e2fsck fixed the problems but requires reboot +-------------------------------------------------------------------------------- + +Changes in version 1.4.31 20100304 +- minor fixes in spanish translations +-------------------------------------------------------------------------------- + +Changes in version 1.4.30 20100208 +- cleanfs: remove cached rpm in /var/cache/apt/archives and /var/cache/apt/archives/partial +-------------------------------------------------------------------------------- + +Changes in version 1.4.29 20100102 +- runlevel.mk: don't use service to launch scripts to preserve environment +- deps.stop: fine tune; start swap before sendsignals +-------------------------------------------------------------------------------- + +Changes in version 1.4.28 20091103 +- spanish transpation updated +-------------------------------------------------------------------------------- + +Changes in version 1.4.27 20091022 +- deps.start: start wicd after haldaemon +- rc: remove multithreaded make warnings about circular dependencies +-------------------------------------------------------------------------------- + +Changes in version 1.4.26 20091010 +- rc.sysinit: + * fix failure message writing failed script name + * unmount /initrd if not in debug mode +-------------------------------------------------------------------------------- + +Changes in version 1.4.25 20090905 +- loadmodules: support /etc/modprobe.d directory and don't complain about missing modprobe.conf +- Makefile: create dir /etc/modules.d +- loadmodules: require .conf extension in /etc/modules.d/ +-------------------------------------------------------------------------------- + +Changes in version 1.4.24 20090725 +- port of patches applied to 1.4.20.1 from Davide Madrisan: + * /sbin/service: use a safe environment when executing a service initscript + * allow setting ethernet paramethers via the "ETHTOOL_OPTS" variable + * split /sbin/ifup into more files: + /sbin/ifup + /etc/sysconfig/network-devices/ifup-wireless + /etc/sysconfig/network-devices/ifup-routes + * ifup-routes: ignore comments and empty lines found in /etc/sysconfig/static-routes + * update email addresses + * /sbin/ifup: if "BROADCAST" is unset do calculate its value using /bin/ipcalc +- rename /etc/modprobe.conf.d/lp to /etc/modprobe.d/lp.conf +-------------------------------------------------------------------------------- + +Changes in version 1.4.23 20090724 +- mountfs: + * remove data=* from /etc/mtab to fix problems with kernel 2.6.30 upgrade + * use -f umount options to force umount with stale nfs mounts +-------------------------------------------------------------------------------- + +Changes in version 1.4.22 20090723 +- deps.start.mk: samba: added dependency on cups +-------------------------------------------------------------------------------- + +Changes in version 1.4.21 20090623 +- runlevel.mk: added mambawelcome +- updated copyright messages +-------------------------------------------------------------------------------- + +Changes in version 1.4.20.1 20090528 +- cleanfs: remove an error in previous fix +-------------------------------------------------------------------------------- + +Changes in version 1.4.20 20090526 +- cleanfs: remove .ICEauthority files in home directories +-------------------------------------------------------------------------------- + +Changes in version 1.4.19 20090515 +- deps.start.mk: added consolekit +- runlevel.mk: removed ivman; added consolekit to local services (runlevel 4 and 5) +-------------------------------------------------------------------------------- + +Changes in version 1.4.18 20090405 +- ifup: update to fix various wlan issues +- ifdown: release dhcp address before deleting dhcp client +- network: add chkconfig data to initscript +- rc*.d: removed network service start/stop symlinks +- deps.start.mk: updated some dependencies +-------------------------------------------------------------------------------- + +Changes in version 1.4.17 20090325 +- ifup: add a delay between ifup and iwlist scan +-------------------------------------------------------------------------------- + +Changes in version 1.4.16 20090306 +- ifup: set wireless options with interface down +- ifup: fix iwlist scan check with "Unknown:" lines +-------------------------------------------------------------------------------- + +Changes in version 1.4.15 20090208 +- ifdown: force removal of wpa_supplicant run file +- cleanfs: remove also sockets on startup lock files cleanup +-------------------------------------------------------------------------------- + +Changes in version 1.4.14 20090207 +- ifup: add check for interface existence; exit if not +-------------------------------------------------------------------------------- + +Changes in version 1.4.13 20090206 +- ifup/ifdown: use /var/run/wpa_supplicant directory to determine if wpa_supplicant is running +- ifdown: use wpa_cli to terminate a running instance of wpa_supplicat for compatibility with + wl_assistant and other tools +-------------------------------------------------------------------------------- + +Changes in version 1.4.12 20090127 +- ifup: fix support for non ASCII WPA keys +-------------------------------------------------------------------------------- + +Changes in version 1.4.11 20090127 +- ifup: add code for WPA wireless automatic configuration using wpa_supplicant +-------------------------------------------------------------------------------- + +Changes in version 1.4.10 20090117 +- ifup: add code for wireless automatic configuration using iwlist scan +- ifup: new configuration variables WIRELESS_FREQUENCY and WIRELESS_CHANNEL +-------------------------------------------------------------------------------- + +Changes in version 1.4.9 20090112 +- rc.sysinit: don't move temporary logfile in debug mode because it is set to /dev/console +-------------------------------------------------------------------------------- + +Changes in version 1.4.8 20081229 +- ifup: set WIRELESS_ENCMODE to "open" by default if variable is empty +-------------------------------------------------------------------------------- + +Changes in version 1.4.7 20081229 +- deps.start.mk: start cpufreqd after macbook-tools +-------------------------------------------------------------------------------- + +Changes in version 1.4.6 +- random: added patch to initscript from Davide Madrisan +-------------------------------------------------------------------------------- + +Changes in version 1.4.5 +- ifup: pass 'mode managed' to iwconfig by default +-------------------------------------------------------------------------------- + +Changes in version 1.4.4 +- ifup: don't set options to auto if not defined in ifconfig config file +-------------------------------------------------------------------------------- + +Changes in version 1.4.3 +- ifup: add workaround to set iwlwifi 4965 on Sony Vaio up +-------------------------------------------------------------------------------- + +Changes in version 1.4.2 +- depinit: add support for "single" kernel option by adding file + /var/init/S.start.rcl and /var/init/S.stop.rcl with the same + content of /var/init/1.start.rcl and /var/init/1.stop.rcl +-------------------------------------------------------------------------------- + +Changes in version 1.4.1 +- ifup, ifdown: updated with support for udev and other fixes +- ifup: added preliminary and optional support for wpa_supplicant +- network: initscript minor fixes +-------------------------------------------------------------------------------- + +Changes in version 1.4.0 +- added support to splashutils 1.5 + * rc, rc.sysinit, functions scripts modified to comply with new system + * dropped support for previous splash versions + * quit splash daemon after boot +- deps.stop.mk: added stop dependency on splash to make it run first +-------------------------------------------------------------------------------- + +Changes in version 1.3.52 +- functions: fix splash fifo patch (use /dev instead of /lib/splash/cache) +-------------------------------------------------------------------------------- + +Changes in version 1.3.51 +- functions: updated for the recent splashutils but support is not complete yet +-------------------------------------------------------------------------------- + +Changes in version 1.3.50 +- runlevel.mk: fix single mode startup by using RUNLEVEL exported variable if + defined +- rc: globally export RUNLEVEL variable +- deps.stop.mk: remove circular dependency between network and mountfs by + excluding sendsignals dependency from network and localnet +-------------------------------------------------------------------------------- + +Changes in version 1.3.49 +- sendsignals: readded wait states after killall -15 and killall -9 +-------------------------------------------------------------------------------- + +Changes in version 1.3.48 +- deps.start.mk: added dependency for cpufreqd +- deps.stop.mk: stop network after umount to have nfs shares unmounted cleanly +-------------------------------------------------------------------------------- + +Changes in version 1.3.47 +- added /etc/modprobe.conf.d/lp that loads lp module after parport_pc +-------------------------------------------------------------------------------- + +Changes in version 1.3.46 +- deps.start.mk: bluetooth: add dependency to messagebus +-------------------------------------------------------------------------------- + +Changes in version 1.3.45 +- deps.start.mk: add requirements for some services; sort by name +-------------------------------------------------------------------------------- + +Changes in version 1.3.44 +- rc: minor modifications for progress bar +- runlevel.mk: modifications for better handling of progressbar +- deps.stop.mk: cleanups and fixes +- sendsignals: don't unload modules +-------------------------------------------------------------------------------- + +Changes in version 1.3.43 +- ifup: pass ESSID to iwconfig if defined +-------------------------------------------------------------------------------- + +Changes in version 1.3.42 +- sysinit: fixed code logic to run ldconfig only when really needed +-------------------------------------------------------------------------------- + +Changes in version 1.3.41 +- sendsignals: remove sleep commands; drop kernel 2.4 support +-------------------------------------------------------------------------------- + +Changes in version 1.3.40 +- functions: fix a bug in killproc when killing a process by name +-------------------------------------------------------------------------------- + +Changes in version 1.3.39 +- inittab: replace vc/* with tty* +-------------------------------------------------------------------------------- + +Changes in version 1.3.38 +- sysinit: fix creation of /boot and /usr/src/linux symlinks +- some scripts minor cleanups +- rc.sysinit/swap: start later (after postplug) +- mountproc: set /sbin/modprobe in /proc/sys/kernel/modprobe +-------------------------------------------------------------------------------- + +Changes in version 1.3.37 +- sysinit: support the include directive in /etc/ld.so.conf +-------------------------------------------------------------------------------- + +Changes in version 1.3.36 +- functions: fixed sintax errors in echo_warning() +-------------------------------------------------------------------------------- + +Changes in version 1.3.35 +- runlevel.mk: use RUNLEVEL and PREVLEVEL from init environment +- rc: remove support for old splash +- rc: fix splash handling for reboot/shutdown +-------------------------------------------------------------------------------- + +Changes in version 1.3.34 +- functions: new functions `__pids_var_run' and `__pids_pidof' +- functions: fixed statusproc +- functions: removed gprintf crap (now it's a alias for printf) +- updated initscript template +- random initscript: exit with error if /dev/urandom does not exist +- functions: `print_status' is now obsolete and should not be used +- network initscript: execute ifconfig and iwconfig over detected wireless + interfaces when network `status' is asked by user +- service: do not force a limited environment +-------------------------------------------------------------------------------- + +Changes in version 1.3.33 +- C tools (src directory) updated to release 8.51 +- Makefile reworked +- service: added support for `--help' and `--version' queries +- service: exit with error code 1 in case of unrecognized services +- service: print all error messages to stderr +- mkkerneldot tool removed +- sysconfig proxy file: added an example with proxy requiring authentication +- added more comments to sysctl.conf +- removed /etc/modules.d directory +- modified initscript template +-------------------------------------------------------------------------------- + +Changes in version 1.3.32 +- runlevel.mk: don't generate an error if splash_progress returns 1 +-------------------------------------------------------------------------------- + +Changes in version 1.3.31 +- functions: + splash_comm_send: check for splash_utils running before writing to fifo +- rc.sysinit: if rc.sysinit.embedded is present, execute it and exit +- rc: if rc.embedded is present, execute it and exit +-------------------------------------------------------------------------------- + +Changes in version 1.3.30 +- sysinit: add support for root devices specified without /dev/ +-------------------------------------------------------------------------------- + +Changes in version 1.3.29 +- runlevel.mk: fix progress bar monotony on boot, halt and reboot +-------------------------------------------------------------------------------- + +Changes in version 1.3.28 +- network: rename network interfaces on start if ifrename exists +-------------------------------------------------------------------------------- + +Changes in version 1.3.27 +- rc: other changes for better spalsh behavior +-------------------------------------------------------------------------------- + +Changes in version 1.3.26 +- rc: don't exit splash daemon at the end +- runlevel.mk: oops, move local target back to deps.start.mk +-------------------------------------------------------------------------------- + +Changes in version 1.3.25 +- runlevel.mk: add support for fbsplash +- runlevel.mk: move here local target from deps.start.mk +- rc: pass fbsplash variables to runlevel.mk +-------------------------------------------------------------------------------- + +Changes in version 1.3.24 +- rc, rc.sysinit: modify for use with fbsplash +- functions: add splash_comm_progress() function +-------------------------------------------------------------------------------- + +Changes in version 1.3.23 +- functions: add splash_comm_send() function +-------------------------------------------------------------------------------- + +Changes in version 1.3.22 +- ifup: bring up interface before setting wireless parameters as needed by + some wireless driver +-------------------------------------------------------------------------------- + +Changes in version 1.3.21 +- set dev.rtc.max-user-freq to 1024 +-------------------------------------------------------------------------------- + +Changes in version 1.3.20 +- rc.sysinit & rc: add support for fbsplash +-------------------------------------------------------------------------------- + +Changes in version 1.3.19 +- ifup: check for dhclient pid, and if found don't run it +-------------------------------------------------------------------------------- + +Changes in version 1.3.18 +- loadmodules: don't exit with 1 if ide-cd probe fails +-------------------------------------------------------------------------------- + +Changes in version 1.3.17 +- rc & rc.sysinit: use $CMDLINE exported from initramfs for variable parsing +- rc & rc.sysinit: accept debug and debug=x to enable debug +- rc: unmount initrd +- runlevel.mk: accept debug variable +-------------------------------------------------------------------------------- + +Changes in version 1.3.16 +- sysinit: fixed ROOT cmdline value parsing +-------------------------------------------------------------------------------- + +Changes in version 1.3.15 +- sysinit: removed suppport for initrd; make root link device from /proc/cmdline +-------------------------------------------------------------------------------- + +Changes in version 1.3.14 +- added french and spanish localization +-------------------------------------------------------------------------------- + +Changes in version 1.3.13 +- fixed several bash syntax errors in sysinit script +-------------------------------------------------------------------------------- + +Changes in version 1.3.12 +- runlevel.mk: ensure haldaemon is running in runlevel 3 before ending LOCAL + services +-------------------------------------------------------------------------------- + +Changes in version 1.3.11 +- usb: unused since long time, removed with /etc/sysconfig/usb +-------------------------------------------------------------------------------- + +Changes in version 1.3.10 +- mountfs: remount root with "mount -o remount,rw /" or fstab options won't be taken +-------------------------------------------------------------------------------- + +Changes in version 1.3.9 +- sysinit: create /usr/src/linux symlink to running kernel sources +- sysinit: create also /boot/vmlinuz and /boot/initrd.img symlinks +-------------------------------------------------------------------------------- + +Changes in version 1.3.8 +- rc script: enable verbose bootsplash on all virtual consoles +-------------------------------------------------------------------------------- + +Changes in version 1.3.7 +- loadmodules: don't load commented modules +- runlevel.mk: support load before and load after mechansims in runlevel 2,3,4 too +-------------------------------------------------------------------------------- + +Changes in version 1.3.6 +- loadmodules: fix support for file /etc/modules +- loadmodules: add support for /etc/modules.d/* (load modules on boot) +-------------------------------------------------------------------------------- + +Changes in version 1.3.5 +- cleanfs: remove hidden files created by Xorg and wine +-------------------------------------------------------------------------------- + +Changes in version 1.3.4 +- add support for file /etc/modules (modules to load on boot) +-------------------------------------------------------------------------------- + +Changes in version 1.3.3 +- i18n: removed and replaced by kbd's own initscript +-------------------------------------------------------------------------------- + +Changes in version 1.3.2 +- multithreaded init: fix an error in endlocal target +-------------------------------------------------------------------------------- + +Changes in version 1.3.1 +- multithred init: set local services for runlevels other than 5 +-------------------------------------------------------------------------------- + +Changes in version 1.3.0 +- multithread init: services startup optimization +- multithread init: add TEST variable to TEST services startup order +- mountfs: fix a mount error preventing usbfs from correctly mounting +-------------------------------------------------------------------------------- + +Changes in version 1.2.22 +- rc.sysinit: add more checks to correctly parse proc cmdline file +-------------------------------------------------------------------------------- + +Changes in version 1.2.21 +- rc.sysinit:add debug support enabling console output on boot +- rc.sysinit:set hostname on boot to avoid recursive ldap searches +-------------------------------------------------------------------------------- + +Changes in version 1.2.20 +- add bluetooth in deps start list +-------------------------------------------------------------------------------- + +Changes in version 1.2.19 +- deps.start.mk: other fixes +-------------------------------------------------------------------------------- + +Changes in version 1.2.18 +- deps.start.mk: add msysklogd +-------------------------------------------------------------------------------- + +Changes in version 1.2.17 +- deps.start.mk: haldaemon depends on acpid +- runlevel.mk: add alsa as local prerequirement +-------------------------------------------------------------------------------- + +Changes in version 1.2.16 +- fix a multithreaded init bug: local services not started before end of local +-------------------------------------------------------------------------------- + +Changes in version 1.2.15 +- start kdm after ivman service +-------------------------------------------------------------------------------- + +Changes in version 1.2.14 +- start kdm after messagebus service (dbus) +-------------------------------------------------------------------------------- + +Changes in version 1.2.13 +- changed some boot message translation +- mountfs: change a mount option to support remount with NFS +-------------------------------------------------------------------------------- + +Changes in version 1.2.12 +- ifup,ifdown: use interface specific pid file to call/kill dhclient process +-------------------------------------------------------------------------------- + +Changes in version 1.2.11 +- ifup: fix wireless option order while calling iwconfig +- deps.stop.mk: remove an udev circular dependency on shutdown +-------------------------------------------------------------------------------- + +Changes in version 1.2.10 +- add support for new splash_text with progress bar support +-------------------------------------------------------------------------------- + +Changes in version 1.2.9 +- /sbin/ifup: added support for more wireless configuration options +-------------------------------------------------------------------------------- + +Changes in version 1.2.8 +- loadmodules: fix check for kernel modules existence +-------------------------------------------------------------------------------- + +Changes in version 1.2.7 +- rc.sysinit: mount tmpfs on /initrd if not already mounted +- loadmodules: do nothing if kernel modules dir is not present +-------------------------------------------------------------------------------- + +Changes in version 1.2.6 +- rc.sysinit: use a tmpfs ramdisk on first stage boot +- loadmodules: console output cleanups +-------------------------------------------------------------------------------- + +Changes in version 1.2.5 +- mountproc: mount proc and sysfs with -n option (don't write to /etc/mtab) +- rc: exit from wait loop if makefile exists with errors +-------------------------------------------------------------------------------- + +Changes in version 1.2.4 +- network-functions: regexps in `get_interface_parameters()' modified + to support loopback interfaces +-------------------------------------------------------------------------------- + +Changes in version 1.2.3 +- multithread init: handle udev/haldaemon/ivman dependencies +-------------------------------------------------------------------------------- + +Changes in version 1.2.2 +- sysinit: create the link /dev/root to the real root device if possible, + otherwise just copy /dev/root from initrd to /dev +-------------------------------------------------------------------------------- + +Changes in version 1.2.1 +- loadmodules: load module ide-cd if ide cdroms are found (it's not hotplugged) +-------------------------------------------------------------------------------- + +Changes in version 1.2.0 +- functions: + - new option `--pidfile' for function `daemon()' + - new functions `warning()', and `echo_warning()' +-------------------------------------------------------------------------------- + +Changes in version 1.1.21 +- makefile: + - clean tag: remove $(PACKAGE).lang + - fixed dist-rpm +- functions: `pidofproc()' and `killproc()' are now LSB 2.x compliant +-------------------------------------------------------------------------------- + +Changes in version 1.1.20 +- network: send make std messages to /dev/null +- sysinit: copy /dev/root from initrd to /dev +-------------------------------------------------------------------------------- + +Changes in version 1.1.19 +- mountproc: access bootsplash /proc/splash after mounting proc +-------------------------------------------------------------------------------- + +Changes in version 1.1.18 +- inittab: rever to /dev/vc/* instead of /dev/tty* for udev compatibility +-------------------------------------------------------------------------------- + +Changes in version 1.1.17 +- setclock: changed initscript to a start/stop script and set systohc on stop +- deps.stop.mk: added dependencies for heartbeat and drbd +-------------------------------------------------------------------------------- + +Changes in version 1.1.16 +- setclock: use --directisa to avoid a /dev/rtc error +-------------------------------------------------------------------------------- + +Changes in version 1.1.15 +- cleanfs: remove files and directories located in /tmp (at every boot) + as recommended by the FHS 2.3 specifications +- mountfs + - do not try to remount sysfs + - added a missing echo command +- mountproc + - fixed the regular expression used to detect if sysfs is mounted +-------------------------------------------------------------------------------- + +Changes in version 1.1.14 +- execute runlevel.mk in it's own dir to avoid file conflicts with services(!!) +-------------------------------------------------------------------------------- + +Changes in version 1.1.13 +- added export HOME=/root in rc initscript +- deps.stop.mk: add support for vmware; stop sysklogd later +-------------------------------------------------------------------------------- + +Changes in version 1.1.12 +- add text "Starting graphical environment..." to bootsplash +- added command "ifrestart" to restart an interface +- updated multithreaded init deps (alsaoss renamed to alsa) +-------------------------------------------------------------------------------- + +Changes in version 1.1.11 +- network-functions: + - `get_interfaces_by_zone()' modified + - `get_interface_parameters()' now set the boolean variable `int_static_ip' +- ifdown, ifup: + - added checks for mandatory script args + - check if the system configuration files are available +-------------------------------------------------------------------------------- + +Changes in version 1.1.10 +- don't change bootsplash in runlevel 5 start +-------------------------------------------------------------------------------- + +Changes in version 1.1.9 +- don't remove /dev/scd0 (kernel 2.6) +-------------------------------------------------------------------------------- + +Changes in version 1.1.8 +- remove progress bar from bootsplash before entering runlevel 5 +-------------------------------------------------------------------------------- + +Changes in version 1.1.7 +- added support for activation of subinterfaces +-------------------------------------------------------------------------------- + +Changes in version 1.1.6 +- added /sbin/service script for smart services execution +-------------------------------------------------------------------------------- + +Changes in version 1.1.5 +- add static-routes support in network device ifup script +- load default gateway in ifup instead of network initscript +-------------------------------------------------------------------------------- + +Changes in version 1.1.4 +- mountfs: remove uneeded entries from /etc/mtab: + - /dev/cloop, devfs, /dev/root.old, (for QiLinux Live CD) + - sysfs, /dev/scd0 (kernel 2.6.x) +-------------------------------------------------------------------------------- + +Changes in version 1.1.3 +- fixed an error in /etc/rc.d/init.d/i18n occurring whith LANG undefined +-------------------------------------------------------------------------------- + +Changes in version 1.1.2 +- added a void file /etc/sysconfig/i18n to avoid errors during boot +- fixed the wrong error message displayed by 'make clean' when *.mo file are + not found +- added a ChangeLog file and some code in the Makefile to check if the + ChangeLog is updated when a new version of initscripts is released +-------------------------------------------------------------------------------- + +Changes in version 1.1.1 +- modified the i18n script to support QiLinux live-CDs + the env variable LANG is set via the boot paramether LANG + KEYMAP is set according to LANG if not found in /etc/sysconfig/keyboard +- removed /etc/sysconfig/i18n +-------------------------------------------------------------------------------- +- dash compatibility (network): fix trap usage +- network: do not create temporary files when not required diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..20bf3f0 --- /dev/null +++ b/Makefile @@ -0,0 +1,100 @@ +# Makefile for openmamba initscripts +# Copyright (C) 2004-2010 by Silvan Calarco +# Copyright (C) 2004-2009 by Davide Madrisan + +include VERSION + +PACKAGE=initscripts + +# system locations +prefix = /usr +exec_prefix = ${prefix} +sysconfdir = /etc +sbindir = ${exec_prefix}/sbin +bindir = ${exec_prefix}/bin +mandir = ${prefix}/usr/share/man +datadir = ${prefix}/share +initrddir = ${sysconfdir}/rc.d/init.d +sysconfigdir= ${sysconfdir}/sysconfig +localstatedir = /var +localesdir = ${datadir}/locale/ + +srcdir = . + +DESTDIR = +INSTALL = /usr/bin/install +INSTALL_PROGRAM = ${INSTALL} -m 755 +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_DIR = ${INSTALL} -d -m 755 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} + +# package related variables +distdir = $(PACKAGE)-$(VERSION) +dist_archive = $(distdir).tar.bz2 + +pck_catalogs := $(wildcard po/*.po) + +.SUFFIXES: +.SUFFIXES: .po .mo +.po.mo:; msgfmt $< -o $@ + +all: tools locales + +locales: $(pck_catalogs:.po=.mo) + +tools: + make -C src + +install-locales: locales + @for f in $(pck_catalogs); do\ + lang=`echo $$f | sed 's,.*/\(.*\)\.po,\1,'`;\ + echo "installing i18n file for language \`$$lang'...";\ + dir="$(DESTDIR)$(localesdir)/$$lang/LC_MESSAGES";\ + $(INSTALL_DIR) $$dir;\ + $(INSTALL_DATA) $${f/.po/.mo} $$dir/$(PACKAGE).mo;\ + done + +install-tools: + make install -C src + +install-dirs: + $(INSTALL_DIR) $(DESTDIR)/sbin + $(INSTALL_DIR) $(DESTDIR)$(localstatedir)/run + $(INSTALL_DIR) $(DESTDIR)$(localstatedir)/log + $(INSTALL_DIR) $(DESTDIR)$(sysconfigdir)/modules.d/ + +install-files: + touch $(DESTDIR)$(localstatedir)/run/utmp + touch $(DESTDIR)$(localstatedir)/log/{btmp,lastlog,wtmp} + cp -a etc var $(DESTDIR) + $(INSTALL_SCRIPT) sbin/* $(DESTDIR)/sbin + for i in `seq 0 6`; do\ + ln -sf rc.d/rc$$i.d/ $(DESTDIR)$(sysconfdir)/rc$$i.d;\ + done + ln -sf rc.d/init.d/ $(DESTDIR)$(sysconfdir)/init.d + ln -sf rc.d/rcsysinit.d/ $(DESTDIR)$(sysconfdir)/rcsysinit.d + +install: install-dirs install-tools install-locales install-files + +dist: clean + @case `sed 15q ChangeLog` in \ + *"$(VERSION)"*) : ;; \ + *) \ + echo "ChangeLog not updated; not releasing" 1>&2;\ + exit 1;; \ + esac + @rm -f $(dist_archive);\ + tar cf - --exclude=$(PACKAGE)*.bz2 -C .. $(distdir) |\ + bzip2 -9 -c > $(dist_archive) + @echo "file \`$(dist_archive)' created" + +dist-rpm: dist + @rpm_sourcedir=`rpm --eval=%{_sourcedir}`;\ + mv -f $(dist_archive) $$rpm_sourcedir;\ + echo "and saved as \`$$rpm_sourcedir/$(dist_archive)'" + +clean: + rm -f $(dist_archive) + rm -f $(pck_catalogs:.po=.mo) + rm -f $(PACKAGE).lang + make clean -C src diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..cebb320 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +VERSION = 1.5.0 \ No newline at end of file diff --git a/etc/inittab b/etc/inittab new file mode 100644 index 0000000..c58705f --- /dev/null +++ b/etc/inittab @@ -0,0 +1,51 @@ +# /etc/inittab - main configuration file of /etc/init +# +# Copyright (c) 2003-2006 by Silvan Calarco +# Copyright (c) 2003-2006 by Davide Madrisan +# +# This is the main configuration file of /etc/init, which is executed +# by the kernel on startup. +# It describes what scripts are used for the different run-levels. +# All scripts for runlevel changes are in /etc/init.d/. + + +# this is the runlevel which should be entered after system boot +id:3:initdefault: + +# first script to be executed during system boot +si::sysinit:/etc/rc.d/init.d/rc.sysinit + +# /etc/init.d/rc takes care of runlevel handling: +# runlevel 0 -- system halt (do NOT use this for initdefault) +# runlevel 1 -- maintenance (single user) mode +# runlevel 2 -- local multiuser without remote network +# runlevel 3 -- full multiuser with network +# runlevel 4 -- not used +# runlevel 5 -- full multiuser with network and xdm +# runlevel 6 -- system reboot (do NOT use this for initdefault) +# +l0:0:wait:/etc/rc.d/init.d/rc 0 +l1:S1:wait:/etc/rc.d/init.d/rc 1 +l2:2:wait:/etc/rc.d/init.d/rc 2 +l3:3:wait:/etc/rc.d/init.d/rc 3 +l4:4:wait:/etc/rc.d/init.d/rc 4 +l5:5:wait:/etc/rc.d/init.d/rc 5 +l6:6:wait:/etc/rc.d/init.d/rc 6 + +# what to do when init receives the SIGINT signal (CTRL-ALT-DEL) +# note: 'shutdown -a' to use /etc/shutdown.allow +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# what to do in single-user mode +su:S016:once:/sbin/sulogin + +# agetty-programs for the normal runlevels +# note: the id field should be the tty suffix of the corresponding tty, +# e.g. 1 for tty1; otherwise, the login accounting might not work +# correctly +1:2345:respawn:/sbin/agetty tty1 9600 +2:2345:respawn:/sbin/agetty tty2 9600 +3:2345:respawn:/sbin/agetty tty3 9600 +4:2345:respawn:/sbin/agetty tty4 9600 +5:2345:respawn:/sbin/agetty tty5 9600 +6:2345:respawn:/sbin/agetty tty6 9600 diff --git a/etc/modprobe.d/ipv6.conf b/etc/modprobe.d/ipv6.conf new file mode 100644 index 0000000..502de8d --- /dev/null +++ b/etc/modprobe.d/ipv6.conf @@ -0,0 +1,2 @@ +alias net-pf-10 off +blacklist ipv6 diff --git a/etc/modprobe.d/lp.conf b/etc/modprobe.d/lp.conf new file mode 100644 index 0000000..0391b74 --- /dev/null +++ b/etc/modprobe.d/lp.conf @@ -0,0 +1 @@ +install parport_pc /sbin/modprobe -i parport_pc; /sbin/modprobe lp diff --git a/etc/modprobe.d/nouveau.conf b/etc/modprobe.d/nouveau.conf new file mode 100644 index 0000000..31075c0 --- /dev/null +++ b/etc/modprobe.d/nouveau.conf @@ -0,0 +1 @@ +blacklist nouveau diff --git a/etc/modprobe.d/rt28xx.conf b/etc/modprobe.d/rt28xx.conf new file mode 100644 index 0000000..2bd62cf --- /dev/null +++ b/etc/modprobe.d/rt28xx.conf @@ -0,0 +1,2 @@ +blacklist rt2800pci +blacklist rt2800usb diff --git a/etc/rc.d/init.d/checkfs b/etc/rc.d/init.d/checkfs new file mode 100755 index 0000000..e2d783b --- /dev/null +++ b/etc/rc.d/init.d/checkfs @@ -0,0 +1,90 @@ +#!/bin/sh +# checkfs - File System Check + +# Based on checkfs script from LFS-3.1 and earlier. +# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org +# Patch to handle all fsck variants by A. Luebke - luebke@users.sourceforge.net + +. /etc/sysconfig/rc +. $rc_functions + +if [ -f /fastboot ]; then + echo "Fast boot requested, will not perform file system checks" + exit 0 +fi + +echo -n "Mounting root file system in read-only mode: " +mount -n -o remount,ro / +evaluate_retval +echo + +if [ $? != 0 ]; then + $FAILURE + echo + echo "Cannot check root file system because it could not" + echo "be mounted in read-only mode." + echo + echo -n "When you press enter, this system will be halted." + $NORMAL + echo + echo "Press enter to continue..." + read ans + echo "gonna run: $rc_base/init.d/halt" + $rc_base/init.d/halt +fi + +if [ -f /forcefsck ]; then + echo "/forcefsck exists, forcing file system check" + options="-f" +else + options="" +fi + +echo -n "Checking file systems: " +$PLYMOUTH message --text=$"Checking file systems..." + +# note: -a option used to be -p; but this fails e.g. on fsck.minix +fsck $options -a -A -C -T +retval=$? + +if [ $retval -eq 0 ]; then + $PLYMOUTH message --text=$"Checking file systems...done" + echo_success + echo +elif [ $retval -eq 1 ]; then + $WARNING + echo "File system errors were found and have been corrected." + echo "You may want to double-check that everything was fixed" + echo -n "properly" + $NORMAL + $PLYMOUTH message --text=$"Checking file systems...fixed" + echo_warning + echo +elif [ $retval -eq 2 ]; then + $WARNING + echo "File system errors were found and have been corrected, but" + echo "the nature of the errors require this system to be rebooted." + $NORMAL + $PLYMOUTH message --text=$"Checking file systems...rebooting" + echo_warning + echo + $rc_base/init.d/reboot +elif [ $retval -eq 4 ]; then + $WARNING + echo "File system errors were encountered that couldn't be" + echo "fixed automatically. The system will continue to boot but" + echo "errors need to be fixed manually by a system administrator." + $NORMAL + $PLYMOUTH message --text=$"Checking file systems...unfixable errors" + echo_warning + echo +elif [ "$retval" -gt 4 ]; then + $FAILURE + echo "An internal error was encountered while checking file systems." + echo "This system will continue to boot but errors need to be fixed" + echo "by a system administrator." + $NORMAL + $PLYMOUTH message --text=$"Checking file systems...operational error!" + echo_warning + echo +fi diff --git a/etc/rc.d/init.d/cleanfs b/etc/rc.d/init.d/cleanfs new file mode 100755 index 0000000..40b0fe5 --- /dev/null +++ b/etc/rc.d/init.d/cleanfs @@ -0,0 +1,52 @@ +#!/bin/sh +# cleanfs - Clean file system + +# Written by Gerard Beekmans +# Modified by Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions + +echo -n "Removing lock files: " +find /var/run/ -type f -o -type s | xargs -n 1 rm -f +find /var/lock/ -type f -o -type s | xargs -n 1 rm -f +find /var/tmp/.*-lock -type f -o -type s 2>/dev/null | xargs -n 1 rm -f +evaluate_retval +echo + +# remove files and directories located in /tmp at every boot +# (recommended by the FHS 2.3 specifications) +echo -n "Removing files and directories from /tmp: " +rm -fr /tmp/* 2>/dev/null +rm -f /tmp/.fam* +rm -f /tmp/.X*-lock +rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix +rm -rf /tmp/.wine-* +evaluate_retval +echo + +echo -n "Removing temporary files created by rpm: " +rm -f /var/lib/rpm/__db* >/dev/null 2>&1 +evaluate_retval +echo + +echo -n "Creating new /var/run/utmp: " +touch /var/run/utmp && chmod 644 /var/run/utmp +evaluate_retval +echo + +# removing possible files /etc/nologin /fastboot /forcefsck +rm -f /etc/nologin /fastboot /forcefsck + +# fix a KDE warning message to speed up applications startup +if [ -d /tmp/.ICE-unix ]; then + chown root:root /tmp/.ICE-unix + chmod 1777 /tmp/.ICE-unix +fi + +# remove .ICEauthority in home directories to avoid permission problems at user login +for d in `getent passwd | cut -d: -f6`; do [ -e $d/.ICEauthority ] && rm -f $d/.ICEauthority; done + +# remove apt cached packages +rm -f /var/cache/apt/archives/*.rpm +rm -f /var/cache/apt/archives/partial/* diff --git a/etc/rc.d/init.d/functions b/etc/rc.d/init.d/functions new file mode 100755 index 0000000..8b446b0 --- /dev/null +++ b/etc/rc.d/init.d/functions @@ -0,0 +1,620 @@ +#!/bin/sh +# +# functions This file contains functions to be used by most or all +# shell scripts in the /etc/init.d directory. +# +# Based on functions scripts from LFS-3.1 and RedHat/Fedora +# Splash functions added by Silvan Calarco +# Modified for LSB and dash compliance by Davide Madrisan + +TEXTDOMAIN=initscripts + +umask 022 + +# Set up a default search path. +PATH="/sbin:/usr/sbin:/bin:/usr/bin" +export PATH + +# Get a sane screen width. +[ -z "${COLUMNS:-}" ] && COLUMNS=80 +[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="`/sbin/consoletype`" + +COL=$(( $COLUMNS - 10 )) +WCOL=$(( $COLUMNS - 30 )) + +if [ -z "${BOOTUP:-}" ]; then + if [ "$CONSOLETYPE" = "serial" ]; then + BOOTUP=serial + MOVE_TO_COL= + MOVE_TO_WCOL= + MOVE_TO_LCOL= + MOVE_CURS_UP= + SETCOLOR_NORMAL= + SETCOLOR_SUCCESS= + SETCOLOR_WARNING= + SETCOLOR_FAILURE= + else + BOOTUP=color + MOVE_TO_COL="/bin/echo -en \\033[${COL}G" + MOVE_TO_WCOL="/bin/echo -en \\033[${WCOL}G" + MOVE_TO_LCOL="/bin/echo -en \\033[0G" + MOVE_CURS_UP="/bin/echo -en \\033[A" + SETCOLOR_NORMAL="/bin/echo -en \\033[0;39m" + SETCOLOR_SUCCESS="/bin/echo -en \\033[1;32m" + SETCOLOR_WARNING="/bin/echo -en \\033[1;33m" + SETCOLOR_FAILURE="/bin/echo -en \\033[1;31m" + fi +fi + +if [ "${BOOTUP:-}" != "verbose" ]; then + INITLOG_ARGS="-q" +else + INITLOG_ARGS= +fi + +if [ -e /bin/plymouth -a -e /sbin/plymouthd ]; then + PLYMOUTH=/bin/plymouth + PLYMOUTHD=/sbin/plymouthd +else + PLYMOUTH=/bin/true + PLYMOUTHD=/bin/true +fi + +# Check if $pid (could be plural) are running +checkpid () +{ + local i + + for i in $*; do + [ -d "/proc/$i" ] && return 0 + done + return 1 +} + +#function getpids +#{ +# # save basename +# base=${1##*/} +# +# pidlist=$(pidof -o $$ -o $PPID -x $base) +# pidlist=$(for p in $pidlist; do echo $p; done | sort) +#} + + +# function: +# __pids_var_run {program} [pidfile] +# description: +# Set $pid to pids from /var/run* for {program}. +# $pid should be declared local in the caller. +# Returns LSB exit code for the 'status' action. +__pids_var_run () +{ + local base=${1##*/} + local pid_file=${2:-/var/run/$base.pid} + + pid= + if [ -f "$pid_file" ] ; then + local line p + read line < "$pid_file" + for p in $line ; do + [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" + done + if [ -n "$pid" ]; then + return 0 + fi + return 1 # "Program is dead and /var/run pid file exists" + fi + return 3 # "Program is not running" +} + +# function: +# __pids_pidof {program} +# description: +# Output PIDs of matching processes, found using pidof. +__pids_pidof () +{ + /bin/pidof -o $$ -o $PPID -o %PPID -x "$1" || \ + /bin/pidof -o $$ -o $PPID -o %PPID -x "${1##*/}" +} + +# function: +# daemon {args} [+/-nicelevel] {program} +# description: +# A function to start a program +daemon () +{ + # test syntax + local gotbase= force= + local base= user= nice= bg= pid= pidfile= + nicelevel=0 + while [ "$1" != "${1##[-+]}" ]; do + case $1 in + '') echo $"daemon: Usage: daemon {args} [+/-nicelevel] {program}" + return 1 + ;; + --check) + base=$2 + gotbase="yes" + shift 2 + ;; + --check=?*) + base=${1#--check=} + gotbase="yes" + shift + ;; + --user) + user=$2 + shift 2 + ;; + --user=?*) + user=${1#--user=} + shift + ;; + --force) + force="force" + shift + ;; + --pidfile=?*) + pidfile=${1#--pidfile=} + shift + ;; + [-+][0-9]*) + nice="nice -n $1" + shift + ;; + *) echo $"daemon: Usage: daemon {args} [+/-nicelevel] {program}" + return 1 ;; + esac + done + + # save basename + [ -z "$gotbase" ] && base=${1##*/} + + [ -z "$pidfile" ] && pidfile="/var/run/${base}.pid" + + # see if it's already running. Look *only* at the pid file + if [ -f $pidfile ]; then + local line p + read line < $pidfile + for p in $line ; do + [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" + done + fi + + [ -n "${pid:-}" -a -z "${force:-}" ] && return 0 + + # make sure it doesn't core dump anywhere unless requested + ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1 + + # if they set NICELEVEL in /etc/sysconfig/foo, honor it + [ -n "$NICELEVEL" ] && nice="nice -n $NICELEVEL" + + # echo daemon + [ "${BOOTUP:-}" = "verbose" -a -z "$LSB" ] && echo -n " $base" + + # and start it up + if [ -z "$user" ]; then + $nice initlog $INITLOG_ARGS -c "$*" + else + $nice initlog $INITLOG_ARGS -c "su -s /bin/bash - $user -c \"$*\"" + fi + [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup" +} + +# function: +# killproc [-p pidfile] {program} [signal] +# description: +# A function to stop a program (LSB 2.x compliant). +killproc () +{ + TEMP=`LANG=C POSIXLY_CORRECT=1 getopt "p:" $*` + if [ $? -ne 0 -o $# -eq 0 ]; then + echo $"Usage: killproc [-p ] pathname [signal]" + return 1 + fi + + eval set -- "$TEMP" + local pid_file + while :; do + case $1 in + -p) pid_file=$2; shift ;; + --) shift; break ;; + *) echo $"Usage: killproc [-p ] pathname [signal]" + return 1 ;; + esac + shift + done + + local base=${1##*/} + + # Check for second arg to be kill level. + local signal=${2:-} + + [ -z "$pid_file" ] && pid_file=/var/run/$base.pid + + # Find pid. + local retcode=0 pid + __pids_var_run "$1" "$pid_file" + + if [ ! -e "$pid_file" -a -z "$pid" ]; then + pid="$(__pids_pidof "$1")" + fi + + # Kill it. + if [ "${pid:-}" ] ; then + # Use specified level only. + if [ "$signal" ]; then + if checkpid $pid 2>&1; then + kill $signal $pid >/dev/null 2>&1 + retcode=$? + else + retcode=1 + fi + else + if checkpid $pid 2>&1; then + # TERM first, then KILL if not dead + kill -s TERM $pid >/dev/null 2>&1 + usleep 100000 + if checkpid $pid && sleep 1 && + checkpid $pid && sleep 3 && + checkpid $pid ; then + kill -s KILL $pid >/dev/null 2>&1 + usleep 100000 + fi + checkpid $pid + retcode=$((! $? )) + fi + fi + else + [ "$signal" ] && retcode=1 + fi + [ "$retcode" -eq 0 ] && + success $"$base shutdown" || failure $"$base shutdown" + + # Remove pid file if any. + rm -f $pidfile >/dev/null 2>&1 + return $retcode +} + +# function: +# pidfileofproc {program} +# description: +# A function to find the pid of a program. Looks *only* at the pidfile. +pidfileofproc () +{ + local base=${1##*/} + + # Test syntax. + if [ "$#" = 0 ] ; then + echo $"Usage: pidfileofproc {program}" + return 1 + fi + + __pids_var_run "$1" + [ -n "$pid" ] && echo $pid + return 0 +} + +# function: +# pidofproc [-p pidfile] {program} +# description: +# A function to find the pid of a program (LSB 2.x compliant). +pidofproc () +{ + TEMP=`LANG=C POSIXLY_CORRECT=1 getopt "p:" $*` + if [ $? -ne 0 -o $# -eq 0 ]; then + echo $"Usage: pidofproc [-p ] {program}" + return 1 + fi + + eval set -- "$TEMP" + local pid_file + while :; do + case $1 in + -p) pid_file=$2; shift ;; + --) shift; break ;; + *) echo $"Usage: pidofproc [-p ] {program}" + return 1 ;; + esac + shift + done + + local base=${1##*/} rc + + if [ -z "$pid_file" ]; then + pid_file=/var/run/$base.pid + else + # Assume program is stopped + [ -f "$pid_file" ] || return 3 + fi + + if [ -f "$pidfile" ]; then + __pids_var_run "$1" "$pid_file" + rc=$? + if [ -n "$pid" ]; then + echo $pid + return 0 + else + return 1 # Dead and /var/run pid file exists + fi + elif [ -x /bin/pidof ]; then + __pids_pidof "$1" + [ "$?" = 1 ] && return 3 # Daemon stopped + return 0 + fi + return 4 # Service status is unknown +} + +# function: +# statusproc [-p pidfile] {program} +# description: +# A function to check the status of a program +statusproc () +{ + local base pid pid_file= + + # Test syntax. + if [ "$#" = 0 ] ; then + echo $"Usage: statusproc [-p pidfile] {program}" + return 1 + fi + + if [ "$1" = "-p" ]; then + pid_file=$2 + shift 2 + fi + + base=${1##*/} + + # First try "pidof" + pid="$(__pids_pidof "$1")" + if [ -n "$pid" ]; then + echo $"${base} (pid $pid) is running..." + return 0 + fi + + # Next try "/var/run/*.pid" files + __pids_var_run "$1" "$pid_file" + case "$?" in + 0) echo $"${base} (pid $pid) is running..." + return 0 + ;; + 1) echo $"${base} dead but pid file exists" + return 1 + ;; + esac + # See if /var/lock/subsys/${base} exists. + if [ -f /var/lock/subsys/${base} ]; then + echo $"${base} dead but subsys locked" + return 2 + fi + echo $"${base} is stopped" + return 3 +} + +loadproc () +{ + if [ $# = 0 ]; then + echo "Usage: loadproc {program}" + exit 1 + fi + + local pid + pid="$(__pids_pidof "$1")" + if [ -z "$pid" ]; then + "$@" + [ $? -eq 0 ] && echo_success || echo_failure + else + $MOVE_TO_WCOL + echo_passed + fi +} + +reloadproc () +{ + if [ $# = 0 ]; then + echo "Usage: reloadproc {program} [signal]" + exit 1 + fi + + local signal + if [ -z "$2" ]; then + signal=HUP + else + signal=${2##-} + signal=${signal##SIG} + fi + + local pid apid failure + pid="$(__pids_pidof "$1")" + if [ -n "$pid" ]; then + failure=0 + for apid in $pid; do + kill -s $signal $apid || failure=1 + done + [ $failure -eq 0 ] && echo_success || echo_failure + else + $MOVE_TO_WCOL + echo_warning not_running + fi +} + + +echo_success () +{ + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS + echo -n $" OK " + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + /bin/echo -ne "\r" + return 0 +} + +echo_failure () +{ + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE + echo -n $"FAILED" + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + /bin/echo -ne "\r" + return 1 +} + +echo_warning () +{ + case "$1" in + running) + [ "$BOOTUP" = "color" ] && $MOVE_TO_WCOL + echo $"Already running" + [ "$BOOTUP" = "color" ] && $MOVE_CURS_UP + ;; + not_running) + [ "$BOOTUP" = "color" ] && $MOVE_TO_WCOL + echo $"Stopped" + [ "$BOOTUP" = "color" ] && $MOVE_CURS_UP + ;; + esac + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING + echo -n $"WARNING" + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + /bin/echo -ne "\r" + return 1 +} + +echo_passed () +{ + # [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + # echo -n "[" + # [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING + # echo -n $"PASSED" + # [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + # echo -n "]" + # /bin/echo -ne "\r" + echo_warning running + return 1 +} + +# Log that something succeeded. +success () +{ + if [ -z "${IN_INITLOG:-}" ]; then + initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 + fi + [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success + return 0 +} + +# Log that something failed. +failure () +{ + local rc=$? + if [ -z "${IN_INITLOG:-}" ]; then + initlog $INITLOG_ARGS -n $0 -s "$1" -e 2 + fi + [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure + return $rc +} + +# Log that something passed, but may have had errors. Useful for fsck +passed () +{ + local rc=$? + if [ -z "${IN_INITLOG:-}" ]; then + initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 + fi + [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_passed + return $rc +} + +# Log a warning. +warning () +{ + local rc=$? + if [ -z "${IN_INITLOG:-}" ]; then + initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 + fi + [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_warning + return $rc +} + +evaluate_retval () +{ + [ $? -eq 0 ] && echo_success || echo_failure +} + +# WARNING: this function is obsolete: do not use it +print_status () +{ + if [ $# = 0 ]; then + echo "Usage: $0 {success|failure|warning}" + return 1 + fi + case "$1" in + success) echo_success ;; + failure) echo_failure ;; + warning) echo_warning $2 ;; + esac +} + +# Run some action. Log its output. +action () +{ + local msg rc + + msg=$1 + echo -n "$msg " + shift + "$@" && success $"$msg" || failure $"$msg" + rc=$? + echo + return $rc +} + +spl_cachedir="/lib/splash/cache" +spl_fifo="/dev/.splashfifo" +spl_pidfile="/dev/.splashpid" + +splash_comm_send () +{ + [ -w "$spl_fifo" -a -r "$spl_pidfile" ] || return 1 + [ "`pidof fbsplashd`" ] || return + echo $* > $spl_fifo || return 1 + return 0 +} + +splash_comm_progress () +{ + [ "$1" ] || return 1 + progress=`expr 65535 \* $1 / 100` + + splash_comm_send progress ${progress} + splash_comm_send repaint +} + +check_link () +{ + if [ $# = 0 ]; then + echo "Usage: check_link " + return 1 + fi + if [ ! -f "$1" ]; then + echo "$1 is a broken symlink, skipping" + return 2 + fi + if [ ! -x "$1" ]; then + echo "$1 is not executable, skipping" + return 3 + fi + return 0 +} + +# define aliases for compatibility +alias status=statusproc +alias gprintf=printf diff --git a/etc/rc.d/init.d/halt b/etc/rc.d/init.d/halt new file mode 100755 index 0000000..c2871ae --- /dev/null +++ b/etc/rc.d/init.d/halt @@ -0,0 +1,21 @@ +#!/bin/sh +# halt - System halt + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +case "$1" in + start) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + halt -d -f -i -p + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac diff --git a/etc/rc.d/init.d/loadmodules b/etc/rc.d/init.d/loadmodules new file mode 100755 index 0000000..46eb17a --- /dev/null +++ b/etc/rc.d/init.d/loadmodules @@ -0,0 +1,30 @@ +#!/bin/sh +# Copyright (C) 2004-2011 Silvan Calarco + +. /etc/sysconfig/rc +. $rc_functions + +KERNELREL=`uname -r` + +# check for modules existence or exit +[ -e /lib/modules/$KERNELREL/modules.dep ] || exit 0 + +KERNELMIN=`echo $KERNELREL | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'` +[ -r /etc/modprobe.conf ] && modulesfile="/etc/modprobe.conf" +[ -d /etc/modprobe.d ] && modulesfile="$modulesfile /etc/modprobe.d/*.conf" + +module_alias=`egrep "^(probeall|alias)( |\t)*on-boot-*( |\t)*" $modulesfile 2>/dev/null | gawk '{ print $2 }'` +module_name=`egrep "^(probeall|alias)( |\t)*on-boot-*( |\t)*" $modulesfile 2>/dev/null | gawk '{ print $3 }'` + +for module in $module_name \ + `cat /etc/modules 2>/dev/null | grep -v ^#`\ + `cat /etc/modules.d/*.conf 2>/dev/null | grep -v ^#`; do + echo -n "Loading $module module: " + modprobe $module 2>&1 + evaluate_retval + echo +done + +[ -e /proc/ide/hd[a-z] ] && \ + cat /proc/ide/hd[a-z]/media | \ + grep cdrom >/dev/null && modprobe ide-cd 2>/dev/null || : diff --git a/etc/rc.d/init.d/localnet b/etc/rc.d/init.d/localnet new file mode 100755 index 0000000..2d4d368 --- /dev/null +++ b/etc/rc.d/init.d/localnet @@ -0,0 +1,42 @@ +#!/bin/sh +# localnet - Loopback device + +# Based on localnet script from LFS-3.1 and earlier. +# Rewritten by Gerard Beekmans + +. /etc/sysconfig/rc +. $rc_functions + +[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network + +case "$1" in + start) + echo -n "Bringing up the loopback interface..." + ifconfig lo 127.0.0.1 + [ $? -eq 0 ] && echo_success || echo_failure + echo + echo -n "Setting hostname to $HOSTNAME..." + hostname $HOSTNAME + [ $? -eq 0 ] && echo_success || echo_failure + echo + ;; + stop) + echo -n "Bringing down the loopback interface..." + ifconfig lo down + [ $? -eq 0 ] && echo_success || echo_failure + echo + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + status) + echo "Hostname is: $(hostname)" + ifconfig lo + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/mountfs b/etc/rc.d/init.d/mountfs new file mode 100755 index 0000000..d66a48c --- /dev/null +++ b/etc/rc.d/init.d/mountfs @@ -0,0 +1,67 @@ +#!/bin/sh +# mountfs - File System Mount Script + +# Based on mountfs script from LFS-3.1 and earlier. +# Rewritten by Gerard Beekmans +# Modified by Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions + +KERNELMIN=`uname -r | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'` + +case "$1" in + start) + echo -n "Remounting root file system in read-write mode: " + mount -n -o remount,rw / + evaluate_retval + echo + + # Dump dmesg to log file + dmesg > /var/log/dmesg.log + + # Clean and recreate /etc/mtab + rm -f /etc/mtab # delete in case of symlink + cat /proc/mounts | \ + grep -v "^rootfs" | \ + grep -v "^/dev/cloop" | \ + grep -v "^devfs" | \ + grep -v "^sysfs" | \ + grep -v "^/dev/root.old" >/etc/mtab + rm -f /etc/mtab~ /etc/mtab~~ + + [ ! -f /proc/bus/usb/devices ] && mount -t usbfs usbfs /proc/bus/usb + #[ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev + + # The follow mount command will mount all file systems. If you + # have other (network based) file system that should not be or + # cannot be mounted at this time, add them to the NO_FS variable + # below. All file systems that are added to the variable in the + # form of no will be skipped. + + NO_FS="nonfs,nosmbfs,noproc,nosysfs,nousbdevfs,nousbfs,nodevfs" + + echo -n "Mounting remaining file systems: " + mount -a -t $NO_FS + evaluate_retval + echo + ;; + stop) + echo -n "Unmounting all other currently mounted file systems: " + # remove data= in /etc/mtab to prevent problems when system reboots with different mode + # (as with kernel 2.6.30 upgrade) + sed -i "s|[,]*data=[a-z]*||" /etc/mtab +# [ -f /proc/bus/usb/devices ] && umount /proc/bus/usb >/dev/null 2>&1 +# umount -l /proc +# umount -l /sys + NO_FS="nonfs,nosmbfs,noproc,nosysfs,nousbdevfs,nousbfs,nodevfs" + sync + umount -a -f -r -t $NO_FS >/dev/null 2>&1 + evaluate_retval + echo + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/mountproc b/etc/rc.d/init.d/mountproc new file mode 100755 index 0000000..dcb3d2e --- /dev/null +++ b/etc/rc.d/init.d/mountproc @@ -0,0 +1,33 @@ +#!/bin/sh +# mountproc - mount /proc and /sysfs (kernel 2.6.x only) +# Copyright (C) 2004-2010 Silvan Calarco +# Copyright (C) 2004-2009 Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions + +. /etc/sysconfig/i18n +LC_ALL=$LANG +TEXTDOMAIN=initscripts +TEXTDOMAINDIR=/usr/share/locale/ + +KERNELMIN=`uname -r | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'` + +if [ ! -e /proc/version ]; then + echo -n "Mounting proc file system: " + mount -n -t proc proc /proc + evaluate_retval + echo "/sbin/modprobe" > /proc/sys/kernel/modprobe + echo +fi + +progress=5 +$PLYMOUTH message --text=$"System booting, please wait..." +$PLYMOUTH update --status="$progress" + +if [ "$KERNELMIN" -ge 6 -a -z "`mount | grep "^sysfs "`" ]; then + echo -n "Mounting sys file system: " + mount -n -t sysfs sysfs /sys + evaluate_retval + echo +fi diff --git a/etc/rc.d/init.d/network b/etc/rc.d/init.d/network new file mode 100755 index 0000000..6e42d05 --- /dev/null +++ b/etc/rc.d/init.d/network @@ -0,0 +1,89 @@ +#! /bin/sh +# network - Network interfaces start/stop script + +# Based on ethnet script from LFS-3.1 and earlier. +# Rewritten by Gerard Beekmans +# Modified by Silvan Calarco +# +# chkconfig: 2345 20 97 +# description: Network interfaces start/stop script + +. /etc/sysconfig/rc +. $rc_functions +. /etc/sysconfig/network + +unset MAKEDEFAULT + +case "$1" in + start) + if [ -x /usr/sbin/ifrename ] && [ -r /etc/iftab ]; then + echo -n "Renaming interfaces: " + ifrename -t + evaluate_retval + echo + fi + + tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/network_makefile_$$ + trap "rm -f $tempfile" HUP INT QUIT ABRT KILL TERM + + for file in `grep -il "ONBOOT=yes" $network_devices/ifconfig.* 2>/dev/null`; do + interface=$(basename $file | sed "s/ifconfig.//") + case "$interface" in + *~) ;; + *) parentinterface=$(echo $interface | sed s/:.*// ) + targetinterface=$(echo $interface | sed s/:/-/ ) + [ "$parentinterface" = "$targetinterface" ] && unset parentinterface + cat >> $tempfile << EOF +$targetinterface: $parentinterface + @$network_devices/ifup $interface +EOF + MAKEDEFAULT="$targetinterface $MAKEDEFAULT" + ;; + esac + done + + if [ "$MAKEDEFAULT" != "" ]; then + echo -n $"Bringing up interface(s): $MAKEDEFAULT" + echo "all: $MAKEDEFAULT" >> $tempfile + make -j -k -f $tempfile all 1>/dev/null + evaluate_retval + echo + fi + rm -f $tempfile + ;; + stop) + if [ "$GATEWAY" != "" ]; then + echo -n "Removing default gateway: " + route del -net default + evaluate_retval + echo + fi + for file in `grep -il "ONBOOT=yes" $network_devices/ifconfig.* 2>/dev/null`; do + interface=$(basename $file | sed s/ifconfig.//) + case "$interface" in + *~) ;; + *) echo -n $"Bringing down the $interface interface: " + $network_devices/ifdown $interface + evaluate_retval + echo + ;; + esac + done + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + status) + [ -x /sbin/ifconfig ] && /sbin/ifconfig || : + for wint in $(find /sys/class/net/wlan[0-9]* \ + -maxdepth 0 -type d -printf "%f " 2>/dev/null); do + /usr/sbin/iwconfig $wint + done + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/network-functions b/etc/rc.d/init.d/network-functions new file mode 100755 index 0000000..e9bbdb7 --- /dev/null +++ b/etc/rc.d/init.d/network-functions @@ -0,0 +1,159 @@ +#! /bin/sh +# +# network-functions: Network functions script for openmamba +# +# Copyright (c) 2003-2005 by Silvan Calarco +# Copyright (c) 2003-2005,2011 by Davide Madrisan + +. /etc/sysconfig/rc + +# ip_check_args() +# +# parameters: +# $1 : ip/bitmask (like 192.168.0.1/24) -or- +# $1 $2 : ip netmask (like 192.168.0.1 255.255.255.0) +# description: +# This function checks if its first / first two arguments are +# a valid ipv4 address. +# If it is a valid one, returns '1' and set the variables +# $ip (ip address) +# $mask_bit (number of active bits in the maks) +# $mask (mask) +# otherwise returns '0' +ip_check_args () +{ + local i + + # checks if the first argument is a valid one, that is something + # like "192.168.0.1" or "192.168.0.1/24" + if ! echo $1 | grep -Eq "^([0-9]+\.){3}[0-9]+(/[0-9]+){0,1}$"; then + return 0 + fi + ip=`echo $1 | cut -f1 -d/` + for i in `seq 1 4`; do # check for range in [0..255] + local byte=`echo $ip | cut -f$i -d.` + [ $byte -le 255 ] || return 0 + done + # gets the mask from $1, if $1 is like '192.168.0.1/24', + # otherwise 'mask_bit' is set to "" + mask_bits=`echo $1 | cut -f2 -s -d/` + if [ $mask_bits ]; then # 'mask_bit' is not "" + [ $mask_bits -le 32 ] || return 0 # illegal 'mask_bit' + # set 'mask'. i.e. mask_bits = 24 --> mask = 255.255.255.0 + local mb=$mask_bits + for i in `seq 1 4`; do + if [ $mb -ge 8 ]; then + mask=$mask"255" + mb=$(($mb - 8)) + else + mask=$mask$(( 256 - (2 << (7-$mb)) )) + [ $mb -gt 0 ] && mb=0 + fi + [ $i -lt 4 ] && mask=$mask"." + done + else # $2 should be a network mask (like 255.255.255.0) + if ! echo $2 | grep -Eq "^([0-9]+\.){3}[0-9]+$"; then + return 0 + fi + mask=$2 + local prev_byte=255 + local prev_bit=1 + mask_bits=0 + for i in `seq 1 4`; do + local byte=`echo $mask | cut -f$i -d.` + [ $byte -gt 255 ] && return 0 + # if the previous was < 255, the current one must be 0 + [ $prev_byte -lt 255 -a $byte -ne 0 ] && return 0 + # internal loop to set 'mask_bits' + for j in `seq 7 0`; do + local bit_value=$(( ($byte >> j) & 1 )) + # if the previous bit was '0', the current can't be '1' + [ $prev_bit -eq 0 -a $bit_value -eq 1 ] && return 0 + [ $bit_value -eq 1 ] && mask_bits=$(( $mask_bits + 1 )) + prev_bit=$bit_value + done + prev_byte=$byte + done + fi + return 1 +} + +# calculate_ip_parameters() +# +# parameters: +# $1 : ip +# $2 : netmask +# description: +# This function set the variables +# $network (network address) +# $broadcast (broadcast address) +# $wildcard (wildcard mask) +# calculated using as input the ip/network address $1/$2. +# If $1/$2 is a valid ipv4 address, returns '0', otherwise +# returns '1' +calculate_ip_parameters () +{ + local i + unset network broadcast wildcard + + ip_check_args $1 $2 + [ $? -eq 0 ] && return 1 + + for i in 1 2 3 4; do + ip_byte=`echo $ip | cut -f$i -d.` + mask_byte=`echo $mask | cut -f$i -d.` + ip_and_mask=$(( $ip_byte & $mask_byte )) + mask_cplm=$(( 255 - $mask_byte )) + wildcard=$wildcard$mask_cplm + network=$network$ip_and_mask + broadcast=$broadcast$((ip_and_mask + mask_cplm)) + if [ $i -lt 4 ]; then + network=$network"." + broadcast=$broadcast"." + wildcard=$wildcard"." + fi + done + return 0 +} + +# get_interface_parameters() +# +# parameters: +# $1 : interface name (i.e. eth0) +# description: +# If no error occurs, this function return '0' and set the variables +# $int_ip +# $int_netmask +# $int_network +# $int_broadcast +# $int_static_ip (0: static IP; 1: dynamic IP (DHCP)) +# to the system values found for interface $1, otherwise returns '1' +get_interface_parameters () +{ + local int_name="$1" + + [ x"$int_name" != x ] || return 1 + + int_ip=`/sbin/ifconfig $int_name 2>/dev/null | \ + sed -n '/inet addr/{s,.*inet addr:\([^ \t]*\).*,\1,;p}'` + int_broadcast=`/sbin/ifconfig $int_name 2>/dev/null | \ + sed -n '/inet addr:.*Bcast:/{s,.*Bcast:\([^ \t]*\).*,\1,;p}'` + int_netmask=`/sbin/ifconfig $int_name 2>/dev/null | \ + sed -n '/inet addr:.*Mask:/{s,.*Mask:\([^ \t]*\).*,\1,;p}'` + + # note: loopback interface has null 'int_broadcast' value + [ -z "$int_ip" -o -z "$int_netmask" ] && return 1 + + int_static_ip=1 + # this check was written to avoid backward compatibility issues + if [ -r $network_devices/ifconfig.$int_name ]; then + if grep -Eq "^BOOTPROTO=dhcp" $network_devices/ifconfig.$int_name; then + int_static_ip=0 + fi + fi + + calculate_ip_parameters "$int_ip" "$int_netmask" + int_network=$network + + return 0 +} diff --git a/etc/rc.d/init.d/random b/etc/rc.d/init.d/random new file mode 100755 index 0000000..09d6d37 --- /dev/null +++ b/etc/rc.d/init.d/random @@ -0,0 +1,49 @@ +#!/bin/sh +# random - save system entropy pool at shutdown and reload it at boot time +# to increase the quality of random number generation + +[ -c /dev/urandom ] || exit 0 + +. /etc/sysconfig/rc +. $rc_functions + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +RANDOMSEED=/var/lib/misc/random-seed +POOLSIZE=512 +[ -r /proc/sys/kernel/random/poolsize ] && POOLSIZE="$(cat /proc/sys/kernel/random/poolsize)" + +case "$1" in + start) + echo -n $"Initializing random number generator: " + if [ -f $RANDOMSEED ]; then + cat $RANDOMSEED > /dev/urandom + else + touch $RANDOMSEED + fi + chmod 600 $RANDOMSEED + dd if=/dev/urandom of=$RANDOMSEED count=1 bs=$POOLSIZE >/dev/null 2>&1 + evaluate_retval + echo + ;; + stop) + echo -n $"Saving random seed: " + touch $RANDOMSEED + chmod 600 $RANDOMSEED + dd if=/dev/urandom of=$RANDOMSEED count=1 bs=$POOLSIZE >/dev/null 2>&1 + evaluate_retval + echo + ;; + status) + echo -n $"Checking for random generator: " + echo_success + echo + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + *) echo "Usage: $0 start|stop|status" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/rc b/etc/rc.d/init.d/rc new file mode 100755 index 0000000..f4dfb0d --- /dev/null +++ b/etc/rc.d/init.d/rc @@ -0,0 +1,143 @@ +#!/bin/sh +# rc - Main Run Level Control Script +# +# Copyright (c) 2003-2011 by Silvan Calarco +# Copyright (c) 2003-2009,2011 by Davide Madrisan + +. /etc/sysconfig/rc + +if [ -r $rc_base/init.d/rc.embedded ]; then + . $rc_base/init.d/rc.embedded + exit 0 +fi + +. $rc_functions +. /etc/sysconfig/i18n + +LC_ALL=$LANG +TEXTDOMAIN=initscripts +TEXTDOMAINDIR=/usr/share/locale/ + +HOME="/root"; export HOME + +trap "" SIGINT SIGQUIT SIGTSTP + +# detect kernel command line parameters +# $CMDLINE is exported from mkinitramfs +[ -z "$CMDLINE" ] && CMDLINE="`cat /proc/cmdline 2>/dev/null`" + +debug=0 +for cmd in $CMDLINE; do + case "$cmd" in + debug) debug=1 ;; + debug=*) debug=${cmd/debug=/} ;; + multithread=*) multithread=${cmd/multithread=/} ;; + esac +done + +[ $debug -gt 0 ] && MAKEADD="DEBUG=1" + +# set current (new) and previous runlevels +runlevel=$1; export runlevel +previous=${PREVLEVEL:-N} +rex="[0-9][0-9]" + +[ "$runlevel" ] || + { echo "Usage: $0 " >&2; exit 1; } + +[ -d $rc_base/rc$runlevel.d ] || + { echo $"$rc_base/rc$runlevel.d does not exist" >&2; exit 1; } + +[ "$previous" = "$runlevel" ] && exit 0 + +export RUNLEVEL + +[ "$previous" != "N" ] && progressbase=10 || progressbase=65 + +if [ "$runlevel" = "0" -o "$runlevel" = "6" ]; then + $PLYMOUTHD --attach-to-session + $PLYMOUTH --show-splash + if [ "$runlevel" = "0" ]; then + $PLYMOUTH message --text=$"System shutting down, please wait..." + else + $PLYMOUTH message --text=$"System rebooting, please wait..." + fi +else + $PLYMOUTH message --text=$"Starting services..." +fi + +$PLYMOUTH update --status=$progressbase + +allservicesnum=`ls -1 $rc_base/rc$runlevel.d/[S,K]* 2>/dev/null | wc -l` + +if [ "$previous" != "N" ]; then + if [ "$multithread" = "1" ]; then + /bin/echo -e $"Stopping runlevel $runlevel services...""\r" >&2 + make -C /var/init --no-print-directory -i -j -f /var/init/runlevel.mk \ + JOB=stop \ + PROGRESS_TOT=${allservicesnum} \ + PROGRESS_BASE=${progressbase} \ + ALLSERVICESNUM=$allservicesnum $MAKEADD + else + i=0 + for servicefile in `ls $rc_base/rc$runlevel.d/K* 2>/dev/null`; do + check_link $servicefile && + { service=${servicefile#$rc_base/rc$runlevel.d/K$rex} + prev_start=$rc_base/rc$previous.d/S$rex$service + sysinit_start=$rc_base/rcsysinit.d/S$rex$service + + if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]; then + [ ! -f $prev_start ] && [ ! -f $sysinit_start ] && continue + fi + + progress=`expr $progressbase + $i \* \( 100 - $progressbase \) / ${allservicesnum}` + $PLYMOUTH update --status=$progress + $servicefile stop + i=`expr $i + 1` + } + done + [ "$progress" ] && progressbase=$progress + fi +fi + +if [ "$multithread" = "1" ]; then + /bin/echo -e $"Starting runlevel $runlevel services...""\r" >&2 + + # recreate multithreaded dependencies + depinit >/dev/null 2>&1 + + # now start multithreaded init + rm -f /var/lock/subsys/local + make -C /var/init --no-print-directory -i -j -k -f /var/init/runlevel.mk \ + JOB=start \ + PROGRESS_TOT=${allservicesnum} \ + PROGRESS_BASE=${progressbase} \ + $MAKEADD 2>/dev/null & + while [ ! -e /var/lock/subsys/local ]; do + [ "`jobs`" ] || break + sleep 1 + done +else + i=0 + for servicefile in `ls $rc_base/rc$runlevel.d/S* 2> /dev/null`; do + check_link $servicefile || { i=`expr $i + 1`; continue; } + + if [ "$previous" != "N" ]; then + service=${servicefile#$rc_base/rc$runlevel.d/S$rex} + stop=$rc_base/rc$runlevel.d/K$rex$service + prev_start=$rc_base/rc$previous.d/S$rex$service + + [ -f $prev_start ] && [ ! -f $stop ] && continue + fi + + progress=`expr $progressbase + $i \* \( 100 - $progressbase \) / ${allservicesnum}` + $PLYMOUTH update --status=$progress + $servicefile start + i=`expr $i + 1` + done +fi + +[ "$runlevel" = "5" ] || chvt 1 + +#$PLYMOUTH message --text=$"System up and running" +$PLYMOUTH quit diff --git a/etc/rc.d/init.d/rc.local b/etc/rc.d/init.d/rc.local new file mode 100755 index 0000000..11712c1 --- /dev/null +++ b/etc/rc.d/init.d/rc.local @@ -0,0 +1,6 @@ +#!/bin/sh +# +# rc.local - This script will be executed at the end of the init process as the +# last service and may be modified by the system administrator for its +# own purposes. This is a startup script only. + diff --git a/etc/rc.d/init.d/rc.sysinit b/etc/rc.d/init.d/rc.sysinit new file mode 100755 index 0000000..8c6f08f --- /dev/null +++ b/etc/rc.d/init.d/rc.sysinit @@ -0,0 +1,104 @@ +#!/bin/sh +# rc.sysinit - System initialization control script + +# Copyright (c) 2008-2011 by Silvan Calarco +# Modified by Davide Madrisan +# + +. /etc/sysconfig/rc + +# first look for an embedded rc.sysinit +if [ -r $rc_base/init.d/rc.sysinit.embedded ]; then + . $rc_base/init.d/rc.sysinit.embedded + exit 0 +fi + +. $rc_functions +. /etc/sysconfig/i18n +LC_ALL=$LANG +TEXTDOMAIN=initscripts +TEXTDOMAINDIR=/usr/share/locale/ + +trap "" SIGINT SIGQUIT SIGTSTP + +runlevel=sysinit +rex="[0-9][0-9]" + +# detect kernel command line parameters +# $CMDLINE may be exported from mkinitramfs +[ "$CMDLINE" ] || { + [ -e /proc/cmdline ] || { + mount -n -t proc proc /proc + fin=/proc/cmdline + } + [ "$fin" -a -e $fin ] && CMDLINE="`cat $fin`" || CMDLINE="" +} + +debug=0 # debug must be defined +for cmd in $CMDLINE; do + case "$cmd" in + debug) debug=1 ;; + debug=*) debug=${cmd/debug=/} ;; + esac +done + +[ $debug -gt 0 ] && logfile="/dev/console" + +[ $logfile ] || { + logfile="/dev/.sysinit.start" +} + +if [ ! -d $rc_base/rc$runlevel.d ]; then + echo $"$rc_base/rc$runlevel.d does not exist" + exit 1 +fi + +> $logfile + +# set dns-resolving safe hostname for sysinit to successfully run +hostname localhost + +startservices="`ls -1 $rc_base/rc$runlevel.d/S* 2>/dev/null`" +startservicesnum=`echo $startservices | wc -w` + +i=0 +for servicefile in $startservices; do + if [ "$previous" != "N" ]; then + service=${servicefile#$rc_base/rc$runlevel.d/S$rex} + stop=$rc_base/rc$runlevel.d/K$rex$service + prev_start=$rc_base/rc$previous.d/S$rex$service + [ -f "$prev_start" ] && [ ! -f "$stop" ] && continue + fi + check_link $servicefile || continue + [ -x /bin/date ] && + echo $"Begin sysinit $service at `/bin/date`" >> $logfile + progress=`expr 5 + $i \* 45 / $startservicesnum` + + $PLYMOUTH update --status="$progress" + + if [ "$service" = "postplug" ]; then + $servicefile start + else + $servicefile start >> $logfile 2>&1 + fi + error_value=$? + if [ $error_value -ne 0 ]; then + echo " +You should not be reading this error message. +It means that an unforseen error took place in $servicefile, +which exited with a return value of $error_value +" >> $logfile + fi + + [ -x /bin/date ] && + echo $"End sysinit $service at `/bin/date`" >> $logfile + + i=`expr $i + 1` +done + +# rootfs should now be mounted rw, we can move logs there and umount tmpfs... +mv $logfile /var/log/initd.sysinit.start + +# ...and remove garbage temp files +rm -f /tmp/.runlevel.start.* 2>/dev/null +rm -f /var/lock/subsys/local diff --git a/etc/rc.d/init.d/reboot b/etc/rc.d/init.d/reboot new file mode 100755 index 0000000..216a489 --- /dev/null +++ b/etc/rc.d/init.d/reboot @@ -0,0 +1,23 @@ +#!/bin/sh +# reboot - System Reboot + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +case "$1" in + start) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + reboot -d -f -i + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/etc/rc.d/init.d/sendsignals b/etc/rc.d/init.d/sendsignals new file mode 100755 index 0000000..28882f2 --- /dev/null +++ b/etc/rc.d/init.d/sendsignals @@ -0,0 +1,35 @@ +#!/bin/sh +# sendsignals - Sendsignals Script +# +# Based on sendsignals script from LFS-3.1 and earlier. +# Rewritten by Gerard Beekmans +# Support for 2.6.x kernels by Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions + +case "${1}" in + stop) + echo -n "Sending all processes the TERM signal..." + killall5 -15 + error_value=$? + [ "$error_value" = 0 ] && echo_success || echo_failure + sleep 2 + + echo -n "Sending all processes the KILL signal: " + killall5 -9 + error_value=$? + [ "$error_value" = 0 ] && echo_success || echo_failure + sleep 2 + + #echo -n "Removing all unused modules: " + #modprobe -r + #error_value=$? + #echo + ;; + + *) + echo "Usage: ${0} {stop}" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/setclock b/etc/rc.d/init.d/setclock new file mode 100755 index 0000000..5874b6a --- /dev/null +++ b/etc/rc.d/init.d/setclock @@ -0,0 +1,44 @@ +#!/bin/sh +# setclock - setting Linux clock + +# Based on setclock script from LFS-3.1 and earlier. +# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org + +. /etc/sysconfig/rc +. $rc_functions + +[ -r /etc/sysconfig/clock ] && . /etc/sysconfig/clock + +CLOCKPARAMS="--directisa" +#CLOCKPARAMS="--systohc --directisa" + +case "$UTC" in + yes|true|1) + CLOCKPARAMS="$CLOCKPARAMS --utc" + ;; + no|false|0) + CLOCKPARAMS="$CLOCKPARAMS --localtime" + ;; +esac + +case "$1" in + start) + echo -n "Setting clock: " + hwclock --hctosys $CLOCKPARAMS + evaluate_retval + echo + ;; + stop) + echo -n "Setting clock: " + hwclock --systohc $CLOCKPARAMS + evaluate_retval + echo + ;; + status) + hwclock $CLOCKPARAMS + ;; + *) + echo "Usage: $0 {start|stop|status}" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/swap b/etc/rc.d/init.d/swap new file mode 100755 index 0000000..7d87503 --- /dev/null +++ b/etc/rc.d/init.d/swap @@ -0,0 +1,34 @@ +#!/bin/sh +# swap - swap control script +# Written by Gerard Beekmans + +. /etc/sysconfig/rc +. $rc_functions + +case "$1" in + start) + echo -n "Activating all swap files/partitions: " + swapon -a + evaluate_retval + echo + ;; + stop) + echo -n "Deactivating all swap files/partitions: " + swapoff -a + evaluate_retval + echo + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + status) + echo -n "Retrieving swap status..." + echo + swapon -s + ;; + *) echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac diff --git a/etc/rc.d/init.d/sysctl b/etc/rc.d/init.d/sysctl new file mode 100755 index 0000000..4263652 --- /dev/null +++ b/etc/rc.d/init.d/sysctl @@ -0,0 +1,14 @@ +#!/bin/sh +# sysctl - System initialization control script +# +# Written by Silvan Calarco + +. /etc/sysconfig/rc +. $rc_functions + +trap "" INT QUIT TSTP + +echo -n "Configuring kernel parameters: " +sysctl -p /etc/sysctl.conf >/dev/null 2>&1 +evaluate_retval +echo diff --git a/etc/rc.d/init.d/sysinit b/etc/rc.d/init.d/sysinit new file mode 100755 index 0000000..24c21b1 --- /dev/null +++ b/etc/rc.d/init.d/sysinit @@ -0,0 +1,89 @@ +#!/bin/sh +# sysinit - System initialization control script +# +# Copyright 2003-2010 (C) Silvan Calarco +# Copyright 2004-2007,2011 (C) Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions + +KERNELVER=`uname -r` + +trap "" INT QUIT TSTP + +if [ ! -L /dev/root ]; then + rootdev= + rootuuid= + for token in `cat /proc/cmdline 2>/dev/null`; do + set -- $token + case "$1" in + root=UUID=*) + rootuuid="${1##*=}" + [ -L /dev/disk/by-uuid/$rootuuid ] && + rootdev=$(readlink -f /dev/disk/by-uuid/$rootuuid 2>/dev/null) ;; + root=*) rootdev="${1##*=}" ;; + esac + done + + if [ -b "$rootdev" ]; then + rm -f /dev/root # to prevent duplicate entries + echo -n "Creating root device link on /dev: " + ln -s $rootdev /dev/root + evaluate_retval + echo + fi +fi + +[ -e /lib/modules/$KERNELVER ] || mkdir -p /lib/modules/$KERNELVER + +if [ ! "$no_auto_depmod" ]; then + DEPMOD_NEEDED="`find /lib/modules/$KERNELVER -type d -cnewer /lib/modules/$KERNELVER/modules.dep`" + if [ "$DEPMOD_NEEDED" -o ! -s /lib/modules/$KERNELVER/modules.dep ]; then + echo -n "Updating modules dependencies: " + depmod -a + evaluate_retval + echo + fi +fi + +if [ ! "$no_auto_ldconfig" ]; then + # do some tests to check if ld.so should rebuild its cache + if [ -s /etc/ld.so.cache ]; then + LIBDIRS="/lib /usr/lib /usr/local/lib" + LIB64DIRS="/lib64 /usr/lib64 /usr/local/lib64" + for DIR in $LIBDIRS $LIB64DIRS \ + `LANG=C grep -he "^/.*" \ + /etc/ld.so.conf /etc/ld.so.conf.d/* 2>/dev/null`; do + if [ -x /sbin/ldconfig -a $DIR -nt /etc/ld.so.cache ]; then + echo -n "Setting up linker cache using ldconfig: " + /sbin/ldconfig 2>&1 + evaluate_retval + echo + break + fi + done + fi +fi + +if [ -w /usr/src -a -e /usr/src/linux-$KERNELVER ]; then + echo -n "Creating current kernel sources symlink /usr/src/linux: " + [ -L /usr/src/linux ] && rm -f /usr/src/linux + ln -s linux-$KERNELVER /usr/src/linux + evaluate_retval + echo +fi + +if [ -e /boot/vmlinuz-$KERNELVER -a -w /boot ]; then + echo -n "Creating current kernel symlinks in /boot: " + if [ -e /boot/vmlinuz-$KERNELVER ]; then + [ -L /boot/vmlinuz ] && rm -f /boot/vmlinuz + ln -s vmlinuz-$KERNELVER /boot/vmlinuz + fi + + if [ -e /boot/initramfs-$KERNELVER.img ]; then + [ -L /boot/initramfs.img ] && rm /boot/initramfs.img + ln -s initramfs-$KERNELVER.img /boot/initramfs.img + fi + evaluate_retval + echo +fi diff --git a/etc/rc.d/init.d/template b/etc/rc.d/init.d/template new file mode 100755 index 0000000..85301fe --- /dev/null +++ b/etc/rc.d/init.d/template @@ -0,0 +1,50 @@ +#!/bin/sh +# +# chkconfig: 2345 xx xx +# description: ... + +. /etc/sysconfig/rc +. $rc_functions + +NAME=service +DAEMON=/usr/sbin/$NAME +DAEMONPID=/var/run/$NAME.pid +DAEMONLOCK=/var/lock/subsys/$NAME +OPTIONS= + +[ -x $DAEMON ] || exit 0 + +[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME + +case "$1" in + start) + echo -n $"Starting"" $NAME: " + daemon --pidfile=$DAEMONPID $DAEMON $OPTIONS + echo + ;; + stop) + echo -n $"Stopping"" $NAME: " + killproc -p $DAEMONPID $DAEMON -TERM + echo + ;; + reload) + echo -n $"Reloading"" $NAME: " + reloadproc $DAEMON + echo + ;; + restart|force-reload) + $0 stop + sleep 1 + $0 start + ;; + condrestart) + [ -e "$DAEMONLOCK" ] && $0 restart || : + ;; + status) + statusproc $DAEMON + ;; + *) + echo $"Usage: ""/etc/init.d/$NAME {start|stop|reload|restart|force-reload|condrestart|status}" + exit 1 + ;; +esac diff --git a/etc/rc.d/rc0.d/K02setclock b/etc/rc.d/rc0.d/K02setclock new file mode 120000 index 0000000..f323d72 --- /dev/null +++ b/etc/rc.d/rc0.d/K02setclock @@ -0,0 +1 @@ +../init.d/setclock \ No newline at end of file diff --git a/etc/rc.d/rc0.d/K90random b/etc/rc.d/rc0.d/K90random new file mode 120000 index 0000000..c46cfac --- /dev/null +++ b/etc/rc.d/rc0.d/K90random @@ -0,0 +1 @@ +../init.d/random \ No newline at end of file diff --git a/etc/rc.d/rc0.d/K94sendsignals b/etc/rc.d/rc0.d/K94sendsignals new file mode 120000 index 0000000..bfd30f3 --- /dev/null +++ b/etc/rc.d/rc0.d/K94sendsignals @@ -0,0 +1 @@ +../init.d/sendsignals \ No newline at end of file diff --git a/etc/rc.d/rc0.d/K95mountfs b/etc/rc.d/rc0.d/K95mountfs new file mode 120000 index 0000000..e426ff3 --- /dev/null +++ b/etc/rc.d/rc0.d/K95mountfs @@ -0,0 +1 @@ +../init.d/mountfs \ No newline at end of file diff --git a/etc/rc.d/rc0.d/K96swap b/etc/rc.d/rc0.d/K96swap new file mode 120000 index 0000000..41a5f76 --- /dev/null +++ b/etc/rc.d/rc0.d/K96swap @@ -0,0 +1 @@ +../init.d/swap \ No newline at end of file diff --git a/etc/rc.d/rc0.d/K98localnet b/etc/rc.d/rc0.d/K98localnet new file mode 120000 index 0000000..9bcd475 --- /dev/null +++ b/etc/rc.d/rc0.d/K98localnet @@ -0,0 +1 @@ +../init.d/localnet \ No newline at end of file diff --git a/etc/rc.d/rc0.d/K99halt b/etc/rc.d/rc0.d/K99halt new file mode 120000 index 0000000..576e1ef --- /dev/null +++ b/etc/rc.d/rc0.d/K99halt @@ -0,0 +1 @@ +../init.d/halt \ No newline at end of file diff --git a/etc/rc.d/rc1.d/S13sysinit b/etc/rc.d/rc1.d/S13sysinit new file mode 120000 index 0000000..e76d9c6 --- /dev/null +++ b/etc/rc.d/rc1.d/S13sysinit @@ -0,0 +1 @@ +../init.d/sysinit \ No newline at end of file diff --git a/etc/rc.d/rc2.d/S12random b/etc/rc.d/rc2.d/S12random new file mode 120000 index 0000000..c46cfac --- /dev/null +++ b/etc/rc.d/rc2.d/S12random @@ -0,0 +1 @@ +../init.d/random \ No newline at end of file diff --git a/etc/rc.d/rc2.d/S13sysinit b/etc/rc.d/rc2.d/S13sysinit new file mode 120000 index 0000000..e76d9c6 --- /dev/null +++ b/etc/rc.d/rc2.d/S13sysinit @@ -0,0 +1 @@ +../init.d/sysinit \ No newline at end of file diff --git a/etc/rc.d/rc2.d/S99rc.local b/etc/rc.d/rc2.d/S99rc.local new file mode 120000 index 0000000..fb4ee0a --- /dev/null +++ b/etc/rc.d/rc2.d/S99rc.local @@ -0,0 +1 @@ +../init.d/rc.local \ No newline at end of file diff --git a/etc/rc.d/rc3.d/S12random b/etc/rc.d/rc3.d/S12random new file mode 120000 index 0000000..c46cfac --- /dev/null +++ b/etc/rc.d/rc3.d/S12random @@ -0,0 +1 @@ +../init.d/random \ No newline at end of file diff --git a/etc/rc.d/rc3.d/S13sysinit b/etc/rc.d/rc3.d/S13sysinit new file mode 120000 index 0000000..e76d9c6 --- /dev/null +++ b/etc/rc.d/rc3.d/S13sysinit @@ -0,0 +1 @@ +../init.d/sysinit \ No newline at end of file diff --git a/etc/rc.d/rc3.d/S99rc.local b/etc/rc.d/rc3.d/S99rc.local new file mode 120000 index 0000000..fb4ee0a --- /dev/null +++ b/etc/rc.d/rc3.d/S99rc.local @@ -0,0 +1 @@ +../init.d/rc.local \ No newline at end of file diff --git a/etc/rc.d/rc4.d/S13sysinit b/etc/rc.d/rc4.d/S13sysinit new file mode 120000 index 0000000..e76d9c6 --- /dev/null +++ b/etc/rc.d/rc4.d/S13sysinit @@ -0,0 +1 @@ +../init.d/sysinit \ No newline at end of file diff --git a/etc/rc.d/rc4.d/S99rc.local b/etc/rc.d/rc4.d/S99rc.local new file mode 120000 index 0000000..fb4ee0a --- /dev/null +++ b/etc/rc.d/rc4.d/S99rc.local @@ -0,0 +1 @@ +../init.d/rc.local \ No newline at end of file diff --git a/etc/rc.d/rc5.d/S12random b/etc/rc.d/rc5.d/S12random new file mode 120000 index 0000000..c46cfac --- /dev/null +++ b/etc/rc.d/rc5.d/S12random @@ -0,0 +1 @@ +../init.d/random \ No newline at end of file diff --git a/etc/rc.d/rc5.d/S13sysinit b/etc/rc.d/rc5.d/S13sysinit new file mode 120000 index 0000000..e76d9c6 --- /dev/null +++ b/etc/rc.d/rc5.d/S13sysinit @@ -0,0 +1 @@ +../init.d/sysinit \ No newline at end of file diff --git a/etc/rc.d/rc5.d/S99rc.local b/etc/rc.d/rc5.d/S99rc.local new file mode 120000 index 0000000..fb4ee0a --- /dev/null +++ b/etc/rc.d/rc5.d/S99rc.local @@ -0,0 +1 @@ +../init.d/rc.local \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K02setclock b/etc/rc.d/rc6.d/K02setclock new file mode 120000 index 0000000..f323d72 --- /dev/null +++ b/etc/rc.d/rc6.d/K02setclock @@ -0,0 +1 @@ +../init.d/setclock \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K90random b/etc/rc.d/rc6.d/K90random new file mode 120000 index 0000000..c46cfac --- /dev/null +++ b/etc/rc.d/rc6.d/K90random @@ -0,0 +1 @@ +../init.d/random \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K94sendsignals b/etc/rc.d/rc6.d/K94sendsignals new file mode 120000 index 0000000..bfd30f3 --- /dev/null +++ b/etc/rc.d/rc6.d/K94sendsignals @@ -0,0 +1 @@ +../init.d/sendsignals \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K95mountfs b/etc/rc.d/rc6.d/K95mountfs new file mode 120000 index 0000000..e426ff3 --- /dev/null +++ b/etc/rc.d/rc6.d/K95mountfs @@ -0,0 +1 @@ +../init.d/mountfs \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K96swap b/etc/rc.d/rc6.d/K96swap new file mode 120000 index 0000000..41a5f76 --- /dev/null +++ b/etc/rc.d/rc6.d/K96swap @@ -0,0 +1 @@ +../init.d/swap \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K97network b/etc/rc.d/rc6.d/K97network new file mode 120000 index 0000000..27f4143 --- /dev/null +++ b/etc/rc.d/rc6.d/K97network @@ -0,0 +1 @@ +../init.d/network \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K98localnet b/etc/rc.d/rc6.d/K98localnet new file mode 120000 index 0000000..9bcd475 --- /dev/null +++ b/etc/rc.d/rc6.d/K98localnet @@ -0,0 +1 @@ +../init.d/localnet \ No newline at end of file diff --git a/etc/rc.d/rc6.d/K99reboot b/etc/rc.d/rc6.d/K99reboot new file mode 120000 index 0000000..a28e7a4 --- /dev/null +++ b/etc/rc.d/rc6.d/K99reboot @@ -0,0 +1 @@ +../init.d/reboot \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S10mountproc b/etc/rc.d/rcsysinit.d/S10mountproc new file mode 120000 index 0000000..a8dad52 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S10mountproc @@ -0,0 +1 @@ +../init.d/mountproc \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S20localnet b/etc/rc.d/rcsysinit.d/S20localnet new file mode 120000 index 0000000..9bcd475 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S20localnet @@ -0,0 +1 @@ +../init.d/localnet \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S22sysctl b/etc/rc.d/rcsysinit.d/S22sysctl new file mode 120000 index 0000000..e22edff --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S22sysctl @@ -0,0 +1 @@ +../init.d/sysctl \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S30loadmodules b/etc/rc.d/rcsysinit.d/S30loadmodules new file mode 120000 index 0000000..ee7f874 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S30loadmodules @@ -0,0 +1 @@ +../init.d/loadmodules \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S45setclock b/etc/rc.d/rcsysinit.d/S45setclock new file mode 120000 index 0000000..f323d72 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S45setclock @@ -0,0 +1 @@ +../init.d/setclock \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S50checkfs b/etc/rc.d/rcsysinit.d/S50checkfs new file mode 120000 index 0000000..d8e737c --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S50checkfs @@ -0,0 +1 @@ +../init.d/checkfs \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S55mountfs b/etc/rc.d/rcsysinit.d/S55mountfs new file mode 120000 index 0000000..e426ff3 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S55mountfs @@ -0,0 +1 @@ +../init.d/mountfs \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S60cleanfs b/etc/rc.d/rcsysinit.d/S60cleanfs new file mode 120000 index 0000000..dec3be1 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S60cleanfs @@ -0,0 +1 @@ +../init.d/cleanfs \ No newline at end of file diff --git a/etc/rc.d/rcsysinit.d/S75swap b/etc/rc.d/rcsysinit.d/S75swap new file mode 120000 index 0000000..41a5f76 --- /dev/null +++ b/etc/rc.d/rcsysinit.d/S75swap @@ -0,0 +1 @@ +../init.d/swap \ No newline at end of file diff --git a/etc/sysconfig/clock b/etc/sysconfig/clock new file mode 100644 index 0000000..d7db339 --- /dev/null +++ b/etc/sysconfig/clock @@ -0,0 +1,4 @@ +# UTC=0: Hardware clock is syncronized with local system clock +# UTC=1: Hardware clock is syncronized with UTC universal time + +UTC=0 diff --git a/etc/sysconfig/i18n b/etc/sysconfig/i18n new file mode 100644 index 0000000..e69de29 diff --git a/etc/sysconfig/keyboard b/etc/sysconfig/keyboard new file mode 100644 index 0000000..e69de29 diff --git a/etc/sysconfig/network b/etc/sysconfig/network new file mode 100644 index 0000000..e552cd6 --- /dev/null +++ b/etc/sysconfig/network @@ -0,0 +1,5 @@ +NETWORKING=yes +HOSTNAME=ombox +#GATEWAY=10.10.10.254 +#GATEWAY_IF=eth0 +#WIRELESS_WPA_SUPPLICANT=1 \ No newline at end of file diff --git a/etc/sysconfig/network-devices/ifdown b/etc/sysconfig/network-devices/ifdown new file mode 120000 index 0000000..577594b --- /dev/null +++ b/etc/sysconfig/network-devices/ifdown @@ -0,0 +1 @@ +/sbin/ifdown \ No newline at end of file diff --git a/etc/sysconfig/network-devices/ifup b/etc/sysconfig/network-devices/ifup new file mode 120000 index 0000000..5e1e137 --- /dev/null +++ b/etc/sysconfig/network-devices/ifup @@ -0,0 +1 @@ +/sbin/ifup \ No newline at end of file diff --git a/etc/sysconfig/network-devices/ifup-routes b/etc/sysconfig/network-devices/ifup-routes new file mode 100644 index 0000000..c1180bd --- /dev/null +++ b/etc/sysconfig/network-devices/ifup-routes @@ -0,0 +1,15 @@ +#!/bin/sh +# adds static routes which go through device $1 + +DEVICE="$1" + +if [ -z "${DEVICE}" ]; then + echo $"usage: ifup-routes " + exit 1 +fi + +[ -r /etc/sysconfig/static-routes ] || exit 0 + +grep -v "^#\|^[ \t]*$" /etc/sysconfig/static-routes | while read dev args; do + [ "$dev" = "${DEVICE}" ] && /sbin/route add ${args} dev ${dev} +done diff --git a/etc/sysconfig/network-devices/ifup-wireless b/etc/sysconfig/network-devices/ifup-wireless new file mode 100644 index 0000000..b7c7919 --- /dev/null +++ b/etc/sysconfig/network-devices/ifup-wireless @@ -0,0 +1,146 @@ +#!/bin/sh +# Copyright (c) 2003-2009 by Silvan Calarco +# Copyright (c) 2003-2009 by Davide Madrisan + +# Only meant to be called from ifup. + +unset WIRELESS_OPTS WIRELESS_OPTS2 + +if [ "$WIRELESS_ESSID" ]; then + tmpfile=`tempfile` + tmpfile1=`tempfile` + + if [ "$tmpfile" ]; then + ifconfig ${DEVICE} up +# sleep 1 + unset vname found_essid + # Note: iwlist scan essid option does not work with all drivers (see man iwlist) + # so we split cell information below + iwlist ${DEVICE} scan essid $WIRELESS_ESSID > $tmpfile + # Note: sometimes iwlist scan fails with "Device or resource busy", so we try again + [ -s $tmpfile ] || { + ifconfig ${DEVICE} down + ifconfig ${DEVICE} up + iwlist ${DEVICE} scan essid $WIRELESS_ESSID > $tmpfile + } + cat $tmpfile | \ + while read line; do + if [ "${line:0:5}" = "Cell " ]; then + [ "$found_essid" ] && break || > $tmpfile1 + fi + echo $line >> $tmpfile1 + [ "$line" = "ESSID:\"$WIRELESS_ESSID\"" ] && found_essid=1 + done + > $tmpfile + cat $tmpfile1 | \ + while read line; do + vname=${line/:*} + if [ "${line:0:4}" = "Cell" ]; then + vname="${line/* }" + vval=${line/*Address:} + vname="Address" + elif [ "${line/Unknown:}" != "$line" ]; then + continue + else + vname=${line/:*} + vname=`echo ${vname} | tr ' ' _` + vname=${vname/_(1)} + vval=${line/*:} + fi + vname=WIRELESS_AUTO_${vname/* } + vval=${vval/ } + vval=\"${vval/GHz*}\" + if [ "$vname" = "WIRELESS_AUTO_Mode" -o "$vname" = "WIRELESS_AUTO_Channel" -o \ + "$vname" = "WIRELESS_AUTO_Address" -o "$vname" = "WIRELESS_AUTO_Frequency" -o \ + "$vname" = "WIRELESS_AUTO_IE" -o "$vname" = "WIRELESS_AUTO_Group_Cipher" -o \ + "$vname" = "WIRELESS_AUTO_Pairwise_Ciphers" -o "$vname" = "WIRELESS_AUTO_Authentication_Suites" ]; then + echo $vname=$vval >> $tmpfile + fi + done + . $tmpfile + rm -f $tmpfile $tmpfile1 + else + echo "Warning: unable to create temporary file; skipping wireless autodetection" + fi +fi + +if [ "$WIRELESS_MODE" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS mode $WIRELESS_MODE" + #elif [ "$WIRELESS_AUTO_MODE" ]; then + # WIRELESS_OPTS="$WIRELESS_OPTS mode $WIRELESS_AUTO_Mode" + #else + #WIRELESS_OPTS="$WIRELESS_OPTS mode managed" +fi +if [ ! "$WIRELESS_ENCMODE" ]; then + WIRELESS_ENCMODE="open" +fi +if [ "$WIRELESS_ESSID" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS essid $WIRELESS_ESSID" +fi +if [ "$WIRELESS_NWID" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS nwid $WIRELESS_NWID" +fi +if [ "$WIRELESS_CHANNEL" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS channel $WIRELESS_CHANNEL" +elif [ "$WIRELESS_AUTO_Channel" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS channel $WIRELESS_AUTO_Channel" +fi +if [ "$WIRELESS_FREQUENCY" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS freq $WIRELESS_FREQUENCY" +elif [ "$WIRELESS_AUTO_Frequency" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS freq ${WIRELESS_AUTO_Frequency}G" +fi +if [ "$WIRELESS_AP" ]; then + WIRELESS_OPTS2="$WIRELESS_OPTS2 ap $WIRELESS_AP" +elif [ "$WIRELESS_AUTO_Address" ]; then + WIRELESS_OPTS2="$WIRELESS_OPTS2 ap $WIRELESS_AUTO_Address" +fi +if [ "$WIRELESS_FREQ" ]; then + WIRELESS_OPTS2="$WIRELESS_OPTS2 freq $WIRELESS_FREQ" +fi +if [ "$WIRELESS_RATE" ]; then + WIRELESS_OPTS2="$WIRELESS_OPTS2 rate $WIRELESS_RATE" +fi +# Note: WIRELESS_ENC must appear as the last option +if [ "$WIRELESS_ENC" -a "${WIRELESS_AUTO_IE:0:3}" != "WPA" ]; then + WIRELESS_OPTS="$WIRELESS_OPTS key $WIRELESS_ENCMODE $WIRELESS_ENC" +fi + +if [ "$WIRELESS_ESSID" -o "$WIRELESS_ENC" ]; then + echo -n "Setting wireless options for ${DEVICE}: " + ifconfig ${DEVICE} down + iwconfig ${DEVICE} $WIRELESS_OPTS + if [ "$WIRELESS_OPTS2" ]; then + iwconfig ${DEVICE} $WIRELESS_OPTS2 + fi + evaluate_retval + echo + + if [ "${WIRELESS_AUTO_IE:0:3}" == "WPA" -a ! -e /var/run/wpa_supplicant/${DEVICE} ]; then + echo -n "Setting WPA options for ${DEVICE}: " + [ "$WIRELESS_AUTO_Authentication_Suites" ] || WIRELESS_AUTO_Authentication_Suites=PSK + [ "$WIRELESS_AUTO_Pairwise_Ciphers" ] || WIRELESS_AUTO_Pairwise_Ciphers=TKIP + [ "$WIRELESS_AUTO_Group_Cipher" ] || WIRELESS_AUTO_Group_Cipher=TKIP + if [ "${WIRELESS_ENC:0:2}" = "s:" ]; then + WPA_PSK=\"${WIRELESS_ENC/s:}\" + else + WPA_PSK=${WIRELESS_ENC} + fi + tmpfile1=`tempfile` + cat >> $tmpfile1 << _EOF +ctrl_interface=/var/run/wpa_supplicant +network={ +scan_ssid=0 +ssid="$WIRELESS_ESSID" +proto=WPA +key_mgmt=WPA-$WIRELESS_AUTO_Authentication_Suites +pairwise=$WIRELESS_AUTO_Pairwise_Ciphers +group=$WIRELESS_AUTO_Group_Cipher +psk=$WPA_PSK +} +_EOF + wpa_supplicant -Dwext -i${DEVICE} -c $tmpfile1 -B + evaluate_retval + echo + fi +fi diff --git a/etc/sysconfig/proxy b/etc/sysconfig/proxy new file mode 100644 index 0000000..c2557e9 --- /dev/null +++ b/etc/sysconfig/proxy @@ -0,0 +1,11 @@ +# System proxy configuration file + +# Here some examples: + +# http_proxy=http://proxy.example.com:8080 +# https_proxy=http://proxy.example.com:8080 +# ftp_proxy=http://proxy.example.com:8080 + +# http_proxy=http://domain\\user:password@proxy.example.com:8080 +# https_proxy=http://domain\\user:password@proxy.example.com:8080 +# ftp_proxy=http://domain\\user:password@proxy.example.com:8080 diff --git a/etc/sysconfig/rc b/etc/sysconfig/rc new file mode 100644 index 0000000..f0e52e5 --- /dev/null +++ b/etc/sysconfig/rc @@ -0,0 +1,15 @@ +rc_base=/etc/rc.d +rc_functions=$rc_base/init.d/functions +rc_networkfunctions=$rc_base/init.d/network-functions + +network_devices=/etc/sysconfig/network-devices + +# multithread = 0: enable standard PosiX SysV5 init +# multithread = 1: enable fast openamba multithreaded init +multithread=1 + +# disable automatic module deps update +#no_auto_depmod=1 + +# disable automatic ldconfig update +#no_auto_ldconfig=1 diff --git a/etc/sysconfig/static-routes b/etc/sysconfig/static-routes new file mode 100644 index 0000000..0b92fbd --- /dev/null +++ b/etc/sysconfig/static-routes @@ -0,0 +1,7 @@ +# Static routes to be added by the network service script +# +# syntax: +# +# int route-options +# wlan0 -net 20.1.2.0/24 gw 192.168.1.254 +# eth1 -host 20.1.2.3 gw 192.168.1.1 diff --git a/etc/sysctl.conf b/etc/sysctl.conf new file mode 100644 index 0000000..ad15bbb --- /dev/null +++ b/etc/sysctl.conf @@ -0,0 +1,39 @@ +# +# Kernel sysctl configuration file +# +# /etc/sysctl.conf - Configuration file for setting system variables +# See sysctl(8) and sysctl.conf (5) for more details. + +# Enable IP packet forwarding between interfaces (act as a firewall, or router) +#net.ipv4.ip_forward = 1 + +# Disable ICMP redirect messages +net.ipv4.conf.all.accept_redirects = 0 + +# Do not accept source routing +net.ipv4.conf.all.accept_source_route = 0 + +# Log packages that have source addresses with no known route ("martians") +net.ipv4.conf.all.log_martians = 1 + +# Controls source route verification +net.ipv4.conf.all.rp_filter = 1 + +# Enable ECN (Explicit Congestion Notification) in TCP connections +#net.ipv4.tcp_ecn = 1 + +# Enable syncookies to hosts when the kernels syn backlog queue is overflowed +net.ipv4.tcp_syncookies = 1 + +# Ignore ICMP messages sent to broadcast or multicast addresses +net.ipv4.icmp_echo_ignore_broadcasts = 1 + +# Do not log bogus responses to broadcast frames send by hosts that ignore RFC 1122 +#net.ipv4.icmp_ignore_bogus_error_responses = 1 + +# Controls the System Request debugging functionality of the kernel +# kernel.sysrq = 0 + +# Controls whether core dumps will append the PID to the core filename. +# Useful for debugging multi-threaded applications. +kernel.core_uses_pid = 1 diff --git a/po/es.po b/po/es.po new file mode 100644 index 0000000..577e336 --- /dev/null +++ b/po/es.po @@ -0,0 +1,48 @@ +# French messages for openmamba initscripts +# Copyright (C) 2006 Stefano Brugiolo +# Copyright (C) 2009 Silvan Calarco +# Copyright (C) 2009 Natalia Garcia Morales +# This file is distributed under the same license as the openmamba distribution. + +#: initscripts +msgid "System booting, please wait..." +msgstr "Iniciando el sistema, espere por favor..." +# +msgid "Checking file systems..." +msgstr "Control de los archivos de sistema..." +# +msgid "Checking file systems...done" +msgstr "Control de los archivos de sistema...completado" +# +msgid "Checking file systems...fixed" +msgstr "Control de los archivos de sistema...errores corregidos" +# +msgid "Checking file systems...rebooting" +msgstr "Control de los archivos de sistema...reinicio" +# +msgid "Checking file systems...unfixable errors" +msgstr "Control de los archivos de sistema...errores no corregibles" +# +msgid "Checking file systems...operational error!" +msgstr "Control de los archivos de sistema...error operativo!" +# +msgid "Starting services..." +msgstr "Iniciando los servicios..." +# +msgid "System rebooting, please wait..." +msgstr "Reiniciando el sistema, espere por favor..." +# +msgid "System shutting down, please wait..." +msgstr "Cerrando el sistema, espere por favor..." +# +msgid "Stopping runlevel $runlevel services..." +msgstr "Parando los servicios de runlevel $runlevel..." +# +msgid "Starting runlevel $runlevel services..." +msgstr "Iniciando los servicios de runlevel $runlevel..." +# +msgid "Starting graphical environment..." +msgstr "Iniciando el ambiente grafico..." +# +msgid "System up and running" +msgstr "Sistema activo y en ejecucion" diff --git a/po/es.po~ b/po/es.po~ new file mode 100644 index 0000000..0460095 --- /dev/null +++ b/po/es.po~ @@ -0,0 +1,30 @@ +# French messages for openmamba initscripts +# Copyright (C) 2006 Stefano Brugiolo +# Copyright (C) 2009 Silvan Calarco +# Copyright (C) 2009 Natalia Garcia Morales +# This file is distributed under the same license as the openmamba distribution. + +#: initscripts +msgid "System booting, please wait..." +msgstr "Iniciando el sistema, espere por favor..." +# +msgid "Starting services..." +msgstr "Iniciando los servicios..." +# +msgid "System rebooting, please wait..." +msgstr "Reiniciando el sistema, espere por favor..." +# +msgid "System shutting down, please wait..." +msgstr "Cerrando el sistema, espere por favor..." +# +msgid "Stopping runlevel $runlevel services..." +msgstr "Parando los servicios de runlevel $runlevel..." +# +msgid "Starting runlevel $runlevel services..." +msgstr "Iniciando los servicios de runlevel $runlevel..." +# +msgid "Starting graphical environment..." +msgstr "Iniciando el ambiente grafico..." +# +msgid "System up and running" +msgstr "Sistema activo y en ejecucion" diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 0000000..557b61e --- /dev/null +++ b/po/fr.po @@ -0,0 +1,26 @@ +# French messages for openmamba initscripts +# Copyright (C) 2006 Davide Madrisan +# Copyright (C) 2009 Silvan Calarco +# This file is distributed under the same license as the openmamba distribution. + +#: initscripts +msgid "System booting, please wait..." +msgstr "Démarrage du système en cours..." +# +msgid "Starting services..." +msgstr "Démarrage des services en cours..." +# +msgid "System rebooting, please wait..." +msgstr "Redémarrage du système en cours..." +# +msgid "System shutting down, please wait..." +msgstr "Arrête du système en cours..." +# +msgid "Stopping runlevel $runlevel services..." +msgstr "Arrête des services du niveau d'exécution $runlevel..." +# +msgid "Starting runlevel $runlevel services..." +msgstr "Démarrage des services du niveau d'exécution $runlevel..." +# +msgid "Starting graphical environment..." +msgstr "Démarrage de l'environnement graphique..." diff --git a/po/it.po b/po/it.po new file mode 100644 index 0000000..1392742 --- /dev/null +++ b/po/it.po @@ -0,0 +1,46 @@ +# Italian messages for openmamba initscripts +# Copyright (C) 2005-2009 Silvan Calarco +# This file is distributed under the same license as the openmamba distribution. + +#: initscripts +msgid "System booting, please wait..." +msgstr "Avvio in corso..." +# +msgid "Checking file systems..." +msgstr "Controllo delle partizioni..." +# +msgid "Checking file systems...done" +msgstr "Controllo delle partizioni...completato" +# +msgid "Checking file systems...fixed" +msgstr "Controllo delle partizioni...errori corretti" +# +msgid "Checking file systems...rebooting" +msgstr "Controllo delle partizioni...riavvio" +# +msgid "Checking file systems...unfixable errors" +msgstr "Controllo delle partizioni...errori non corretti" +# +msgid "Checking file systems...operational error!" +msgstr "Controllo delle partizioni...errore interno!" +# +msgid "Starting services..." +msgstr "Avvio dei servizi..." +# +msgid "System rebooting, please wait..." +msgstr "Riavvio in corso..." +# +msgid "System shutting down, please wait..." +msgstr "Spegnimento in corso..." +# +msgid "Stopping runlevel $runlevel services..." +msgstr "Si stanno fermando i servizi del runlevel $runlevel..." +# +msgid "Starting runlevel $runlevel services..." +msgstr "Avvio dei servizi del runlevel $runlevel..." +# +msgid "Starting graphical environment..." +msgstr "Avvio dell'ambiente grafico..." +# +msgid "System up and running" +msgstr "Sistema avviato ed attivo" diff --git a/sbin/depinit b/sbin/depinit new file mode 100644 index 0000000..d001fbd --- /dev/null +++ b/sbin/depinit @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Generate init.d database files required by multithreaded init system +# +# (c) 2003-2009 by Silvan Calarco - silvan.calarco@mambasoft.it + +rcldir=/var/init + +function get_runlevel_files() { + unset ALL_RUNLEVEL + runlevel=$1 + startstop=$2 + + if [ $startstop = "S" ]; then + min="$start_min" + else + min="$stop_min" + fi + + for i in $(ls -v /etc/rc$runlevel.d/$startstop* 2>/dev/null); do + #suffix=${i#/etc/rc$runlevel.d/$startstop} + service=${i#/etc/rc$runlevel.d/$startstop[0-9][0-9]} + #seqnum=${suffix:0:2} + ALL_RUNLEVEL="$ALL_RUNLEVEL $service" + done +} + +get_runlevel_files 0 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/0.start.rcl + +get_runlevel_files 1 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/1.start.rcl +cp $rcldir/1.start.rcl $rcldir/S.start.rcl + +get_runlevel_files 2 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/2.start.rcl + +get_runlevel_files 3 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/3.start.rcl + +get_runlevel_files 4 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/4.start.rcl + +get_runlevel_files 5 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/5.start.rcl + +get_runlevel_files 6 S +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/6.start.rcl + +get_runlevel_files 0 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/0.stop.rcl + +get_runlevel_files 1 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/1.stop.rcl +cp $rcldir/1.stop.rcl $rcldir/S.stop.rcl + +get_runlevel_files 2 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/2.stop.rcl + +get_runlevel_files 3 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/3.stop.rcl + +get_runlevel_files 4 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/4.stop.rcl + +get_runlevel_files 5 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/5.stop.rcl + +get_runlevel_files 6 K +echo "ALL_RUNLEVEL =$ALL_RUNLEVEL" > $rcldir/6.stop.rcl diff --git a/sbin/ifdown b/sbin/ifdown new file mode 100644 index 0000000..4ab5c26 --- /dev/null +++ b/sbin/ifdown @@ -0,0 +1,29 @@ +#!/bin/bash +# Copyright (c) 2003-2009 by Silvan Calarco +# Copyright (c) 2003-2009 by Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions + +DEVICE=${1} + +[ "${DEVICE}" ] || exit 1 + +[ -r $network_devices/ifconfig.${DEVICE} ] && + . $network_devices/ifconfig.${DEVICE} + +if [ -x $network_devices/ifdown-${DEVICE} ]; then + $network_devices/ifdown-${DEVICE} +else + if [ -r /var/run/wpa_supplicant/${DEVICE} ]; then + wpa_cli -i${DEVICE} terminate >/dev/null + fi + + if [ -r /var/run/dhclient.${DEVICE}.pid ]; then + /sbin/dhclient ${DEVICE} -r -pf /var/run/dhclient.${DEVICE}.pid + kill -9 `cat /var/run/dhclient.${DEVICE}.pid` 2>/dev/null + rm -f /var/run/dhclient.${DEVICE}.pid + fi + + /sbin/ifconfig ${DEVICE} down +fi diff --git a/sbin/ifrestart b/sbin/ifrestart new file mode 100644 index 0000000..94895a1 --- /dev/null +++ b/sbin/ifrestart @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright (c) 2005-2009 by Silvan Calarco +# +# ifrestart: restart insterface script +# +# usage: ifrestart + +[ "$1" ] || exit 1 + +/sbin/ifdown $1 +/sbin/ifup $1 diff --git a/sbin/ifup b/sbin/ifup new file mode 100644 index 0000000..331eddb --- /dev/null +++ b/sbin/ifup @@ -0,0 +1,77 @@ +#!/bin/bash +# Copyright (c) 2003-2009 by Silvan Calarco +# Copyright (c) 2003-2009 by Davide Madrisan + +. /etc/sysconfig/rc +. $rc_functions +. $rc_networkfunctions + +DEVICE=${1} + +[ "${DEVICE}" ] || exit 1 + +[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network +[ -r $network_devices/ifconfig.${DEVICE} ] && . $network_devices/ifconfig.${DEVICE} + +[ "$2" = "--udev" -a "$ONBOOT" != "yes" -a "$ONBOOT" != "1" -a "$ONBOOT" != "true" ] \ + && exit 0 + +# udev boot: exit if root filesystem is read only +[ "$2" = "--udev" -a ! -w /var/run ] && exit 0 + +if [ -x $network_devices/ifup-${DEVICE} ]; then + $network_devices/ifup-${DEVICE} + exit 0 +fi + +[ -r $network_devices/ifup-wireless ] && . $network_devices/ifup-wireless + +if [ "$BOOTPROTO" = "dhcp" ]; then + if [ ! -r /var/run/dhclient.${DEVICE}.pid ]; then + echo -n "Bringing up the ${DEVICE} interface: " + /sbin/ifconfig ${DEVICE} up + dhclient -q ${DEVICE} -nw -pf /var/run/dhclient.${DEVICE}.pid >/dev/null + evaluate_retval + echo + else + echo -n "Error: dhclient is already running for the interface" + fi +else + [ "$IPADDR" ] || IPADDR=$IP + + if [ "$IPADDR" ]; then + if [ -z "$NETMASK" ]; then + echo "\ +NETMASK variable missing in ifconfig.${DEVICE}, echo using 255.255.255.0" + NETMASK=255.255.255.0 + fi + + [ "$BROADCAST" ] || eval `/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}` + + echo -n "Bringing up the ${DEVICE} interface: " + /sbin/ifconfig ${DEVICE} $IPADDR netmask $NETMASK broadcast $BROADCAST + evaluate_retval + echo + else + # if IPADDR is missing interface is brought up anyway without address + echo -n "Bringing up the ${DEVICE} interface with no address: " + /sbin/ifconfig ${DEVICE} up + evaluate_retval + echo + fi + + if [ -n "$ETHTOOL_OPTS" ] ; then + /usr/sbin/ethtool -s ${DEVICE} $ETHTOOL_OPTS + fi + + if [[ "$GATEWAY_IF" = "${DEVICE}" && -n "$GATEWAY" ]]; then + echo -n "Setting up default gateway: " + route add default gateway $GATEWAY metric 1 dev $GATEWAY_IF + evaluate_retval + echo + fi +fi + +[ -r $network_devices/ifup-routes ] && . $network_devices/ifup-routes ${DEVICE} + +exit 0 diff --git a/sbin/service b/sbin/service new file mode 100644 index 0000000..a0defe4 --- /dev/null +++ b/sbin/service @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Simple service execution tool + +USAGE=$"Usage: ""$0 [service_name [start|stop|restart|..]]" +VERSION="${0##*/} ver. 0.61" + +INITDDIR="/etc/init.d" +SERVICE= +OPTIONS= + +if [ $# -eq 0 ]; then + echo "${USAGE}" >&2 + exit 1 +fi + +while [ $# -gt 0 ]; do + case "$1" in + --help | -h) + echo "${USAGE}" >&2 + exit 0 + ;; + --version | -V) + echo "${VERSION}" >&2 + exit 0 + ;; + *) + if [ -z "${SERVICE}" ]; then + SERVICE="${1}" + else + OPTIONS="${OPTIONS} ${1}" + fi + shift + ;; + esac +done + +if [ -x "${INITDDIR}/${SERVICE}" ]; then + env -i PATH="$PATH" TERM="$TERM" "${INITDDIR}/${SERVICE}" ${OPTIONS} +else + echo "${SERVICE}: "$"unrecognized service" >&2 + exit 1 +fi diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..b9b88ea --- /dev/null +++ b/src/Makefile @@ -0,0 +1,78 @@ +# Makefile for the initscripts tools +# Copyright (C) 2007 by Davide Madrisan +# +# Based on the Makefile provided by Fedora in the initscripts tarball + +PROGS = usernetctl doexec netreport usleep ipcalc minilogd initlog fstab-decode getkey consoletype genhostid +INITLOG_OBJS = initlog.o process.o +USLEEP_OBJS = usleep.o + +prefix = /usr +exec_prefix = ${prefix} +sysconfdir = /etc +sbindir = ${exec_prefix}/sbin +mandir = ${prefix}/share/man +localstatedir = /var + +INSTALL = /usr/bin/install +INSTALL_PROGRAM = ${INSTALL} -m 755 +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_DIR = ${INSTALL} -d -m 755 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} + +CFLAGS += $(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE + +all: $(PROGS) + +getkey: getkey.o + $(CC) $(LDFLAGS) -o $@ $< -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +initlog: $(INITLOG_OBJS) + $(CC) $(LDFLAGS) -o $@ $(INITLOG_OBJS) -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +ipcalc: ipcalc.o + $(CC) $(LDFLAGS) -o $@ $< -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +usleep: $(USLEEP_OBJS) + $(CC) $(LDFLAGS) -o $@ $(USLEEP_OBJS) -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +usernetctl.o: usernetctl.c + $(CC) $(CFLAGS) -fPIE -c usernetctl.c -o usernetctl.o + +usernetctl: usernetctl.c usernetctl.o + $(CC) $(LDFLAGS) -pie -o $@ $@.o + +install: + $(INSTALL_DIR) $(DESTDIR)/bin + $(INSTALL_DIR) $(DESTDIR)/sbin + $(INSTALL_DIR) $(DESTDIR)$(sbindir) + $(INSTALL_DIR) $(DESTDIR)$(mandir)/man{1,8} + $(INSTALL_DIR) $(DESTDIR)$(sysconfdir) + $(INSTALL_DIR) $(DESTDIR)$(localstatedir)/run/netreport/ + $(INSTALL_PROGRAM) doexec $(DESTDIR)/bin/doexec + $(INSTALL_PROGRAM) usleep $(DESTDIR)/bin/usleep + $(INSTALL_PROGRAM) ipcalc $(DESTDIR)/bin/ipcalc + $(INSTALL_PROGRAM) netreport $(DESTDIR)/sbin/netreport + $(INSTALL_PROGRAM) consoletype $(DESTDIR)/sbin/consoletype + $(INSTALL_PROGRAM) fstab-decode $(DESTDIR)/sbin/fstab-decode + $(INSTALL_PROGRAM) genhostid $(DESTDIR)/sbin/genhostid + $(INSTALL_PROGRAM) getkey $(DESTDIR)/sbin/getkey + $(INSTALL_PROGRAM) initlog $(DESTDIR)/sbin/initlog + $(INSTALL_PROGRAM) minilogd $(DESTDIR)/sbin/minilogd + $(INSTALL_PROGRAM) usernetctl $(DESTDIR)$(sbindir)/usernetctl + $(INSTALL_DATA) initlog.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) genhostid.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) doexec.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) getkey.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) netreport.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) usleep.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) ipcalc.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) consoletype.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) fstab-decode.8 $(DESTDIR)$(mandir)/man8 + $(INSTALL_DATA) usernetctl.8 $(DESTDIR)$(mandir)/man8 + $(INSTALL_DATA) initlog.conf $(DESTDIR)$(sysconfdir) +# install -m 2755 netreport $(DESTDIR)/sbin/netreport +# install -m 4755 usernetctl $(DESTDIR)$(sbindir)/usernetctl + +clean: + rm -f $(PROGS) *.o diff --git a/src/Makefile.orig b/src/Makefile.orig new file mode 100644 index 0000000..a18ce00 --- /dev/null +++ b/src/Makefile.orig @@ -0,0 +1,77 @@ +# Makefile for the initscripts tools +# Copyright (C) 2007 by Davide Madrisan +# Copyright (C) 2010 by Silvan Calarco +# +# Based on the Makefile provided by Fedora in the initscripts tarball + +PROGS = usernetctl doexec netreport usleep ipcalc minilogd initlog getkey consoletype genhostid +INITLOG_OBJS = initlog.o process.o +USLEEP_OBJS = usleep.o + +prefix = /usr +exec_prefix = ${prefix} +sysconfdir = /etc +sbindir = ${exec_prefix}/sbin +mandir = ${prefix}/share/man +localstatedir = /var + +INSTALL = /usr/bin/install +INSTALL_PROGRAM = ${INSTALL} -m 755 +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_DIR = ${INSTALL} -d -m 755 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} + +CFLAGS += $(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE + +all: $(PROGS) + +getkey: getkey.o + $(CC) $(LDFLAGS) -o $@ $< -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +initlog: $(INITLOG_OBJS) + $(CC) $(LDFLAGS) -o $@ $(INITLOG_OBJS) -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +ipcalc: ipcalc.o + $(CC) $(LDFLAGS) -o $@ $< -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +usleep: $(USLEEP_OBJS) + $(CC) $(LDFLAGS) -o $@ $(USLEEP_OBJS) -Wl,-Bstatic -lpopt -Wl,-Bdynamic + +usernetctl.o: usernetctl.c + $(CC) $(CFLAGS) -fPIE -c usernetctl.c -o usernetctl.o + +usernetctl: usernetctl.c usernetctl.o + $(CC) $(LDFLAGS) -pie -o $@ $@.o + +install: + $(INSTALL_DIR) $(DESTDIR)/bin + $(INSTALL_DIR) $(DESTDIR)/sbin + $(INSTALL_DIR) $(DESTDIR)$(sbindir) + $(INSTALL_DIR) $(DESTDIR)$(mandir)/man{1,8} + $(INSTALL_DIR) $(DESTDIR)$(sysconfdir) + $(INSTALL_DIR) $(DESTDIR)$(localstatedir)/run/netreport/ + $(INSTALL_PROGRAM) doexec $(DESTDIR)/bin/doexec + $(INSTALL_PROGRAM) usleep $(DESTDIR)/bin/usleep + $(INSTALL_PROGRAM) ipcalc $(DESTDIR)/bin/ipcalc + $(INSTALL_PROGRAM) netreport $(DESTDIR)/sbin/netreport + $(INSTALL_PROGRAM) consoletype $(DESTDIR)/sbin/consoletype + $(INSTALL_PROGRAM) genhostid $(DESTDIR)/sbin/genhostid + $(INSTALL_PROGRAM) getkey $(DESTDIR)/sbin/getkey + $(INSTALL_PROGRAM) initlog $(DESTDIR)/sbin/initlog + $(INSTALL_PROGRAM) minilogd $(DESTDIR)/sbin/minilogd + $(INSTALL_PROGRAM) usernetctl $(DESTDIR)$(sbindir)/usernetctl + $(INSTALL_DATA) initlog.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) genhostid.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) doexec.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) getkey.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) netreport.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) usleep.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) ipcalc.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) consoletype.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) usernetctl.8 $(DESTDIR)$(mandir)/man8 + $(INSTALL_DATA) initlog.conf $(DESTDIR)$(sysconfdir) +# install -m 2755 netreport $(DESTDIR)/sbin/netreport +# install -m 4755 usernetctl $(DESTDIR)$(sbindir)/usernetctl + +clean: + rm -f $(PROGS) *.o diff --git a/src/consoletype.1 b/src/consoletype.1 new file mode 100644 index 0000000..3f4ec14 --- /dev/null +++ b/src/consoletype.1 @@ -0,0 +1,39 @@ +.TH CONSOLETYPE 1 "Red Hat, Inc" "RH" \" -*- nroff -*- +.SH NAME +\fBconsoletype +\- print type of the console connected to standard input +.SH SYNOPSIS +\fBconsoletype [\fIfg\fR] +.SH DESCRIPTION +\fBconsoletype +prints the type of console connected to standard input, and checks +whether the console connected to standard input is the current +foreground virtual console. With no arguments, it prints +\fIvt\fR +if console is a virtual terminal (/dev/tty* or /dev/console device if not on +a serial console), +\fIserial\fR +if standard input is a serial console (/dev/console or /dev/ttyS*) and +\fIpty\fR +if standard input is a pseudo terminal. +.SH RETURN VALUE +\fBconsoletype +when passed no arguments returns +.TP +\fI0 +if on virtual terminal +.TP +\fI1 +if on serial console +.TP +\fI2 +if on a pseudo terminal. +.TP +When passed the \fIfg\fR argument, \fBconsoletype\fR returns +.TP +\fI0 +if the console connected to standard input is the current virtual +terminal +.TP +\fI1 +otherwise. \ No newline at end of file diff --git a/src/consoletype.c b/src/consoletype.c new file mode 100644 index 0000000..ab7e753 --- /dev/null +++ b/src/consoletype.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + unsigned char twelve = 12; + char *type; + int maj, min, ret = 0, fg = -1; + struct stat sb; + + fstat(0, &sb); + maj = major(sb.st_rdev); + min = minor(sb.st_rdev); + if (maj != 3 && (maj < 136 || maj > 143)) { + if ((fg = ioctl (0, TIOCLINUX, &twelve)) < 0) { + type = "serial"; + ret = 1; + } else { +#ifdef __powerpc__ + int fd; + char buf[65536]; + + fd = open("/proc/tty/drivers",O_RDONLY); + read(fd, buf, 65535); + if (strstr(buf,"vioconsole /dev/tty")) { + type = "vio"; + ret = 3; + } else { + type = "vt"; + ret = 0; + } +#else + type = "vt"; + ret = 0; +#endif + } + } else { + type = "pty"; + ret = 2; + } + if (argc > 1 && !strcmp(argv[1],"fg")) { + if (fg < 0 || fg != (min-1)) + return 1; + return 0; + } else { + printf("%s\n",type); + return ret; + } +} diff --git a/src/doexec.1 b/src/doexec.1 new file mode 100644 index 0000000..59b8b91 --- /dev/null +++ b/src/doexec.1 @@ -0,0 +1,12 @@ +.TH DOEXEC 1 "Red Hat Software" "RHS" \" -*- nroff -*- +.SH NAME +doexec \- run an executable with an arbitrary argv[0] +.SH SYNOPSIS +.B doexec +\fI/path/to/executable\fP \fIargv[0]\fP [\fIargv[1-n]\fP] +.SH DESCRIPTION +.B doexec +simply runs the executable with the argv list provided. It allows you +to specify an argv[0] other than the name of the executable. +.SH OPTIONS +All options are passed in the argv list to the executable being run. diff --git a/src/doexec.c b/src/doexec.c new file mode 100644 index 0000000..1b04532 --- /dev/null +++ b/src/doexec.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 1997-1999 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include + +int main(int argc, char ** argv) { + if (argc<2) return 1; + execvp(argv[1], argv + 2); + return 1; +} diff --git a/src/fstab-decode.8 b/src/fstab-decode.8 new file mode 100644 index 0000000..216dee8 --- /dev/null +++ b/src/fstab-decode.8 @@ -0,0 +1,45 @@ +.\" A man page for fstab-decode(8). +.\" +.\" Copyright (C) 2006 Red Hat, Inc. All rights reserved. +.\" +.\" This copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" GNU General Public License v.2. +.\" +.\" 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., +.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" +.\" Author: Miloslav Trmac +.TH fstab-decode 8 "May 2006" + +.SH NAME +fstab-decode \- run a command with fstab-encoded arguments + +.SH SYNOPSIS +\fB fstab-decode\fR \fICOMMAND\fR [\fIARGUMENT\fR]... + +.SH DESCRIPTION +.B fstab-decode +decodes escapes in the specified \FIARGUMENT\fRs +and uses them to run \fICOMMAND\fR. +The argument escaping uses the same rules as path escaping in +\fB/etc/fstab\fR, +.B /etc/mtab +and \fB/proc/mtab\fR. + +.SH EXIT STATUS +.B fstab-decode +exits with status 127 if +.I COMMAND +can't be run. +Otherwise it exits with the status returned by \fICOMMAND\fR. + +.SH EXAMPLES + +.B fstab-decode umount $(awk '$3 == "vfat" { print $2 }' /etc/fstab) diff --git a/src/fstab-decode.c b/src/fstab-decode.c new file mode 100644 index 0000000..4a162df --- /dev/null +++ b/src/fstab-decode.c @@ -0,0 +1,86 @@ +/* fstab-decode(8). + +Copyright (c) 2006 Red Hat, Inc. All rights reserved. + +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +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., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac */ + +#include +#include +#include +#include +#include + +/* Decode the fstab-encoded string in place. */ +static void +decode(char *s) +{ + const char *src; + char *dest; + + src = s; + dest = s; + while (*src != '\0') { + if (*src != '\\') + *dest = *src++; + else { + static const struct repl { + char orig[4]; + size_t len; + char new; + } repls[] = { +#define R(X, Y) { X, sizeof(X) - 1, Y } + R("\\", '\\'), + R("011", '\t'), + R("012", '\n'), + R("040", ' '), + R("134", '\\') +#undef R + }; + + size_t i; + + for (i = 0; i < sizeof (repls) / sizeof (repls[0]); + i++) { + if (memcmp(src + 1, repls[i].orig, + repls[i].len) == 0) { + *dest = repls[i].new; + src += 1 + repls[i].len; + goto found; + } + } + *dest = *src++; + found: + ; + } + dest++; + } + *dest = '\0'; +} + +int +main (int argc, char *argv[]) +{ + size_t i; + + if (argc < 2) { + fprintf(stderr, "Usage: fstab-decode command [arguments]\n"); + return EXIT_FAILURE; + } + for (i = 2; i < (size_t)argc; i++) + decode(argv[i]); + execvp(argv[1], argv + 1); + fprintf(stderr, "fstab-decode: %s: %s\n", argv[1], strerror(errno)); + return 127; +} diff --git a/src/genhostid.1 b/src/genhostid.1 new file mode 100644 index 0000000..436d953 --- /dev/null +++ b/src/genhostid.1 @@ -0,0 +1,12 @@ +.TH GENHOSTID 1 +.SH NAME +genhostid \- generate and set a hostid for the current host +.SH SYNOPSIS +.B genhostid + +.SH DESCRIPTION +\fBgenhostid\fR generates a random hostid and stores it in /etc/hostid, +if /etc/hostid does not already exist. + +.SH "SEE ALSO" +hostid(1), gethostid(2), sethostid(2) diff --git a/src/genhostid.c b/src/genhostid.c new file mode 100644 index 0000000..a56cad8 --- /dev/null +++ b/src/genhostid.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2003 Red Hat, Inc. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +int +main (void) +{ + struct stat st; + long int n; + if (stat ("/etc/hostid", &st) == 0 && S_ISREG (st.st_mode) + && st.st_size >= sizeof (n)) + return 0; + int fd = open ("/dev/random", O_RDONLY); + if (fd == -1 || read (fd, &n, sizeof (n)) != sizeof (n)) + { + srand48 ((long int) time (NULL) ^ (long int) getpid ()); + n = lrand48 (); + } + return sethostid (n); +} diff --git a/src/getkey.1 b/src/getkey.1 new file mode 100644 index 0000000..f6c1161 --- /dev/null +++ b/src/getkey.1 @@ -0,0 +1,80 @@ +.\" A man page for getkey(1). -*- nroff -*- +.\" +.\" Copyright (C) 2006 Red Hat, Inc. All rights reserved. +.\" +.\" This copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" GNU General Public License v.2. +.\" +.\" 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., +.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" +.\" Author: Miloslav Trmac +.TH getkey 1 "Jan 2006" + +.SH NAME +getkey \- wait until a key is pressed + +.SH SYNOPSIS +\fBgetkey\fR [\fIOPTION\fR]... [\fIKEYS\fR] + +.SH DESCRIPTION +.B getkey +waits until one of +.I KEYS +is pressed. +If +.I KEYS +are not specified, any key is accepted. +.I KEYS +are matched case-insensitive. + +.SH EXIT STATUS +.B getkey +exits with status 0 if one of the expected keys is pressed. +If invalid arguments are specified, +.B getkey +exits with status 255. +If +.B getkey +is interrupted or the wait times out, +.B getkey +exits with other non-zero status. + +.SH OPTIONS +.TP +\fB\-c\fR, \fB\-\-wait\fR \fISECONDS\fR +Wait only for +.I SECONDS +seconds. +The default is 0, which means to wait without a time limit. + +.TP +\fB\-i\fR, \fB\-\-ignore\-control\-chars\fR +Don't treat Ctrl+C and Ctrl+D specially. +When this option is not specified, these characters interrupt \fBgetkey\fR. + +.TP +\fB\-m\fR, \fB\-\-message\fR \fIMESSAGE\fR +Display +.I MESSAGE +while waiting. +The message is used as a format string in +.BR sprintf (3), +with a single argument, the number of seconds left. +Typical usage is therefore +\fB"Press a key within %d seconds to ..."\fR. +If +.I MESSAGE +contains other format string directives, the behavior is undefined and +.B getkey +may crash. + +If there is no time limit specified, +the number of seconds left is reported as 0. diff --git a/src/getkey.c b/src/getkey.c new file mode 100644 index 0000000..f3b094d --- /dev/null +++ b/src/getkey.c @@ -0,0 +1,135 @@ +/* + * Copyright (c) 1999-2003, 2006 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * getkey + * + * A very simple keygrabber. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "popt.h" + +static struct termios orig_tp; + +static void reset_term(int x) { + tcsetattr(0,TCSANOW,&orig_tp); + _exit(x); +} + +int main(int argc, char **argv) { + static const char default_list[] = ""; + + const char *list; + char *waitmessage = NULL; + char *waitprint, *waitsprint; + int waitseconds=0; + int alarmlen=0; + int ignore_control=0; + struct termios tp; + int r; + struct pollfd ufds; /* only one, no need for an array... */ + poptContext context; + struct poptOption options[] = { + { "wait", 'c', POPT_ARG_INT, &waitseconds, 0, "Number of seconds to wait for keypress", NULL }, + { "message", 'm', POPT_ARG_STRING, &waitmessage, 0, "Message to print out while waiting for string\nNOTE: The message may have a \"%d\" in it, to hold the number of seconds left to wait.", NULL }, + { "ignore-control-chars", 'i', POPT_ARG_NONE, &ignore_control, 0, "Ignore Control-C and Control-D", NULL }, + POPT_AUTOHELP + POPT_TABLEEND + }; + + context = poptGetContext("getkey", argc, (const char **)argv, options, + POPT_CONTEXT_POSIXMEHARDER); + poptSetOtherOptionHelp(context, "[keys]"); + + r = poptGetNextOpt(context); + if (r < -1) { + fprintf(stderr, "%s: %s\n", + poptBadOption(context, POPT_BADOPTION_NOALIAS), + poptStrerror(r)); + + return -1; + } + list = poptGetArg(context); + if (list != NULL) { + char *p; + + p = strdup(list); + list = p; + while (*p != 0) { + *p = toupper(*p); + p++; + } + } else + list = default_list; + if (waitseconds) { + if (waitseconds < 0) { + fprintf(stderr, "--wait: Invalid time %d seconds\n", + waitseconds); + return -1; + } + alarmlen = waitseconds; + } + + tcgetattr(0,&tp); + orig_tp = tp; + signal(SIGTERM,reset_term); + if (alarmlen != 0) { + signal(SIGALRM,reset_term); + alarm(alarmlen); + } + + tp.c_iflag=0; + tp.c_oflag &= ~OPOST; + tp.c_lflag &= ~(ISIG | ICANON); + tcsetattr(0,TCSANOW,&tp); + + ufds.events = POLLIN; + ufds.fd = 0; + + if (waitmessage) { + waitprint = alloca (strlen(waitmessage)+15); /* long enough */ + waitprint[0] = '\r'; + waitsprint = waitprint + 1; + } + + while (1) { + if (waitmessage) { + sprintf (waitsprint, waitmessage, waitseconds); + write (1, waitprint, strlen(waitprint)); + } + r = poll(&ufds, 1, alarmlen ? 1000 : -1); + if (r == 0) { + /* we have waited a whole second with no keystroke... */ + waitseconds--; + } + if (r > 0) { + char ch; + + read(0, &ch, sizeof(ch)); + ch = toupper(ch); + /* Die if we get a control-c or control-d */ + if (ignore_control == 0 && (ch == 3 || ch == 4)) + reset_term(1); + /* Don't let a null character be interpreted as a match + by strchr */ + if (ch != 0 + && (strcmp(list, "") == 0 || strchr(list, ch) != NULL)) + reset_term(0); + } + } +} diff --git a/src/initlog.1 b/src/initlog.1 new file mode 100644 index 0000000..b508b29 --- /dev/null +++ b/src/initlog.1 @@ -0,0 +1,87 @@ +.TH initlog 8 "Sun Jan 24 1999" +.SH NAME +initlog \- log messages and events to the system logger +.SH SYNOPSIS +.B initlog +[\-cefnpqrs] [\-\-cmd=ARG] [\-\-event=ARG] [\-\-facility=ARG] +[\-\-name=ARG] [\-\-priority=ARG] [\-\-run=ARG] [\-\-string=ARG] +.SH DESCRIPTION +\fBinitlog\fR logs messages and events to the system logger. +It is mainly designed for use in init scripts. initlog +reads a configuration file +.I /etc/initlog.conf +by default, to determine its settings. Any line preceded with a +.I # +is a comment, and the following configuration directives +are recognized: +.TP +.I facility +Sets the default logging facility +.TP +.I priority +Sets the default logging priority +.TP +.I ignore +Messages that match the regular expression will not be logged. +.TP +initlog behavior can also be configured by command-line options. + +\fBNote that initlog is deprecated and will be removed in a future +release.\fR + +.SS OPTIONS +.TP +.I "\-c, \-\-cmd=[program]" +Execute the specified program, logging anything output to +stdout or stderr. +.TP +.I "\-e, \-\-event=[number]" +Logs that the specified event happened. Used in conjuction +with \fB\-\-name\fR. Currently specified events are: +.PD 0 +.RS 8n +.TP 3n +.B 1 +the action completed successfully +.TP +.B 2 +the action failed +.TP +.B 3 +the action was cancelled at user request +.TP +.B 4 +the action failed due to the failure of a dependent action +.RE +.PD +.TP +.I "\-f, \-\-facility=[facility]" +Log at the specified syslog facility. The default +is \fBdaemon\fR (see syslog(3)). +.TP +.I "\-n, \-\-name=[string]" +Log the event under the specified string, such as +"inetd". +.TP +.I "\-p, \-\-priority=[priority]" +Log at the specified syslog priority. The default +is \fBnotice\fR (see syslog(3)). +.TP +.I "\-q" +Do not print the program's output, unless it exits +with a non-zero exit code. +.TP +.I "\-r, \-\-run=[program]" +Execute the specified program, with an open file +descriptor so that the program can pass back +commands to initlog. +.TP +.I "\-s, \-\-string=[string]" +Log the specified string to the logger. +.TP +.I "\-\-conf=[file]" +Specifies an alternate configuration file. +.SH FILES +.I /etc/initlog.conf +.SH "SEE ALSO" +syslog(3), logger(1) diff --git a/src/initlog.c b/src/initlog.c new file mode 100644 index 0000000..6c6630e --- /dev/null +++ b/src/initlog.c @@ -0,0 +1,446 @@ +/* + * Copyright (c) 1999-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYSLOG_NAMES +#include + +#include +#include +#include +#include + +#define _(String) gettext((String)) + +#include + +#include + +#include "initlog.h" +#include "process.h" + +static int logfacility=LOG_DAEMON; +static int logpriority=LOG_NOTICE; +static int reexec=0; +static int quiet=0; +int debug=0; + +regex_t **regList = NULL; + +static int logEntries = 0; +struct logInfo *logData = NULL; + +void readConfiguration(char *fname) { + int fd,num=0; + struct stat sbuf; + char *data,*line, *d; + regex_t *regexp; + int lfac=-1,lpri=-1; + + if ((fd=open(fname,O_RDONLY))==-1) return; + if (fstat(fd,&sbuf)) { + close(fd); + return; + } + d = data=malloc(sbuf.st_size+1); + if (read(fd,data,sbuf.st_size)!=sbuf.st_size) { + close(fd); + free(data); + return; + } + close(fd); + data[sbuf.st_size] = '\0'; + while ((line=getLine(&data))) { + if (line[0]=='#') continue; + if (!strncmp(line,"ignore ",7)) { + regexp = malloc(sizeof(regex_t)); + if (!regcomp(regexp,line+7,REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) { + regList = realloc(regList,(num+2) * sizeof(regex_t *)); + regList[num] = regexp; + regList[num+1] = NULL; + num++; + } + } + if (!strncmp(line,"facility ",9)) { + lfac=atoi(line+9); + if ((lfac == 0) && strcmp(line+9,"0")) { + int x =0; + + lfac = LOG_DAEMON; + for (x=0;facilitynames[x].c_name;x++) { + if (!strcmp(line+9,facilitynames[x].c_name)) { + lfac = facilitynames[x].c_val; + break; + } + } + } + } + if (!strncmp(line,"priority ",9)) { + lpri = atoi(line+9); + if ((lpri == 0) && strcmp(line+9,"0")) { + int x=0; + + lpri = LOG_NOTICE; + for (x=0;prioritynames[x].c_name;x++) { + if (!strcmp(line+9,prioritynames[x].c_name)) { + lpri = prioritynames[x].c_val; + break; + } + } + } + } + } + if (lfac!=-1) logfacility=lfac; + if (lpri!=-1) logpriority=lpri; + free(d); +} + +char *getLine(char **data) { + /* Get one line from data */ + /* Anything up to a carraige return (\r) or a backspace (\b) is discarded. */ + /* If this really bothers you, mail me and I might make it configurable. */ + /* It's here to avoid confilcts with fsck's progress bar. */ + char *x, *y; + + if (!*data) return NULL; + x=*data; + while (*x && (*x != '\n')) { + while (*x && (*x != '\n') && (*x != '\r') && (*x != '\b')) x++; + if (*x && (*x=='\r' || *x =='\b')) { + *data = x+1; + x++; + } + } + if (*x) { + x++; + } else { + if (x-*data) { + y=malloc(x-*data+1); + y[x-*data] = 0; + y[x-*data-1] = '\n'; + memcpy(y,*data,x-*data); + } else { + y=NULL; + } + *data = NULL; + return y; + } + y = malloc(x-*data); + y[x-*data-1] = 0; + memcpy(y,*data,x-*data-1); + *data = x; + return y; +} + +char **toArray(char *line, int *num) { + /* Converts a long string into an array of lines. */ + char **lines; + char *tmpline; + + *num = 0; + lines = NULL; + + while ((tmpline=getLine(&line))) { + if (!*num) + lines = (char **) malloc(sizeof(char *)); + else + lines = (char **) realloc(lines, (*num+1)*sizeof(char *)); + lines[*num] = tmpline; + (*num)++; + } + return lines; +} + +int trySocket() { + int s; + struct sockaddr_un addr; + + s = socket(AF_LOCAL, SOCK_DGRAM, 0); + if (s<0) + return 1; + + bzero(&addr,sizeof(addr)); + addr.sun_family = AF_LOCAL; + strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); + + if (connect(s,(struct sockaddr *) &addr,sizeof(addr))<0) { + if (errno == EPROTOTYPE || errno == ECONNREFUSED) { + DDEBUG("connect failed (EPROTOTYPE), trying stream\n"); + close(s); + s = socket(AF_LOCAL, SOCK_STREAM, 0); + if (connect(s,(struct sockaddr *) &addr, sizeof(addr)) < 0) { + DDEBUG("connect failed: %s\n",strerror(errno)); + close(s); + return 1; + } + close(s); + return 0; + } + close(s); + DDEBUG("connect failed: %s\n",strerror(errno)); + return 1; + } else { + close(s); + return 0; + } +} + +int logLine(struct logInfo *logEnt) { + /* Logs a line... somewhere. */ + int x; + struct stat statbuf; + + /* Don't log empty or null lines */ + if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0; + + + if ((stat(_PATH_LOG,&statbuf)==-1) || trySocket()) { + DDEBUG("starting daemon failed, pooling entry %d\n",logEntries); + logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo)); + logData[logEntries].fac = logEnt->fac; + logData[logEntries].pri = logEnt->pri; + logData[logEntries].cmd = strdup(logEnt->cmd); + logData[logEntries].line = strdup(logEnt->line); + logEntries++; + } else { + if (logEntries>0) { + for (x=0;xline); + openlog(logEnt->cmd,0,logEnt->fac); + syslog(logEnt->pri,"%s",logEnt->line); + closelog(); + } + return 0; +} + +int logEvent(char *cmd, int eventtype,char *string) { + char *eventtable [] = { + _("%s babbles incoherently"), + _("%s succeeded"), + _("%s failed"), + _("%s cancelled at user request"), + _("%s failed due to a failed dependency"), + /* insert more here */ + NULL + }; + int x=0,len, rc; + struct logInfo logentry; + + if (cmd) { + logentry.cmd = basename(cmd); + if ((logentry.cmd[0] =='K' || logentry.cmd[0] == 'S') && + ( logentry.cmd[1] >= '0' && logentry.cmd[1] <= '9' ) && + ( logentry.cmd[2] >= '0' && logentry.cmd[2] <= '9' ) ) + logentry.cmd+=3; + logentry.cmd = strdup(logentry.cmd); + } else + logentry.cmd = strdup(_("(none)")); + if (!string) { + string = alloca(strlen(cmd)+1); + strcpy(string,cmd); + } + + while (eventtable[x] && x= '0' && logentry.cmd[1] <= 0x39 ) && + ( logentry.cmd[2] >= '0' && logentry.cmd[2] <= 0x39 ) ) + logentry.cmd+=3; + logentry.cmd = strdup(logentry.cmd); + } else + logentry.cmd = strdup(_("")); + logentry.line = strdup(string); + logentry.pri = logpriority; + logentry.fac = logfacility; + + rc = logLine(&logentry); + free(logentry.line); + free(logentry.cmd); + return rc; +} + +int processArgs(int argc, char **argv, int silent) { + char *cmdname=NULL; + char *conffile=NULL; + int cmdevent=0; + char *cmd=NULL; + char *logstring=NULL; + char *fac=NULL,*pri=NULL; + int lfac=-1, lpri=-1; + poptContext context; + int rc; + struct poptOption optTable[] = { + POPT_AUTOHELP + { "conf", 0, POPT_ARG_STRING, &conffile, 0, + "configuration file (default: /etc/initlog.conf)", NULL + }, + { "name", 'n', POPT_ARG_STRING, &cmdname, 0, + "name of service being logged", NULL + }, + { "event", 'e', POPT_ARG_INT, &cmdevent, 0, + "event being logged (see man page)", NULL + }, + { "cmd", 'c', POPT_ARG_STRING, &cmd, 0, + "command to run, logging output", NULL + }, + { "debug", 'd', POPT_ARG_NONE, &debug, 0, + "print lots of verbose debugging info", NULL + }, + { "run", 'r', POPT_ARG_STRING, &cmd, 3, + "command to run, accepting input on open fd", NULL + }, + { "string", 's', POPT_ARG_STRING, &logstring, 0, + "string to log", NULL + }, + { "facility", 'f', POPT_ARG_STRING, &fac, 1, + "facility to log at (default: 'local7')", NULL + }, + { "priority", 'p', POPT_ARG_STRING, &pri, 2, + "priority to log at (default: 'notice')", NULL + }, + { "quiet", 'q', POPT_ARG_NONE, &quiet, 0, + "suppress stdout/stderr", NULL + }, + { 0, 0, 0, 0, 0, 0 } + }; + + context = poptGetContext("initlog", argc, argv, optTable, 0); + + while ((rc = poptGetNextOpt(context)) > 0) { + switch (rc) { + case 1: + lfac=atoi(fac); + if ((lfac == 0) && strcmp(fac,"0")) { + int x =0; + + lfac = LOG_DAEMON; + for (x=0;facilitynames[x].c_name;x++) { + if (!strcmp(fac,facilitynames[x].c_name)) { + lfac = facilitynames[x].c_val; + break; + } + } + } + break; + case 2: + lpri = atoi(pri); + if ((lpri == 0) && strcmp(pri,"0")) { + int x=0; + + lpri = LOG_NOTICE; + for (x=0;prioritynames[x].c_name;x++) { + if (!strcmp(pri,prioritynames[x].c_name)) { + lpri = prioritynames[x].c_val; + break; + } + } + } + break; + case 3: + reexec = 1; + break; + default: + break; + } + } + + if ((rc < -1)) { + if (!silent) + fprintf(stderr, "%s: %s\n", + poptBadOption(context, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); + + return -1; + } + if ( (cmd && logstring) || (cmd && cmdname) ) { + if (!silent) + fprintf(stderr, _("--cmd and --run are incompatible with --string or --name\n")); + return -1; + } + if ( cmdname && (!logstring && !cmdevent)) { + if (!silent) + fprintf(stderr, _("--name requires one of --event or --string\n")); + return -1; + } + if (cmdevent && cmd) { + if (!silent) + fprintf(stderr, _("--cmd and --run are incompatible with --event\n")); + return -1; + } + if (conffile) { + readConfiguration(conffile); + } else { + readConfiguration("/etc/initlog.conf"); + } + if (cmd) { + while (isspace(*cmd)) cmd++; + } + if (lpri!=-1) logpriority=lpri; + if (lfac!=-1) logfacility=lfac; + if (cmdevent) { + logEvent(cmdname,cmdevent,logstring); + } else if (logstring) { + logString(cmdname,logstring); + } else if ( cmd && *cmd) { + return(runCommand(cmd,reexec,quiet,debug)); + } else { + if (!silent) + fprintf(stderr,"nothing to do!\n"); + return -1; + } + return 0; +} + +int main(int argc, char **argv) { + + setlocale(LC_ALL,""); + bindtextdomain("initlog","/etc/locale"); + textdomain("initlog"); + exit(processArgs(argc,argv,0)); +} diff --git a/src/initlog.c.orig b/src/initlog.c.orig new file mode 100644 index 0000000..6c6630e --- /dev/null +++ b/src/initlog.c.orig @@ -0,0 +1,446 @@ +/* + * Copyright (c) 1999-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYSLOG_NAMES +#include + +#include +#include +#include +#include + +#define _(String) gettext((String)) + +#include + +#include + +#include "initlog.h" +#include "process.h" + +static int logfacility=LOG_DAEMON; +static int logpriority=LOG_NOTICE; +static int reexec=0; +static int quiet=0; +int debug=0; + +regex_t **regList = NULL; + +static int logEntries = 0; +struct logInfo *logData = NULL; + +void readConfiguration(char *fname) { + int fd,num=0; + struct stat sbuf; + char *data,*line, *d; + regex_t *regexp; + int lfac=-1,lpri=-1; + + if ((fd=open(fname,O_RDONLY))==-1) return; + if (fstat(fd,&sbuf)) { + close(fd); + return; + } + d = data=malloc(sbuf.st_size+1); + if (read(fd,data,sbuf.st_size)!=sbuf.st_size) { + close(fd); + free(data); + return; + } + close(fd); + data[sbuf.st_size] = '\0'; + while ((line=getLine(&data))) { + if (line[0]=='#') continue; + if (!strncmp(line,"ignore ",7)) { + regexp = malloc(sizeof(regex_t)); + if (!regcomp(regexp,line+7,REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) { + regList = realloc(regList,(num+2) * sizeof(regex_t *)); + regList[num] = regexp; + regList[num+1] = NULL; + num++; + } + } + if (!strncmp(line,"facility ",9)) { + lfac=atoi(line+9); + if ((lfac == 0) && strcmp(line+9,"0")) { + int x =0; + + lfac = LOG_DAEMON; + for (x=0;facilitynames[x].c_name;x++) { + if (!strcmp(line+9,facilitynames[x].c_name)) { + lfac = facilitynames[x].c_val; + break; + } + } + } + } + if (!strncmp(line,"priority ",9)) { + lpri = atoi(line+9); + if ((lpri == 0) && strcmp(line+9,"0")) { + int x=0; + + lpri = LOG_NOTICE; + for (x=0;prioritynames[x].c_name;x++) { + if (!strcmp(line+9,prioritynames[x].c_name)) { + lpri = prioritynames[x].c_val; + break; + } + } + } + } + } + if (lfac!=-1) logfacility=lfac; + if (lpri!=-1) logpriority=lpri; + free(d); +} + +char *getLine(char **data) { + /* Get one line from data */ + /* Anything up to a carraige return (\r) or a backspace (\b) is discarded. */ + /* If this really bothers you, mail me and I might make it configurable. */ + /* It's here to avoid confilcts with fsck's progress bar. */ + char *x, *y; + + if (!*data) return NULL; + x=*data; + while (*x && (*x != '\n')) { + while (*x && (*x != '\n') && (*x != '\r') && (*x != '\b')) x++; + if (*x && (*x=='\r' || *x =='\b')) { + *data = x+1; + x++; + } + } + if (*x) { + x++; + } else { + if (x-*data) { + y=malloc(x-*data+1); + y[x-*data] = 0; + y[x-*data-1] = '\n'; + memcpy(y,*data,x-*data); + } else { + y=NULL; + } + *data = NULL; + return y; + } + y = malloc(x-*data); + y[x-*data-1] = 0; + memcpy(y,*data,x-*data-1); + *data = x; + return y; +} + +char **toArray(char *line, int *num) { + /* Converts a long string into an array of lines. */ + char **lines; + char *tmpline; + + *num = 0; + lines = NULL; + + while ((tmpline=getLine(&line))) { + if (!*num) + lines = (char **) malloc(sizeof(char *)); + else + lines = (char **) realloc(lines, (*num+1)*sizeof(char *)); + lines[*num] = tmpline; + (*num)++; + } + return lines; +} + +int trySocket() { + int s; + struct sockaddr_un addr; + + s = socket(AF_LOCAL, SOCK_DGRAM, 0); + if (s<0) + return 1; + + bzero(&addr,sizeof(addr)); + addr.sun_family = AF_LOCAL; + strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); + + if (connect(s,(struct sockaddr *) &addr,sizeof(addr))<0) { + if (errno == EPROTOTYPE || errno == ECONNREFUSED) { + DDEBUG("connect failed (EPROTOTYPE), trying stream\n"); + close(s); + s = socket(AF_LOCAL, SOCK_STREAM, 0); + if (connect(s,(struct sockaddr *) &addr, sizeof(addr)) < 0) { + DDEBUG("connect failed: %s\n",strerror(errno)); + close(s); + return 1; + } + close(s); + return 0; + } + close(s); + DDEBUG("connect failed: %s\n",strerror(errno)); + return 1; + } else { + close(s); + return 0; + } +} + +int logLine(struct logInfo *logEnt) { + /* Logs a line... somewhere. */ + int x; + struct stat statbuf; + + /* Don't log empty or null lines */ + if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0; + + + if ((stat(_PATH_LOG,&statbuf)==-1) || trySocket()) { + DDEBUG("starting daemon failed, pooling entry %d\n",logEntries); + logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo)); + logData[logEntries].fac = logEnt->fac; + logData[logEntries].pri = logEnt->pri; + logData[logEntries].cmd = strdup(logEnt->cmd); + logData[logEntries].line = strdup(logEnt->line); + logEntries++; + } else { + if (logEntries>0) { + for (x=0;xline); + openlog(logEnt->cmd,0,logEnt->fac); + syslog(logEnt->pri,"%s",logEnt->line); + closelog(); + } + return 0; +} + +int logEvent(char *cmd, int eventtype,char *string) { + char *eventtable [] = { + _("%s babbles incoherently"), + _("%s succeeded"), + _("%s failed"), + _("%s cancelled at user request"), + _("%s failed due to a failed dependency"), + /* insert more here */ + NULL + }; + int x=0,len, rc; + struct logInfo logentry; + + if (cmd) { + logentry.cmd = basename(cmd); + if ((logentry.cmd[0] =='K' || logentry.cmd[0] == 'S') && + ( logentry.cmd[1] >= '0' && logentry.cmd[1] <= '9' ) && + ( logentry.cmd[2] >= '0' && logentry.cmd[2] <= '9' ) ) + logentry.cmd+=3; + logentry.cmd = strdup(logentry.cmd); + } else + logentry.cmd = strdup(_("(none)")); + if (!string) { + string = alloca(strlen(cmd)+1); + strcpy(string,cmd); + } + + while (eventtable[x] && x= '0' && logentry.cmd[1] <= 0x39 ) && + ( logentry.cmd[2] >= '0' && logentry.cmd[2] <= 0x39 ) ) + logentry.cmd+=3; + logentry.cmd = strdup(logentry.cmd); + } else + logentry.cmd = strdup(_("")); + logentry.line = strdup(string); + logentry.pri = logpriority; + logentry.fac = logfacility; + + rc = logLine(&logentry); + free(logentry.line); + free(logentry.cmd); + return rc; +} + +int processArgs(int argc, char **argv, int silent) { + char *cmdname=NULL; + char *conffile=NULL; + int cmdevent=0; + char *cmd=NULL; + char *logstring=NULL; + char *fac=NULL,*pri=NULL; + int lfac=-1, lpri=-1; + poptContext context; + int rc; + struct poptOption optTable[] = { + POPT_AUTOHELP + { "conf", 0, POPT_ARG_STRING, &conffile, 0, + "configuration file (default: /etc/initlog.conf)", NULL + }, + { "name", 'n', POPT_ARG_STRING, &cmdname, 0, + "name of service being logged", NULL + }, + { "event", 'e', POPT_ARG_INT, &cmdevent, 0, + "event being logged (see man page)", NULL + }, + { "cmd", 'c', POPT_ARG_STRING, &cmd, 0, + "command to run, logging output", NULL + }, + { "debug", 'd', POPT_ARG_NONE, &debug, 0, + "print lots of verbose debugging info", NULL + }, + { "run", 'r', POPT_ARG_STRING, &cmd, 3, + "command to run, accepting input on open fd", NULL + }, + { "string", 's', POPT_ARG_STRING, &logstring, 0, + "string to log", NULL + }, + { "facility", 'f', POPT_ARG_STRING, &fac, 1, + "facility to log at (default: 'local7')", NULL + }, + { "priority", 'p', POPT_ARG_STRING, &pri, 2, + "priority to log at (default: 'notice')", NULL + }, + { "quiet", 'q', POPT_ARG_NONE, &quiet, 0, + "suppress stdout/stderr", NULL + }, + { 0, 0, 0, 0, 0, 0 } + }; + + context = poptGetContext("initlog", argc, argv, optTable, 0); + + while ((rc = poptGetNextOpt(context)) > 0) { + switch (rc) { + case 1: + lfac=atoi(fac); + if ((lfac == 0) && strcmp(fac,"0")) { + int x =0; + + lfac = LOG_DAEMON; + for (x=0;facilitynames[x].c_name;x++) { + if (!strcmp(fac,facilitynames[x].c_name)) { + lfac = facilitynames[x].c_val; + break; + } + } + } + break; + case 2: + lpri = atoi(pri); + if ((lpri == 0) && strcmp(pri,"0")) { + int x=0; + + lpri = LOG_NOTICE; + for (x=0;prioritynames[x].c_name;x++) { + if (!strcmp(pri,prioritynames[x].c_name)) { + lpri = prioritynames[x].c_val; + break; + } + } + } + break; + case 3: + reexec = 1; + break; + default: + break; + } + } + + if ((rc < -1)) { + if (!silent) + fprintf(stderr, "%s: %s\n", + poptBadOption(context, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); + + return -1; + } + if ( (cmd && logstring) || (cmd && cmdname) ) { + if (!silent) + fprintf(stderr, _("--cmd and --run are incompatible with --string or --name\n")); + return -1; + } + if ( cmdname && (!logstring && !cmdevent)) { + if (!silent) + fprintf(stderr, _("--name requires one of --event or --string\n")); + return -1; + } + if (cmdevent && cmd) { + if (!silent) + fprintf(stderr, _("--cmd and --run are incompatible with --event\n")); + return -1; + } + if (conffile) { + readConfiguration(conffile); + } else { + readConfiguration("/etc/initlog.conf"); + } + if (cmd) { + while (isspace(*cmd)) cmd++; + } + if (lpri!=-1) logpriority=lpri; + if (lfac!=-1) logfacility=lfac; + if (cmdevent) { + logEvent(cmdname,cmdevent,logstring); + } else if (logstring) { + logString(cmdname,logstring); + } else if ( cmd && *cmd) { + return(runCommand(cmd,reexec,quiet,debug)); + } else { + if (!silent) + fprintf(stderr,"nothing to do!\n"); + return -1; + } + return 0; +} + +int main(int argc, char **argv) { + + setlocale(LC_ALL,""); + bindtextdomain("initlog","/etc/locale"); + textdomain("initlog"); + exit(processArgs(argc,argv,0)); +} diff --git a/src/initlog.conf b/src/initlog.conf new file mode 100644 index 0000000..4505c7d --- /dev/null +++ b/src/initlog.conf @@ -0,0 +1,23 @@ +# /etc/initlog.conf +# +# initlog configuration file +# +# lines preceded by a '#' are comments +# +# anything not recognized is ignored. :) + +# This sets the default logging facility. (can override with command line arguments) +facility local7 + +# This sets the default logging priority. (can override with command line arguments) +priority notice + +# ignore foo +# means to discard any output lines that match the regular expression foo + +# This regexp is useful if you use fsck's -C option. +ignore [^:]+: \|[=]+ +# This regexp is useful for fsck's feature of setting file types +ignore [^:]+: Setting filetype +# This regexp is useful for quotacheck +ignore ^[-\\\|\/]$ diff --git a/src/initlog.h b/src/initlog.h new file mode 100644 index 0000000..94f467b --- /dev/null +++ b/src/initlog.h @@ -0,0 +1,20 @@ + +#define _GNU_SOURCE 1 + +#ifndef INITLOG_H +#define INITLOG_H + +struct logInfo { + char *cmd; + char *line; + int fac; + int pri; +}; + +char *getLine(char **data); +int logString(char *cmd, char *string); +int processArgs(int argc, char **argv, int silent); + +#define DDEBUG if (debug) printf + +#endif diff --git a/src/ipcalc.1 b/src/ipcalc.1 new file mode 100644 index 0000000..fd9b212 --- /dev/null +++ b/src/ipcalc.1 @@ -0,0 +1,58 @@ +.TH IPCALC 1 "April 30 2001" "Red Hat, Inc." RH \" -*- nroff -*- +.SH NAME +ipcalc \- perform simple manipulation of IP addresses +.SH SYNOPSIS +.B ipcalc +[\fIOPTION\fR]... <\fBIP address\fR>[\fI/prefix\fR] [\fInetmask\fR] + +.SH DESCRIPTION +\fBipcalc\fR provides a simple way to calculate IP information for a host. +The various options specify what information \fBipcalc\fR should display +on standard out. Multiple options may be specified. An IP address to +operate on must always be specified. Most operations also require a +netmask or a CIDR prefix as well. + +.SH OPTIONS +.TP +.TP +\fB\-b\fR, \fB\-\-broadcast\fR +Display the broadcast address for the given IP address and netmask. + +.TP +\fB\-h\fR, \fB\-\-hostname\fR +Display the hostname for the given IP address. + +.TP +\fB\-m\fR, \fB\-\-netmask\fR +Calculate the netmask for the given IP address. It assumes that the IP +address is in a complete class A, B, or C network. Many networks do +not use the default netmasks, in which case an inappropriate value will +be returned. + +.TP +\fB\-p\fR, \fB\-\-prefix\fR +Show the prefix for the given mask/IP address. + +.TP +\fB\-n\fR, \fB\-\-network\fR +Display the network address for the given IP address and netmask. + +.TP +\fB\-s\fR, \fB\-\-silent\fR +Don't ever display error messages. + +.SH AUTHORS +.nf +Erik Troan +.nf +Preston Brown +.fi +.SH "REPORTING BUGS" +Report bugs to our bugtracking system: +http://bugzilla.redhat.com/bugzilla. +.SH COPYRIGHT +Copyright \(co 1997-2001 Red Hat, Inc. +.br +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. diff --git a/src/ipcalc.c b/src/ipcalc.c new file mode 100644 index 0000000..f133412 --- /dev/null +++ b/src/ipcalc.c @@ -0,0 +1,361 @@ +/* + * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Authors: + * Erik Troan + * Preston Brown + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \def IPBITS + \brief the number of bits in an IP address. +*/ +#define IPBITS (sizeof(u_int32_t) * 8) +/*! + \def IPBYTES + \brief the number of bytes in an IP address. +*/ +#define IPBYTES (sizeof(u_int32_t)) + + +/*! + \file ipcalc.c + \brief provides utilities for manipulating IP addresses. + + ipcalc provides utilities and a front-end command line interface for + manipulating IP addresses, and calculating various aspects of an ip + address/netmask/network address/prefix/etc. + + Functionality can be accessed from other languages from the library + interface, documented here. To use ipcalc from the shell, read the + ipcalc(1) manual page. + + When passing parameters to the various functions, take note of whether they + take host byte order or network byte order. Most take host byte order, and + return host byte order, but there are some exceptions. + +*/ + +/*! + \fn u_int32_t prefix2mask(int bits) + \brief creates a netmask from a specified number of bits + + This function converts a prefix length to a netmask. As CIDR (classless + internet domain internet domain routing) has taken off, more an more IP + addresses are being specified in the format address/prefix + (i.e. 192.168.2.3/24, with a corresponding netmask 255.255.255.0). If you + need to see what netmask corresponds to the prefix part of the address, this + is the function. See also \ref mask2prefix. + + \param prefix is the number of bits to create a mask for. + \return a network mask, in network byte order. +*/ +u_int32_t prefix2mask(int prefix) { + return htonl(~((1 << (32 - prefix)) - 1)); +} + +/*! + \fn int mask2prefix(u_int32_t mask) + \brief calculates the number of bits masked off by a netmask. + + This function calculates the significant bits in an IP address as specified by + a netmask. See also \ref prefix2mask. + + \param mask is the netmask, specified as an u_int32_teger in network byte order. + \return the number of significant bits. */ +int mask2prefix(u_int32_t mask) +{ + int i; + int count = IPBITS; + + for (i = 0; i < IPBITS; i++) { + if (!(ntohl(mask) & ((2 << i) - 1))) + count--; + } + + return count; +} + +/*! + \fn u_int32_t default_netmask(u_int32_t addr) + + \brief returns the default (canonical) netmask associated with specified IP + address. + + When the Internet was originally set up, various ranges of IP addresses were + segmented into three network classes: A, B, and C. This function will return + a netmask that is associated with the IP address specified defining where it + falls in the predefined classes. + + \param addr an IP address in network byte order. + \return a netmask in network byte order. */ +u_int32_t default_netmask(u_int32_t addr) +{ + if (((ntohl(addr) & 0xFF000000) >> 24) <= 127) + return htonl(0xFF000000); + else if (((ntohl(addr) & 0xFF000000) >> 24) <= 191) + return htonl(0xFFFF0000); + else + return htonl(0xFFFFFF00); +} + +/*! + \fn u_int32_t calc_broadcast(u_int32_t addr, int prefix) + + \brief calculate broadcast address given an IP address and a prefix length. + + \param addr an IP address in network byte order. + \param prefix a prefix length. + + \return the calculated broadcast address for the network, in network byte + order. +*/ +u_int32_t calc_broadcast(u_int32_t addr, + int prefix) +{ + return (addr & prefix2mask(prefix)) | ~prefix2mask(prefix); +} + +/*! + \fn u_int32_t calc_network(u_int32_t addr, int prefix) + \brief calculates the network address for a specified address and prefix. + + \param addr an IP address, in network byte order + \param prefix the network prefix + \return the base address of the network that addr is associated with, in + network byte order. +*/ +u_int32_t calc_network(u_int32_t addr, int prefix) +{ + return (addr & prefix2mask(prefix)); +} + +/*! + \fn const char *get_hostname(u_int32_t addr) + \brief returns the hostname associated with the specified IP address + + \param addr an IP address to find a hostname for, in network byte order + + \return a hostname, or NULL if one cannot be determined. Hostname is stored + in a static buffer that may disappear at any time, the caller should copy the + data if it needs permanent storage. +*/ +const char *get_hostname(u_int32_t addr) +{ + struct hostent * hostinfo; + int x; + + hostinfo = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET); + if (!hostinfo) + return NULL; + + for (x=0; hostinfo->h_name[x]; x++) { + hostinfo->h_name[x] = tolower(hostinfo->h_name[x]); + } + return hostinfo->h_name; +} + +/*! + \fn main(int argc, const char **argv) + \brief wrapper program for ipcalc functions. + + This is a wrapper program for the functions that the ipcalc library provides. + It can be used from shell scripts or directly from the command line. + + For more information, please see the ipcalc(1) man page. +*/ +int main(int argc, const char **argv) { + int showBroadcast = 0, showPrefix = 0, showNetwork = 0; + int showHostname = 0, showNetmask = 0; + int beSilent = 0; + int rc; + poptContext optCon; + char *ipStr, *prefixStr, *netmaskStr, *hostName, *chptr; + struct in_addr ip, netmask, network, broadcast; + int prefix = 0; + char errBuf[250]; + struct poptOption optionsTable[] = { + { "broadcast", 'b', 0, &showBroadcast, 0, + "Display calculated broadcast address", }, + { "hostname", 'h', 0, &showHostname, 0, + "Show hostname determined via DNS" }, + { "netmask", 'm', 0, &showNetmask, 0, + "Display default netmask for IP (class A, B, or C)" }, + { "network", 'n', 0, &showNetwork, 0, + "Display network address", }, + { "prefix", 'p', 0, &showPrefix, 0, + "Display network prefix", }, + { "silent", 's', 0, &beSilent, 0, + "Don't ever display error messages " }, + POPT_AUTOHELP + { NULL, '\0', 0, 0, 0, NULL, NULL } + }; + + optCon = poptGetContext("ipcalc", argc, argv, optionsTable, 0); + poptReadDefaultConfig(optCon, 1); + + if ((rc = poptGetNextOpt(optCon)) < -1) { + if (!beSilent) { + fprintf(stderr, "ipcalc: bad argument %s: %s\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); + poptPrintHelp(optCon, stderr, 0); + } + return 1; + } + + if (!(ipStr = (char *) poptGetArg(optCon))) { + if (!beSilent) { + fprintf(stderr, "ipcalc: ip address expected\n"); + poptPrintHelp(optCon, stderr, 0); + } + return 1; + } + + if (strchr(ipStr,'/') != NULL) { + prefixStr = strchr(ipStr, '/') + 1; + prefixStr--; + *prefixStr = '\0'; /* fix up ipStr */ + prefixStr++; + } else + prefixStr = NULL; + + if (prefixStr != NULL) { + prefix = atoi(prefixStr); + if (prefix == 0) { + if (!beSilent) + fprintf(stderr, "ipcalc: bad prefix: %s\n", + prefixStr); + return 1; + } + } + + if (showBroadcast || showNetwork || showPrefix) { + if (!(netmaskStr = (char *) poptGetArg(optCon)) && + (prefix == 0)) { + if (!beSilent) { + fprintf(stderr, "ipcalc: netmask or prefix expected\n"); + poptPrintHelp(optCon, stderr, 0); + } + return 1; + } else if (netmaskStr && prefix != 0) { + if (!beSilent) { + fprintf(stderr, "ipcalc: both netmask and prefix specified\n"); + poptPrintHelp(optCon, stderr, 0); + } + return 1; + } else if (netmaskStr) { + if (!inet_aton(netmaskStr, &netmask)) { + if (!beSilent) + fprintf(stderr, "ipcalc: bad netmask: %s\n", + netmaskStr); + return 1; + } + prefix = mask2prefix(netmask.s_addr); + } + } + + if ((chptr = (char *) poptGetArg(optCon))) { + if (!beSilent) { + fprintf(stderr, "ipcalc: unexpected argument: %s\n", chptr); + poptPrintHelp(optCon, stderr, 0); + } + return 1; + } + + /* Handle CIDR entries such as 172/8 */ + if (prefix) { + char *tmp = ipStr; + int i; + + for(i=3; i> 0; i--) { + tmp = strchr(tmp,'.'); + if (!tmp) + break; + else + tmp++; + } + tmp = NULL; + for (; i>0; i--) { + tmp = malloc(strlen(ipStr) + 3); + sprintf(tmp,"%s.0",ipStr); + ipStr = tmp; + } + } + + if (!inet_aton(ipStr, (struct in_addr *) &ip)) { + if (!beSilent) + fprintf(stderr, "ipcalc: bad ip address: %s\n", ipStr); + return 1; + } + + + if (!(showNetmask|showPrefix|showBroadcast|showNetwork|showHostname)) { + poptPrintHelp(optCon, stderr, 0); + return 1; + } + + poptFreeContext(optCon); + + /* we know what we want to display now, so display it. */ + + if (showNetmask) { + if (prefix) { + netmask.s_addr = prefix2mask(prefix); + } else { + netmask.s_addr = default_netmask(ip.s_addr); + prefix = mask2prefix(netmask.s_addr); + } + + printf("NETMASK=%s\n", inet_ntoa(netmask)); + } + + if (showPrefix) { + if (!prefix) + prefix = mask2prefix(ip.s_addr); + printf("PREFIX=%d\n", prefix); + } + + if (showBroadcast) { + broadcast.s_addr = calc_broadcast(ip.s_addr, prefix); + printf("BROADCAST=%s\n", inet_ntoa(broadcast)); + } + + if (showNetwork) { + network.s_addr = calc_network(ip.s_addr, prefix); + printf("NETWORK=%s\n", inet_ntoa(network)); + } + + if (showHostname) { + if ((hostName = (char *) get_hostname(ip.s_addr)) == NULL) { + if (!beSilent) { + sprintf(errBuf, "ipcalc: cannot find hostname for %s", ipStr); + herror(errBuf); + } + return 1; + } + + printf("HOSTNAME=%s\n", hostName); + } + + return 0; +} diff --git a/src/minilogd.c b/src/minilogd.c new file mode 100644 index 0000000..8543097 --- /dev/null +++ b/src/minilogd.c @@ -0,0 +1,187 @@ +/* minilogd.c + * + * A pale imitation of syslogd. Most notably, doesn't write anything + * anywhere except possibly back to syslogd. + * + * Copyright (c) 1999-2001 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static int we_own_log=0; +static char **buffer=NULL; +static int buflines=0; + +int debug; + +int recvsock; + +void alarm_handler(int x) { + alarm(0); + close(recvsock); + recvsock = -1; +} + +void freeBuffer() { + struct sockaddr_un addr; + int sock; + int x=0,conn; + + bzero(&addr,sizeof(addr)); + addr.sun_family = AF_LOCAL; + strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); + /* wait for klogd to hit syslog */ + sleep(2); + sock = socket(AF_LOCAL, SOCK_DGRAM,0); + conn=connect(sock,(struct sockaddr *) &addr,sizeof(addr)); + while (x0) && pfds.revents & (POLLIN | POLLPRI)) { + message = calloc(8192,sizeof(char)); + addrlen = sizeof(struct sockaddr_un); + recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen); + if (recvsock == -1) + continue; + alarm(2); + signal(SIGALRM, alarm_handler); + len = recv(recvsock,message,8192,0); + alarm(0); + close(recvsock); + if (len>0) { + if (buflines < 200000) { + if (buffer) + buffer = realloc(buffer,(buflines+1)*sizeof(char *)); + else + buffer = malloc(sizeof(char *)); + message[strlen(message)]='\n'; + buffer[buflines]=message; + buflines++; + } + } + else { + recvsock=-1; + } + } + if ( (x>0) && ( pfds.revents & (POLLHUP | POLLNVAL)) ) + done = 1; + /* Check to see if syslogd's yanked our socket out from under us */ + if ( (stat(_PATH_LOG,&s2)!=0) || + (s1.st_ino != s2.st_ino ) || (s1.st_ctime != s2.st_ctime) || + (s1.st_mtime != s2.st_mtime) ) { + done = 1; + we_own_log = 0; + } + } + cleanup(0); +} + +int main(int argc, char **argv) { + struct sockaddr_un addr; + int sock; + int pid; + + /* option processing made simple... */ + if (argc>1) debug=1; + /* just in case */ + sock = open("/dev/null",O_RDWR); + dup2(sock,0); + dup2(sock,1); + dup2(sock,2); + close(sock); + + bzero(&addr, sizeof(addr)); + addr.sun_family = AF_LOCAL; + strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); + sock = socket(AF_LOCAL, SOCK_STREAM,0); + unlink(_PATH_LOG); + /* Bind socket before forking, so we know if the server started */ + if (!bind(sock,(struct sockaddr *) &addr, sizeof(addr))) { + we_own_log = 1; + listen(sock,5); + if ((pid=fork())==-1) { + perror("fork"); + exit(3); + } + if (pid) { + exit(0); + } else { + runDaemon(sock); + /* shouldn't get back here... */ + exit(4); + } + } else { + exit(5); + } +} diff --git a/src/netreport.1 b/src/netreport.1 new file mode 100644 index 0000000..75ed074 --- /dev/null +++ b/src/netreport.1 @@ -0,0 +1,22 @@ +.TH NETREPORT 1 "Red Hat, Inc." "RH" \" -*- nroff -*- +.SH NAME +netreport \- request notification of network interface changes +.SH SYNOPSIS +.B netreport +\fI[\fP-r\fI]\fP +.SH DESCRIPTION +.B netreport +tells the network management scripts to send a SIGIO signal +to the process which called netreport when any network interface +status changes occur. +.SH OPTIONS +.TP +.B -r +Remove the current request (if any) for the calling process. +.PP +.SH NOTES +If a program does not call netreport with the +.B -r +option before it exits, and another process is created with the +same PID before any changes take place in interface status, it +is possible that the new process will receive a spurious SIGIO. diff --git a/src/netreport.c b/src/netreport.c new file mode 100644 index 0000000..6eb220c --- /dev/null +++ b/src/netreport.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1997-2002 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +#include +#include +#include +#include +#include +#include + +/* this will be running setgid root, so be careful! */ + +static void +usage(void) { + fprintf(stderr, "usage: netreport [-r]\n"); + exit(1); +} + +#define ADD 1 +#define DEL 0 +int main(int argc, char ** argv) { + int action = ADD; + /* more than long enough for "/var/run/netreport/\0" */ + char netreport_name[64]; + int netreport_file; + + if (argc > 2) { + usage(); + } + + if (argc > 1) { + if (argc == 2 && strcmp(argv[1], "-r") == 0) { + action = DEL; + } else { + usage(); + } + } + + snprintf(netreport_name, sizeof(netreport_name), + "/var/run/netreport/%d", getppid()); + if (action == ADD) { + netreport_file = open(netreport_name, + O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0); + if (netreport_file == -1) { + if (errno != EEXIST) { + perror("Could not create netreport file"); + exit (1); + } + } else { + close(netreport_file); + } + } else { + /* ignore errors; not much we can do, won't hurt anything */ + unlink(netreport_name); + } + + return 0; +} diff --git a/src/process.c b/src/process.c new file mode 100644 index 0000000..475d188 --- /dev/null +++ b/src/process.c @@ -0,0 +1,324 @@ +/* + * Copyright (c) 1999-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include "initlog.h" +#include "process.h" + +extern regex_t **regList; + +int forkCommand(char **args, int *outfd, int *errfd, int *cmdfd, int quiet) { + /* Fork command 'cmd', returning pid, and optionally pointer + * to open file descriptor fd */ + int fdout=-1, fderr=-1, fdcmd=-1, pid; + int outpipe[2], errpipe[2], fdpipe[2]; + int ourpid; + + if ( (pipe(outpipe)==-1) || (pipe(errpipe)==-1) || (pipe(fdpipe)==-1) ) { + perror("pipe"); + return -1; + } + + if (outfd) { + fdout = outpipe[1]; + *outfd = outpipe[0]; + } else { + if (!quiet) + fdout=dup(1); + } + if (errfd) { + fderr = errpipe[1]; + *errfd = errpipe[0]; + } else { + if (!quiet) + fderr=dup(2); + } + + if (cmdfd) { + *cmdfd = fdpipe[0]; + fdcmd = fdpipe[1]; + } else { + fdcmd = open("/dev/null",O_WRONLY); + } + if (fdout==-1 || fderr==-1 || fdcmd==-1) + return -1; + ourpid = getpid(); + if ((pid = fork())==-1) { + perror("fork"); + return -1; + } + /* We exec the command normally as the child. However, if we're getting passed + * back arguments via an fd, we'll exec it as the parent. Therefore, if Bill + * fucks up and we segfault or something, we don't kill rc.sysinit. */ + if ( (cmdfd&&!pid) || (pid &&!cmdfd)) { + /* parent */ + close(fdout); + close(fderr); + close(fdcmd); + if (!pid) + return ourpid; + else + return pid; + } else { + /* kid */ + int sc_open_max; + + if (outfd) { + if ( (dup2(fdout,1)==-1) ) { + perror("dup2"); + exit(-1); + } + } else if (quiet) + if ((dup2(open("/dev/null",O_WRONLY),1))==-1) { + perror("dup2"); + exit(-1); + } + + if (errfd) { + if ((dup2(fderr,2)==-1)) { + perror("dup2"); + exit(-1); + } + } else if (quiet) + if ((dup2(open("/dev/null",O_WRONLY),2))==-1) { + perror("dup2"); + exit(-1); + } + + + if ((dup2(fdcmd,CMD_FD)==-1)) { + perror("dup2"); + exit(-1); + } + close(fdout); + close(fderr); + close(fdcmd); + if (outfd) + close(*outfd); + if (errfd) + close(*errfd); + if (cmdfd) + close(*cmdfd); + + /* close up extra fds, and hope this doesn't break anything */ + sc_open_max = sysconf(_SC_OPEN_MAX); + if(sc_open_max > 1) { + int fd; + for(fd = 3; fd < sc_open_max; fd++) { + if (!(cmdfd && fd == CMD_FD)) + close(fd); + } + } + + execvp(args[0],args); + perror("execvp"); + exit(-1); + } +} + +int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, int debug) { + struct pollfd *pfds; + char *outbuf=NULL; + char *tmpstr=NULL; + int x,y,rc=-1; + int done=0; + int output=0; + char **cmdargs=NULL; + char **tmpargs=NULL; + int cmdargc; + char *procpath = NULL; + + if (reexec) { + procpath=malloc(20*sizeof(char)); + snprintf(procpath,20,"/proc/%d",pid); + } + + pfds = malloc(numfds*sizeof(struct pollfd)); + for (x=0;x= '0' && cmdname[1] <= '9' ) && + ( cmdname[2] >= '0' && cmdname[2] <= '9' ) ) + cmdname+=3; + if (!reexec) { + pid=forkCommand(args,&fds[0],&fds[1],NULL,quiet); + if (pid == -1) + return -1; + x=monitor(cmdname,pid,2,fds,reexec,quiet,debug); + } else { + setenv("IN_INITLOG","yes",1); + pid=forkCommand(args,NULL,NULL,&fds[0],quiet); + if (pid == -1) + return -1; + unsetenv("IN_INITLOG"); + x=monitor(cmdname,pid,1,&fds[0],reexec,quiet,debug); + } + return x; +} diff --git a/src/process.h b/src/process.h new file mode 100644 index 0000000..ef98f78 --- /dev/null +++ b/src/process.h @@ -0,0 +1,9 @@ +#ifndef PROCESS_H +#define PROCESS_H + + +#define CMD_FD 21 + +int runCommand(char *cmd, int reexec, int quiet, int debug); + +#endif diff --git a/src/usernetctl.8 b/src/usernetctl.8 new file mode 100644 index 0000000..2fb84da --- /dev/null +++ b/src/usernetctl.8 @@ -0,0 +1,39 @@ +.TH USERNETCTL 8 "Red Hat, Inc." "RHS" \" -*- nroff -*- +.SH NAME +usernetctl \- allow a user to manipulate a network interface if permitted +.SH SYNOPSIS +.B usernetctl +\fIinterface-name\fP up\fI|\fPdown\fI|\fPreport +.SH DESCRIPTION +.B usernetctl +checks to see if users are allowed to manipulate the network interface +specified by \fIinterface-name\fP, and then tries to bring the network +interface up or down, if up or down was specified on the command line, +or returns true or false status (respectively) if the report option was +specified. + +.B usernetctl +is not really meant to be called directly by users, though it currently +works fine that way. It is used as a wrapper by the ifup and ifdown +scripts, so that users can do exactly the same thing as root: +.nf +ifup \fIinterface-name\fP +ifdown \fIinterface-name\fP +.fi +and \fBifup\fP and \fBifdown\fP will call usernetctl automatically to +allow the interface status change. +.SH OPTIONS +.TP +.I "\fIinterface-name" +The name of the network interface to check; for example, "ppp0". For +backwards compatibility, "ifcfg-ppp0" and +"/etc/sysconfig/network-scripts/ifcfg-ppp0" are also supported. +.TP +up\fI|\fPdown +Attempt to bring the interface up or down. +.TP +report +Report on whether users can bring the interface up or down. +.SH NOTES +Alternate device configurations may inherit the default configuration's +permissions. diff --git a/src/usernetctl.c b/src/usernetctl.c new file mode 100644 index 0000000..aa77c8a --- /dev/null +++ b/src/usernetctl.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* This will be running setuid root, so be careful! */ +static const char * safeEnviron[] = { + "PATH=/bin:/sbin:/usr/bin:/usr/sbin", + "HOME=/root", + NULL +}; + +#define FOUND_FALSE -1 +#define NOT_FOUND 0 +#define FOUND_TRUE 1 + +static void +usage(void) { + fprintf(stderr, "usage: usernetctl \n"); + exit(1); +} + +static size_t +testSafe(char *ifaceConfig, int fd) { + struct stat sb; + + /* These shouldn't be symbolic links -- anal, but that's fine w/ mkj. */ + if (fstat(fd, &sb)) { + fprintf(stderr, "failed to stat %s: %s\n", ifaceConfig, + strerror(errno)); + exit(1); + } + + /* Safety/sanity checks. */ + if (!S_ISREG(sb.st_mode)) { + fprintf(stderr, "%s is not a normal file\n", ifaceConfig); + exit(1); + } + + if (sb.st_uid) { + fprintf(stderr, "%s should be owned by root\n", ifaceConfig); + exit(1); + } + + if (sb.st_mode & S_IWOTH) { + fprintf(stderr, "%s should not be world writeable\n", ifaceConfig); + exit(1); + } + + return sb.st_size; +} + + +static int +userCtl(char *file) { + char *buf; + char *contents = NULL; + char *chptr = NULL; + char *next = NULL; + int fd = -1, retval = NOT_FOUND; + size_t size = 0; + + /* Open the file and then test it to see if we like it. This way + we avoid switcheroo attacks. */ + if ((fd = open(file, O_RDONLY)) == -1) { + fprintf(stderr, "failed to open %s: %s\n", file, strerror(errno)); + exit(1); + } + + size = testSafe(file, fd); + if (size > INT_MAX) { + fprintf(stderr, "file %s is too big\n", file); + exit(1); + } + + buf = contents = malloc(size + 2); + if (contents == NULL) { + fprintf(stderr, "failed to allocate memory\n"); + exit(1); + } + + if (read(fd, contents, size) != size) { + perror("error reading device configuration"); + exit(1); + } + close(fd); + + contents[size] = '\n'; + contents[size + 1] = '\0'; + + /* Each pass parses a single line (until an answer is found), The contents + pointer itself points to the beginning of the current line. */ + while (*contents) { + chptr = contents; + while (*chptr != '\n') chptr++; + next = chptr + 1; + while (chptr >= contents && isspace(*chptr)) chptr--; + *(++chptr) = '\0'; + + if (!strncasecmp(contents, "USERCTL=", 8)) { + contents += 8; + if ((contents[0] == '"' && + contents[strlen(contents) - 1] == '"') || + (contents[0] == '\'' && + contents[strlen(contents) - 1] == '\'')) + { + contents++; + contents[strlen(contents) - 1] = '\0'; + } + + if (!strcasecmp(contents, "yes") || !strcasecmp(contents, "true")) + retval = FOUND_TRUE; + else + retval = FOUND_FALSE; + + break; + } + + contents = next; + } + + free(buf); + + return retval; +} + +int +main(int argc, char ** argv) { + char * ifaceConfig; + char * chptr; + char * cmd = NULL; + int report = 0; + char tmp; + + if (argc != 3) usage(); + + if (!strcmp(argv[2], "up")) { + cmd = "./ifup"; + } else if (!strcmp(argv[2], "down")) { + cmd = "./ifdown"; + } else if (!strcmp(argv[2], "report")) { + report = 1; + } else { + usage(); + } + + if (chdir("/etc/sysconfig/network-scripts")) { + fprintf(stderr, "error switching to /etc/sysconfig/network-scripts: " + "%s\n", strerror(errno)); + exit(1); + } + + /* force the interface configuration to be in the current directory */ + chptr = ifaceConfig = argv[1]; + while (*chptr) { + if (*chptr == '/') + ifaceConfig = chptr + 1; + chptr++; + } + + /* automatically prepend "ifcfg-" if it is not specified */ + if (strncmp(ifaceConfig, "ifcfg-", 6)) { + char *temp; + size_t len = strlen(ifaceConfig); + + /* Make sure a wise guys hasn't tried an integer wrap-around or + stack overflow attack. There's no way it could refer to anything + bigger than the largest filename, so cut 'em off there. */ + if (len > PATH_MAX) + exit(1); + + temp = (char *) alloca(len + 7); + strcpy(temp, "ifcfg-"); + /* strcat is safe because we got the length from strlen */ + strcat(temp, ifaceConfig); + ifaceConfig = temp; + } + + if(getuid() != 0) + switch (userCtl(ifaceConfig)) { + char *dash; + + case NOT_FOUND: + /* a `-' will be found at least in "ifcfg-" */ + dash = strrchr(ifaceConfig, '-'); + if (*(dash-1) != 'g') { + /* This was a clone configuration; ask the parent config */ + tmp = *dash; + *dash = '\0'; + if (userCtl(ifaceConfig) == FOUND_TRUE) { + /* exit the switch; users are allowed to control */ + *dash = tmp; + break; + } + *dash = tmp; + } + /* else fall through */ + case FOUND_FALSE: + if (! report) + fprintf(stderr, + "Users are not allowed to control this interface.\n"); + exit(1); + break; + } + + /* looks good to me -- let's go for it if we are changing the interface, + * report good status to the user otherwise */ + + if (report) + exit(0); + + /* pppd wants the real uid to be the same as the effective (god only + knows why when it works fine setuid out of the box) */ + setuid(geteuid()); + + execle(cmd, cmd, ifaceConfig, NULL, safeEnviron); + fprintf(stderr, "exec of %s failed: %s\n", cmd, strerror(errno)); + + exit(1); +} diff --git a/src/usleep.1 b/src/usleep.1 new file mode 100644 index 0000000..2d7520f --- /dev/null +++ b/src/usleep.1 @@ -0,0 +1,25 @@ +.TH USLEEP 1 "Red Hat, Inc" \" -*- nroff -*- +.SH NAME +usleep \- sleep some number of microseconds +.SH SYNOPSIS +.B usleep +[\fInumber\fP] +.SH DESCRIPTION +.B usleep +sleeps some number of microseconds. The default is 1. +.SH OPTIONS +\fI--usage\fP +Show short usage message. +.TP +\fI--help, -?\fP +Print help information. +.TP +\fI-v, --version\fP +Print version information. +.SH BUGS +Probably not accurate on many machines down to the microsecond. Count +on precision only to -4 or maybe -5. +.SH AUTHOR +Donald Barnes +.br +Erik Troan diff --git a/src/usleep.c b/src/usleep.c new file mode 100644 index 0000000..f00b6f1 --- /dev/null +++ b/src/usleep.c @@ -0,0 +1,76 @@ +/* + * usleep + * + * Written by Donald Barnes for Red Hat, Inc. + * + * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved. + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + + +#include +#include +#include +#include + +#include "popt.h" + +int main(int argc, char **argv) { + unsigned long count; + poptContext optCon; + int showVersion = 0; + int showOot = 0; + int rc; + char * countStr = NULL; + struct poptOption options[] = { + { "version", 'v', POPT_ARG_NONE, &showVersion, 0, + "Display the version of this program, and exit" }, + { "oot", 'o', POPT_ARG_NONE, &showOot, 0, + "oot says hey!" }, + POPT_AUTOHELP + { 0, 0, 0, 0, 0 } + }; + + optCon = poptGetContext("usleep", argc, argv, options,0); + /*poptReadDefaultConfig(optCon, 1);*/ + poptSetOtherOptionHelp(optCon, "[microseconds]"); + + if ((rc = poptGetNextOpt(optCon)) < -1) { + fprintf(stderr, "usleep: bad argument %s: %s\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); + return 2; + } + + if (showVersion) { + printf("usleep version 1.2\n usleep --help for more info\n"); + return 0; + } + + if (showOot) { + printf("oot says hey!\n"); + return 0; + } + + countStr = poptGetArg(optCon); + + if (countStr == NULL) count = 1; + + else if (countStr && poptGetArg(optCon)) { + fprintf(stderr, "%s: exactly one argument (number of microseconds) " + "must be used\n", argv[0]); + return 2; + } + + else count = strtoul(countStr, NULL, 0); + + usleep(count); + return 0; +} diff --git a/var/init/deps.start.mk b/var/init/deps.start.mk new file mode 100644 index 0000000..2e84a6a --- /dev/null +++ b/var/init/deps.start.mk @@ -0,0 +1,75 @@ +# GNU Makefile listing dependencies between services when services are +# started. +# Copyright (c) 2006-2009 by Silvan Calarco +# +# The following services have already been activated at this point: +# +# devfsd mountproc loadkeys localnet hotplug loadmodules hdparm +# swap setclock checkfs mountfs cleanfs +# +acpid : syslog +alsa : sysinit +apmd : syslog +bluetooth : messagebus +consolekit : haldaemon +cpufreqd : syslog acpid macbook-tools +crond : syslog +cups : syslog messagebus +dhcpd : network iptables +drbd : network iptables +gpm : syslog +haldaemon : messagebus acpid alsa +heartbeat : drbd network iptables +httpd : network iptables +ipsec : network iptables +iptables : network +ipvsadm : network iptables +ivman : haldaemon +lisa : network +lisa4 : network haldaemon +mailman : mysql postfix +mambawelcome : haldaemon +messagebus : syslog +mrtg : snmpd +msysklogd : random +mysql : syslog +named : network iptables +nessusd : network iptables +network : syslog +NetworkManager : syslog messagebus +nscd : syslog +ntop : network iptables +ntpd : network iptables +openldap : syslog +postfix : syslog mysql postgresql +postgresql : syslog +random : +samba : network iptables cups +snmpd : network iptables +snort : network +squid : network iptables +sshd : network iptables +sysklogd : random +sysinit : syslog +syslog : syslog-ng msysklogd sysklogd +syslog-ng : +udev-post : messagebus +xinetd : network iptables +wine : syslog +wicd : haldaemon +endlocal : local + @sleep 5 +rc.local : $(filter-out rc.local, $(ALL_RUNLEVEL)) +$(STARTAFTER_RUNLEVEL) : endlocal +# +# when local is started a semaphore file indicates that +# init can proceed +# +local: $(LOCAL) + @$(ECHO) "Begin \"$(JOB) $@\" at `$(DATE)`" > $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).$@ 2>&1; \ + rm -f $(PROG_FILE); \ + $(ECHO) "" > /var/lock/subsys/local; \ + [ "$(TEST)" = "1" ] && $(ECHO) local; \ + $(ECHO) "End \"$(JOB) $@\" at `$(DATE)`" >> $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).$@ 2>&1; + +# EOF diff --git a/var/init/deps.stop.mk b/var/init/deps.stop.mk new file mode 100644 index 0000000..0d0bf4b --- /dev/null +++ b/var/init/deps.stop.mk @@ -0,0 +1,54 @@ +# GNU Makefile listing dependencies between services when services are +# stopped +# +# rc[1-5].d dependencies +acpid : sendsignals +alsa : splash +consolekit : splash +cpufreqd : sendsignals +crond : splash +cups : splash +drbd : splash heartbeat +gpm : splash +haldaemon : splash wicd +heartbeat : splash +httpd : splash +iptables : sendsignals +lisa : splash +lisa4 : splash +localnet : splash network +logrotate : splash +mountfs : splash sendsignals swap create_final_log +mrtg : splash +mysql : splash +named : splash +nessusd : splash +network : splash mountfs vmware heartbeat drbd +nscd : splash +ntpd : splash +openldap : splash +postgresql : splash +random : splash +samba : splash +snort : splash +splash : +sshd : splash +swap : sendsignals +udev : splash mountfs +virtualbox : splash +vmware : splash +wine : splash +xinetd : splash +wicd : splash +# services to be started last +sysklogd : $(filter-out sysklogd udev mountfs sendsignals create_final_log swap reboot halt,$(ALL_RUNLEVEL)) +sendsignals : $(filter-out sendsignals acpid iptables localnet network udev mountfs network cpufreqd reboot halt,$(ALL_RUNLEVEL)) +reboot : $(filter-out reboot,$(ALL_RUNLEVEL)) +halt : $(filter-out halt,$(ALL_RUNLEVEL)) +local : + + +create_final_log : sendsignals swap + @$(LS) -Srt $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).* | $(XARGS) $(CAT) > $(FINAL_OUTPUT_FILE) 2>/dev/null + @$(RM) -f $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).* 2>/dev/null +# EOF diff --git a/var/init/runlevel.mk b/var/init/runlevel.mk new file mode 100644 index 0000000..0af1568 --- /dev/null +++ b/var/init/runlevel.mk @@ -0,0 +1,195 @@ +######################################################################## +# Description : Gnu Makefile to control the services in the specified +# runlevel. It will run the required services, and log +# the output of the services to the file +# /var/log/initd.$runlevel.start (for service startup) and +# /var/log/initd.$runlevel.stop (for service shutdown). +# +# This controlling program is designed to be invoked by +# the "/etc/rc.d/rc" script. +# +# Author : jameshunt@uk.ibm.com +# Modified by : Silvan Calarco +# +# Notes : +# +# - Run as, +# +# make [-n] -j -f runlevel.mk \ +# RUNLEVEL={0|1|2|3|4|5|6} \ +# JOB={start|stop|restart|status} +# +# - $(JOB) is not validated - that is left to the service program. +# - $(RUNLEVEL) is not validated - that is left to the calling program +# (usually /etc/rc.d/rc). +# - It wouldn't take too much effort to auto-generate this Makefile. +# +######################################################################## + +# passed as a parameter +export RUNLEVEL := $(shell echo $$RUNLEVEL) +PREV_RUNLEVEL := $(shell echo $$PREVLEVEL) +PREV_RUNLEVEL_DIR = /etc/rc.d/rc$(PREV_RUNLEVEL).d + +SERVICE= /sbin/service +# passed as a parameter (start, stop, status, etc) +JOB = + +JB = `case $(JOB) in "start") echo S;; "stop") echo K;; esac` + +# set to a value to enable debug output +DEBUG = + +# with TEST=1 only print service startup order +TEST = + +######################################################################## +# START CONFIGURATION + +# system commands used by this facility +CAT = /bin/cat +RM = /bin/rm +ECHO = /bin/echo +DATE = /bin/date +LS = /bin/ls +XARGS = /usr/bin/xargs + +# Directory containing scripts/programs to run. +INITD_DIR := /etc/init.d + +# Directory into which a lock file is created when a service starts. +# (Note that the lock file is created by the service). +SUBSYS_FILE_DIR := /var/lock/subsys + +# Rcl init database/dependecies file dir +RCL_DIR := /var/init + +# Used to create temporary files, before collating them all into +# $(FINAL_OUTPUT_FILE). +TMP_DIR := /tmp + +ifneq ($(DEBUG),) +DEBUG_FILE = /dev/stdout +else +DEBUG_FILE = /dev/null +endif +TMPFILE_PREFIX := .runlevel +TMP_FILE = $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).$@ + +# Variable used for splash progress bar +PROGRESS_TOT := 0 +PROGRESS_BASE := 0 +PROGRESS_FILEDIR := /dev/shm/progcounter + +# File that contains all output of programs/scripts run. +FINAL_OUTPUT_FILE := /var/log/initd.$(RUNLEVEL).$(JOB) + +# +# List of all runlevel services to be started/stopped +# +include $(RCL_DIR)/$(RUNLEVEL).$(JOB).rcl + +START_RUNLEVEL = $(ALL_RUNLEVEL) +STARTAFTER_RUNLEVEL = +LOCAL = openldap messagebus haldaemon + +ifeq ($(JOB)$(RUNLEVEL),start5) +START_RUNLEVEL = random sysinit syslog-ng sysklogd msysklogd network iptables wicd acpid apmd +# LOCAL: list of services that have to be started before KDM +LOCAL = openldap messagebus haldaemon alsa bluetooth consolekit mambawelcome +STARTAFTER_RUNLEVEL = $(filter-out $(LOCAL) $(START_RUNLEVEL), $(ALL_RUNLEVEL)) +endif + +ifeq ($(JOB)$(RUNLEVEL),start4) +START_RUNLEVEL = random sysinit syslog-ng sysklogd msysklogd network iptables wicd acpid apmd +# LOCAL: list of services that have to be started before KDM +LOCAL = openldap messagebus haldaemon alsa bluetooth consolekit +STARTAFTER_RUNLEVEL = $(filter-out $(LOCAL) $(START_RUNLEVEL), $(ALL_RUNLEVEL)) +endif + +ifeq ($(JOB)$(RUNLEVEL),start3) +START_RUNLEVEL = random sysinit syslog-ng sysklogd msysklogd network iptables wicd acpid apmd +# LOCAL: list of services that have to be started before agetty +LOCAL = openldap messagebus haldaemon +STARTAFTER_RUNLEVEL = $(filter-out $(LOCAL) $(START_RUNLEVEL), $(ALL_RUNLEVEL)) +endif + +ifeq ($(JOB)$(RUNLEVEL),start2) +# runlevel 2: don't wait for network before agetty +START_RUNLEVEL = random sysinit syslog-ng sysklogd msysklogd acpid apmd +# LOCAL: list of services that have to be started before agetty +LOCAL = openldap +STARTAFTER_RUNLEVEL = $(filter-out $(LOCAL) $(START_RUNLEVEL), $(ALL_RUNLEVEL)) +endif + +# END CONFIGURATION +######################################################################## + +# Check command-line parameters +ifndef RUNLEVEL +$(error must specify RUNLEVEL, so I know what to run) +endif + +ifndef JOB +$(error must specify JOB, so I know what to do) +endif + +default: prep $(START_RUNLEVEL) local $(STARTAFTER_RUNLEVEL) create_final_output_file + +prep: + @mkdir -p $(PROGRESS_FILEDIR) || rm -f $(PROGRESS_FILEDIR)/* + @rm -f $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).* + +ifeq ($(DEBUG),2) + @$(ECHO) "RUNLEVEL=$(RUNLEVEL)" >> $(DEBUG_FILE) + @$(ECHO) "JOB=$(JOB)" >> $(DEBUG_FILE) + @$(ECHO) "FINAL_OUTPUT_FILE=$(FINAL_OUTPUT_FILE)" >> $(DEBUG_FILE) + @$(ECHO) "TMP_FILE=$(TMP_FILE)" >> $(DEBUG_FILE) + @$(ECHO) "ALL_RUNLEVEL=|$(ALL_RUNLEVEL)|" >> $(DEBUG_FILE) + @$(ECHO) "START_RUNLEVEL=|$(START_RUNLEVEL)|" >> $(DEBUG_FILE) + @$(ECHO) "STARTAFTER_RUNLEVEL=|$(STARTAFTER_RUNLEVEL)|" >> $(DEBUG_FILE) + @$(ECHO) "LOCAL=|$(LOCAL)|" >> $(DEBUG_FILE) + @$(ECHO) "($(JB)$(RUNLEVEL),S5)" >> $(DEBUG_FILE) + @$(ECHO) >> $(DEBUG_FILE) +endif + +############################################################## +# Rule that executes all services jobs +# +$(ALL_RUNLEVEL): + @if [ "$(TEST)" = "1" ]; then echo $@; sleep 1; fi + @if [ ! -e $(PREV_RUNLEVEL_DIR)/$(JB)??$@ ]; then \ + $(ECHO) "Begin \"$(JOB) $@\" at `$(DATE)`" | tee -a $(TMP_FILE) >$(DEBUG_FILE); \ + RUNLEVEL=$(RUNLEVEL) $(INITD_DIR)/$@ $(JOB) 2>&1 | tee -a $(TMP_FILE) >$(DEBUG_FILE); \ + $(ECHO) "End \"$(JOB) $@\" at `$(DATE)`" | tee -a $(TMP_FILE) >$(DEBUG_FILE); \ + else \ + $(ECHO) "Already running \"$(JOB) $@\" at `$(DATE)`" | tee -a $(TMP_FILE) >$(DEBUG_FILE); \ + fi; \ + if [ -d $(PROGRESS_FILEDIR) ]; then \ + >$(PROGRESS_FILEDIR)/$@ \ + i=`ls $(PROGRESS_FILEDIR) | wc -w`; \ + . /etc/init.d/functions; \ + progress=`expr $(PROGRESS_BASE) + $$i \* \( 100 - $(PROGRESS_BASE) \) / $(PROGRESS_TOT)`; \ + fi; + +############################################################## +# List of services that have dependencies. +# +# (Note: It is not necessary to list services that have no +# dependencies). + +# Include the relevant dependencies. If you intend to use this facility, +# you must provide 2 makefiles / runlevel, one for starting the services +# in the runlevel, and one for stopping the services in the runlevel. +# +# WARNING: If make attempts to include a file that does not exist, it will +# exit. This could cause your system to boot in an unfamiliar way. +include $(RCL_DIR)/deps.$(JOB).mk + +# Lastly, merge all the service output files into a single file. +# Note that the order of the service output in the merged file is not +# chronological. +create_final_output_file: $(START_RUNLEVEL) $(STARTAFTER_RUNLEVEL) + @$(LS) -Srt $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).* 2>/dev/null | $(XARGS) $(CAT) > $(FINAL_OUTPUT_FILE) 2>/dev/null + @$(RM) -f $(TMP_DIR)/$(TMPFILE_PREFIX).$(JOB).* 2>/dev/null +# EOF