[debian-edu-commits] debian-edu/upstream/ 02/02: tagging version 0.0.12
Petter Reinholdtsen
pere at moszumanska.debian.org
Mon Mar 31 19:50:39 UTC 2014
This is an automated email from the git hooks/post-receive script.
pere pushed a commit to annotated tag 0.0.12
in repository sitesummary.
commit 238dd5195ba8f26ac13e894369c9303e08c1ff19
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Wed Oct 4 08:40:19 2006 +0000
tagging version 0.0.12
---
sitesummary/COPYING | 340 +++++++++++++++++++++++
sitesummary/Makefile | 63 +++++
sitesummary/README | 69 +++++
sitesummary/SiteSummary.pm | 153 ++++++++++
sitesummary/TODO | 3 +
sitesummary/apache.conf | 17 ++
sitesummary/collect.d/debian-edu | 11 +
sitesummary/collect.d/siteinfo | 13 +
sitesummary/collect.d/system | 29 ++
sitesummary/debian/changelog | 156 +++++++++++
sitesummary/debian/compat | 1 +
sitesummary/debian/control | 34 +++
sitesummary/debian/copyright | 35 +++
sitesummary/debian/po/POTFILES.in | 1 +
sitesummary/debian/po/output | 1 +
sitesummary/debian/po/templates.pot | 71 +++++
sitesummary/debian/rules | 13 +
sitesummary/debian/sitesummary-client.config | 41 +++
sitesummary/debian/sitesummary-client.cron.daily | 3 +
sitesummary/debian/sitesummary-client.dirs | 1 +
sitesummary/debian/sitesummary-client.init | 33 +++
sitesummary/debian/sitesummary-client.install | 4 +
sitesummary/debian/sitesummary-client.postinst | 91 ++++++
sitesummary/debian/sitesummary-client.templates | 23 ++
sitesummary/debian/sitesummary.cron.daily | 5 +
sitesummary/debian/sitesummary.install | 6 +
sitesummary/debian/sitesummary.postinst | 14 +
sitesummary/debian_edu-summary | 32 +++
sitesummary/kernelversion-summary | 28 ++
sitesummary/site-summary | 33 +++
sitesummary/sitesummary-client | 88 ++++++
sitesummary/sitesummary-client.conf | 5 +
sitesummary/sitesummary-collector.cgi | 158 +++++++++++
sitesummary/sitesummary-makewebreport | 29 ++
sitesummary/sitesummary-upload | 102 +++++++
35 files changed, 1706 insertions(+)
diff --git a/sitesummary/COPYING b/sitesummary/COPYING
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/sitesummary/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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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.
+
+ <signature of Ty Coon>, 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/sitesummary/Makefile b/sitesummary/Makefile
new file mode 100644
index 0000000..8b2005b
--- /dev/null
+++ b/sitesummary/Makefile
@@ -0,0 +1,63 @@
+DESTDIR =
+
+prefix = /usr
+sbindir = $(prefix)/sbin
+datadir = $(prefix)/share
+libdir = $(prefix)/lib
+cgibindir = $(libdir)/cgi-bin
+pkgdatadir = $(datadir)/sitesummary
+pkgdir = $(libdir)/sitesummary
+collectordir = $(libdir)/sitesummary/collect.d
+perldir = $(datadir)/perl5
+pkgvardir = /var/lib/sitesummary
+
+INSTALL = install
+INSTALL_DATA = $(INSTALL) -m 644
+
+COLLECTORS = \
+ collect.d/debian-edu \
+ collect.d/system \
+ collect.d/siteinfo
+
+SUMMARYSCRIPTS = \
+ site-summary \
+ kernelversion-summary \
+ debian_edu-summary
+
+all:
+
+install: install-server install-client
+
+install-server:
+ $(INSTALL) -d $(DESTDIR)$(cgibindir)
+ $(INSTALL) sitesummary-collector.cgi $(DESTDIR)$(cgibindir)
+
+ $(INSTALL) -d $(DESTDIR)$(sbindir)
+ $(INSTALL) sitesummary-makewebreport $(DESTDIR)$(sbindir)
+
+ $(INSTALL) -d $(DESTDIR)$(perldir)
+ $(INSTALL) -d $(DESTDIR)$(pkgdir)
+ $(INSTALL_DATA) SiteSummary.pm $(DESTDIR)$(perldir)
+ $(INSTALL) $(SUMMARYSCRIPTS) $(DESTDIR)$(pkgdir)/
+
+ $(INSTALL) -d $(DESTDIR)/etc/apache2/conf.d
+ $(INSTALL_DATA) apache.conf $(DESTDIR)/etc/apache2/conf.d/sitesummary
+
+ $(INSTALL) -o www-data -d $(DESTDIR)$(pkgvardir)/entries
+ $(INSTALL) -o www-data -d $(DESTDIR)$(pkgvardir)/tmpstorage
+ $(INSTALL) -d $(DESTDIR)$(pkgvardir)/www
+
+install-client:
+ $(INSTALL) -d $(DESTDIR)$(sbindir)
+ $(INSTALL) sitesummary-client sitesummary-upload $(DESTDIR)$(sbindir)
+ $(INSTALL) -d $(DESTDIR)$(pkgdatadir)
+ $(INSTALL_DATA) sitesummary-client.conf $(DESTDIR)$(pkgdatadir)/
+
+ $(INSTALL) -d $(DESTDIR)$(collectordir)
+ for collector in $(COLLECTORS) ; do \
+ $(INSTALL) $$collector $(DESTDIR)$(collectordir); \
+ done
+
+clean:
+ $(RM) *~ */*~
+distclean: clean
diff --git a/sitesummary/README b/sitesummary/README
new file mode 100644
index 0000000..1d3baef
--- /dev/null
+++ b/sitesummary/README
@@ -0,0 +1,69 @@
+Design draft
+
+sitesummary
+===========
+
+system to collect key info about all the machines on a site, to help
+the sysadmin keep track of a lot of hosts.
+
+Should be capable of handling both thin clients and "real machines"
+
+ - two package, one server sitesummary and one client sitesummary-client
+
+ - the client submits information to the server using HTTP put. It
+ include the list of files it intend to submit, to detect deleted
+ files.
+
+ - the HTTP connection is either using SSL, or the file(s) transfered
+ are GPG encrypted. (figure out key exchange system)
+
+ - the client submit a set of files and output from commands with hw
+ information etc (need plugin system to make it submit more files)
+
+ - lspci
+ - lsusb
+ - dmidecode
+ - uname -s / -m / -r / -v / -o
+ - ifconfig -a
+
+ - public ssh host key
+ - /etc/debian_version
+ - dpkg -l
+ - /etc/apt/sources.list
+ - /etc/fstab
+ - /proc/cpuinfo
+ - /proc/meminfo
+
+ - the server track changes done to the files (some version control
+ system like rcs?) on each host, and make summary report on the
+ number of individual machines reporting to the server
+
+ - how do we identify machines? MAC address could work (ip -s -f link
+ maddr - which when several interfaces?). IP addess will not work
+ for thin clients on private networks behind two different servers.
+ the linux hostid command is only using IP address and is useless.
+ Can not generate random key stored on the file system, as this
+ would give all thin clients on a server the same ID. dmidecode
+ serial number might work for some models, but others have the same
+ serial number on several machines.
+
+ - ideas for use of this info
+
+ - machine count, grouped by os/kernel/etc
+
+ - can generate a list of host keys for distribution to the clients
+
+ - can generate dhcp MAC<->IP mapping
+
+ - can generate lts.conf files for the LTSP clients
+
+The server can either be a CGI script, or listen on some port on its
+own.
+
+The client should be a platform independent script with as few
+dependencies as possible, to make it lightweight and easy to install
+on all machines. (perl, python, /bin/sh?)
+
+Should the client know which files to report, or should the server be
+able to affect it? Can cfengine, nagios or munin be used for this
+instead?
diff --git a/sitesummary/SiteSummary.pm b/sitesummary/SiteSummary.pm
new file mode 100644
index 0000000..1f33468
--- /dev/null
+++ b/sitesummary/SiteSummary.pm
@@ -0,0 +1,153 @@
+#
+# Support library for scripts parsing the sitesummary files.
+#
+
+package SiteSummary;
+require Exporter;
+
+our $VERSION = 0.01;
+our @ISA = qw(Exporter);
+our @EXPORT = qw(
+ for_all_hosts
+ get_filepath_current
+ get_site
+ get_sitegroup
+ get_linux_kernel_ver
+ get_debian_edu_profile
+ get_debian_edu_ver
+ );
+
+my $pwd = "/var/lib/sitesummary/entries"; # Path to the entries
+
+# File for debian-edu configuration
+my $debian_edu_config = "/debian-edu/config";
+
+sub get_filepath_current {
+ my ($hostid, $file) = @_;
+ return "$pwd/$hostid$file";
+}
+
+#
+# Return the value string from a file, ignoring comments
+#
+sub get_file_string {
+ my ($hostid, $filename) = @_;
+ my $path = get_filepath_current($hostid, $filename);
+ my $string;
+ if (open (FILE, $path)) {
+ while(<FILE>) {
+ chomp;
+ s/\#.+$//;
+ next if (/^\s*$/);
+ $string = $_;
+ }
+ close(FILE);
+ return $string;
+ } else {
+ return undef;
+ }
+}
+
+#
+# Return the site string
+#
+sub get_site {
+ my $hostid = shift;
+ return get_file_string($hostid, "/siteinfo/site");
+}
+
+#
+# Return the sitegroup string
+#
+sub get_sitegroup {
+ my $hostid = shift;
+ return get_file_string($hostid, "/siteinfo/sitegroup");
+}
+
+#
+# Return Linux kernel version for the machines using Linux.
+#
+sub get_linux_kernel_ver {
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, "/system/uname-smr");
+ my $kver;
+ if (open (FILE, $path)) {
+ while(<FILE>) {
+ chomp;
+ s/\#.+$//;
+ next if (/^\s*$/);
+ my @f = (split(/\s+/, $_));
+ $kver = $f[1] if ("Linux" eq $f[0]);
+ }
+ close(FILE);
+ return $kver;
+ } else {
+ return undef;
+ }
+}
+
+sub get_debian_edu_profile {
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, $debian_edu_config);
+ if ( ! -e $path ) {
+ return undef;
+ }
+ if (open (FILE, $path)) {
+ while (<FILE>) {
+ chomp;
+ s/\#.+$//;
+ next if not (/PROFILE/);
+ s/^PROFILE=//;
+ return $_;
+ }
+ }
+ close(FILE);
+}
+
+sub get_debian_edu_ver {
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, $debian_edu_config);
+ if ( ! -e $path ) {
+ return undef;
+ }
+ if (open (FILE, $path)) {
+ while (<FILE>) {
+ chomp;
+ s/\#.+$//;
+ next if not (/DEBIAN-EDU-VERSION/);
+ s/^"DEBIAN-EDU-VERSION=//;
+ return $_;
+ }
+ }
+}
+
+sub for_all_hosts {
+ my $callback = shift;
+
+ if ( ! -d $pwd ) {
+ print STDERR "error: Missing $pwd directory.\n";
+ return undef;
+ }
+ opendir(DIR, $pwd) or die "$!: $pwd\nDied";
+ my $count = 0;
+ foreach (readdir(DIR)) {
+ chomp;
+ next if m/^$/ || m/^.$/ || m/^..$/;
+ my $hostid = $_;
+ if ( -d "$pwd/$hostid" ) {
+ $count ++ if ($callback->($hostid));
+ } else {
+ print STDERR "warning: Junk in filelog: $pwd/$hostid\n";
+ }
+ }
+ closedir(DIR);
+ return $count;
+}
+
+1;
+
+########################################################################
+# Local Variables:
+# mode: perl
+# End:
+########################################################################
diff --git a/sitesummary/TODO b/sitesummary/TODO
new file mode 100644
index 0000000..e5dea60
--- /dev/null
+++ b/sitesummary/TODO
@@ -0,0 +1,3 @@
+- include version number in protocol exchange
+- implement encryption of submissions
+- generate more elegant web pages (with support for templates)
diff --git a/sitesummary/apache.conf b/sitesummary/apache.conf
new file mode 100644
index 0000000..262d525
--- /dev/null
+++ b/sitesummary/apache.conf
@@ -0,0 +1,17 @@
+#
+# New URL http://<host>/sitesummary/ listing the current statistics, and
+# http://<host>/cgi-bin/sitesummary-collector.cgi to receive submissions.
+#
+
+Alias /sitesummary /var/lib/sitesummary/www
+ScriptAlias /cgi-bin/sitesummary-collector.cgi /usr/lib/cgi-bin/sitesummary-collector.cgi
+
+<Directory /var/lib/sitesummary/www>
+ AllowOverride None
+ Options +SymLinksIfOwnerMatch -MultiViews
+
+ # allow only localhost per default
+ Order deny,allow
+ Deny from all
+ Allow from 127.0.0.1
+</Directory>
diff --git a/sitesummary/collect.d/debian-edu b/sitesummary/collect.d/debian-edu
new file mode 100644
index 0000000..8c054ff
--- /dev/null
+++ b/sitesummary/collect.d/debian-edu
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+mkdir debian-edu && cd debian-edu
+for filename in config ; do
+ file=/etc/debian-edu/$filename
+ if [ -f $file ] ; then
+ cp $file $filename
+ fi
+done
diff --git a/sitesummary/collect.d/siteinfo b/sitesummary/collect.d/siteinfo
new file mode 100755
index 0000000..73ad428
--- /dev/null
+++ b/sitesummary/collect.d/siteinfo
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# site = location
+# sitegroup = sublocation
+# hostclass = type of host (server, workstation, laptop, etc)
+
+mkdir siteinfo && cd siteinfo
+for filename in site sitegroup hostclass ; do
+ file=/etc/sitesummary/$filename
+ if [ -f $file ] ; then
+ cp $file $filename
+ fi
+done
diff --git a/sitesummary/collect.d/system b/sitesummary/collect.d/system
new file mode 100644
index 0000000..89b44bc
--- /dev/null
+++ b/sitesummary/collect.d/system
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
+
+# Keep going even if one of the programs report an error code
+# set -e
+
+mkdir system && cd system
+
+if type dmidecode >/dev/null 2>&1; then
+ dmidecode > dmidecode
+fi
+
+if type lspci >/dev/null 2>&1; then
+ lspci > lspci
+ lspci -n > lspci-n
+fi
+
+if type lsusb >/dev/null 2>&1; then
+ lsusb > lsusb
+fi
+
+if type lsscsi >/dev/null 2>&1; then
+ lsscsi > lsscsi
+fi
+
+uname -smr > uname-smr
+uname -n > hostname
+ifconfig -a > ifconfig-a
diff --git a/sitesummary/debian/changelog b/sitesummary/debian/changelog
new file mode 100644
index 0000000..ce502bb
--- /dev/null
+++ b/sitesummary/debian/changelog
@@ -0,0 +1,156 @@
+sitesummary (0.0.12) unstable; urgency=low
+
+ * Modify the system info collector script to ignore non-true exit
+ codes from the programs. This make sure it work on systems
+ without usb support, among other things.
+ * Modify client script to ignore non-true exit codes from the
+ collector fragments.
+ * Modify the sitesummary postinst script to make sure
+ /var/lib/sitesummary/tmpstorage and /var/lib/sitesummary/entries
+ are owned by user www-data. This give the cgi-script write access
+ to the storage area.
+ * Switch the client from cron.d to cron.daily.
+ * Add collector for debian-edu configuration. Correct server
+ summary part to use the collected file.
+
+ -- Petter Reinholdtsen <pere at debian.org> Wed, 4 Oct 2006 10:39:18 +0200
+
+sitesummary (0.0.11) unstable; urgency=low
+
+ * Fix minor typo in debian_edu-summary.
+ * Quiet down debian_edu-summary runs for machines without the
+ Debian Edu config file.
+
+ -- Petter Reinholdtsen <pere at debian.org> Fri, 22 Sep 2006 08:33:39 +0200
+
+sitesummary (0.0.10) unstable; urgency=low
+
+ * Fix typo in sitesummary postinst, breaking upgrades.
+
+ -- Petter Reinholdtsen <pere at debian.org> Wed, 20 Sep 2006 21:24:01 +0200
+
+sitesummary (0.0.9) unstable; urgency=low
+
+ * Initial upload into Debian.
+ * Improve template text.
+
+ -- Petter Reinholdtsen <pere at debian.org> Sun, 17 Sep 2006 20:17:48 +0200
+
+sitesummary (0.0.8) terra; urgency=low
+
+ [ Steffen Joeris ]
+ * Add missing dependency for sitesummary against apache2-common
+ which is needed for a2dissite in the postinst script
+ * Write subroutine for debian_edu_profile which is needed for the
+ debian-edu report to reflect the profile
+ * Add debian_edu-summary script and adjust Makefile and the
+ sitesummary-makewebreport script
+ * Write subroutine for debian_edu_vers to reflect the current
+ debian-edu-version
+
+ -- Steffen Joeris <steffen.joeris at skolelinux.de> Tue, 5 Sep 2006 21:21:24 +1000
+
+sitesummary (0.0.7) terra; urgency=low
+
+ [ Petter Reinholdtsen ]
+ * Add daily cron job to update web pages once a day.
+ * Remove old /etc/apache2/sites-available/sitesummary if it exist, to
+ cope with the new apache config structure introduced version 0.0.6.
+
+ [ Holger Levsen ]
+ * because debhelper.mk is used, the dependency on debhelper needs to
+ be >=4.1.0
+ * moved the build-depends-indep back to to build-depends, as build-depends
+ on cdbs and debhelper must not be arch independent build depends.
+ * updated fsf address in copyright
+
+ -- Holger Levsen <debian at layer-acht.org> Fri, 1 Sep 2006 16:12:33 +0200
+
+sitesummary (0.0.6) terra; urgency=low
+
+ [ Petter Reinholdtsen ]
+ * Let the client recommend cron, as it need it to call
+ in after the initial submission after boot.
+ * Add trivial sitesummary-makewebreport to make a web page with the summary
+ results.
+ * Let the collector store the IP peer info about each entry. Not
+ yet working, as the getpeername() code is broken.
+ * Extend package descriptions and make them more useful.
+ * Improve copyright file.
+ * Change build-depend to build-depend-indep, as this package
+ currently is architecture neutral.
+
+ [ Morten Werner Olsen ]
+ * Rewrite Apache example config and place it in /etc/apache2/conf.d/
+ as /etc/apache2/sites-available/ is ment for new virtualhosts (which
+ is not what we want).
+ * Add myself as uploader.
+
+ -- Petter Reinholdtsen <pere at debian.org> Thu, 31 Aug 2006 08:34:30 +0200
+
+sitesummary (0.0.5) terra; urgency=low
+
+ [ Petter Reinholdtsen ]
+ * Add debconf question for sitegroup and host class.
+ * Collect output from lsusb and lsscsi if they are present.
+ * Drop wget as dependency for sitesummary-client. It is no longer used.
+ * Include apache2 example configuration.
+ * Try to create the directories in /var/lib/sitesummary/ with www-data
+ as the owner, to allow the cgi script to write into them.
+ * Remove sitecontact references. I'm not sure it is the right place
+ for it, and we can reintroduce it if it proves to be a good idea.
+
+ [ Steffen Joeris ]
+ * Update debian/copyright file
+
+ -- Petter Reinholdtsen <pere at debian.org> Mon, 28 Aug 2006 18:26:01 +0200
+
+sitesummary (0.0.4) terra; urgency=low
+
+ [ Petter Reinholdtsen ]
+ * Reduce code duplication in SiteSummary.pm. Add new function
+ get_sitegroup().
+ * Extend site-summary script to also entries per sitegroup within a
+ site.
+
+ [ Steffen Joeris ]
+ * Add cdbs to build-depends
+ * Change build-depends-indep to build-depends as programs are needed
+ for the clean target
+ * Clean up control file and fix Recommends to make sure lintian is
+ happy
+ * Update debconf templates to fix a lintian warning
+
+ [ Petter Reinholdtsen ]
+ * Reduce compat level to 4 as #337664 is not affecting this package
+ after I modified it to not start the init.d script when the
+ package is installed. This make the source buildable in sarge.
+
+ -- Petter Reinholdtsen <pere at debian.org> Mon, 28 Aug 2006 08:05:55 +0200
+
+sitesummary (0.0.3) terra; urgency=low
+
+ * Remove temp file when it is processed by the collector.
+ * Include the directories in /var/lib/sitesummary/ used by the
+ collector in the sitesummary package.
+ * Make it easier to configure the time delay from the boot until a
+ report is submitted.
+ * Change the sitesummary-client postinst to not submit information
+ when the package is installed.
+
+ -- Petter Reinholdtsen <pere at debian.org> Sun, 27 Aug 2006 22:13:06 +0200
+
+sitesummary (0.0.2) terra; urgency=low
+
+ * Make temp file name more unique by adding process id to it, while
+ I wait for a working getpeername call.
+ * Add debconf question for collector URLs and site.
+
+ -- Petter Reinholdtsen <pere at debian.org> Sun, 27 Aug 2006 13:58:13 +0200
+
+sitesummary (0.0.1) terra; urgency=low
+
+ * Initial release.
+
+ -- Petter Reinholdtsen <pere at debian.org> Sat, 26 Aug 2006 12:04:28 +0200
+
diff --git a/sitesummary/debian/compat b/sitesummary/debian/compat
new file mode 100644
index 0000000..b8626c4
--- /dev/null
+++ b/sitesummary/debian/compat
@@ -0,0 +1 @@
+4
diff --git a/sitesummary/debian/control b/sitesummary/debian/control
new file mode 100644
index 0000000..110cf07
--- /dev/null
+++ b/sitesummary/debian/control
@@ -0,0 +1,34 @@
+Source: sitesummary
+Section: misc
+Priority: optional
+Maintainer: Debian Edu Developers <debian-edu at lists.debian.org>
+Uploaders: Petter Reinholdtsen <pere at debian.org>, Morten Werner Olsen <werner at debian.org>, Holger Levsen <debian at layer-acht.org>
+Build-Depends: debhelper (>= 4.1.0), cdbs
+Standards-Version: 3.7.2
+
+Package: sitesummary
+Architecture: all
+Depends: gnupg, apache2-common
+Recommends: ${misc:Depends}, apache2-mpm-worker | httpd, sitesummary-client
+Description: Generate site summary of submitting hosts (server part)
+ The sitesummary system makes it easier to keep track of a lot of
+ machines, by allowing each machine to report their existence once a
+ day to a central collector, and using this collector to make summary
+ reports about the hosts.
+ .
+ This package is the server part, with the collector and report
+ scripts.
+
+Package: sitesummary-client
+Architecture: all
+Depends: ${misc:Depends}, gnupg
+Recommends: cron, dmidecide, pciutils, usbutils, lsscsi, sitesummary
+Description: Generate site summary of submitting hosts (client part)
+ The sitesummary system makes it easier to keep track of a lot of
+ machines, by allowing each machine to report their existence once a
+ day to a central collector, and using this collector to make summary
+ reports about the hosts.
+ .
+ This package is the client part, reporting in to the server after
+ boot and once a day.
+
diff --git a/sitesummary/debian/copyright b/sitesummary/debian/copyright
new file mode 100644
index 0000000..40a1853
--- /dev/null
+++ b/sitesummary/debian/copyright
@@ -0,0 +1,35 @@
+This package was debianized by Petter Reinholdtsen on
+Thu Aug 24 10:02:05 CEST 2006 +0200.
+
+The current Debian maintainer is Petter Reinholdtsen
+
+It was downloaded from:
+ http://svn.debian.org/wsvn/debian-edu/trunk/src/sitesummary/
+
+Created by Petter Reinholdtsen, upstream authors are the debian-edu
+ team <debian-edu at lists.debian.org>
+
+Copyright: 2006 Petter Reinholdtsen
+
+ 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; version 2 of the License.
+
+ 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 with
+ the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
+ Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU General Public
+License, version 2, can be found in /usr/share/common-licenses/GPL-2.
+
+The file sitesummary-upload is placed in the public domain and was
+written by Bill Allombert and modified by Petter Reinholdtsen.
+
+The Debian packaging is copyright 2006 by Petter Reinholdtsen and
+licensed under the terms of the GNU General Public License version 2.
diff --git a/sitesummary/debian/po/POTFILES.in b/sitesummary/debian/po/POTFILES.in
new file mode 100644
index 0000000..e8c6bc0
--- /dev/null
+++ b/sitesummary/debian/po/POTFILES.in
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] sitesummary-client.templates
diff --git a/sitesummary/debian/po/output b/sitesummary/debian/po/output
new file mode 100644
index 0000000..8a91a1e
--- /dev/null
+++ b/sitesummary/debian/po/output
@@ -0,0 +1 @@
+2 utf8
diff --git a/sitesummary/debian/po/templates.pot b/sitesummary/debian/po/templates.pot
new file mode 100644
index 0000000..cb921e7
--- /dev/null
+++ b/sitesummary/debian/po/templates.pot
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: debian-edu at lists.debian.org\n"
+"POT-Creation-Date: 2006-09-17 20:23+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:1001
+msgid "URL:"
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:1001
+msgid ""
+"Insert the URL to the sitesummary collector, where should the sitesummary "
+"information be submitted. Several URLs can be specified separated by space."
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:2001
+msgid "Site:"
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:2001
+msgid "Insert a string identifying the site where this machine is located."
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:3001
+msgid "Sitegroup:"
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:3001
+msgid ""
+"Insert a string identifying the subgroup within the site where this machine "
+"is located."
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:4001
+msgid "Host class:"
+msgstr ""
+
+#. Type: string
+#. Description
+#: ../sitesummary-client.templates:4001
+msgid ""
+"Insert string identifying the host class, like workstation, server, laptop, "
+"thin client etc."
+msgstr ""
diff --git a/sitesummary/debian/rules b/sitesummary/debian/rules
new file mode 100755
index 0000000..0e44ce1
--- /dev/null
+++ b/sitesummary/debian/rules
@@ -0,0 +1,13 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/class/makefile.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+
+MAKE = make
+DEB_DESTDIR = debian/tmp
+
+# No need to submit information when the package is installed
+DEB_DH_INSTALLINIT_ARGS=--no-start
+
+common-install-indep::
+ $(MAKE) install DESTDIR=$(DEB_DESTDIR)
diff --git a/sitesummary/debian/sitesummary-client.config b/sitesummary/debian/sitesummary-client.config
new file mode 100644
index 0000000..ac5ebab
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.config
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# if we do not have debconf, we just skip this
+. /usr/share/debconf/confmodule || exit 0
+
+# Read the package default, need to match the code in sitesummary-client
+[ -f /usr/share/sitesummary/sitesummary-client.conf ] && \
+ . /usr/share/sitesummary/sitesummary-client.conf
+for confdir in \
+ /usr/share/sitesummary/config.d \
+ /etc/sitesummary/config.d
+do
+ [ -d $confdir ] || continue
+ for config in $confdir/* ; do
+ [ -f $config ] && . $config
+ done
+done
+db_set sitesummary-client/collector_url "$serverurls"
+db_input medium sitesummary-client/collector_url || true
+db_go || true
+
+if [ -f /etc/sitesummary/site ] ; then
+ SITE="`cat /etc/sitesummary/site`"
+ db_set sitesummary-client/site "$SITE"
+fi
+db_input medium sitesummary-client/site || true
+db_go || true
+
+if [ -f /etc/sitesummary/sitegroup ] ; then
+ SITEGROUP="`cat /etc/sitesummary/sitegroup`"
+ db_set sitesummary-client/sitegroup "$SITEGROUP"
+fi
+db_input medium sitesummary-client/sitegroup || true
+db_go || true
+
+if [ -f /etc/sitesummary/hostclass ] ; then
+ HOSTCLASS="`cat /etc/sitesummary/hostclass`"
+ db_set sitesummary-client/hostclass "$HOSTCLASS"
+fi
+db_input medium sitesummary-client/hostclass || true
+db_go || true
diff --git a/sitesummary/debian/sitesummary-client.cron.daily b/sitesummary/debian/sitesummary-client.cron.daily
new file mode 100644
index 0000000..9d9f0ae
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.cron.daily
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Run once a day to report the whereabouts of the machine
+[ -x /usr/sbin/sitesummary-client ] && nice /usr/sbin/sitesummary-client
diff --git a/sitesummary/debian/sitesummary-client.dirs b/sitesummary/debian/sitesummary-client.dirs
new file mode 100644
index 0000000..4000afd
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.dirs
@@ -0,0 +1 @@
+/etc/sitesummary
diff --git a/sitesummary/debian/sitesummary-client.init b/sitesummary/debian/sitesummary-client.init
new file mode 100644
index 0000000..c9f2dac
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.init
@@ -0,0 +1,33 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# provides: sitesummary-client
+# required-start: $network $remote_fs
+# required-stop:
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: Report status to sitesummary server after boot
+# Description: Report to sitesummary server 5 minutes
+# after the machine boots normally (not in single user)
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+CLIENT=/usr/sbin/sitesummary-client
+REPORTDELAY=300
+
+[ -f /etc/default/sitesummary-client ] && . /etc/default/sitesummary-client
+
+test -x $CLIENT || exit 0
+
+case "$1" in
+ start)
+ ( sleep $REPORTDELAY ; nice $CLIENT ) < /dev/null > /dev/null 2>&1 &
+ ;;
+ stop|reload|force-reload|restart)
+ ;;
+ *)
+ echo "Usage: /etc/init.d/atd {start|stop|restart|force-reload|reload}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/sitesummary/debian/sitesummary-client.install b/sitesummary/debian/sitesummary-client.install
new file mode 100644
index 0000000..d4ec071
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.install
@@ -0,0 +1,4 @@
+debian/tmp/usr/lib/sitesummary/collect.d
+debian/tmp/usr/sbin/sitesummary-client
+debian/tmp/usr/sbin/sitesummary-upload
+debian/tmp/usr/share/sitesummary/sitesummary-client.conf
diff --git a/sitesummary/debian/sitesummary-client.postinst b/sitesummary/debian/sitesummary-client.postinst
new file mode 100644
index 0000000..4a21703
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.postinst
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+case "$1" in
+ configure)
+ PREV_VER=$2
+ ;;
+ abort-upgrade|abort-remove|abort-deconfigure)
+ exit 0
+ ;;
+esac
+
+# Read the package default, need to match the code in sitesummary-client
+[ -f /usr/share/sitesummary/sitesummary-client.conf ] && \
+ . /usr/share/sitesummary/sitesummary-client.conf
+for confdir in \
+ /usr/share/sitesummary/config.d \
+ /etc/sitesummary/config.d
+do
+ [ -d $confdir ] || continue
+ for config in $confdir/* ; do
+ [ -f $config ] && . $config
+ done
+done
+
+db_get sitesummary-client/collector_url
+URL="$RET"
+
+# Only update the URLs if it is different from the current value
+if [ "$URL" != "$serverurls" ] ; then
+ if [ -f /etc/sitesummary/config.d/00debconf ] ; then
+ if grep -q '^serverurls=' /etc/sitesummary/config.d/00debconf ; then
+ sed "s%^serverurls=.*\$%serverurls=\"$URL\"%" < /etc/sitesummary/config.d/00debconf > /etc/sitesummary/config.d/00debconf.new && mv /etc/sitesummary/config.d/00debconf.new /etc/sitesummary/config.d/00debconf
+ else
+ echo "serverurls=\"$URL\"/" >> /etc/sitesummary/config.d/00debconf
+ fi
+ else
+ mkdir -p /etc/sitesummary/config.d
+ echo "serverurls=\"$URL\"" > /etc/sitesummary/config.d/00debconf
+ fi
+fi
+
+db_get sitesummary-client/site
+SITE="$RET"
+# Only replace the site file if the content changed
+if [ -f /etc/sitesummary/site ] ; then
+ OLDSITE="`cat /etc/sitesummary/site`"
+ if [ "$SITE" != "$OLDSITE" ] ; then
+ echo "$SITE" > /etc/sitesummary/site
+ fi
+else
+ echo "$SITE" > /etc/sitesummary/site
+fi
+
+db_get sitesummary-client/sitegroup
+SITEGROUP="$RET"
+# Only replace the sitegroup file if the content changed
+if [ -f /etc/sitesummary/sitegroup ] ; then
+ OLDSITEGROUP="`cat /etc/sitesummary/sitegroup`"
+ if [ "$SITEGROUP" != "$OLDSITEGROUP" ] ; then
+ echo "$SITEGROUP" > /etc/sitesummary/sitegroup
+ fi
+else
+ echo "$SITEGROUP" > /etc/sitesummary/sitegroup
+fi
+
+db_get sitesummary-client/hostclass
+HOSTCLASS="$RET"
+# Only replace the hostclass file if the content changed
+if [ -f /etc/sitesummary/hostclass ] ; then
+ OLDHOSTCLASS="`cat /etc/sitesummary/hostclass`"
+ if [ "$HOSTCLASS" != "$OLDHOSTCLASS" ] ; then
+ echo "$HOSTCLASS" > /etc/sitesummary/hostclass
+ fi
+else
+ echo "$HOSTCLASS" > /etc/sitesummary/hostclass
+fi
+
+db_stop
+
+# Switched from cron.d to cron.daily script in version 0.0.12
+if dpkg --compare-versions "$PREV_VER" lt "0.0.12" && \
+ [ -f /etc/cron.d/sitesummary-client ]
+then
+ rm -f /etc/cron.d/sitesummary-client
+fi
+
+#DEBHELPER#
diff --git a/sitesummary/debian/sitesummary-client.templates b/sitesummary/debian/sitesummary-client.templates
new file mode 100644
index 0000000..65fdc5c
--- /dev/null
+++ b/sitesummary/debian/sitesummary-client.templates
@@ -0,0 +1,23 @@
+Template: sitesummary-client/collector_url
+Type: string
+_Description: URL:
+ Insert the URL to the sitesummary collector, where should the
+ sitesummary information be submitted. Several URLs can be specified
+ separated by space.
+
+Template: sitesummary-client/site
+Type: string
+_Description: Site:
+ Insert a string identifying the site where this machine is located.
+
+Template: sitesummary-client/sitegroup
+Type: string
+_Description: Sitegroup:
+ Insert a string identifying the subgroup within the site where this
+ machine is located.
+
+Template: sitesummary-client/hostclass
+Type: string
+_Description: Host class:
+ Insert string identifying the host class, like workstation, server,
+ laptop, thin client etc.
diff --git a/sitesummary/debian/sitesummary.cron.daily b/sitesummary/debian/sitesummary.cron.daily
new file mode 100755
index 0000000..ca37ce5
--- /dev/null
+++ b/sitesummary/debian/sitesummary.cron.daily
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Update the web report once a day
+
+[ -x /usr/sbin/sitesummary-makewebreport ] && nice /usr/sbin/sitesummary-makewebreport
diff --git a/sitesummary/debian/sitesummary.install b/sitesummary/debian/sitesummary.install
new file mode 100644
index 0000000..1223730
--- /dev/null
+++ b/sitesummary/debian/sitesummary.install
@@ -0,0 +1,6 @@
+debian/tmp/etc/apache2
+debian/tmp/usr/lib/cgi-bin
+debian/tmp/usr/lib/sitesummary/*-summary
+debian/tmp/usr/sbin/sitesummary-makewebreport
+debian/tmp/usr/share/perl5
+debian/tmp/var/lib/sitesummary
diff --git a/sitesummary/debian/sitesummary.postinst b/sitesummary/debian/sitesummary.postinst
new file mode 100644
index 0000000..84b3f88
--- /dev/null
+++ b/sitesummary/debian/sitesummary.postinst
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+# Adjust to the new config location, in /etc/apache2/conf.d/sitesummary
+if [ -f /etc/apache2/sites-available/sitesummary ]; then
+ a2dissite sitesummary
+ rm /etc/apache2/sites-available/sitesummary
+fi
+
+# Make sure the cgi script can write to the storage area
+chown www-data /var/lib/sitesummary/tmpstorage /var/lib/sitesummary/entries
+
+#DEBHELPER#
diff --git a/sitesummary/debian_edu-summary b/sitesummary/debian_edu-summary
new file mode 100755
index 0000000..10e55d6
--- /dev/null
+++ b/sitesummary/debian_edu-summary
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use SiteSummary;
+my %profiles;
+my %versions;
+
+for_all_hosts(\&handle_host);
+
+print_summary();
+
+exit 0;
+
+sub handle_host {
+ my $hostid = shift;
+ my $profile = get_debian_edu_profile($hostid);
+ my $version = get_debian_edu_ver($hostid);
+ $profiles{$profile}++ if (defined $profile);
+ $versions{$version}++ if (defined $version);
+}
+
+sub print_summary {
+ printf(" %-30s %5s\n", "debian-edu-profile", "count");
+ foreach ( keys %profiles ) {
+ printf(" %30s %5s\n", $_ || "n/a", $profiles{$_});
+ }
+ printf(" %-30s %5s\n", "debian-edu-version", "count");
+ foreach ( keys %versions ) {
+ printf(" %30s %5s\n", $_ || "n/a", $versions{$_});
+ }
+}
diff --git a/sitesummary/kernelversion-summary b/sitesummary/kernelversion-summary
new file mode 100755
index 0000000..0298004
--- /dev/null
+++ b/sitesummary/kernelversion-summary
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use SiteSummary;
+
+my %kernelvers;
+
+for_all_hosts(\&handle_host);
+
+print_summary();
+
+sub handle_host {
+ my $hostid = shift;
+ #print "$hostid\n";
+ for my $kver (get_linux_kernel_ver($hostid)) {
+ $kver = "" unless defined $kver;
+ $kernelvers{$kver}++;
+ }
+}
+
+sub print_summary {
+ printf(" %-20s %5s\n", "kernel", "count");
+ for my $kver (sort keys %kernelvers) {
+ printf(" %-20s %5d\n", $kver, $kernelvers{$kver});
+ }
+}
diff --git a/sitesummary/site-summary b/sitesummary/site-summary
new file mode 100755
index 0000000..8461ef0
--- /dev/null
+++ b/sitesummary/site-summary
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use SiteSummary;
+
+my %sites;
+my %sitegroups;
+
+for_all_hosts(\&handle_host);
+
+print_summary();
+
+sub handle_host {
+ my $hostid = shift;
+ #print "$hostid\n";
+ for my $site (get_site($hostid)) {
+ $site = "" unless defined $site;
+ $sites{$site}++;
+ $sitegroups{$site}{get_sitegroup($hostid)}++ if get_sitegroup($hostid);
+ }
+}
+
+sub print_summary {
+ printf(" %-20s %5s\n", "site", "count");
+ for my $site (sort keys %sites) {
+ printf(" %-20s %5d\n", $site, $sites{$site});
+ for my $sitegroup (sort keys %{$sitegroups{$site}}) {
+ printf(" %-18s %5d\n", $sitegroup, $sitegroups{$site}{$sitegroup});
+ }
+ }
+}
diff --git a/sitesummary/sitesummary-client b/sitesummary/sitesummary-client
new file mode 100644
index 0000000..9e53e1f
--- /dev/null
+++ b/sitesummary/sitesummary-client
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Collect sytem information and pass it on to the sitesummary server
+# using HTTP put.
+
+# https://svn.revolutionlinux.com/MILLE/XTERM/trunk/mille-xterm-getltscfg/src/getltscfg.script
+
+set -e
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+# Make sure to store files in a ramfs backed
+# storage area on diskless clients, so use /tmp/.
+tmpdir=/tmp/sitesummary-$$
+
+log() {
+ msg="$@"
+ echo "$msg"
+ logger -p user.info -t sitesummary-client "$msg"
+}
+
+error() {
+ msg="$@"
+ log "error: $msg"
+}
+
+# Check or get GPG key, return false if it is unavailable
+get_gpg_key_if_missing() {
+ url="$1"
+ true
+}
+gpg_encrypt_for_url() {
+ url="$1"
+ infile="$2"
+ outfile="$2"
+
+ return
+
+ GPGOPTS="--no-default-keyring --keyring $urlkeyring"
+ gpg $GPGOPTS -e $infile > $outfile
+}
+
+# Read the package default
+[ -f /usr/share/sitesummary/sitesummary-client.conf ] && \
+ . /usr/share/sitesummary/sitesummary-client.conf
+for confdir in \
+ /usr/share/sitesummary/config.d \
+ /etc/sitesummary/config.d
+do
+ [ -d $confdir ] || continue
+ for config in $confdir/* ; do
+ [ -f $config ] && . $config
+ done
+done
+
+mkdir $tmpdir && cd $tmpdir
+
+for fragdir in $fragdirs ; do
+ [ -d $fragdir ] || continue
+ for frag in $fragdir/*; do
+ [ -x $frag ] && $frag || true
+ done
+done
+
+# Wrap up the package
+hostsummaryfile=$tmpdir.tar.gz
+tar zcf $hostsummaryfile .
+
+for url in $serverurls ; do
+ if [ "$gpgencrypt" != false ] ; then
+ if get_gpg_key_if_missing $url ; then
+ error "gpg key for '$url' is unavailable. refusing to submit."
+ continue
+ fi
+ gpg_encrypt_for_url $url "$hostsummaryfile" "$hostsummaryfile.gpg"
+ hostsummaryfile="$hostsummaryfile.gpg"
+ fi
+
+ #WGETOPTS="--no-check-certificate"
+ if sitesummary-upload -u $url -f $hostsummaryfile -d; then
+ :
+ else
+ error "unable to submit to '$url'"
+ fi
+done
+
+rm $hostsummaryfile
+rm -r $tmpdir
diff --git a/sitesummary/sitesummary-client.conf b/sitesummary/sitesummary-client.conf
new file mode 100644
index 0000000..0d74905
--- /dev/null
+++ b/sitesummary/sitesummary-client.conf
@@ -0,0 +1,5 @@
+serverurls="http://localhost/cgi-bin/sitesummary-collector.cgi"
+
+fragdirs="/usr/lib/sitesummary/collect.d /etc/sitesummary/collect.d"
+
+gpgencrypt=false
diff --git a/sitesummary/sitesummary-collector.cgi b/sitesummary/sitesummary-collector.cgi
new file mode 100644
index 0000000..6e4e676
--- /dev/null
+++ b/sitesummary/sitesummary-collector.cgi
@@ -0,0 +1,158 @@
+#!/usr/bin/perl -wT
+#
+# Receive HTTP post request with a file upload and process it as a
+# sitesummary submission.
+#
+# Handle three different submission methods
+# - mime-encoded upload with sitesummary report in compressed form
+
+use strict;
+use CGI;
+use POSIX qw(strftime);
+use Socket;
+
+my $basedir = "/var/lib/sitesummary";
+my $handlerdir = "/usr/lib/sitesummary/handler.d";
+
+$ENV{PATH} = "/bin:/usr/bin";
+
+print "Content-Type: text/plain\n\n";
+if (exists $ENV{REQUEST_METHOD} && $ENV{REQUEST_METHOD} ne "POST")
+{
+ print "Sitesummary HTTP-POST submission URL\n";
+ print "Visit http://debian-edu.alioth.debian.org/ for more info.\n";
+ exit 0;
+}
+
+# Extract post data, handle both simple and multipart way
+my @entry;
+my $filename = "unknown";
+if (exists $ENV{CONTENT_TYPE} && $ENV{CONTENT_TYPE} =~ m%multipart/form-data%){
+ my $query = new CGI;
+ my $fh = $query->upload("sitesummary");
+ if ($fh) {
+ $filename = $query->param("sitesummary");
+ my $type = $query->uploadInfo($filename)->{'Content-Type'};
+ if ("application/octet-stream" ne $type) {
+ print "Only 'application/octet-stream' is supported (not $type)!";
+ die;
+ } else {
+ my $encoding = $query->uploadInfo($filename)->{'Content-Encoding'};
+ if ("x-gzip" eq $encoding || "gzip" eq $encoding) {
+ # Uncompress
+ print "Compressed ($encoding) encoding detected.\n";
+ my $data;
+ # $data = join("", <$fh>);
+ my $len = (stat($fh))[7];
+ read $fh, $data, $len;
+ $data = Compress::Zlib::memGunzip($data);
+ @entry = ($data);
+ } else { # Pass throught
+ #print STDERR "Identity encoding detected.\n";
+ @entry = <$fh>;
+ }
+ }
+ } else {
+ print $query->cgi_error;
+ die;
+ }
+} else {
+ print <<EOF;
+Unsupported submission method.
+EOF
+}
+
+my ($peeripaddr, $peername) = get_peerinfo(\*STDIN);
+my $timestamp = strftime("%Y-%m-%dT%H:%M:%S", gmtime());
+
+if ($filename =~ m/.tar.gz$/) {
+ $filename = "sitesummary.tar.gz";
+} elsif ($filename =~ m/.tar.gz.gpg$/) {
+ $filename = "sitesummary.tar.gz.gpg";
+} else {
+ die "Unhandled file type '$filename'"
+}
+
+# XXX Come up with some unique file name.
+my $savefile = "$basedir/tmpstorage/$peeripaddr-$timestamp-$$-$filename";
+
+open(SITESUMMARY, ">$savefile") or die "Unable to write to $savefile";
+print SITESUMMARY @entry;
+close SITESUMMARY;
+
+print "Thanks for your submission to site-summary!\n";
+print "SITESUMMARY HTTP-POST OK\n";
+
+process_entry($peeripaddr, $peername, $savefile);
+
+unlink $savefile;
+
+exit 0;
+
+sub extract_unique_id {
+ my $eth0mac;
+ open(IFCONFIG, "system/ifconfig-a") || die "Unable to read ifconfig-a";
+ while (<IFCONFIG>) {
+ chomp;
+ $eth0mac = $1 if (m/eth0\s+Link encap:Ethernet HWaddr (\S+)/);
+ }
+ close (IFCONFIG);
+ #print STDERR "MAC: $eth0mac\n";
+ return "ether-$eth0mac";
+}
+
+sub process_entry {
+ my ($peeripaddr, $peername, $filename) = @_;
+ my $dirname;
+ if ($filename =~ m/(.+).tar.gz$/) {
+ $dirname = $1;
+ mkdir $dirname;
+ chdir $dirname;
+ `tar zxf $filename`;
+ } else {
+ die "Unhandled file format '$filename'";
+ }
+
+ open(PEERINFO, ">peerinfo") || die;
+ print PEERINFO "$peeripaddr $peername\n";
+ close(PEERINFO) || die;
+
+ my $id = extract_unique_id($dirname);
+ my $newdir = "$basedir/entries/$id";
+
+ my $status = "new";
+ if ( -d $newdir ) {
+ `rm -r $newdir`;
+ my $status = "update";
+ }
+
+ rename $dirname, $newdir || die;
+ for my $handler (<$handlerdir/*>) {
+ `$handler $newdir $status`;
+ }
+}
+
+sub get_peerinfo {
+ my $sockethandle = shift;
+
+ # Return something while this function do not work.
+ return ("127.0.0.1", "localhost");
+
+ # XXX The call to sockaddr_in trigger "Bad arg length for
+ # Socket::unpack_sockaddr_in, length is 2, should be 16 at
+ # /usr/lib/perl/5.8/Socket.pm line 198." No idea why.
+ my ($peerport, $peeripaddr) = sockaddr_in(getpeername($sockethandle));
+ if ($peerport) {
+ my $peername = gethostbyaddr($peeripaddr, AF_INET);
+
+ if ("" eq $peername) {
+ syslog('warning', "client without DNS entry connected from \[$peeripaddr\]");
+ $peername = "$peeripaddr";
+ }
+ } else {
+ # Running on the command line, use test host
+ $peeripaddr = "127.0.0.1";
+ $peername = "localhost";
+ }
+ return ($peeripaddr, $peername);
+}
diff --git a/sitesummary/sitesummary-makewebreport b/sitesummary/sitesummary-makewebreport
new file mode 100755
index 0000000..f517c88
--- /dev/null
+++ b/sitesummary/sitesummary-makewebreport
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# Make simple web page with summary information. This should be rewritten
+# to use some template system and be more flexible.
+#
+
+(
+cat <<EOF
+<html>
+<head>
+<title>sitesummary report</title>
+</head>
+<body>
+<h1>sitesummary report</h1>
+<pre>
+EOF
+
+for f in site-summary kernelversion-summary debian_edu-summary ; do
+ /usr/lib/sitesummary/$f
+ echo
+done
+
+cat <<EOF
+</pre>
+</body>
+EOF
+) > /var/lib/sitesummary/www/index.html
+
+exit 0
diff --git a/sitesummary/sitesummary-upload b/sitesummary/sitesummary-upload
new file mode 100755
index 0000000..6e5504c
--- /dev/null
+++ b/sitesummary/sitesummary-upload
@@ -0,0 +1,102 @@
+#!/usr/bin/perl -w
+# Written by Bill Allombert for the Debian popularity-contest project.
+# This file is placed in the public domain.
+# Rewritten for sitesummary by Petter Reinholdtsen
+
+use strict;
+use IO::Socket;
+use Getopt::Std;
+use File::Basename;
+
+my %opts;
+getopts("du:f:", \%opts);
+
+sub usage {
+ print <<"EOF";
+Usage: $0 [-Cd] [-u <url>] [-f <file>]
+ -d enable debugging
+ -u <url> submit to the given URL (default localhost)
+ -f <file> read popcon report from file (default stdin)
+EOF
+}
+
+my ($submiturl) = $opts{'u'} || "http://localhost/cgi-bin/sitesummary-collector.cgi";
+my ($file) = $opts{'f'} || "-";
+
+my ($host) = $submiturl =~ m%http://([^/]+)%;
+
+print "Unable to parse url\n" if ($opts{'d'} && ! $host);
+
+# Configure the proxy:
+my ($http_proxy,$proxy,$port,$remote);
+
+$http_proxy=$ENV{'http_proxy'};
+if (defined($http_proxy))
+{
+ $http_proxy =~ m{http://([^:]*)(?::([0-9]+))?}
+ or die ("unrecognized http_proxy");
+ $proxy=$1; $port=$2;
+}
+
+$proxy=$host unless (defined($proxy));
+$port=80 unless (defined($port));
+
+# Compress the report:
+my ($str,$len);
+my $encoding;
+open FILE, "< $file" or die "reading from '$file'";
+$encoding = "identity";
+$str .= $_ while(<FILE>);
+close(FILE);
+$len = length($str);
+
+# 30 second timeout on http connections
+$SIG{ALRM} = sub { die "timeout in sitesummary-upload\n" };
+alarm(30);
+
+# Connect to server
+$remote = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $proxy,
+ PeerPort => $port);
+unless ($remote) { die "cannot connect to $proxy:$port" }
+
+my $boundary = "----------ThIs_Is_tHe_bouNdaRY_\$";
+
+my $basefile = basename($file);
+
+#Content-Length: $len
+# text/plain; charset=utf-8
+my $ORS = "\r\n"; # Use DOS line endings to make HTTP happy
+my $form;
+$form .= "--${boundary}$ORS";
+$form .= "Content-Disposition: form-data; name=\"sitesummary\"; filename=\"$basefile\"$ORS";
+$form .= "Content-Encoding: $encoding$ORS";
+$form .= "Content-Type: application/octet-stream$ORS$ORS";
+$form .= "$str$ORS";
+$form .= "--${boundary}--$ORS";
+$form .= "$ORS";
+
+my $formlen = length($form);
+
+#Send data
+print $remote <<"EOF";
+POST $submiturl HTTP/1.1
+User-Agent: sitesummary-upload
+Host: $host
+content-type: multipart/form-data; boundary=$boundary
+content-length: $formlen
+
+$form
+EOF
+
+#Get answer
+my($answer)="";
+while(<$remote>)
+{
+ $answer.=$_;
+ m/SITESUMMARY HTTP-POST OK/ and last;
+}
+close ($remote);
+#Check answer
+my $status = ($answer =~ m/SITESUMMARY HTTP-POST OK/) ? 0 : 1;
+print "Failed to upload, answer '$answer'\n" if $status && $opts{'d'};
+exit $status;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/sitesummary.git
More information about the debian-edu-commits
mailing list