Removed
Link Here
|
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 |
create_crontab_entries() { |
36 |
local b e |
37 |
b=$1 |
38 |
e=$2 |
39 |
|
40 |
if crontab -u munin -l > /dev/null 2>&1 |
41 |
then |
42 |
if ! crontab -u munin -l | grep -q MANUAL_MUNIN_CRONTAB |
43 |
then |
44 |
TMPFILE=`mktemp -t munin` || exit 1 |
45 |
cat > $TMPFILE |
46 |
crontab -u munin -l | sed -e "/^$b$/,/^$e$/d" | \ |
47 |
cat - $TMPFILE | crontab -u munin - |
48 |
rm $TMPFILE |
49 |
fi |
50 |
else |
51 |
crontab -u munin - |
52 |
fi |
53 |
} |
54 |
|
55 |
move_www_dir() { |
56 |
if [ -d ${PKG_PREFIX}/www/data/munin -a ! -d ${PKG_PREFIX}/www/munin ] |
57 |
then |
58 |
echo Migrating ${PKG_PREFIX}/www/data/munin to ${PKG_PREFIX}/www/munin |
59 |
mv ${PKG_PREFIX}/www/data/munin ${PKG_PREFIX}/www/munin |
60 |
fi |
61 |
} |
62 |
|
63 |
move_newsyslog_conf() { |
64 |
oldfile=${PKG_PREFIX}/etc/newsyslog.conf.d/munin-master |
65 |
newfile=${PKG_PREFIX}/etc/newsyslog.conf.d/munin-master.conf |
66 |
samplefile=${PKG_PREFIX}/etc/munin/munin-master.newsyslog |
67 |
if [ -f ${oldfile} ]; then |
68 |
echo "Configuration file found in old location: ${oldfile}" |
69 |
if cmp -s ${samplefile} ${newfile} > /dev/null; then |
70 |
echo "Configuration file in new location has not been modified from the default: ${newfile}" |
71 |
echo " => Moving old configuration file to new location" |
72 |
mv -f ${oldfile} ${newfile} |
73 |
else |
74 |
echo "Configuration file in new location has been modified from the default: ${newfile}" |
75 |
echo " => Deleting old configuration file" |
76 |
rm ${oldfile} |
77 |
fi |
78 |
fi |
79 |
} |
80 |
|
81 |
######################################################################## |
82 |
|
83 |
case $2 in |
84 |
PRE-INSTALL) |
85 |
move_www_dir # at some point in the installation, the www dir is created |
86 |
;; |
87 |
POST-INSTALL) |
88 |
if [ -z "${PACKAGE_BUILDING}" ] |
89 |
then |
90 |
create_crontab_entries '#BEGIN_MUNIN_MAIN' '#END_MUNIN_MAIN' <<EOT |
91 |
#BEGIN_MUNIN_MAIN |
92 |
MAILTO=root |
93 |
|
94 |
*/5 * * * * ${PKG_PREFIX}/bin/munin-cron |
95 |
#END_MUNIN_MAIN |
96 |
EOT |
97 |
fi |
98 |
move_newsyslog_conf |
99 |
;; |
100 |
esac |