ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/mports/trunk/sysutils/munin-master/pkg-deinstall
Revision: 21892
Committed: Sun Sep 11 12:49:17 2016 UTC (7 years, 7 months ago) by laffer1
File size: 1899 byte(s)
Log Message:
modernize munin ports. add some zfs plugins

File Contents

# Content
1 #! /bin/sh
2 # ex:sw=4 sts=4
3
4 ask() {
5 local question default answer
6
7 question=$1
8 default=$2
9 if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]
10 then
11 read -p "${question} [${default}]? " answer
12 fi
13 if [ x${answer} = x ]
14 then
15 answer=${default}
16 fi
17 echo ${answer}
18 }
19
20 yesno() {
21 local dflt question answer
22
23 question=$1
24 dflt=$2
25 while :; do
26 answer=$(ask "${question}" "${dflt}")
27 case "${answer}" in
28 [Yy]*) return 0;;
29 [Nn]*) return 1;;
30 esac
31 echo "Please answer yes or no."
32 done
33 }
34
35 delete_crontab_entries() {
36 local b e
37 b=$1
38 e=$2
39
40 TMPFILE=`mktemp -t munin` || exit 1
41 crontab -u munin -l | sed -e "/^$b\$/,/^$e\$/d" -e '/^[ ]*#/d' -e '/^$/d' > $TMPFILE
42 if [ -s $TMPFILE ]
43 then
44 crontab -u munin -l | sed -e "/^$b\$/,/^$e\$/d" | crontab -u munin -
45 echo "The crontab for user munin had manually created entries."
46 echo "Only the automatically created entries have been removed."
47 echo "These are the remaining lines:"
48 crontab -u munin -l
49 else
50 echo y | crontab -u munin -r
51 echo "crontab for user munin removed"
52 fi
53 rm $TMPFILE
54 }
55
56 delnewsyslog() {
57 tmp=`mktemp -t munin` || exit 1
58 sed -e '/^\/var\/log\/munin\/\*\.log[ ]/d' /etc/newsyslog.conf >${tmp}
59 cat ${tmp} > /etc/newsyslog.conf
60 rm ${tmp}
61 }
62
63 newsyslog() {
64 ENTRY=`fgrep '/var/log/munin/*' /etc/newsyslog.conf`
65 DEFAULT='/var/log/munin/*.log munin:munin 644 7 * @T00 GNWZ'
66 if [ -z "$ENTRY" ]
67 then
68 exit 0
69 elif [ "$ENTRY" = "$DEFAULT" ]
70 then
71 delnewsyslog
72 elif yesno "You have changed the default munin-master entry in \"/etc/newsyslog.conf\".
73 Do you want me to delete it?" y
74 then
75 delnewsyslog
76 echo "Done."
77 fi
78 }
79
80
81 case $2 in
82 DEINSTALL)
83 if [ -z "${PACKAGE_BUILDING}" ]
84 then
85 delete_crontab_entries '#BEGIN_MUNIN_MAIN' '#END_MUNIN_MAIN'
86 newsyslog
87 fi
88 ;;
89 POST-DEINSTALL)
90 ;;
91 esac