aboutsummaryrefslogtreecommitdiffstats
path: root/mandriva/partmon
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2011-10-21 01:28:48 +0100
committerColin Guthrie <colin@mageia.org>2011-10-21 10:10:39 +0100
commitbe75c98a06d569fbaa2d86f92676af961795d094 (patch)
treee2ce8ce7ffb97af34164634a3fbd8630dc7463e8 /mandriva/partmon
parent4688ea25c9a5a87e48f89fc91a3c93a7c8c95b4a (diff)
downloadinitscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar
initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar.gz
initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar.bz2
initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar.xz
initscripts-be75c98a06d569fbaa2d86f92676af961795d094.zip
Add the mdkconf patch
Diffstat (limited to 'mandriva/partmon')
-rw-r--r--mandriva/partmon/Makefile14
-rw-r--r--mandriva/partmon/partmon59
-rw-r--r--mandriva/partmon/partmon.pl64
-rw-r--r--mandriva/partmon/partmon.sysconfig5
4 files changed, 142 insertions, 0 deletions
diff --git a/mandriva/partmon/Makefile b/mandriva/partmon/Makefile
new file mode 100644
index 00000000..7aaa5489
--- /dev/null
+++ b/mandriva/partmon/Makefile
@@ -0,0 +1,14 @@
+SH=partmon
+PL=partmon.pl
+
+all: check
+
+check:
+ @for i in $(SH);do /bin/bash -n $$i || exit 1;echo $$i syntax OK;done
+ @for i in $(PL);do perl -wc $$i || exit 1;done
+
+install:
+ mkdir -p $(ROOT)/usr/bin $(ROOT)/etc/rc.d/init.d
+ install -D -m755 partmon $(ROOT)/etc/rc.d/init.d/partmon
+ install -D -m755 partmon.pl $(ROOT)/usr/bin/partmon
+ install -D -m644 partmon.sysconfig $(ROOT)/etc/sysconfig/partmon
diff --git a/mandriva/partmon/partmon b/mandriva/partmon/partmon
new file mode 100644
index 00000000..60405d8f
--- /dev/null
+++ b/mandriva/partmon/partmon
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# Checks if a partition is close to full up
+#
+# description: Checks if a partition is close to full up
+# chkconfig: 345 13 20
+#
+### BEGIN INIT INFO
+# Provides: partmon
+# Default-Start: 3 4 5
+# Short-Description: Checks if a partition is close to full up
+# Description: Checks if a partition is close to full up
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# The following file prevents from "starting" again when changing
+# runlevel
+SYSCONF_FILE=/var/lock/subsys/partmon
+
+# See how we were called.
+case "$1" in
+ start)
+ gprintf "Checking if partitions have enough free diskspace: "
+ str=`/usr/bin/partmon`
+ if [ "$str" = "" ]; then
+ echo_success
+ touch $SYSCONF_FILE
+ else
+ echo # to start to print problems at column 0
+ echo $str
+ echo_failure
+ echo
+ exit 1
+ fi
+ echo
+ ;;
+ stop)
+ rm -f $SYSCONF_FILE
+ ;;
+ status)
+ if [ -f $SYSCONF_FILE ]
+ then
+ gprintf "partmon has been started"
+ else
+ gprintf "partmon has not been started, or check gave a failure"
+ fi
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ gprintf "Usage: %s\n" "$0 {start|stop|restart|status}"
+ exit 1
+esac
+
+exit 0
diff --git a/mandriva/partmon/partmon.pl b/mandriva/partmon/partmon.pl
new file mode 100644
index 00000000..d6d297b6
--- /dev/null
+++ b/mandriva/partmon/partmon.pl
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+#
+# Guillaume Cottenceau (gc@mandriva.com)
+#
+# Copyright 2002 Mandriva
+#
+# This software may be freely redistributed under the terms of the GNU
+# public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+#use strict;
+use MDK::Common;
+
+my ($verbose);
+
+sub free_space {
+ my ($mntpoint) = @_;
+ my ($blocksize, $size, $avail);
+ my $buf = ' ' x 20000;
+ syscall_('statfs', $mntpoint, $buf) or return;
+ (undef, $blocksize, $size, undef, $avail, undef) = unpack "L!6", $buf;
+ return $avail * ($blocksize / 1024);
+}
+
+my %partlimits = map { if_(/^(.*\S)(?:\s+?)(\d+)$/, $1 => $2 ) } cat_('/etc/sysconfig/partmon');
+
+
+my $params = join '', @ARGV;
+
+$params =~ /-h/ and die "usage: partmon [-v]\n";
+$params =~ /-v/ and $verbose = 1;
+
+
+my $ok = 1;
+foreach (cat_('/etc/fstab')) {
+ /^\s*#/ and next;
+ my (undef, $mountpoint, undef, undef, undef, undef) = split or next; #- I want at least 6 fields to consider it a valid entry
+ member($mountpoint, keys %partlimits) or next;
+ my $free = free_space($mountpoint);
+ $verbose and print "Free space of <$mountpoint> is <$free>\n";
+ if ($free < $partlimits{$mountpoint}) {
+ print "Warning, free space for <$mountpoint> is only <", free_space($mountpoint), "> (which is inferior to <$partlimits{$mountpoint}>\n";
+ $ok = 0;
+ }
+}
+
+$ok or exit -1;
+
+
+#-------------------------------------------------
+#- $Log$
+#- Revision 1.3 2006/05/11 12:45:38 tvignaud
+#- more s/Mandrakesoft/mandriva/
+#-
+#- Revision 1.2 2002/01/15 13:45:24 chmouel
+#- Fix warnings.
+#-
+#- Revision 1.1 2002/01/15 13:44:15 chmouel
+#- Add partition monitor from GC
+#-
diff --git a/mandriva/partmon/partmon.sysconfig b/mandriva/partmon/partmon.sysconfig
new file mode 100644
index 00000000..622e4492
--- /dev/null
+++ b/mandriva/partmon/partmon.sysconfig
@@ -0,0 +1,5 @@
+/ 20000
+/tmp 20000
+/usr 50000
+/var 50000
+/boot 5000