aboutsummaryrefslogtreecommitdiff
path: root/net/analyzer/munin/munin.build
blob: 5f6d0618bd1e5d9be226ff73e35518de7896df08 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
#
# build script for munin
# by rhatto at riseup.net by rhatto | gpl
# 

#
# TODO: criacao de configuracoes padroes no /etc/munin
#       pegar mais plugins de vserver em http://svn.debian.org/wsvn/pkg-vserver/people/holger/munin-plugins/plugins/?rev=0&sc=0
#

if [ -s "slack-required" ]; then
  echo Recomended and required packages for building munin.build are:
  cat slack-required | sed -e 's/^/\t/'
  if [ "$INTERACT" != "no" ]; then
    echo If you dont have those installed, press Ctrl-C. Otherwise, hit ENTER.
    read crap
#  else
#    echo Sleeping 3 seconds...
#    sleep 3
  fi
fi

CWD="`pwd`"

if [ -f "/etc/slackbuildrc" ]; then
  source /etc/slackbuildrc
fi

if [ -f "~/.slackbuildrc" ]; then
  source ~/.slackbuildrc
fi

# default settings
PACKAGE="munin"
TMP=${TMP:=/tmp}
VERSION=${VERSION:=1.2.5}
ARCH=${ARCH:=i386}
BUILD=${BUILD:=3rha}
SRC_DIR=${SRC:=$CWD}

# -------  error codes for createpkg  --------------
ERROR_WGET=31;      ERROR_MAKE=32;      ERROR_INSTALL=33
ERROR_MD5=34;       ERROR_CONF=35;      ERROR_HELP=36
ERROR_TAR=37;       ERROR_MKPKG=38;     ERROR_GPG=39
ERROR_PATCH=40

if ! grep -qe "^$PACKAGE:" /etc/passwd || ! grep -qe "^$PACKAGE:" /etc/group; then
  echo "WARNING: user and/or group $PACKAGE does not exist"
  echo "Create it manually with \"groupadd $PACKAGE ; useradd $PACKAGE -g $PACKAGE\" and run this script again."
  exit 1
fi

cat << EOCAT
Attention: be sure that theres no munin installed on this system, otherwiser installation
procedure will fail to copy plugins to their right place. Please uninstall any munin packages
before continue.

EOCAT

if [ "$INTERACT" != "no" ]; then
  echo Hit enter to proceed.
  read garbage
fi

if [ "$ARCH" == "x86_64" ]; then
  LIBDIR=/usr/lib64
else
  LIBDIR=/usr/lib
fi

RTOOL="wget"
PACKAGE_EXT="gz"
SRC="$PACKAGE"_"$VERSION.tar.$PACKAGE_EXT"
URL="http://easynews.dl.sourceforge.net/sourceforge/$PACKAGE/$SRC"

SRC_DIR="$SRC_DIR/$PACKAGE"

if [ ! -d "$SRC_DIR" ]; then
  mkdir -p $SRC_DIR
fi

if [ "$RTOOL" == "wget" ] && [ ! -f "$SRC_DIR/$SRC" ]; then
 rm -f $SRC_DIR/$SRC
 wget "$URL" -O "$SRC_DIR/$SRC" || exit $ERROR_WGET
fi

TMP="$TMP/$PACKAGE"

if [ ! -d "$TMP" ]; then
  mkdir -p $TMP
fi

cd $TMP

tar xvf $SRC_DIR/$SRC || exit $ERROR_TAR
cd $PACKAGE-$VERSION

# config and install!

mkdir -p /install

sed -e 's/PREFIX     = $(DESTDIR)\/opt\/munin/PREFIX     = $(DESTDIR)\/usr/' \
    -e 's/CONFDIR    = $(DESTDIR)\/etc\/opt\/munin/CONFDIR    = $(DESTDIR)\/etc\/munin/' \
    -e 's/DBDIR      = $(DESTDIR)\/var\/opt\/munin/DBDIR      = $(DESTDIR)\/var\/munin/' \
    -e 's/LIBDIR     = $(PREFIX)\/lib/LIBDIR     = $(PREFIX)\/lib\/munin/' \
    -e 's/HTMLDIR    = $(PREFIX)\/var\/www/HTMLDIR    = \/var\/www/' \
    -e 's/CGIDIR     = $(HTMLDIR)\/cgi/CGIDIR     = $(HTMLDIR)\/cgi-bin/' Makefile.config > Makefile.config.new

mv Makefile.config.new Makefile.config

make install-main || exit $ERROR_INSTALL
make install-doc install-man || exit $ERROR_INSTALL
make install-node install-node-plugins || exit $ERROR_INSTALL

# make the package

cp $CWD/plugins/* /usr/lib/munin/plugins/
chmod 755 /usr/lib/munin/plugins/*

mkdir -p /etc/munin/plugin{s,-conf.d}
mv /etc/munin/munin.conf /etc/munin/munin.conf.sample
mv /etc/munin-node.conf /etc/munin-node.conf.sample

mkdir -p /etc/rc.d
cp $CWD/rc.munin-node /etc/rc.d/rc.munin-node.new

cat << EOF > /install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

     |-----handy-ruler-----------------------------------------------------|
munin: munin (system to gather and graph all sorts of information)
munin: 
munin: Munin the tool surveys all your computers and remembers what it saw.
munin: It presents all the information in in graphs through a web interface.
munin: Its emphasis is on plug and play capabilities. After completing a
munin: installation a high number of monitoring plugins will be playing with 
munin: no more effort. Using Munin you can easily monitor the performance of 
munin: your computers, networks, SANs, and quite possibly applications as 
munin: well. It makes it easy to determine "what's different today" when 
munin: a performance problem crops up. It makes it easy to see how you're 
munin: doing capacity wise on all limited resources.
EOF

echo '( chroot . /sbin/ldconfig )' > /install/doinst.sh
echo '( if ! grep -qe "^munin:" etc/group; then echo creating group munin ; chroot . /usr/sbin/groupadd munin; fi )' >> /install/doinst.sh
echo '( if ! grep -qe "^munin:" etc/passwd; then echo creating user munin ; chroot . /usr/sbin/useradd munin -g munin; fi )' >> /install/doinst.sh
echo '( if [ ! -f "etc/rc.d/rc.munin-node" ]; then mv etc/rc.d/rc.munin-node.new etc/rc.d/rc.munin-node; fi )' >> /install/doinst.sh
echo '( mkdir -p var/log/munin var/run/munin var/munin )' >> /install/doinst.sh
echo '( chroot . /usr/bin/chown munin.munin /var/log/munin /var/run/munin /var/munin )' >> /install/doinst.sh