From 5b1ff87ac527d9481d9f3f2984794058d8938c1f Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Tue, 4 Jun 2013 21:16:10 -0400 Subject: [PATCH 1/1] =?utf8?q?Ajout=20hv-utilities=20et=20conversion=20?= =?utf8?q?=C3=A0=20autoconf?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- AUTHORS | 1 + COPYING | 340 +++++++++++++++++++++++++++++++++ ChangeLog | 2 + INSTALL | 370 ++++++++++++++++++++++++++++++++++++ Makefile.am | 20 ++ NEWS | 3 + README | 16 ++ TODO | 6 + autogen.sh | 4 + config/.gitignore | 0 configure.ac | 14 ++ data/Makefile.am | 14 ++ data/backup.conf | 7 + scripts/Makefile.am | 33 ++++ scripts/camera-download | 52 +++++ scripts/cd-copy | 26 +++ scripts/cd-erase | 38 ++++ scripts/cgrep | 16 ++ scripts/crypt.pl | 16 ++ scripts/distro-backup | 13 ++ scripts/dos2unix | 35 ++++ scripts/fix-avi | 149 +++++++++++++++ scripts/flac2mp3 | 46 +++++ scripts/flac2ogg | 44 +++++ scripts/gztobz2 | 49 +++++ scripts/hv-backup | 91 +++++++++ scripts/hv-scan | 77 ++++++++ scripts/hv-video-dvd | 140 ++++++++++++++ scripts/mail-files | 307 ++++++++++++++++++++++++++++++ scripts/mail-if-fail | 34 ++++ scripts/mail-statistics | 50 +++++ scripts/media-write | 157 +++++++++++++++ scripts/pstopdf | 37 ++++ scripts/replace.pl | 44 +++++ scripts/rotatelogs | 98 ++++++++++ scripts/setdate | 6 + scripts/strip-debug-symbols | 2 + scripts/tape-backup | 91 +++++++++ scripts/tape-backup-mult | 87 +++++++++ scripts/tape-list | 75 ++++++++ scripts/tape-restore | 36 ++++ scripts/tarbz2 | 26 +++ scripts/tildes-clean | 64 +++++++ scripts/vd | 25 +++ scripts/vl | 32 ++++ scripts/vs | 37 ++++ 46 files changed, 2830 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 TODO create mode 100755 autogen.sh create mode 100644 config/.gitignore create mode 100644 configure.ac create mode 100644 data/Makefile.am create mode 100755 data/backup.conf create mode 100644 scripts/Makefile.am create mode 100755 scripts/camera-download create mode 100755 scripts/cd-copy create mode 100755 scripts/cd-erase create mode 100755 scripts/cgrep create mode 100755 scripts/crypt.pl create mode 100755 scripts/distro-backup create mode 100755 scripts/dos2unix create mode 100755 scripts/fix-avi create mode 100755 scripts/flac2mp3 create mode 100755 scripts/flac2ogg create mode 100755 scripts/gztobz2 create mode 100755 scripts/hv-backup create mode 100755 scripts/hv-scan create mode 100755 scripts/hv-video-dvd create mode 100755 scripts/mail-files create mode 100755 scripts/mail-if-fail create mode 100755 scripts/mail-statistics create mode 100755 scripts/media-write create mode 100755 scripts/pstopdf create mode 100755 scripts/replace.pl create mode 100755 scripts/rotatelogs create mode 100755 scripts/setdate create mode 100755 scripts/strip-debug-symbols create mode 100755 scripts/tape-backup create mode 100755 scripts/tape-backup-mult create mode 100755 scripts/tape-list create mode 100755 scripts/tape-restore create mode 100755 scripts/tarbz2 create mode 100755 scripts/tildes-clean create mode 100755 scripts/vd create mode 100755 scripts/vl create mode 100755 scripts/vs diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..4295f32 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Author: Hugo Villeneuve (hugo@hugovil.com) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..09e39ed --- /dev/null +++ b/ChangeLog @@ -0,0 +1,2 @@ +2013-06-04 Hugo Villeneuve + * First version diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..a1e89e1 --- /dev/null +++ b/INSTALL @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, +Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..6709674 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,20 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in + +AUTOMAKE_OPTIONS = gnu + +SUBDIRS = scripts data + +## we want these in the dist tarball +EXTRA_DIST = autogen.sh + +ACLOCAL = aclocal -I $(ac_aux_dir) + +CLEANFILES = *~ + +DISTCLEANFILES = .deps/*.P + +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config-h.in \ + stamp-h.in $(ac_aux_dir)/depcomp \ + $(ac_aux_dir)/install-sh $(ac_aux_dir)/missing \ + $(ac_aux_dir)/mkinstalldirs $(ac_aux_dir)/config.guess \ + $(ac_aux_dir)/config.sub $(ac_aux_dir)/ltmain.sh diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..bed28c1 --- /dev/null +++ b/NEWS @@ -0,0 +1,3 @@ + +2-13-06-04: hv-utilities-0.1.0 has been released. + This is the initial release. diff --git a/README b/README new file mode 100644 index 0000000..1386306 --- /dev/null +++ b/README @@ -0,0 +1,16 @@ + hv-utilities + +A collection of vrious shell scripts + +Project website: + http://www.hugovil.com/en/hv-utilities + +For recent project news, see the NEWS file. + + +Building hv-utilities: +---------------------- + +For generic installation instructions, see the "INSTALL" file. + +If you are building from the git repository, first run the "autogen.sh" script. diff --git a/TODO b/TODO new file mode 100644 index 0000000..d432611 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +TODO +==== + +-Ajout répertoire conf +-Ajout optionel scripts tape + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..7d91719 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# autogen.sh -- Use this script to create generated files from the git distribution + +autoreconf -vfi diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..28c98f8 --- /dev/null +++ b/configure.ac @@ -0,0 +1,14 @@ +# configure.ac -- Process this file with autoconf to produce configure. + +dnl Initialization stuff. +AC_INIT(hv-utilities, 0.1.0) +AC_CONFIG_AUX_DIR(config) +AC_CONFIG_SRCDIR(scripts/vs) +dnl Checking if the NEWS file has been updated to reflect the current version. +AM_INIT_AUTOMAKE(check-news) +AM_SILENT_RULES([yes]) + +AC_SUBST(ac_aux_dir) + +dnl Creating output file(s) +AC_OUTPUT(Makefile scripts/Makefile data/Makefile) diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..8d76a5c --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,14 @@ +# This file is processed by GNU automake to generate Makefile.in + +# Install configuration files in $(sysconfdir) and distribute them. +dist_sysconf_DATA = \ + backup.conf + +# we want these in the dist tarball +EXTRA_DIST = + +CLEANFILES = *~ + +DISTCLEANFILES = .deps/*.P + +MAINTAINERCLEANFILES = Makefile.in diff --git a/data/backup.conf b/data/backup.conf new file mode 100755 index 0000000..6fab501 --- /dev/null +++ b/data/backup.conf @@ -0,0 +1,7 @@ +#!/bin/bash + +# List of files/directories to backup +BKP_FILES_LIST="/etc /root /srv /usr/local/bin" + +# Where to put backup +BKP_DEST_DIR="/mnt/nas/backup" diff --git a/scripts/Makefile.am b/scripts/Makefile.am new file mode 100644 index 0000000..476da1f --- /dev/null +++ b/scripts/Makefile.am @@ -0,0 +1,33 @@ +# This file is processed by GNU automake to generate Makefile.in + +# Install scripts in $(bindir) and distribute them. +dist_bin_SCRIPTS = \ + camera-download \ + cd-erase cd-copy media-write \ + cgrep \ + pstopdf \ + distro-backup \ + dos2unix \ + fix-avi \ + gztobz2 tarbz2 \ + hv-backup \ + hv-video-dvd \ + mail-files mail-if-fail mail-statistics \ + replace.pl \ + rotatelogs \ + setdate \ + strip-debug-symbols \ + tildes-clean \ + vd vs vl \ + flac2ogg flac2mp3 \ + hv-scan \ + tape-backup tape-backup-mult tape-list tape-restore + +# we want these in the dist tarball +EXTRA_DIST = + +CLEANFILES = *~ + +DISTCLEANFILES = .deps/*.P + +MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/camera-download b/scripts/camera-download new file mode 100755 index 0000000..5734b67 --- /dev/null +++ b/scripts/camera-download @@ -0,0 +1,52 @@ +#!/bin/sh + +PROG_NAME=$(basename $0) + +MOUNTPOINT=/media/camera +DIRNAME=$(date +%Y%m%d-%Hh%M) + +print_usage() +{ + echo "Usage: ${PROG_NAME} [OPTION]..." + echo + echo "Copy and delte images from digital camera." + echo + echo "Options:" + echo " -h display this help and exit" + exit 0 +} + +while getopts "h" flag ;do + case ${flag} in + h) + print_usage + ;; + ?) + echo "${PROG_NAME}: Invalid option: ${OPTARG}." + echo "Try \`${PROG_NAME} -h' for more information." + exit 1 + ;; + esac +done +shift `expr "${OPTIND}" - 1` + +# `$#' now represents the number of arguments after the options. +# `$1' is the first argument, etc. +if [ $# -ne 0 ]; then + echo "${PROG_NAME}: Too many arguments." + echo "Try \`${PROG_NAME} -h' for more information." + exit 1 +fi + + +if ! mount | grep -q ${MOUNTPOINT}; then + mount ${MOUNTPOINT} || exit 1 +fi + +mkdir -p ~/camera/${DIRNAME} && + +mv ${MOUNTPOINT}/dcim/???_???? ~/camera/${DIRNAME} + +umount /media/camera + +exit $? diff --git a/scripts/cd-copy b/scripts/cd-copy new file mode 100755 index 0000000..166698e --- /dev/null +++ b/scripts/cd-copy @@ -0,0 +1,26 @@ +#!/bin/sh + +# cd-copy: CD to CD copy + +# Load configuration informations about device +. /etc/sysconfig/cdrecord + +print_usage() +{ + echo "Usage: $(basename $0)" +} + +if [ $# != 0 ]; then + print_usage + exit 1 +fi + +if [ "x${CDROM_DEVICE}" != "x${CDREC_DEVICE}" ];then + CDRDAO_OPTS="--on-the-fly" +fi + +cdrdao copy ${CDRDAO_OPTS} \ + --source-device ${CDROM_DEVICE} \ + --device ${CDREC_DEVICE} ${CDRECORD_OPTS} --eject + +exit $? diff --git a/scripts/cd-erase b/scripts/cd-erase new file mode 100755 index 0000000..74930c2 --- /dev/null +++ b/scripts/cd-erase @@ -0,0 +1,38 @@ +#!/bin/sh + +# cd-erase + +# Load configuration informations about device +. /etc/sysconfig/cdrecord + +print_usage() +{ + echo "Usage: $(basename $0) {all|fast|session}" +} + +if [ $# = 0 -o $# -gt 1 ]; then + print_usage + exit 1 +fi + +ERASE_TYPE=${1} + +case "${ERASE_TYPE}" in + all) + ;; + + fast) + ;; + + session) + ;; + + *) + print_usage + exit 1 + ;; +esac + +cdrecord ${CDRECORD_OPTS} dev=${CDREC_DEVICE} blank=${ERASE_TYPE} + +exit $? diff --git a/scripts/cgrep b/scripts/cgrep new file mode 100755 index 0000000..84be2f1 --- /dev/null +++ b/scripts/cgrep @@ -0,0 +1,16 @@ +#!/bin/bash + +print_usage() +{ + echo "$(basename $0) -- Grep and Less front end." + echo "Usage: $(basename $0) GREP_STRING" +} + +if [ $# -ne 1 ]; then + print_usage + exit 1 +fi + +GREP_STRING=${1} + +grep --color=always -rn "${GREP_STRING}" * | less -RFX diff --git a/scripts/crypt.pl b/scripts/crypt.pl new file mode 100755 index 0000000..0b67a68 --- /dev/null +++ b/scripts/crypt.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +# Taken from http://rasterweb.net/raster/code/crypt.html +# +# I needed this for creating shadow passwords under Red Hat Linux 6.1, since +# passwords are not stored in plain text (that's a good idea) if I remember +# correctly, Red Hat had broken useradd, or adduser, or whatever the hell they +# were using at the time... + +srand (time()); +my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))"; +my $salt = sprintf ("%c%c", eval $randletter, eval $randletter); +my $plaintext = shift; +my $crypttext = crypt ($plaintext, $salt); + +print "${crypttext}\n"; diff --git a/scripts/distro-backup b/scripts/distro-backup new file mode 100755 index 0000000..006ab2b --- /dev/null +++ b/scripts/distro-backup @@ -0,0 +1,13 @@ +#!/bin/sh + +# linux HV backup + +export MEDIA_DEV="/dev/dvd" +export MEDIA_DIR="/media/dvd" + +export BKP_TMP_DIR=/mnt/video/tmp +BKP_FILES_LIST="/bin /boot /dev /etc /home /lib /opt /root /sbin /var /usr" + +media-write ${BKP_FILES_LIST} + +exit $? diff --git a/scripts/dos2unix b/scripts/dos2unix new file mode 100755 index 0000000..aca541a --- /dev/null +++ b/scripts/dos2unix @@ -0,0 +1,35 @@ +#!/bin/sh + +print_usage() +{ + echo "$(basename $0) -- Translates multiple DOS text file to UNIX." + echo "Usage: $(basename $0) dos-text-file" +} + +if [ $# = 0 ]; then + print_usage + exit 1 +fi + +TMPFILE="/tmp/dos2unix$$" + +while [ $# -ne 0 ]; do + # Checking if input file exist. + if [ ! -f $1 ]; then + echo "$0: File $1 not found." + print_usage + exit 1 + fi + # DOS files lines ends with CR+LF. Unix files lines ends with LF. + # Removing CR from DOS file (CR is 0x0D --> 015 in octal notation). + tr -d '\015' < $1 > $TMPFILE + if [ $? -eq 0 ] ; then + # Success + mv $TMPFILE $1 + fi + shift +done + +if [ -f $TMPFILE ]; then + rm $TMPFILE +fi diff --git a/scripts/fix-avi b/scripts/fix-avi new file mode 100755 index 0000000..0462a62 --- /dev/null +++ b/scripts/fix-avi @@ -0,0 +1,149 @@ +#!/bin/bash +# +# A script to correct the resolution of an AVI file and +# make a DVD without any stretching or squashing +# + +# NTSC values +dvd_width=720 +dvd_height=480 + +# Precision of computations +BC_SCALE=10 + +print_usage() +{ + echo "Usage: ${PROG_NAME} [OPTION]... WIDTHxHEIGHT" + echo + echo "Outputs ffmpeg options to correctly convert an AVI file," + echo "of width WIDTH and height HEIGHT, for creating a" + echo "video DVD." + echo + echo "Options:" + echo " -h display this help and exit" + echo " -w output in widescreen format (preferred)" + echo " -v verbose output" + echo + echo "When encoding to a 16:9 aspect MPEG (*see note below*)" + echo " +Source NTSC/PAL NTSC/PAL NTSC/PAL +Aspect CVD SVCD DVD + 4:3 Not Applicable: See above table for 1.33 resolutions + +16:9 *352x480 / *352x576 *480x480 / *480x576 352x480 / 352x576 704x480 / 704x576 720x480 / 720x576 + +1.85 *352x460 / *352x552 *480x460 / *480x552 352x460 / 352x552 704x460 / 704x552 720x460 / 720x552 + +2.20 *352x388 / *352x432 *480x388 / *480x464 352x388 / 352x464 704x388 / 704x464 720x388 / 720x464 + +2.35 *352x360 / *352x432 *480x360 / *480x432 352x360 / 352x432 704x360 / 704x432 720x360 / 720x432" +} + +#dvd_dar this is either 16:9 or 4:3 the Display Aspect Ratio +dvd_dar=`echo "scale=${BC_SCALE}; 4/3" | bc` +DISPLAY_DAR="4:3" + +while getopts "hwv" flag ;do + case ${flag} in + h) + print_usage + exit 0 + ;; + w) + # Widescreen, 16:9 + dvd_dar=`echo "scale=${BC_SCALE}; 16/9" | bc` + DISPLAY_DAR="16:9" + widescreen=yes + ;; + v) + VERBOSE=yes + ;; + ?) + echo "${PROG_NAME}: Invalid option: ${OPTARG}." + echo "Try \`${PROG_NAME} --help' for more information." + exit 1 + ;; + esac +done +shift `expr "${OPTIND}" - 1` + +# `$#' now represents the number of arguments after the options. +# `$1' is the first argument, etc. +if [ $# -ne 1 ]; then + print_usage + exit 1 +fi + + +calc_par() +{ + width=$1 + height=$2 + dar=$3 + + echo "scale=${BC_SCALE}; ($height*$dar)/$width" | bc +} + +src_width=$(echo $1 | sed "s!\([0-9]*\)x[0-9]*!\1!") +src_height=$(echo $1 | sed "s![0-9]*x\([0-9]*\)!\1!") + +src_dar=`echo "scale=${BC_SCALE}; $src_width/$src_height" | bc` +src_par=$(calc_par $src_width $src_height $src_dar) + +dvd_par=$(calc_par $dvd_width $dvd_height $dvd_dar) + +# when width of DVD is going to be 720, height will be: +out_height=`echo "scale=0; ($dvd_par*$dvd_width)/$src_dar" | bc` + +# Temporaire: +if [ ${out_height} -gt 480 -a ${out_height} -lt 485 ]; then + out_height=${dvd_height} +fi + +h22=`echo "scale=0; ($out_height/2)*2" | bc` + +# ...and working out height is even, if not add 1 to make it even +if [ $out_height != $h22 ]; then + out_height=`expr $out_height + 1` +fi + +#Padding needed +#And test if even pixels + +p=`echo "scale=0; ($dvd_height-$out_height)/2" | bc` +p22=`echo "scale=0; ($p/2)*2" | bc` + +# Padding values must be even. +if [ $p != $p22 ]; then + p_top=`expr $p - 1` + p_bot=`expr $p + 1` +else + p_bot=$p + p_top=$p +fi + +if [ "x${VERBOSE}" = "xyes" ]; then + out_par=$(calc_par $dvd_width $out_height $dvd_dar) + echo "Source:" + echo " Size................: ${src_width}x${src_height}" + echo " Display Aspect Ratio: ${src_dar}" + echo " Pixel Aspect Ratio..: ${src_par}" + echo + echo "DVD:" + echo " Size................: ${dvd_width}x${dvd_height}" + echo " Display Aspect Ratio: ${dvd_dar}" + echo " Pixel Aspect Ratio..: ${dvd_par}" + echo + echo "Output:" + echo " Size................: ${dvd_width}x${out_height}" + echo " Display Aspect Ratio: ${dvd_dar}" + echo " Pixel Aspect Ratio..: ${out_par}" + echo " Padding Top.........: ${p_top}" + echo " Padding Bottom......: ${p_bot}" + echo + echo "ffmpeg options:" +fi + +echo " -s ${dvd_width}x${out_height} -padtop ${p_top} -padbottom ${p_bot} -aspect ${DISPLAY_DAR}" + +exit $? diff --git a/scripts/flac2mp3 b/scripts/flac2mp3 new file mode 100755 index 0000000..5846f73 --- /dev/null +++ b/scripts/flac2mp3 @@ -0,0 +1,46 @@ +#!/bin/bash + +# default = 4 +# 0 = highest quality. +VBR_QUALITY="-V0" +LAME_OPTS="--noreplaygain ${VBR_QUALITY} --add-id3v2 --pad-id3v2 \ + --ignore-tag-errors" +METAFLAC="metaflac" + +print_usage() +{ + echo "$(basename $0) -- Translates FLAC file to MP3." + echo "Usage: $(basename $0) flac-file" +} + +if [ $# = 0 ]; then + print_usage + exit 1 +fi + +a=${1} + +# Checking if input file exist. +if [ ! -f $1 ]; then + echo "$0: File $a not found." + print_usage + exit 1 +fi + +OUTF=`echo "$a" | sed s/\.flac$/.mp3/g` + +ARTIST=`${METAFLAC} "$a" --show-tag=ARTIST | sed s/.*=//g` +TITLE=`${METAFLAC} "$a" --show-tag=TITLE | sed s/.*=//g` +ALBUM=`${METAFLAC} "$a" --show-tag=ALBUM | sed s/.*=//g` +GENRE=`${METAFLAC} "$a" --show-tag=GENRE | sed s/.*=//g` +TRACKNUMBER=`${METAFLAC} "$a" --show-tag=TRACKNUMBER | sed s/.*=//g` +DATE=`${METAFLAC} "$a" --show-tag=DATE | sed s/.*=//g` + +flac -c -d "$a" | lame ${LAME_OPTS} \ + --tt "$TITLE" \ + --tn "${TRACKNUMBER:-0}" \ + --ta "$ARTIST" \ + --tl "$ALBUM" \ + --ty "$DATE" \ + --tg "${GENRE:-12}" \ + - "$OUTF" diff --git a/scripts/flac2ogg b/scripts/flac2ogg new file mode 100755 index 0000000..08495d9 --- /dev/null +++ b/scripts/flac2ogg @@ -0,0 +1,44 @@ +#!/bin/bash + +# default = 3. +OGG_QUALITY="4" +OGGENC_OPTS="-q ${OGG_QUALITY}" +METAFLAC="metaflac" + +print_usage() +{ + echo "$(basename $0) -- Translates FLAC file to OGG." + echo "Usage: $(basename $0) flac-file" +} + +if [ $# = 0 ]; then + print_usage + exit 1 +fi + +a=${1} + +# Checking if input file exist. +if [ ! -f $1 ]; then + echo "$0: File $a not found." + print_usage + exit 1 +fi + +OUTF=`echo "$a" | sed s/\.flac$/.ogg/g` + +ARTIST=`${METAFLAC} "$a" --show-tag=ARTIST | sed s/.*=//g` +TITLE=`${METAFLAC} "$a" --show-tag=TITLE | sed s/.*=//g` +ALBUM=`${METAFLAC} "$a" --show-tag=ALBUM | sed s/.*=//g` +GENRE=`${METAFLAC} "$a" --show-tag=GENRE | sed s/.*=//g` +TRACKNUMBER=`${METAFLAC} "$a" --show-tag=TRACKNUMBER | sed s/.*=//g` +DATE=`${METAFLAC} "$a" --show-tag=DATE | sed s/.*=//g` + +flac -c -d "$a" | oggenc ${OGGENC_OPTS} \ + -t "$TITLE" \ + -N "${TRACKNUMBER:-0}" \ + -a "$ARTIST" \ + -l "$ALBUM" \ + -d "$DATE" \ + -G "${GENRE:-12}" \ + -o "$OUTF" - diff --git a/scripts/gztobz2 b/scripts/gztobz2 new file mode 100755 index 0000000..5bb9918 --- /dev/null +++ b/scripts/gztobz2 @@ -0,0 +1,49 @@ +#!/bin/sh + +print_usage() +{ + echo "$(basename $0) -- Convert multiple compressed gzip files to bzip2." + echo "Usage: $(basename $0) [FILES]" +} + +if [ $# = 0 ]; then + print_usage + exit 1 +fi + +while [ $# -ne 0 ]; do + ORIG_GZIPPED_FILENAME=${1} + + # Checking if input file exist. + if [ ! -f $1 ]; then + echo "$0: File ${ORIG_GZIPPED_FILENAME} not found." + exit 1 + fi + + # Checking if input file is a valid gzipped file. + gzip -t ${ORIG_GZIPPED_FILENAME} + if [ $? -ne 0 ] ; then + echo "$0: File ${ORIG_GZIPPED_FILENAME} is not a valid gzip file." + exit 1 + fi + + # Obtaining uncompressed name of file + FILENAME=$(gunzip -l ${ORIG_GZIPPED_FILENAME} | sed '1d' | sed 's/\(.*\)% \(.*\)/\2/') + + # Decompressing file to standard output and piping result to bzip2 + gunzip ${ORIG_GZIPPED_FILENAME} --stdout | bzip2 --best > ${FILENAME}.bz2 + if [ $? -ne 0 ] ; then + echo "$0: Error converting file ${ORIG_GZIPPED_FILENAME} to bzip2." + exit 1 + fi + + # Keeping the original file's timestamp + touch --reference=${ORIG_GZIPPED_FILENAME} ${FILENAME}.bz2 + + # Deleting original .gz file + if [ -f ${FILENAME}.bz2 ]; then + rm ${ORIG_GZIPPED_FILENAME} + fi + + shift +done diff --git a/scripts/hv-backup b/scripts/hv-backup new file mode 100755 index 0000000..81e2c96 --- /dev/null +++ b/scripts/hv-backup @@ -0,0 +1,91 @@ +#!/bin/bash + +# backup +# +# Creates a single compressed archive. + +if [ ! -f /etc/backup.conf ]; then + echo "Error: missing /etc/backup.conf configuration file." + exit 1 +fi + +# Read list of backup files/directories +source /etc/backup.conf + +# Set default value if not specified +: ${BKP_DEST_DIR:="./"} + +# Default value +ARCHIVE_LABEL="backup-data-amd64-`date '+%Y-%m-%d'`" + +# Exclude files list +EXC_LIST="/tmp/hv-backup-exclude-list" + +print_usage() +{ + echo "$(basename $0) - Backup files/directories." + echo "Usage: $(basename $0) [-h] [--label "label"]" +} + +if [ ${#} -gt 0 ]; then + if [ "x${1}" = "x-h" ]; then + print_usage + exit 0 + fi + if [ "x${1}" = "x--label" ]; then + if [ $# -lt 2 ]; then + echo "Missing arguments for --label option" + print_usage + exit 1 + fi + + ARCHIVE_LABEL=${2} + shift + shift + + if [ $# = 0 ]; then + echo "No directory to backup specified" + print_usage + exit 1 + fi + else + echo "Unknown arguments: ${@}" + print_usage + exit 1 + fi +fi + +ARCHIVE_NAME=${BKP_DEST_DIR}/${ARCHIVE_LABEL}.tar.bz2 + +echo "ARCHIVE_LABEL=$ARCHIVE_LABEL" + +cat > ${EXC_LIST} << "EOF" +/media/* +/proc/* +/dev/* +/sys/* +/tmp/* +*.sock +*.lock +*/.gvfs* +EOF + +# Finding sockets, and listing them in the exclude file. +# Errors and warnings must be discarded because of .gvfs directory for example. +# Even when using -prune option, find exits with a non-zero status when resding +# .gvfs +find ${BKP_FILES_LIST} -type s >> ${EXC_LIST} 2> /dev/null + +# Archiving +tar jcf ${ARCHIVE_NAME} ${BKP_FILES_LIST} \ + --label="${ARCHIVE_LABEL}" \ + --ignore-failed-read \ + --exclude-backups \ + --exclude-caches \ + --exclude-from=${EXC_LIST} \ + --absolute-names \ + --totals + +rm ${EXC_LIST} + +exit $? diff --git a/scripts/hv-scan b/scripts/hv-scan new file mode 100755 index 0000000..6398599 --- /dev/null +++ b/scripts/hv-scan @@ -0,0 +1,77 @@ +#!/bin/bash + +# Numérisation d'un document texte, et conversion en PDF + +jpeg_quality=10 +color_mode="Gray" +resolution="200" +extension="pdf" +scan_area="--scan-area Letter" +PROG_NAME=$(basename $0) + +print_usage() +{ + echo "${PROG_NAME} -- Numérisation document 8.5\"x11\" en PDF" + echo "Usage: ${PROG_NAME} [OPTIONS...] FICHIER" + echo + echo "Options:" + echo " -c numérisation en couleur (défaut = noir et blanc)" + echo " -h display this help and exit" + echo " -j format de sortie JPEG (défaut = PDF)" + echo " -q qualité JPEG (défaut = 10)" + echo " 1 = basse qualité" + echo " 100 = haute qualité" + echo " -r résolution (défaut = 200 DPI)" + echo " -p taille photo, 8.5\"x5.5\" (défaut = 8.5\"x11\")" + echo +} + +while getopts "chjpq:r:" flag ;do + case ${flag} in + c) + color_mode="Color" + ;; + j) + extension="jpg" + ;; + h) + print_usage + exit 0 + ;; + p) + scan_area="-l 0 -t 0 -x 215.9 -y 150" + ;; + q) + jpeg_quality=${OPTARG} + ;; + r) + # JPEG resolution + resolution=${OPTARG} + ;; + ?) + echo "${PROG_NAME}: Option invalide: ${OPTARG}." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 + ;; + esac +done +shift `expr "${OPTIND}" - 1` + +# `$#' now represents the number of arguments after the options. +# `$1' is the first argument, etc. +if [ $# -gt 1 ]; then + echo "${PROG_NAME}: Too many arguments." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 +fi + +if [ ${#} -ne 1 ]; then + echo "${PROG_NAME}: Nom de fichier manquant." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 +fi + +src=${1} + +scanimage --mode ${color_mode} --resolution ${resolution} ${scan_area} | \ + convert - -compress jpeg -quality ${jpeg_quality} ${src}.${extension} diff --git a/scripts/hv-video-dvd b/scripts/hv-video-dvd new file mode 100755 index 0000000..b3e5f9f --- /dev/null +++ b/scripts/hv-video-dvd @@ -0,0 +1,140 @@ +#!/bin/sh + +#==================================================== +# Options modifiables par l'usager. +#==================================================== + +# Pour convertir une portion seulement, ajouter: "-ss 00:00:00 -t 00:00:30" +START_TIME="00:00:00" +#DURATION="00:01:00" + +# Taille du fichier de sortie selon le video bitrate, +# pour un fichier source AVI de 345M: +# +# Non-spécifié: 811M +# 2000k: 726M +# 1400k: 594M + +# 1 ou 2 +PASSES=1 + +#==================================================== +# Fin des options modifiables par l'usager. +#==================================================== + +print_usage() +{ + echo "Usage: ${PROG_NAME} [OPTION]... FICHIER" + echo "" + echo "Conversion d'un fichier vidéo AVI au format MPEG-2 pour créer un DVD vidéo." + echo "" + echo "Options:" + echo " -a Display Aspect Ratio du DVD, 4:3 (avec barres noires ajoutées) ou 16:9 (widescreen)" + echo " -b video bitrate (ex: -b 1400k)" + echo " -h affiche cette aide et termine" + echo " -o nom du fichier de sortie" + echo " -s taille du fichier source [WxH]" + echo " -w grave le DVD" +} + +#==================================================== +# Options de la ligne de commande +#==================================================== + +while getopts "a:b:ho:s:w" flag ;do + case ${flag} in + a) + # Display Aspect Ratio of DVD, 4:3 (with blank bars added) or 16:9 (widescreen) + dvd_dar=${OPTARG} + ;; + b) + # Video bitrate + video_bitrate=${OPTARG} + ;; + h) + print_usage + exit 0 + ;; + o) + outfile=${OPTARG} + ;; + s) + src_size=${OPTARG} + ;; + w) + bruler="yes" + ;; + ?) + echo "${PROG_NAME}: Option invalide: ${OPTARG}." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 + ;; + esac +done +shift `expr "${OPTIND}" - 1` + +# `$#' now represents the number of arguments after the options. +# `$1' is the first argument, etc. +if [ $# -ne 1 ]; then + echo "Erreur: fichier source non-spécifié." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 +fi + +INFILE="${1}" + +if [ -z ${outfile} ]; then + outfile="$(basename ${INFILE} .avi).mpg" +fi + +if [ -z ${DURATION} ]; then + ARG_DURATION="" +else + ARG_DURATION="-t ${DURATION}" +fi + +if [ "x${dvd_dar}" = "x16:9" ]; then + ARG_WIDESCREEN="-w" +else + ARG_WIDESCREEN="" +fi + +if [ -z ${video_bitrate} ]; then + ARG_VIDEO_BIT_RATE="" +else + ARG_VIDEO_BIT_RATE="-b ${video_bitrate}" +fi + +if [ -z ${src_size} ]; then + echo "Erreur: taille du fichier source non-spécifiée." + exit 1 +fi + +#==================================================== +# Obtention des options à utiliser avec FFMPEG +#==================================================== +DVD_CONVERSION_OPTIONS=$(fix-avi ${ARG_WIDESCREEN} ${src_size} ) +# -y : Overwrite output files. +FFMPEG_OPT="-y -ss ${START_TIME} ${ARG_DURATION} -target ntsc-dvd ${ARG_VIDEO_BIT_RATE} ${DVD_CONVERSION_OPTIONS}" + +if [ ! -f ${INFILE} ]; then + echo "Erreur: fichier source absent." + exit 1 +fi + +if [ -f ${outfile} ]; then + echo "Fichier <${outfile}> déjà convertit, terminé." +else + for passe in $(seq ${PASSES}); do + if [ "x${PASSES}" = "x1" ]; then + PASSES_OPT="" + else + PASSES_OPT="-pass $passe" + fi + + echo "FFMPEG options: ${PASSES_OPT} ${FFMPEG_OPT}" + ffmpeg ${PASSES_OPT} -i ${INFILE} ${FFMPEG_OPT} ${outfile} || exit 1 + done +fi + +exit $? diff --git a/scripts/mail-files b/scripts/mail-files new file mode 100755 index 0000000..b910580 --- /dev/null +++ b/scripts/mail-files @@ -0,0 +1,307 @@ +#!/bin/sh + +# script to email files as attachments. +# ------------------------------------ + +# Additional documentation for this script, including a brief introdcution +# to MIME can be found at: http://home.clara.net/dwotton/unix/mail_files.htm + +# Written: Dave Wotton, July 1998, (Cambridge UK) +# This script comes with no warranty or support. You are +# free to modify it as you wish, but please retain an +# acknowledgement of my original authorship. + +# Amended: Dave Wotton, 6/3/99 +# -t flag now optional. subject also optional +# +# Amended: Dave Wotton, 3/8/00 +# added -b and -u options. By default a file-list which is not +# preceded by a -n, -b, or -u flag is now NOT encoded (the previous +# default was to base64 encode it.). +# +# Amended: Dave Wotton, 10/10/00 +# added a -c (cc:) option. +# Added a tty -s test to prevent the prompt to enter the text body +# being displayed when not connected to a tty. (The text body is +# still required though. /dev/null will suffice.) +# +# Amended: Dave Wotton, 24/2/01 +# Now uses perl to perform the base64 encoding, as it comes as +# standard on most modern Unixes. (You need the perl MIME package +# though, which I believe is standard. ) + +# Amended: Dave Wotton, 22/09/01 +# Now creates a "To:" header and uses the sendmail -t flag to +# duplicate this as the envelope recipients, rather than using the +# user supplied list of addresses simply as envelope recipients. +# This confused some mail clients, specifically Lotus Notes. + +# Amended: Dave Wotton, 30/09/01 +# Now initialises the main variables, so that previously set +# environment variable values (eg. $CC) aren't used instead. +# Enable multiple occurrences of the -t and -c flags. Thanks to +# Jason Judge for these suggestions. + + +# Usage: mail_files [-t] mailid [ -c mailid ] [ -s subject ] [ -f mailid ] +# [-n file_list] [-u file_list] [-b file_list] file_list +# +# -f : The mailid of the sender ( defaults to your userid ) +# Only userids that have been defined as "trusted" in the sendmail +# config file can make use of the -f option. For non-trusted users +# any value specified by this parameter will be ignored by +# sendmail. +# -t : The mailid of the recipient. Mandatory, no default +# multiple mailids can be specified, separated by commas. +# -c : The mailid of any carbon-copy recipients. Optional. +# multiple mailids can be specified, separated by commas. +# -s : The subject string. Optional, default = "Not specified". +# Enclose in quotes. +# -n : no-encode: indicates a list of files which are NOT to be base64 +# or uuencode encoded. Multiple files may be enclosed in double +# quotes. Usual wildcard notation can be used. This option is +# for completeness and can be omitted because the default action +# is not to encode the file-list. +# -b : base64 encoding: indicates a list of files which are to be +# base64 encoded. Multiple files may be enclosed in double quotes. +# Usual wildcard notation can be used. +# -u : uuencode encoding: indicates a list of files which are to be +# uuencode encoded. Multiple files may be enclosed in double +# quotes. Usual wildcard notation can be used. +# file_list : The list of files to send as attachments with no-encoding +# (same as -n option, but the file list does not need to be +# enclosed in quotes if more than one file specified). +# Usual wildcard notation can be used. + +# The program will also prompt for text to be supplied on standard input +# as the main text of the message. + +# eg. +# 1) mail_files Dave.Wotton -b file9.gif t*.htm < /dev/null +# +# email file9.gif as a base64 encoded attachment and the t*.htm +# files unencoded. +# +# 2) mail_files Dave.Wotton -s "my test" -b "file1.gif file2.gif" \ +# < /dev/null +# +# email file1.gif and file2.gif as base64 encoded attachments. + +# The script makes use of perl's MIME package to perform the base-64 +# encoding/decoding. + +# Note that files destined for Windows environments should have a name of +# the form aaaa.bbb where aaaa is up to 8 characters long, and bbb is a +# 3 character sufix. The suffix determines which program is used to +# display/process the data at the remote end. + +# Simple text files can be emailed unencoded. Binary files, or text files +# with long lines ( ie > 1000 chars ) should use the base64 or uuencode +# encoding procedures. Base64 is preferred because it is more universally +# supported. In particular, most PC mail-clients can automatically decode +# base64 encoded attachments. Note that simple text files with short lines +# which are destined for PC environments should not be base64 encoded. +# This is because PCs use a different line-break character to Unix. +# If the text is base64 encoded, the line-breaks are not converted +# automatically and so the data arrives at the remote end without +# line-breaks. + +# set up a 'usage' routine +# ------------------------ + +usage() +{ + [ "$1" ] && ( echo $* ; echo "" ) + + cat <);' < $F + + done +fi + +# Now process the uuencode encrypted attachments ... +# ---------------------------------------------- + +# Sorry, this bit is untested - I haven't got a mail-client which can +# handle uuencoded MIME messages automatically, so can't test if the +# 'Content-Transfer-Encoding: uuencode' line is correct and whether I +# need the uuencode "begin" and "end" lines. + +if [ "$UUE" ] +then + for F in $UUE + do + + BASE=`basename $F` + + echo --DMW.Boundary.605592468 + echo Content-Type: application/octet-stream\; name=\"$BASE\" + echo Content-Disposition: attachment\; filename=\"$BASE\" + echo Content-Transfer-Encoding: uuencode + echo + + uuencode < $F xxx + + done +fi + +# append the final boundary line ... + +echo --DMW.Boundary.605592468-- + +) | /usr/sbin/sendmail -t -r ${FROM} +#> test.txt diff --git a/scripts/mail-if-fail b/scripts/mail-if-fail new file mode 100755 index 0000000..733ff9b --- /dev/null +++ b/scripts/mail-if-fail @@ -0,0 +1,34 @@ +#!/bin/sh + +# This script is used to run a command. If the command failed, +# an email is sent to the address specified by MAILTO. + +# Begin of user modifiable variables +MAILFROM="${USER}" +MAILTO="root" +# End of User modifiable variables + +SENDMAIL="/usr/sbin/sendmail -t -r ${MAILFROM}" +MAILFILE="/tmp/mail-if-fail-output$$" +LOGFILE="/tmp/mail-if-fail-log$$" + +# Running the specified command +${*} 1> ${LOGFILE} 2>&1 + +ERROR_CODE=${?} + +if [ ${ERROR_CODE} -ne "0" ]; then + echo "From: ${MAILFROM}" > ${MAILFILE} + echo "To: ${MAILTO}" >> ${MAILFILE} + echo "Subject: \"${1}\" FAILED (${ERROR_CODE})" >> ${MAILFILE} + echo "Content-type: text/plain" >> ${MAILFILE} + echo "Output of command ${*}:" >> ${MAILFILE} + echo >> ${MAILFILE} + cat ${LOGFILE} >> ${MAILFILE} + cat ${MAILFILE} | ${SENDMAIL} || exit 1 + rm -f ${MAILFILE} +fi + +rm -f ${LOGFILE} + +exit ${ERROR_CODE} diff --git a/scripts/mail-statistics b/scripts/mail-statistics new file mode 100755 index 0000000..565aff8 --- /dev/null +++ b/scripts/mail-statistics @@ -0,0 +1,50 @@ +#!/bin/sh + +# Sendmail and Procmail log file analyzer + +# If no parameters are given, use current log file +if [ ${#} = 0 ]; then + SUFFIX="" + SUBDIR="" +elif [ $# -eq 1 ]; then + SUFFIX=".$1" + SUBDIR="backup" +else + echo "Usage: $0 [log file number]" + exit 1 +fi + + +SM_LOG_FILE=/var/log/${SUBDIR}/mail.log${SUFFIX} +PM_LOG_FILE=/var/log/${SUBDIR}/procmail.log${SUFFIX} + + +# Computes a ratio +# arg 1: numerator +# arg 2: denumerator +hv_ratio() +{ + echo $(( ( ( ${1} * 100000 ) / ${2} ) / 1000 )) +} + + +# Sendmail (MTA) statistics +SM_REJECTED=$(cat ${SM_LOG_FILE} | grep 'ruleset=' | wc -l) +SM_ACCEPTED=$(cat ${SM_LOG_FILE} | grep 'stat=Sent' | grep 'mailer=local' | wc -l) +SM_TOTAL=$(( ${SM_REJECTED} + ${SM_ACCEPTED} )) + +# Procmail (MDA) statistics +SPAM_COUNT=$(cat ${PM_LOG_FILE} | grep 'procmail: Match on \"\^X-Spam-Status: Yes' | wc -l) +HAM_COUNT=$(cat ${PM_LOG_FILE} | grep 'procmail: No match on \"\^X-Spam-Status: Yes' | wc -l) +SA_TOTAL=$(( ${SPAM_COUNT} + ${HAM_COUNT} )) + +echo "Sendmail statistics (MTA):" +echo " Accepted: $((${SM_ACCEPTED}))" +echo " Total: ${SM_TOTAL}" +echo " Ratio: $(hv_ratio ${SM_ACCEPTED} ${SM_TOTAL})%" +echo "SpamAssassin statistics:" +echo " Spam: $((${SPAM_COUNT}))" +echo " Total: ${SA_TOTAL}" +echo " Ratio: $(hv_ratio ${SPAM_COUNT} ${SA_TOTAL})%" + +exit 0 diff --git a/scripts/media-write b/scripts/media-write new file mode 100755 index 0000000..e66dba6 --- /dev/null +++ b/scripts/media-write @@ -0,0 +1,157 @@ +#!/bin/sh + +# Write files/directories on CD or DVD + +# Load configuration informations about device +. /etc/sysconfig/cdrecord + +# Maximum size in Mbytes +CD_MEDIA_SIZE=700 +DVD_MEDIA_SIZE=4400 + +GROWISOFS_OPTS="-dvd-compat" + +# Try to read ATIP infos for CD disks to estimate capacity... +MEDIA_ATIP_INFOS=$(cdrecord dev=${MEDIA_DEV} -atip 2>&1) + +if echo ${MEDIA_ATIP_INFOS} | grep -q "ATIP info from disk"; then + MEDIA_SIZE=${CD_MEDIA_SIZE} + MEDIA_TYPE="CD" + echo "CD disk detected" +elif echo ${MEDIA_ATIP_INFOS} | grep -q "Found DVD media but"; then + MEDIA_SIZE=${DVD_MEDIA_SIZE} + MEDIA_TYPE="DVD" + echo "DVD disk detected" +elif echo ${MEDIA_ATIP_INFOS} | grep -q "cdrecord: No disk / Wrong disk"; then + echo "No disk inserted, aborting" + exit 1 +else + echo "Unable to determine disk capacity, aborting" + exit 1 +fi + +echo "Disk capacity is ${MEDIA_SIZE} Mbytes" + +BKP_TMP_DIR=${BKP_TMP_DIR:-"/tmp"} +TMP_FILE="${BKP_TMP_DIR}/media-write-file$$" +TMP_MOUNT="${BKP_TMP_DIR}/media-write-mount$$" + +print_usage() +{ + echo "Usage: $(basename $0) files..." +} + +evaluate_retval() +{ + last_error=$? + if [ ${last_error} -ne 0 ]; then + exit ${last_error} + fi +} + +if [ $# = 0 ]; then + print_usage + exit 1 +fi + +FILES_SIZE="0" + +FILES_WRITE_LIST=${*} + +for file in ${FILES_WRITE_LIST}; do + if [ -d ${file} -o -f ${file} ]; then + FILES_SIZE=$(expr ${FILES_SIZE} + `du -m ${file} -s | sed 's/\([0-9]*\).*/\1/g'`) + else + echo "$0: Directory or file ${file} not found." + print_usage + exit 1 + fi +done + +echo "Total size of files to backup is ${FILES_SIZE}Mbytes" + +# The ext2 filesystem is not as space-efficient as the reiser filesystem, +# so we must add a few megabytes... +FILES_SIZE=`expr $FILES_SIZE + 20` + +if [ ${FILES_SIZE} -gt ${MEDIA_SIZE} ]; then + echo "Total size is greater than media capacity, aborting" + exit 1 + #####FILES_SIZE=${MEDIA_SIZE} +fi + +# Create an empty file of $FILES_SIZE +dd if=/dev/zero of=${TMP_FILE} bs=1024k count=${FILES_SIZE} +if [ $? -ne 0 ]; then + echo "Error while creating empty file..." + rm -f ${TMP_FILE} + exit 1 +fi + +# Create an extended-2 filesystem on this file +echo y | /sbin/mke2fs -m 0 -b 2048 ${TMP_FILE} +if [ $? -ne 0 ]; then + echo "Error creating file system on empty file..." + rm -f ${TMP_FILE} + exit 1 +fi + +# Mount this empty file through the loopback device. +mkdir -p ${TMP_MOUNT} +mount -o loop -t ext2 ${TMP_FILE} ${TMP_MOUNT} +if [ $? -ne 0 ]; then + echo "Error mounting empty file..." + rm -f ${TMP_FILE} + rm -rf $TMP_MOUNT + exit 1 +fi + +# Removing lost+found directory +rmdir ${TMP_MOUNT}/lost+found + +# Copy files to $TMP_MOUNT and umount it afterwards. +echo "Copying files..." +cp -a --parents ${FILES_WRITE_LIST} ${TMP_MOUNT} +if [ $? -ne 0 ]; then + echo "Error while copying files..." + umount ${TMP_MOUNT} + rm -rf ${TMP_MOUNT} + rm -f ${TMP_FILE} + exit 1 +fi + +umount ${TMP_MOUNT} + +echo Press any key to burn files +read + +#*************************************************** +# Burning... +#*************************************************** +case "${MEDIA_TYPE}" in + CD) + cdrecord ${CDRECORD_OPTS} dev=${MEDIA_DEV} -data ${TMP_FILE} || exit 1 + ;; + DVD) + growisofs ${GROWISOFS_OPTS} -Z /dev/dvd=${TMP_FILE} || exit 1 + ;; + *) + echo "Unknown removable media type, aborting" + exit 1 + ;; +esac + +# Mounting the media to verify burned capacity +if ! grep -q ${MEDIA_DEV} /etc/mtab; then + mount ${MEDIA_DEV} ${MEDIA_DIR} || exit 1 +fi + +FILES_SIZE=$(du -m ${MEDIA_DIR} -s | sed 's/\([0-9]*\).*/\1/g') +echo "Total size of files backed-up is ${FILES_SIZE}Mbytes" + +umount ${MEDIA_DIR} + +rmdir ${TMP_MOUNT} +rm -f ${TMP_FILE} + +exit $? diff --git a/scripts/pstopdf b/scripts/pstopdf new file mode 100755 index 0000000..36e3b1c --- /dev/null +++ b/scripts/pstopdf @@ -0,0 +1,37 @@ +#!/bin/sh + +print_usage() +{ + echo "pstopdf -- Translates multiple Postscript files into a" + echo " unique PDF document." + echo "Usage: $(basename $0) [OPTION]... [FILE]..." + echo + echo " -o filename Specify the name of the generated PDF file. The" + echo " default is 'output.pdf'." +} + +while getopts ":o:" opt; do + case $opt in + o ) + PDF_FILE=$OPTARG + ;; + \? ) + print_usage + ;; + esac +done + +if [ -z "${PDF_FILE}" ]; then + PDF_FILE="output.pdf" +fi + +shift $(($OPTIND - 1)) + +if [ $# -eq 0 ]; then + print_usage + exit 1 +fi + +gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=${PDF_FILE} $@ + +exit 0 diff --git a/scripts/replace.pl b/scripts/replace.pl new file mode 100755 index 0000000..8347be6 --- /dev/null +++ b/scripts/replace.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w +# +# Usage: replace.pl original_string replacement_string input_filename +# This Perl script changes the string $original to $replacement in all files +# specified on the command line. +# 19950926 gkj +$original=$ARGV[0]; +$replacement=$ARGV[1]; +# The input record separator is defined by Perl global +# variable $/. It can be anything, including multiple +# characters. Normally it is "\n", newline. Here, we +# say there is no record separator, so the whole file +# is read as one long record, newlines included. +undef $/; + +$file=$ARGV[2]; + +if (! open(INPUT,"<$file") ) { + print STDERR "Can't open input file $bakfile\n"; + exit(0); +} + +# Read input file as one long record. +$data=; +close INPUT; + +if ($data =~ s/$original/$replacement/gi) { + $bakfile = "$file.bak"; + # Abort if can't backup original or output. + if (! rename($file,$bakfile)) { + die "Can't rename $file $!"; + } + if (! open(OUTPUT,">$file") ) { + die "Can't open output file $file\n"; + } + print OUTPUT $data; + close OUTPUT; + print STDERR "$file changed\n"; +} +else { + print STDERR "$file not changed\n"; +} + +exit(0); diff --git a/scripts/rotatelogs b/scripts/rotatelogs new file mode 100755 index 0000000..dd5cc41 --- /dev/null +++ b/scripts/rotatelogs @@ -0,0 +1,98 @@ +#!/bin/sh +# +# rotatelogs - rotate log files (local host) +# + +BACKUP_LOGDIR="/var/log/backup" + +LOGDIR_GLOBAL=/var/log +LOGFILES_GLOBAL="auth.log clamd.log freshclam.log cron.log daemon.log kern.log mail.log procmail.log scrollkeeper.log sys.log user.log xdm.log Xorg.0.log" + +LOGDIR_APACHE=/var/log/apache +LOGFILES_APACHE="access_log error_log ssl_request_log" + +LOGDIR_CUPS=/var/log/cups +LOGFILES_CUPS="access_log error_log" + +LOGDIR_NAMED=/srv/named/etc/namedb +LOGFILES_NAMED="named.run" + +# arg 1: Backup log directory +# arg 2: log filename +rotate_log() +{ + backup_log_dir=${1} + file=${2} + + for day in 8 7 6 5 4 3 2 1 0 ; do + if [ -f ${backup_log_dir}/${file}.${day} ]; then + mv ${backup_log_dir}/${file}.${day} ${backup_log_dir}/${file}.$((${day}+1)) || exit 1 + fi + done + + if [ -f ${file} ]; then + user=$(ls -l --numeric-uid-gid ${file} | awk '{ print $3 }') + group=$(ls -l --numeric-uid-gid ${file} | awk '{ print $4 }') + cp -a ${file} ${backup_log_dir}/${file}.0 || exit 1 + fi + + # Empty file + cp /dev/null ${file} && + chown ${user}.${group} ${file} && + chmod 640 ${file} + + return $? +} + +if [ ! -d ${BACKUP_LOGDIR} ]; then + mkdir ${BACKUP_LOGDIR} +fi + +# syslogd files +LOGDIR=${LOGDIR_GLOBAL} +cd ${LOGDIR} && +for file in ${LOGFILES_GLOBAL}; do + rotate_log ${BACKUP_LOGDIR} ${file} || exit 1 +done + +kill -HUP `cat /var/run/syslogd.pid` && + +# named (BIND) server log files (if installed) +LOGDIR=${LOGDIR_NAMED} +if [ -d ${LOGDIR} ]; then + cd ${LOGDIR} && + for file in ${LOGFILES_NAMED}; do + rotate_log ${BACKUP_LOGDIR} ${file} || exit 1 + done + + kill -HUP `cat /srv/named/var/run/named.pid` || exit 1 +fi + +# For Apache web server (if installed) +LOGDIR=${LOGDIR_APACHE} +if [ -d ${LOGDIR} ]; then + if [ ! -d ${BACKUP_LOGDIR}/apache ]; then + mkdir -p ${BACKUP_LOGDIR}/apache + fi + cd ${LOGDIR} && + for file in ${LOGFILES_APACHE}; do + rotate_log ${BACKUP_LOGDIR}/apache ${file} || exit 1 + done + + /usr/sbin/apachectl graceful && + sleep 2 +fi + +# For CUPS +LOGDIR=${LOGDIR_CUPS} +if [ -d ${LOGDIR} ]; then + if [ ! -d ${BACKUP_LOGDIR}/cups ]; then + mkdir -p ${BACKUP_LOGDIR}/cups + fi + cd ${LOGDIR} && + for file in ${LOGFILES_CUPS}; do + rotate_log ${BACKUP_LOGDIR}/cups ${file} || exit 1 + done +fi + +exit $? diff --git a/scripts/setdate b/scripts/setdate new file mode 100755 index 0000000..ce2f14e --- /dev/null +++ b/scripts/setdate @@ -0,0 +1,6 @@ +#!/bin/sh + +rm /var/lib/hwclock/adjtime +hwclock --localtime --set --date "2004/03/02 23:56:00" +hwclock --localtime --hctosys +date diff --git a/scripts/strip-debug-symbols b/scripts/strip-debug-symbols new file mode 100755 index 0000000..6adf92a --- /dev/null +++ b/scripts/strip-debug-symbols @@ -0,0 +1,2 @@ +find /{,usr/,usr/local/}{bin,sbin,lib} -type f -exec /usr/bin/strip --strip-debug '{}' ';' + diff --git a/scripts/tape-backup b/scripts/tape-backup new file mode 100755 index 0000000..1782eaf --- /dev/null +++ b/scripts/tape-backup @@ -0,0 +1,91 @@ +#!/bin/sh + +# tape-backup +# +# Creates a single archive on tape. After the backup is finished, +# the tape is rewound. + +# Read configuration informations +source /etc/backup.conf + +# Exclude files list +EXC_LIST="/tmp/exclude-sockets" + +print_usage() +{ + echo "$(basename $0) - Backup directories/files, starting at the beginning of the tape." + echo " After the backup is finished, the tape is rewound." + echo "Usage: $(basename $0) [-h] [--label "label"] DIR1 DIR2 ..." +} + +if [ ${#} -gt 0 ]; then + if [ "x${1}" = "x-h" ]; then + print_usage + exit 0 + fi +fi + +if [ $# = 0 ]; then + echo "Missing arguments" + print_usage + exit 1 +fi + +if [ "x${1}" = "x--label" ]; then + if [ $# -lt 2 ]; then + echo "Missing arguments for --label option" + print_usage + exit 1 + fi + + TAPE_LABEL=${2} + shift + shift + + if [ $# = 0 ]; then + echo "No directory to backup specified" + print_usage + exit 1 + fi + +else + TAPE_LABEL="CVDS Linux Mail/Web Server Backup (`date '+%Y-%m-%d'`)." +fi + +DIRECTORIES=${@} + +echo "TAPE_LABEL=$TAPE_LABEL" + +if ${MT} status | grep "ONLINE"; then + # Rewinding the tape + ${MT} rewind || exit 1 + + # Finding sockets + find ${DIRECTORIES} -type s > ${EXC_LIST} || exit 1 + + # Setting compression on + ${MT} compression 1 || exit 1 + + # Archiving + tar -cf /dev/tape ${DIRECTORIES} --ignore-failed-read --label="${TAPE_LABEL}" \ + --exclude="*.sock" --exclude="*.lock" --exclude-from=${EXC_LIST} \ + --absolute-names --totals || exit 1 + + if ! ${MT} status | grep "ONLINE"; then + echo "***** tape-drive status is not ONLINE" + exit 1 + fi + + # Rewinding the tape + ${MT} rewind || exit 1 + + # Ejecting tape + ${MT} offline || exit 1 + + rm ${EXC_LIST} +else + echo "***** WARNING TAPE DRIVE IS OFFLINE, NO BACKUPS PERFORMED" + exit 1 +fi + +exit $? diff --git a/scripts/tape-backup-mult b/scripts/tape-backup-mult new file mode 100755 index 0000000..e07269f --- /dev/null +++ b/scripts/tape-backup-mult @@ -0,0 +1,87 @@ +#!/bin/sh + +# tape-backup-mult +# +# Creates archive at current position of tape, thus enabling creation of +# multiple archives on a single tape. After the backup is finished, +# the tape is NOT rewound. + +# Read configuration informations +source /etc/backup.conf + +# Exclude files list +EXC_LIST="/tmp/exclude-sockets" + +print_usage() +{ + echo "$(basename $0) - Backup directories/files, starting at the current position of the tape." + echo " After the backup is finished, the tape is NOT rewound." + echo "Usage: $(basename $0) [-h] [--label "label"] DIR1 DIR2 ..." +} + +if [ ${#} -gt 0 ]; then + if [ "x${1}" = "x-h" ]; then + print_usage + exit 0 + fi +fi + +if [ $# = 0 ]; then + echo "Missing arguments" + print_usage + exit 1 +fi + +if [ "x${1}" = "x--label" ]; then + if [ $# -lt 2 ]; then + echo "Missing arguments for --label option" + print_usage + exit 1 + fi + + TAPE_LABEL=${2} + shift + shift + + if [ $# = 0 ]; then + echo "No directory to backup specified" + print_usage + exit 1 + fi + +else + TAPE_LABEL="Backup (`date '+%Y-%m-%d'`)" +fi + +DIRECTORIES=${@} + +echo "TAPE_LABEL=$TAPE_LABEL" + +if ${MT} status | grep "ONLINE"; then + + # We don't rewind the tape, we add a new archive at the current position of the tape. + + # Finding sockets + # Removed, because the find command returned: "find: /root/big-file.tar.bz2: Value too large for defined data type" + # (the file was 6G) + # find ${DIRECTORIES} -type s > ${EXC_LIST} || exit 1 + echo "" > ${EXC_LIST} + + # Setting compression on + ${MT} compression 1 || exit 1 + + # Archiving + tar -cf /dev/tape ${DIRECTORIES} --label="${TAPE_LABEL}" --exclude-from=${EXC_LIST} --absolute-names --totals || exit 1 + + if ! ${MT} status | grep "ONLINE"; then + echo "***** tape-drive status is not ONLINE" + exit 1 + fi + + rm ${EXC_LIST} +else + echo "***** WARNING TAPE DRIVE IS OFFLINE, NO BACKUPS PERFORMED" + exit 1 +fi + +exit $? diff --git a/scripts/tape-list b/scripts/tape-list new file mode 100755 index 0000000..d689cf6 --- /dev/null +++ b/scripts/tape-list @@ -0,0 +1,75 @@ +#!/bin/sh + +# tape-list + +# Read configuration informations +source /etc/backup.conf + +print_usage() +{ + echo "$(basename $0) - List content of tape archive." + echo "Usage: $(basename $0) [-h] [--label]" +} + +if [ ${#} -gt 0 ]; then + if [ "x${1}" = "x-h" ]; then + print_usage + exit 0 + fi +fi + +if [ $# -gt 1 ]; then + print_usage + exit 1 +fi + +if [ $# = 1 ]; then + if [ "x${1}" != "x--label" ]; then + echo "Invalid argument" + print_usage + exit 1 + fi + + print_label="1" +fi + +if ${MT} status | grep "ONLINE" 1> /dev/null 2>&1; then + + # Rewinding the tape + ${MT} rewind || exit 1 + + file="0" + quit="0" + + while [ ${quit} = "0" ]; do + + file="$(( ${file} + 1 ))" + + if [ "x${print_label}" = "x1" ]; then + echo "Label for archive #$file:" + tar tvf /dev/tape | grep "V---------" + if [ $? -ne 0 ]; then + echo "No archive #$file:" + quit="1" + fi + else + echo "Content of archive #$file:" + tar tvf /dev/tape || exit 1 + fi + + if [ ${quit} = "0" ]; then + # Position tape on next file + ${MT} fsf 1 + if [ $? -ne 0 ]; then + quit="1" + fi + fi + + done + +else + echo "TAPE DRIVE IS OFFLINE, NO LISTING PERFORMED" + exit 1 +fi + +exit $? diff --git a/scripts/tape-restore b/scripts/tape-restore new file mode 100755 index 0000000..5c101af --- /dev/null +++ b/scripts/tape-restore @@ -0,0 +1,36 @@ +#!/bin/sh + +# tape-restore + +# Read configuration informations +source /etc/backup.conf + +print_usage() +{ + echo "$(basename $0) - Restore file or directory from tape." + echo "Usage: $(basename $0) [-h] FILE" +} + +if [ ${#} -gt 0 ]; then + if [ "x${1}" = "x-h" ]; then + print_usage + exit 0 + fi +fi + +if [ $# != 1 ]; then + print_usage + exit 1 +fi + +if ${MT} status | grep "ONLINE"; then + # Rewinding the tape + ${MT} rewind || exit 1 + + # The tape is now positioned on the first archive + tar xvf /dev/tape ${@} || exit 1 +else + echo "TAPE DRIVE IS OFFLINE, NO RESTORE PERFORMED" +fi + +exit $? diff --git a/scripts/tarbz2 b/scripts/tarbz2 new file mode 100755 index 0000000..e7a6d93 --- /dev/null +++ b/scripts/tarbz2 @@ -0,0 +1,26 @@ +#!/bin/sh + +print_usage() +{ + echo "$(basename $0) -- Create bzip2 compressed TAR archive." + echo "Usage: $(basename $0) DIR" +} + +if [ $# -ne 1 ]; then + print_usage + exit 1 +fi + +DIR=${1%/} +BASE=$(basename ${DIR}) + +# Checking if directory exists. +if [ ! -d ${DIR} ]; then + echo "$0: Directory ${DIR} not found." + exit 1 +fi + +# Decompressing file to standard output and piping result to bzip2 +tar cvf - ${DIR} | bzip2 -9 > ${BASE}.tar.bz2 + +exit $? diff --git a/scripts/tildes-clean b/scripts/tildes-clean new file mode 100755 index 0000000..8c7dfaa --- /dev/null +++ b/scripts/tildes-clean @@ -0,0 +1,64 @@ +#!/bin/sh + +# No arguments --> clean the current directory + +PROG_NAME=$(basename $0) +MAXDEPTH="-maxdepth 1" + +print_usage() +{ + echo "Usage: ${PROG_NAME} [OPTION]... [SOURCE]" + echo + echo "Remove emacs backup files (ending with \`~') in SOURCE directory." + echo "If no SOURCE directory is specified, the current directory is" + echo "taken as SOURCE. Directory names ending with \`~' are not" + echo "removed, only files." + echo + echo "Options:" + echo " -h display this help and exit" + echo " -r allow cleanning of subdirectories" + exit 0 +} + +while getopts "hr" flag ;do + case ${flag} in + h) + print_usage + ;; + r) + MAXDEPTH="" + ;; + ?) + echo "${PROG_NAME}: Invalid option: ${OPTARG}." + echo "Try \`${PROG_NAME} --help' for more information." + exit 1 + ;; + esac +done +shift `expr "${OPTIND}" - 1` + +# `$#' now represents the number of arguments after the options. +# `$1' is the first argument, etc. +if [ $# -gt 1 ]; then + echo "${PROG_NAME}: Too many arguments." + echo "Try \`${PROG_NAME} --help' for more information." + exit 1 +fi + +if [ $# = 0 ]; then + source_dir="." +else + source_dir="${1}" +fi + +if [ ! -d ${source_dir} ]; then + echo "${PROG_NAME}: ${source_dir}: No such directory." + exit 1 +fi + +# We remove the trailing `/' at the end of directory, if present. +source_dir=$(echo ${source_dir} | sed 's/\/$//g') + +find ${source_dir} ${MAXDEPTH} -name '*~' -exec /bin/rm '{}' + + +exit $? diff --git a/scripts/vd b/scripts/vd new file mode 100755 index 0000000..9eb09a5 --- /dev/null +++ b/scripts/vd @@ -0,0 +1,25 @@ +#!/bin/bash + +VCS_SUPPORTED="GIT, Subversion or Mercurial" + +print_usage() +{ + echo "$(basename $0) -- diff for version control (${VCS_SUPPORTED}) with color output." + echo "Usage: $(basename $0) [OPTIONS...]" +} + +if [ "x${1}" = "x--help" ]; then + print_usage + exit 1 +fi + +if git diff 1> /dev/null 2>&1; then + git diff "$@" +elif svn diff 1> /dev/null 2>&1; then + svn diff --diff-cmd colordiff -x "-u -w -p" "$@" | less -RFX +elif hg status 1> /dev/null 2>&1; then + hg diff "$@" +else + echo "Not a ${VCS_SUPPORTED} repository" + exit 1 +fi diff --git a/scripts/vl b/scripts/vl new file mode 100755 index 0000000..a19a374 --- /dev/null +++ b/scripts/vl @@ -0,0 +1,32 @@ +#!/bin/bash + +VCS_SUPPORTED="GIT, Subversion or Mercurial" + +print_usage() +{ + echo "$(basename $0) -- log for version control (${VCS_SUPPORTED})." + echo "Usage: $(basename $0) [OPTIONS...]" +} + +if [ "x${1}" = "x--help" ]; then + print_usage + exit 1 +fi + +SVN_LOG_REV_INFO_COLOR=$(echo -e '\033[1;31m') # Red +SVN_LOG_SEPARATION_COLOR=$(echo -e '\033[1;32m') # Green +NORMAL=$(echo -e '\033[0m') + +if git diff 1> /dev/null 2>&1; then + git log "$@" +elif svn diff 1> /dev/null 2>&1; then + # Colore les lignes --------- en vert + # Colore en rouge les infos de la révision + svn log "$@" | sed -e "s/^-\+$/${SVN_LOG_SEPARATION_COLOR}\0${NORMAL}/" \ + -e "s/^r[0-9]\+.\+$/${SVN_LOG_REV_INFO_COLOR}\0${NORMAL}/" | less -RFX +elif hg status 1> /dev/null 2>&1; then + hg glog "$@" +else + echo "Not a ${VCS_SUPPORTED} repository" + exit 1 +fi diff --git a/scripts/vs b/scripts/vs new file mode 100755 index 0000000..6719db1 --- /dev/null +++ b/scripts/vs @@ -0,0 +1,37 @@ +#!/bin/bash + +VCS_SUPPORTED="GIT, Subversion or Mercurial" + +print_usage() +{ + echo "$(basename $0) -- status for version control (${VCS_SUPPORTED})." + echo "Usage: $(basename $0) [OPTIONS...]" +} + +if [ "x${1}" = "x--help" ]; then + print_usage + exit 1 +fi + +SVN_ST_UNKNOWN_COLOR=$(echo -e '\033[1;34m') # Blue +SVN_ST_DELETED_COLOR=$(echo -e '\033[0;31m') # Red +SVN_ST_MISSING_COLOR=$(echo -e '\033[1;31m') # Red +SVN_ST_ADDED_COLOR=$(echo -e '\033[1;32m') # Green +SVN_ST_MODIFIED_COLOR=$(echo -e '\033[1;33m') # Yellow +NORMAL=$(echo -e '\033[0m') + +if git diff 1> /dev/null 2>&1; then + git status "$@" +elif svn diff 1> /dev/null 2>&1; then + svn status --ignore-externals "$@" | grep -v "^X" | \ + sed -e "s/^\?.*$/${SVN_ST_UNKNOWN_COLOR}\0${NORMAL}/" \ + -e "s/^!.*$/${SVN_ST_MISSING_COLOR}\0${NORMAL}/" \ + -e "s/^A.*$/${SVN_ST_ADDED_COLOR}\0${NORMAL}/" \ + -e "s/^M.*$/${SVN_ST_MODIFIED_COLOR}\0${NORMAL}/" \ + -e "s/^D.*$/${SVN_ST_DELETED_COLOR}\0${NORMAL}/" +elif hg status 1> /dev/null 2>&1; then + hg status "$@" +else + echo "Not a ${VCS_SUPPORTED} repository" + exit 1 +fi -- 2.20.1