Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

620 lines (561 sloc) 22.484 kb
#!/bin/bash
#
# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# David GUENAULT, dguenault@monitoring-fr.org
#
# This file is part of Shinken.
#
# Shinken is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Shinken 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
# temporary path
export TMP=${TMP:-"/tmp"}
export LOGFILE=${LOGFILE:-"$TMP/shinken.install.log"}
# proxy support
export USEPROXY=${USEPROXY:-0}
# Skip prerequisites installation
export SKIPPREREQUISITES=${SKIPPREREQUISITES:-0}
# for shinken
export VERSION=${VERSION:-"master"}
export TARGET=${TARGET:-"/usr/local/shinken"}
export ETC=${ETC:-"$TARGET/etc"}
export LIBEXEC=${LIBEXEC:-"$TARGET/libexec"}
export VAR=${VAR:-"$TARGET/var"}
export BACKUPDIR=${BACKUPDIR:-"/opt/backup"}
export SKUSER=${SKUSER:-"shinken"}
export SKGROUP=${SKGROUP:-"shinken"}
export MANAGEPYRO=${MANAGEPYRO:-0}
export KEEPDAYSLOG=7
# default retention module (pickle|mongodb)
# work only if ENABLEOPTPKGS
export RETENTIONMODULE=${RETENTIONMODULE:-"pickle"}
export LOGSTORE=${LOGSTORE:-"sqlite"}
export MONGOSERVER=${MONGOSERVER:-"localhost"}
# Quiet mode (default answer for all questions)
export QUIET=${QUIET:-0}
# FOR CES INTEGRATION
export IF="eth0" # local iface
export ADDPOLLERS="poller-2=172.16.1.2"
# DO NOT MODIFY THIS
export DISTROS="REDHAT:5 REDHAT:6 DEBIAN Fedora:16 Fedora:17"
export DATE=$(date +%Y%m%d%H%M%S)
export GIT="https://github.com/naparuba/shinken.git"
export ARCH=$(uname -i)
if [ "$ARCH" = "unknown" ]
then
ARCH=$(uname -m)
fi
LSB_RELEASE="/usr/bin/lsb_release"
if test -x "${LSB_RELEASE}"; then
export DIST="`${LSB_RELEASE} -i | awk '{print $NF}'`"
export VERS="`${LSB_RELEASE} -r | awk '{print $NF}' | awk -F. '{print $1}'`"
else
echo "You must install lsb_release binary before launching this install script."
exit 2
fi
case $DIST in
CentOS)
export CODE="REDHAT"
;;
RedHatEnterpriseServer)
export CODE="REDHAT"
;;
Fedora)
export CODE="Fedora"
;;
Debian)
export CODE="DEBIAN"
;;
Ubuntu)
export CODE="DEBIAN"
;;
LinuxMint)
export CODE="DEBIAN"
;;
*)
export CODE=""
;;
esac
which systemctl > /dev/null 2>&1
if [ $? -eq 0 ]
then
export INIT="systemd"
else
export INIT="init"
fi
case $CODE in
REDHAT)
if [ "$VERS" = "5" ]
then
export EPELVERS="5-4"
#export YUMPKGS="gcc python26 sqlite-devel python26-devel git mysql-devel nmap wget unzip pymongo-gridfs pymongo"
export YUMPKGS="gcc python26 sqlite-devel python26-devel git mysql-devel nmap wget unzip python-ldap"
export PYLIBSRHEL="paramiko:paramiko netifaces:netifaces multiprocessing:multiprocessing simplejson:simplejson pysqlite:sqlite3 MySQL-python:MySQLdb pyro:Pyro.core pymongo:pymongo kombu:kombu"
elif [ "$VERS" = "6" ]
then
export EPELVERS="6-7"
#export YUMPKGS="gcc python sqlite-devel python-devel git mysql-devel python-setuptools nmap wget unzip pymongo-gridfs pymongo"
export YUMPKGS="gcc python sqlite-devel python-devel git mysql-devel python-setuptools nmap wget unzip python-ldap"
export PYLIBSRHEL6="paramiko:paramiko pymongo:pymongo netifaces:netifaces simplejson:simplejson pysqlite:sqlite3 MySQL-python:MySQLdb pyro:Pyro.core kombu:kombu"
fi
export EPELNAME="epel-release"
export EPELPKG="${EPELNAME}-${EPELVERS}.noarch.rpm"
export EPEL="http://download.fedoraproject.org/pub/epel/$VERS/$ARCH/$EPELPKG"
export SETUPTOOLSVERS="0.6c11"
export RHELSETUPTOOLS="http://pypi.python.org/packages/source/s/setuptools/setuptools-$SETUPTOOLSVERS.tar.gz"
export MONGOPKGS="mongo-10gen mongo-10gen-server "
;;
Fedora)
if [ "$VERS" = "16" ]
then
export YUMPKGS="gcc python26 sqlite-devel python26-devel git mysql-devel nmap wget unzip python-ldap python-setuptools python-paramiko python-simplejson"
export MONGOPKGS="mongodb-server pymongo"
export PYLIBS="netifaces:netifaces multiprocessing:multiprocessing pysqlite:sqlite3 MySQL-python:MySQLdb pyro:Pyro.core kombu:kombu pymongo:pymongo"
export SYSTEMDSERVICES="shinken-arbiter.service shinken-broker.service shinken-poller.service shinken-reactionner.service shinken-receiver.service shinken-scheduler.service"
elif [ "$VERS" = "17" ]
then
export YUMPKGS="gcc python sqlite-devel python-devel git mysql-devel nmap wget unzip python-ldap python-setuptools python-paramiko python-simplejson python-pyro python-kombu python-sqlite3dbm python-netifaces MySQL-python "
export MONGOPKGS="mongodb-server pymongo"
export PYLIBS="multiprocessing:multiprocessing"
export SYSTEMDSERVICES="shinken-arbiter.service shinken-broker.service shinken-poller.service shinken-reactionner.service shinken-receiver.service shinken-scheduler.service"
fi
;;
DEBIAN)
if [ "$VERS" = "6" ]
then
# workaround a problem with pyro3 on debian squeeze
export PYLIBSDEB="paramiko:paramiko netifaces:netifaces simplejson:simplejson pysqlite:sqlite3 MySQL_python:MySQLdb pymongo:pymongo pyro4:pyro kombu:kombu"
export APTPKGS="build-essential libperl-dev python-setuptools libsqlite3-dev python-dev sqlite3 nmap unzip libmysqlclient-dev python-ldap libevent-dev"
export MONGOPKGS="mongodb-10gen"
else
export PYLIBSDEB="paramiko:paramiko netifaces:netifaces simplejson:simplejson pysqlite:sqlite3 MySQL_python:MySQLdb pymongo:pymongo kombu:kombu"
export APTPKGS="build-essential libperl-dev python-setuptools libsqlite3-dev python-dev pyro sqlite3 nmap unzip libmysqlclient-dev python-ldap libevent-dev"
export MONGOPKGS="mongodb-10gen"
fi
;;
esac
#export VSPHERESDKAPTPKGS="libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl ia32-libs libclass-methodmaker-perl libsoap-lite-perl libsoap-lite-perl libuuid-perl make libnagios-plugin-perl"
export VSPHERESDKVER="4.0.0-161974"
export VSPHERESDK="http://www.shinken-monitoring.org/archives/VMware-vSphere-SDK-for-Perl-$VSPHERESDKVER.$ARCH.tar.gz"
export CHECK_ESX3_SCRIPT="http://www.shinken-monitoring.org/archives/check_esx3.pl"
if [ "$ARCH" = "x86_64" ]
then
export VSPHERESDKAPTPKGS="libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl ia32-libs libclass-methodmaker-perl libsoap-lite-perl make libnagios-plugin-perl"
else
export VSPHERESDKAPTPKGS="libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl libclass-methodmaker-perl libsoap-lite-perl make libnagios-plugin-perl"
fi
export VSPHERESDKYUMPKGS="openssl-devel perl-URI perl-XML-LibXML perl-Crypt-SSLeay perl-SOAP-Lite perl-Class-MethodMaker uuid-perl make perl-libwww-perl.noarch"
export NAGPLUGYUMPKGS="perl-Class-Accessor perl-Config-Tiny perl-Math-Calc-Units perl-Params-Validate"
export NAGPLUGPERL="http://search.cpan.org/CPAN/authors/id/T/TO/TONVOON/Nagios-Plugin-0.36.tar.gz"
export NAGPLUGVERS="1.4.15"
export NAGPLUGBASEURI="http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/$NAGPLUGVERS/nagios-plugins-$NAGPLUGVERS.tar.gz"
export NAGPLUGAPTPKG="libgnutls-dev libmysqlclient-dev libssl-dev libsnmp-perl libkrb5-dev libldap2-dev libsnmp-dev libnet-snmp-perl gawk libwrap0-dev libmcrypt-dev fping snmp gettext smbclient dnsutils"
export NAGPLUGYUMPKG="gnutls-devel mysql-devel openssl-devel net-snmp-perl krb5-devel openldap-devel net-snmp-devel gawk libmcrypt-devel fping net-snmp gettext samba-client"
export CHECKNETAPP2="http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=389\&cf_id=24"
export CHECKNETAPP2APTPKGS="snmp libnet-snmp-perl"
export CHECKNETAPP2YUMPKGS="perl-Net-SNMP net-snmp"
export CAPTURE_PLUGIN="http://www.waggy.at/nagios/capture_plugin.txt"
export CHECKORACLEHEALTHAPTPKG="libdbi-perl libaio1"
export CHECKORACLEHEALTHYUMPKG="perl-DBI libaio"
export CHECKORACLEHEALTHCPAN="http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.36.tar.gz"
export CHECKORACLEHEALTH="http://labs.consol.de/wp-content/uploads/2011/09/check_oracle_health-1.7.3.tar.gz"
export CHECKMONGOAPTPKG="" #python-pymongo"
export CHECKMONGOYUMPKG="" #pymongo"
export CHECKMONGO="https://raw.github.com/mzupan/nagios-plugin-mongodb/master/check_mongodb.py"
export CHECKIBMDSHEALTH="http://www.shinken-monitoring.org/archives/check_IBM_DS_health_1.2.sh"
export CHECKIBMDSPERF="http://www.shinken-monitoring.org/archives/check_IBM_performance_v1.4"
export CHECKIBM="http://www.shinken-monitoring.org/pub/plugins/check_snmp_systemHealth.pl http://www.shinken-monitoring.org/pub/plugins/check_snmp_HACMP.pl http://www.shinken-monitoring.org/pub/plugins/check_snmp_Safekit.pl http://www.shinken-monitoring.org/pub/plugins/check_snmp_aixVGstate.pl"
export CHECKHPUX="http://www.shinken-monitoring.org/pub/plugins/check_snmp_hpux_storage.pl http://www.shinken-monitoring.org/pub/plugins/check_snmp_hpux_mem"
export CHECKEMCAPTPKG=""
export CHECKEMCYUMPKG=""
export CHECKEMC="https://www.netways.org/attachments/download/393/check_emc.zip"
export CHECKMEM="https://github.com/justintime/nagios-plugins/tarball/master"
export CHECKNWCAPTPKG="autoconf automake m4 libtool"
export CHECKNWCYUMPKG="autoconf automake m4 libtool"
export CHECKNWC="https://github.com/lausser/check_nwc_health/tarball/1.3"
export CHECKMYSQLHEALTH="http://labs.consol.de/wp-content/uploads/2011/08/check_mysql_health-2.1.7.tar.gz"
export CHECKMYSQLHEALTHYUMPKG="perl-Time-HiRes"
export CHECKMYSQLHEALTHAPTPKG="libclass-dbi-mysql-perl"
export PNPBRANCH="0.6"
export PNPRELEASE="17"
export PNPPREFIX="/usr/local/pnp4nagios"
export PNPURI="http://downloads.sourceforge.net/project/pnp4nagios/PNP-$PNPBRANCH/pnp4nagios-$PNPBRANCH.$PNPRELEASE.tar.gz"
export PNPAPTPKG="rrdtool apache2 libapache2-mod-php5 librrds-perl php5-gd"
export PNPYUMPKG="rrdtool httpd php rrdtool-perl php-gd perl-Time-HiRes"
export NAGVIS="http://downloads.sourceforge.net/project/nagvis/NagVis%201.6/nagvis-1.6.3.tar.gz"
export NAGVISPREFIX="/usr/local/nagvis"
export NAGVISAPTPKGS="apache2 libapache2-mod-php5 php5-gd php5-sqlite php-net-socket php5-mysql graphviz"
export NAGVISYUMPKGS="httpd php php-gd php-sqlite php-mysql graphviz"
export MKVER="1.1.12p7"
export MKURI="http://mathias-kettner.de/download/check_mk-$MKVER.tar.gz"
export MKPREFIX="/usr/local/check_mk"
export MKAPTPKG="libapache2-mod-python sudo"
export MKYUMPKG="mod_python sudo"
export WMICAPTPKG="autoconf libdatetime-perl libnagios-plugin-perl libconfig-inifiles-perl"
export WMICYUMPKG="autoconf python perl-DateTime perl-Config-IniFiles"
export WMIC="http://www.shinken-monitoring.org/archives/wmi-1.3.14.tar.gz"
export CHECKWMIPLUS="http://edcint.co.nz/checkwmiplus/sites/default/files/check_wmi_plus.v1.49.tar.gz"
export CHECKHPASM="http://labs.consol.de/wp-content/uploads/2011/10/check_hpasm-4.3.tar.gz"
export CHECKHPASMAPTPKGS="snmp libnet-snmp-perl"
export CHECKHPASMYUMPKGS="perl-Net-SNMP net-snmp"
export MANUBULON="http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz"
export MANUBULONYUMPKG="perl-Net-SNMP"
export MANUBULONAPTPKG="libsnmp-perl"
export CHECKSNMPBANDWIDTH="https://gitorious.org/check_snmp_bandwidth/check_snmp_bandwidth/blobs/raw/stable/check_snmp_bandwidth"
export CHECKSNMPBANDWIDTHPNP="https://gitorious.org/check_snmp_bandwidth/check_snmp_bandwidth/blobs/raw/stable/pnp4nagios/check_snmp_bandwidth.php"
export CHECKNETINT="http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=1475&cf_id=35"
export NCONF="http://downloads.sourceforge.net/project/nconf/nconf/1.3.0-0/nconf-1.3.0-0.tgz"
export NCONFYUMPKG="httpd php php-ldap php-mysql perl-DBI perl-DBD-MySQL"
export NCONFAPTPKG="debconf-utils apache2 php5 php5-ldap php5-mysql libdbi-perl libdbd-mysql-perl"
export CHECKRSYNC="http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=307&cf_id=29"
# experimental for application performance monitoring
export EUEYUMPKG="ruby rubygems ruby-devel libxml2-devel libxslt-devel openssl-devel gcc gcc-c++ automake autoconf libtool make firefox xorg-x11-server-Xvfb"
export EUEGEMS="bson_ext:1.6.4 mongo:1.6.4 unicode:0.4.3 inifile:1.1.0 cucumber:1.2.1 rspec:2.11.0 watir-webdriver:0.6.1 headless:0.3.1"
###################################
### TEXT PRESENTATION FUNCTIONS ###
###################################
function cecho ()
{
# Argument $1 = message
# Argument $2 = foreground color
# Argument $3 = background color
# Argument $4 = if not zero then do not add line feed
case "$2" in
"black")
fcolor='30'
;;
"red")
fcolor='31'
;;
"green")
fcolor='32'
;;
"yellow")
fcolor='33'
;;
"blue")
fcolor='34'
;;
"magenta")
fcolor='35'
;;
"cyan")
fcolor='36'
;;
"white")
fcolor='37'
;;
*)
fcolor=''
esac
case "$3" in
"black")
bcolor='40'
;;
"red")
bcolor='41'
;;
"green")
bcolor='42'
;;
"yellow")
bcolor='43'
;;
"blue")
bcolor='44'
;;
"magenta")
bcolor='45'
;;
"cyan")
bcolor='46'
;;
"white")
bcolor='47'
;;
*)
bcolor=""
esac
if [ -z $bcolor ]
then
echo -ne $1"\n" >> $LOGFILE
echo -ne "\E["$fcolor"m"$1"\n"
else
echo -ne $1"\n" >> $LOGFILE
echo -ne "\E["$fcolor";"$bcolor"m"$1"\n"
fi
tput sgr0
return
}
function cread(){
# $1: text
# $2: color
# $3: default
# $3: choices
# Argument $4 = if not zero then do not add line feed
case "$2" in
"black")
fcolor='30'
;;
"red")
fcolor='31'
;;
"green")
fcolor='32'
;;
"yellow")
fcolor='33'
;;
"blue")
fcolor='34'
;;
"magenta")
fcolor='35'
;;
"cyan")
fcolor='36'
;;
"white")
fcolor='37'
;;
*)
fcolor=''
esac
if [ $QUIET -eq 1 ]
then
tput sgr0
readvalue=$3
return
fi
if [ -z $bcolor ]
then
echo -ne "\E["$fcolor"m"$1""
else
echo -ne "\E["$fcolor";"$bcolor"m"$1""
fi
read readvalue
if [ -z "$readvalue" ]
then
readvalue=$3
tput sgr0
return
else
if [ "$4" = "nocheck" ]
then
return
fi
match=0
for av in $4
do
if [ "$av" = "$readvalue" ]
then
match=1
fi
done
if [ $match -eq 0 ]
then
tput sgr0
cecho " > Invalid value ($readvalue) allowed values are [$4]" red
cread "$1" "$2" "$3" "$4"
return
else
tput sgr0
return
fi
fi
}
function creads(){
# $1: text
# $2: color
# Argument $4 = if not zero then do not add line feed
case "$2" in
"black")
fcolor='30'
;;
"red")
fcolor='31'
;;
"green")
fcolor='32'
;;
"yellow")
fcolor='33'
;;
"blue")
fcolor='34'
;;
"magenta")
fcolor='35'
;;
"cyan")
fcolor='36'
;;
"white")
fcolor='37'
;;
*)
fcolor=''
esac
if [ -z $bcolor ]
then
echo -ne "\E["$fcolor"m"$1" "
else
echo -ne "\E["$fcolor";"$bcolor"m"$1" "
fi
read readvalue
tput sgr0
return
}
function cadre(){
# display a colored enclosure
# $1 => text
# $2 => color
cecho "+--------------------------------------------------------------------------------" $2
cecho "| $1" $2
cecho "+--------------------------------------------------------------------------------" $2
}
######################
### MISC FUNCTIONS ###
######################
function pyroset(){
case $CODE in
REDHAT)
if [ "$VERS" = "5" ]
then
export PYRO="Pyro==3.16"
elif [ "$VERS" = "6" ]
then
export PYRO="Pyro4==4.12"
fi
;;
Fedora)
export PYRO="Pyro4==4.12"
;;
DEBIAN)
if [ "$VERS" = "6" ]
then
export PYRO="Pyro4==4.12"
elif [ "$VERS" = "5" ]
then
export PYRO="Pyro==3.16"
else
export PYRO="Pyro4==4.12"
fi
;;
esac
}
#Check if we launch the script with root privileges (aka sudo)
if [ "$UID" != "0" ]
then
echo "You should start the script with sudo!"
exit 2
fi
function pythonver(){
versions="2.4 2.5 2.6 2.7"
LASTFOUND=""
# is there any python here?
for v in $versions
do
which python$v >> /tmp/shinken.install.log 2>&1
if [ $? -eq 0 ]
then
LASTFOUND="python$v"
fi
done
if [ -z "$LASTFOUND" ]
then
# finaly try to find a default python
which python >> /tmp/shinken.install.log 2>&1
if [ $? -ne 0 ]
then
echo "No python interpreter found!"
exit 2
else
echo "python found"
LASTFOUND=$(which python)
fi
fi
PY=$LASTFOUND
echo $PY
}
function pythonvershort(){
versions="2.4 2.5 2.6 2.7"
LASTFOUND=""
# is there any python here?
for v in $versions
do
which python$v >> /tmp/shinken.install.log 2>&1
if [ $? -eq 0 ]
then
LASTFOUND="$v"
fi
done
PY=$LASTFOUND
echo $PY
}
function rheldvd(){
# this is only for my personal needs
# dvd mounted?
if [ "$CODE" != "REDHAT" ]
then
cecho " > Only for REDHAT" red
exit 2
fi
cadre "Setup rhel dvd for yum (this is only for my development purpose)" green
dvdm=$(cat /proc/mounts | grep "^\/dev\/cdrom")
if [ -z "$dvdm" ]
then
if [ ! -d "/media/cdrom" ]
then
mkdir -p "/media/cdrom"
fi
cecho " > Insert RHEL/CENTOS DVD and press ENTER" yellow
read -p " > ENTER when ready "
mount -t iso9660 -o ro /dev/cdrom /media/cdrom >> /tmp/shinken.install.log 2>&1
if [ $? -eq 0 ]
then
dvdm=$(cat /proc/mounts | grep "^\/dev\/cdrom")
if [ -z "$dvdm" ]
then
cecho " > Unable to mount RHEL/CENTOS DVD!" red
exit 2
else
if [ ! -d "/media/cdrom/Server" ]
then
cecho "Invalid DVD" red
exit 2
else
if [ ! -f "/etc/yum.repos.d/rheldvd.repo" ]
then
echo "[dvd]" > /etc/yum.repos.d/rheldvd.repo
echo "name=rhel dvd" >> /etc/yum.repos.d/rheldvd.repo
echo "baseurl=file:///media/cdrom/Server" >> /etc/yum.repos.d/rheldvd.repo
echo "enabled=1" >> /etc/yum.repos.d/rheldvd.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/rheldvd.repo
fi
fi
fi
else
cecho " > Error while mounting DVD" red
fi
fi
}
if [ $USEPROXY -eq 1 ]
then
cecho "WARNNG: USE PROXY IS ENABLED" yellow
cecho "YOU MUST VERIFY THAT http_proxy and https_proxy IS ENABLED" yellow
cecho "YOU MUST VERIFY THAT YOUR PACKAGE MANAGER IS CONFIGURED TO USE PROXY" yellow
cecho "HIT ENTER TO CONTINUE OR CTRL+C TO ABORT" yellow
read
fi
Jump to Line
Something went wrong with that request. Please try again.