summaryrefslogtreecommitdiff
path: root/src/pmdas/mailq/Install
blob: efe1fd580a300008e68ac40e5bbef8b2ac4106f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /bin/sh
#
# Copyright (c) 1997-2000,2003 Silicon Graphics, Inc.  All Rights Reserved.
# 
# 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.
# 
# Install the mailq PMDA and/or PMNS
#

. $PCP_DIR/etc/pcp.env
. $PCP_SHARE_DIR/lib/pmdaproc.sh

iam=mailq
pmda_interface=2
forced_restart=false

# Do it
#
pmdaSetup

if $do_pmda
then

    dso_opt=false
    socket_opt=false
    pipe_opt=true

    mqueue=""
    chk=""

    if [ -f /etc/sendmail.cf ]
    then
	chk=`sed -n '/^O *QueueDirectory *= */s///p' /etc/sendmail.cf`
	[ -z "$chk" ] && chk=`sed -n '/^O *Q *\//s//\//p' /etc/sendmail.cf`
    fi

    if [ ! -z "$chk" -a -d "$chk" ]
    then
	mqueue="$chk"
    else
	mqueue=/var/spool/mqueue
    fi

    while true
    do
	$PCP_ECHO_PROG $PCP_ECHO_N 'Mail queue directory ['"$mqueue"'] '"$PCP_ECHO_C"
	read ans
	[ -z "$ans" ] && break
	if [ -d "$ans" ]
	then
	    mqueue="$ans"
	    break
	fi
	echo "Error: \"$ans\" is not a directory"
    done

    echo
    regex=""
    $PCP_ECHO_PROG $PCP_ECHO_N 'Mail basename regex ['"$regex"'] '"$PCP_ECHO_C"
    read regex
    [ -z "$regex" ] || args="$args -r $regex"

    echo
    args="$args $mqueue"

    while true
    do
	echo 'The default delay thresholds for grouping the pending mail items are:'
	echo '    1 hour, 4 hours, 8 hours, 1 day, 3 days and 7 days'
	echo
	$PCP_ECHO_PROG $PCP_ECHO_N 'Do you wish to use the default delay thresholds [y]? '"$PCP_ECHO_C"
	read ans
	if [ -z "$ans" -o "$ans" = "y" -o "$ans" = "Y" ]
	then
	    break
	else
	    bucketlist=''
	    while true
	    do
		$PCP_ECHO_PROG $PCP_ECHO_N 'Threshold? [return if no more] '"$PCP_ECHO_C"
		read ans
		[ -z "$ans" ] && break
		# strip blanks so args in pmcd.conf get passed correctly to
		# the mailqpmda binary
		#
		ans=`echo "$ans" | sed -e 's/ //g'`
		if [ -z "$bucketlist" ]
		then
		    bucketlist="$ans"
		else
		    bucketlist="$bucketlist,$ans"
		fi
	    done
	    if [ ! -z "$bucketlist" ]
	    then
		args="$args -b $bucketlist"
		break
	    fi
	    echo
	    echo 'Error: you must specify at least one threshold'
	    echo
	fi
    done
    echo
fi

pmdaInstall

exit 0