[Logwatch-Devel] Patch for install_logwatch.sh in order to run under HP UX

laurent.dufour at havas.com laurent.dufour at havas.com
Wed Jan 25 12:03:05 MST 2006


Hi guys,


I modified a little bit the logwatch installer in order to make it run with
HP UX

In fact in HP UX (even in version 11.11) the install command does not have
the '-m' switch neither does it have the '-d' switch.


So I replace all 'install -m -d' with either 'cp' , 'cp -r', and chmod.


I also added a question to ask if the user want to install additional perl
modules.


Here is the patch against the current cvs tree.

[root at termx tmp]# diff -u install_logwatch_cvs.sh install_logwatch.sh
--- install_logwatch_cvs.sh     2006-01-25 19:23:05.000000000 +0100
+++ install_logwatch.sh 2006-01-25 19:55:02.000000000 +0100
@@ -43,7 +43,116 @@
 MANDIR="/usr/share/man"


+DEF_LSM_TITLE=logwatch
+DEF_LSM_VERSION=7.2.1
+DEF_LSM_DESCRIPTION="Logwatch is a customizable, pluggable log-monitoring
system.  It will go
+through your logs for a given period of time and make a report in the
areas
+that you wish with the detail that you wish.  Easy to use - works right
out
+of the package on many systems."
+DEF_LSM_AUTHOR="Kirk Bauer <kirk at kaybee.org>"
+DEF_LSM_COPY_POLICY=MIT
+
+
+
+
+
+
+
+# This function prompts the user with a question, returning true or false
+# depending on the answer.  The default return value should be specified
as
+# a second parameter (the question is the first).  0=yes, 1=no
+#
+function query
+{
+       QUESTION=$1
+       DEFAULT=$2
+                       echo "$QUESTION"
+                       if [ 0 -eq $DEFAULT ]; then
+                               echo " [Y/n/q] "
+                       else
+                               echo " [y/N/q] "
+                       fi
+                       read R
+
+                       [ "$R" = "Y" -o "$R" = "y" ] && return 0
+                       [ "$R" = "N" -o "$R" = "n" ] && return 1
+                       [ "$R" = "Q" -o "$R" = "q" ] && exit 1
+                       return $DEFAULT
+}
+
+
+# Greet the user, tell him what package he is about to install and
+# tell him who wrote this wonderful installation program.
+#
+function say_hello
+{
+       MESSAGE="You are about to install:
+    $DEF_LSM_TITLE $DEF_LSM_VERSION by $DEF_LSM_AUTHOR
+
+$DEF_LSM_DESCRIPTION
+
+Copying-policy: $DEF_LSM_COPY_POLICY
+
+This script will attempt to automagically set $DEF_LSM_TITLE up on your
+computer.
+
+Continue?"
+
+#      $CLEARSCR
+       if ! query "$MESSAGE" 0; then
+               exit 1
+       fi
+}
+
+
+function mkinstalldirs
+{
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman at prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id: setup.sh,v 1.16 1999/11/03 15:48:49 bre Exp $
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\//
/g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$INSTALLROOT/$pathcomp"; then
+        echo "mkdir $pathcomp" 1>&2
+
+        mkdir "$INSTALLROOT/$pathcomp" || lasterr=$?
+
+        if test ! -d "$INSTALLROOT/$pathcomp"; then
+          errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+return $errstatus
+
+# mkinstalldirs ends here
+}
+
+
 #Talk to user
+say_hello
+#Start install
 printf "#################################\n"
 printf "Preparing to install Logwatch\n"
 printf "Enter the path to the Logwatch BaseDir [$BASEDIR] : "
@@ -94,47 +203,93 @@
 echo "### Installing"

 #BASE
-install -m 0755 -d $BASEDIR
-install -m 0755 -d $BASEDIR/dist.conf
-install -m 0755 -d $BASEDIR/dist.conf/logfiles
-install -m 0755 -d $BASEDIR/dist.conf/services
-install -m 0755 -d $BASEDIR/default.conf
-install -m 0755 -d $BASEDIR/default.conf/logfiles
-install -m 0755 -d $BASEDIR/default.conf/services
-install -m 0755 -d $BASEDIR/default.conf/html
-install -m 0755 -d $BASEDIR/scripts
-install -m 0755 -d $BASEDIR/scripts/logfiles
-install -m 0755 -d $BASEDIR/scripts/services
-install -m 0755 -d $BASEDIR/scripts/shared
-install -m 0755 -d $BASEDIR/lib
-install -m 0644 README $BASEDIR/README
-install -m 0644 HOWTO-Customize-LogWatch $BASEDIR/HOWTO-Customize-LogWatch
-install -m 0644 conf/*.conf $BASEDIR/default.conf
-install -m 0644 conf/logfiles/* $BASEDIR/default.conf/logfiles
-install -m 0644 conf/services/* $BASEDIR/default.conf/services
-install -m 0644 conf/html/* $BASEDIR/default.conf/html
-install -m 0755 scripts/logwatch.pl $BASEDIR/scripts/logwatch.pl
+mkinstalldirs $BASEDIR
+mkinstalldirs $BASEDIR/dist.conf
+mkinstalldirs $BASEDIR/dist.conf/logfiles
+mkinstalldirs $BASEDIR/dist.conf/services
+mkinstalldirs $BASEDIR/default.conf
+mkinstalldirs $BASEDIR/default.conf/logfiles
+mkinstalldirs $BASEDIR/default.conf/services
+mkinstalldirs $BASEDIR/default.conf/html
+mkinstalldirs $BASEDIR/scripts
+mkinstalldirs $BASEDIR/scripts/logfiles
+mkinstalldirs $BASEDIR/scripts/services
+mkinstalldirs $BASEDIR/scripts/shared
+mkinstalldirs $BASEDIR/lib
+
+chmod 0755 $BASEDIR
+chmod 0755 $BASEDIR/dist.conf
+chmod 0755 $BASEDIR/dist.conf/logfiles
+chmod 0755 $BASEDIR/dist.conf/services
+chmod 0755 $BASEDIR/default.conf
+chmod 0755 $BASEDIR/default.conf/logfiles
+chmod 0755 $BASEDIR/default.conf/services
+chmod 0755 $BASEDIR/default.conf/html
+chmod 0755 $BASEDIR/scripts
+chmod 0755 $BASEDIR/scripts/logfiles
+chmod 0755 $BASEDIR/scripts/services
+chmod 0755 $BASEDIR/scripts/shared
+chmod 0755 $BASEDIR/lib
+
+
+
+
+
+cp README $BASEDIR/README
+cp HOWTO-Customize-LogWatch $BASEDIR/HOWTO-Customize-LogWatch
+cp -r conf/*.conf $BASEDIR/default.conf
+cp -r conf/logfiles/* $BASEDIR/default.conf/logfiles
+cp -r conf/services/* $BASEDIR/default.conf/services
+cp -r conf/html/* $BASEDIR/default.conf/html
+cp scripts/logwatch.pl $BASEDIR/scripts/logwatch.pl
+
+chmod 0644 $BASEDIR/README
+chmod 0644 $BASEDIR/HOWTO-Customize-LogWatch
+chmod -R 0644 $BASEDIR/default.conf
+chmod -R 0644 $BASEDIR/default.conf/logfiles
+chmod -R 0644 $BASEDIR/default.conf/services
+chmod -R 0644 $BASEDIR/default.conf/html
+chmod 0755 $BASEDIR/scripts/logwatch.pl
+
+
+
 for i in scripts/logfiles/* ; do
    if [ `ls $i | grep -v CVS | wc -l` -ne 0 ] ; then
-      install -m 0755 -d $BASEDIR/$i
-      install -m 0644 $i/* $BASEDIR/$i
+      mkinstalldirs $BASEDIR/$i
+      chmod -R 0755 $BASEDIR/$i
+
+      cp -r $i/* $BASEDIR/$i
+      chmod -R 0644 "$BASEDIR/$i/"
    fi
 done
-install -m 0644 scripts/shared/* $BASEDIR/scripts/shared
-install -m 0644 scripts/services/* $BASEDIR/scripts/services
-install -m 0644 lib/* $BASEDIR/lib
+
+cp -r scripts/shared/* $BASEDIR/scripts/shared
+cp -r scripts/services/* $BASEDIR/scripts/services
+cp -r lib/* $BASEDIR/lib
+
+chmod -R 0644 $BASEDIR/scripts/shared
+chmod -R 0644 $BASEDIR/scripts/services
+chmod -R 0644 $BASEDIR/lib
+

 if [ $munge_base ]; then
        perl -pi -e "s%/usr/share/logwatch%$BASEDIR%"
$BASEDIR/scripts/logwatch.pl
 fi

 #CONFIG
-install -m 0755 -d $CONFIGDIR
-install -m 0755 -d $CONFIGDIR/scripts
-install -m 0755 -d $CONFIGDIR/conf
-install -m 0755 -d $CONFIGDIR/conf/logfiles
-install -m 0755 -d $CONFIGDIR/conf/services
-install -m 0755 -d $CONFIGDIR/conf/html
+mkinstalldirs $CONFIGDIR
+mkinstalldirs $CONFIGDIR/scripts
+mkinstalldirs $CONFIGDIR/conf
+mkinstalldirs $CONFIGDIR/conf/logfiles
+mkinstalldirs $CONFIGDIR/conf/services
+mkinstalldirs $CONFIGDIR/conf/html
+
+chmod 0755 $CONFIGDIR
+chmod 0755 $CONFIGDIR/scripts
+chmod 0755 $CONFIGDIR/conf
+chmod 0755 $CONFIGDIR/conf/logfiles
+chmod 0755 $CONFIGDIR/conf/services
+chmod 0755 $CONFIGDIR/conf/html

 if [ $munge_conf ]; then
        perl -pi -e "s%/etc/logwatch/conf%$CONFIGDIR/conf%"
$BASEDIR/scripts/logwatch.pl
@@ -149,7 +304,8 @@
 #The install would destory the perms on /tmp
 if [ ! -d $TEMPDIR ]; then
        #Should this be 0700 -d $TEMPDIR ??
-       install -m 0755 -d $TEMPDIR
+       mkinstalldirs $TEMPDIR
+       chmod 0755 $TEMPDIR
 fi

 #This can create duplicates need to grep first -mgt
@@ -165,16 +321,20 @@
 #Man page
 if [ -d $MANDIR/man8 ]; then
        #Should exist in BSD and Linux
-       install -m 0644 logwatch.8 $MANDIR/man8
+       cp logwatch.8 $MANDIR/man8
+        chmod 0644 $MANDIR/man8
        makewhatis -u -s 8 $MANDIR
 else
  if [ `uname -s` = "SunOS" ]; then
        #Go for the safe install rather then editing man.cf
-       install -m 0644 logwatch.8 $MANDIR/man1m
+       cp logwatch.8 $MANDIR/man1m
+        chmod 0644 $MANDIR/man1m
        catman -w -M /usr/share/man/man1m
  else
-       install -m 0755 -d $MANDIR/man8
-       install -m 0644 logwatch.8 $MANDIR/man8
+       mkinstalldirs $MANDIR/man8
+       chmod 0755 $MANDIR/man8
+       cp logwatch.8 $MANDIR/man8
+        chmod 0644 $MANDIR/man8
        printf "Installed manpage in $MANDIR/man8.\n"
        printf "Check your man.cf or man.conf to enable MANSECTS 8\n"
  fi
@@ -184,6 +344,15 @@
 ln -f -s $BASEDIR/scripts/logwatch.pl /usr/sbin/logwatch
 printf "Created symlink for /usr/sbin/logwatch \n"

+
+MESSAGE_INSTALL_PERL_MODULES="Do you want to install the perl modules
needed by logwatch"
+if query "$MESSAGE_INSTALL_PERL_MODULES" 0; then
+       perl -MCPAN -e 'install Date::Manip'
+       perl -MCPAN -e 'install Sys::CPU'
+       perl -MCPAN -e 'install Sys::MemInfo'
+fi
+
+
 #Cron
 if [ -d /etc/cron.daily ]; then
        rm -f /etc/cron.daily/0logwatch
@@ -191,7 +360,7 @@
        printf "Created /etc/cron.daily/0logwatch \n"
 else
        printf "You need to setup your cron job for logwatch, something
like \n"
-       printf "2 0 * * * /etc/logwatch/scripts/logwatch.pl >/dev/null 2>&1
\n"
+       printf "2 0 * * * /usr/sbin/logwatch >/dev/null 2>&1 \n"

 fi





Cheers.

----------------------------------------------------------------------------------------

Laurent DUFOUR - HAVAS IT
Vice Chief Technical Officer - Directeur Technique Adjoint
2 Allée de Longchamp - 92281 - Suresnes - France
tel: +33 (0)158478830 - fax: +33 (0)1 58478815
mailto:laurent.dufour at havas.com
http://www.havas.com
----------------------------------------------------------------------------------------





More information about the Logwatch-Devel mailing list