| 1 | #!/bin/sh |
|---|
| 2 | ################################################################### |
|---|
| 3 | # Oreon is developped with GPL Licence 2.0 |
|---|
| 4 | # |
|---|
| 5 | # GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt |
|---|
| 6 | # |
|---|
| 7 | # Developped by : Julien Mathis - Romain Le Merlus |
|---|
| 8 | # Christophe Coraboeuf - Mathieu Chateau |
|---|
| 9 | # Modified by : Sugumaran Mat |
|---|
| 10 | # |
|---|
| 11 | ################################################################### |
|---|
| 12 | # This program is free software; you can redistribute it and/or |
|---|
| 13 | # modify it under the terms of the GNU General Public License |
|---|
| 14 | # as published by the Free Software Foundation; either version 2 |
|---|
| 15 | # of the License, or (at your option) any later version. |
|---|
| 16 | # |
|---|
| 17 | # This program is distributed in the hope that it will be useful, |
|---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | # GNU General Public License for more details. |
|---|
| 21 | # |
|---|
| 22 | # For information : infos@oreon-project.org |
|---|
| 23 | #################################################################### |
|---|
| 24 | |
|---|
| 25 | cat <<EOF |
|---|
| 26 | ############################################################################### |
|---|
| 27 | # Centreon (www.centreon.com) # |
|---|
| 28 | # Thanks for using Centreon # |
|---|
| 29 | # # |
|---|
| 30 | # v 1.4.2 # |
|---|
| 31 | # # |
|---|
| 32 | # infos@oreon-project.org # |
|---|
| 33 | # # |
|---|
| 34 | # Make sure you have installed and configured # |
|---|
| 35 | # sudo - sed # |
|---|
| 36 | # php - apache - rrdtool - mysql # |
|---|
| 37 | # # |
|---|
| 38 | # # |
|---|
| 39 | ############################################################################### |
|---|
| 40 | # The Team OREON # |
|---|
| 41 | ############################################################################### |
|---|
| 42 | EOF |
|---|
| 43 | |
|---|
| 44 | #Load install script functions |
|---|
| 45 | if [ -z "$BASH" ]; then # Test if BASH is in path |
|---|
| 46 | if ! which bash > /dev/null 2>&1; then |
|---|
| 47 | echo "Install bash and try `bash install.sh`." |
|---|
| 48 | fi # Exit if we are not in BASH |
|---|
| 49 | echo "Error: The script must be run with BASH shell. Try:" |
|---|
| 50 | echo "# bash install.sh" |
|---|
| 51 | exit 1 |
|---|
| 52 | fi |
|---|
| 53 | . functions |
|---|
| 54 | |
|---|
| 55 | ## |
|---|
| 56 | ## VARIABLES |
|---|
| 57 | ## |
|---|
| 58 | ## Make sure you know what you do if you modify it !! |
|---|
| 59 | |
|---|
| 60 | SRC_OREON="oreon_src" |
|---|
| 61 | |
|---|
| 62 | PLUGINS_DIR="Plugins/" |
|---|
| 63 | |
|---|
| 64 | PWD=`pwd` |
|---|
| 65 | |
|---|
| 66 | LOG_FILE="$PWD/log/install_oreon.log" |
|---|
| 67 | |
|---|
| 68 | date > $LOG_FILE |
|---|
| 69 | |
|---|
| 70 | TRUETYPE="/usr/X11R6/lib/X11/fonts/truetype" |
|---|
| 71 | |
|---|
| 72 | test_yes_or_not(){ |
|---|
| 73 | if [ $1 != "y" ] && [ $1 != "n" ] && [ ! -z $1 ] ;then |
|---|
| 74 | res=$1 |
|---|
| 75 | while [ $res != "y" ] && [ $res != "n" ] && [ ! -z $res ] |
|---|
| 76 | do |
|---|
| 77 | echo $2 |
|---|
| 78 | echo -n $3 |
|---|
| 79 | read res |
|---|
| 80 | done |
|---|
| 81 | eval $1=$res |
|---|
| 82 | fi |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | echo "" |
|---|
| 86 | $SETCOLOR_WARNING |
|---|
| 87 | echo " Make sure you have root permissions !" |
|---|
| 88 | echo "" |
|---|
| 89 | echo "" |
|---|
| 90 | echo " WARNING : Setup will delete all previous informations in your Centreon DATABASE. " |
|---|
| 91 | $SETCOLOR_NORMAL |
|---|
| 92 | echo "" |
|---|
| 93 | echo "Are you sure to continue ?" |
|---|
| 94 | echo -n "[y/n], default to [n]:" |
|---|
| 95 | read temp |
|---|
| 96 | if [ "$temp" != "y" ] && [ "$temp" != "n" ] && [ ! -z "$temp" ] ;then |
|---|
| 97 | while [ "$temp" != "y" ] && [ "$temp" != "n" ] && [ ! -z "$temp" ] |
|---|
| 98 | do |
|---|
| 99 | echo "Are you sure to continue ?" |
|---|
| 100 | echo -n "[y/n], default to [n]:" |
|---|
| 101 | read temp |
|---|
| 102 | done |
|---|
| 103 | fi |
|---|
| 104 | if [ -z $temp ];then |
|---|
| 105 | temp="n" |
|---|
| 106 | fi |
|---|
| 107 | if [ $temp = "n" ];then |
|---|
| 108 | echo "Setup aborted..." |
|---|
| 109 | exit |
|---|
| 110 | fi |
|---|
| 111 | |
|---|
| 112 | test_answer(){ |
|---|
| 113 | #$1 variable to fill |
|---|
| 114 | #$2 text typed by user |
|---|
| 115 | if [ ! -z $2 ];then |
|---|
| 116 | if [ $2 != "" ];then |
|---|
| 117 | eval $1=$2 |
|---|
| 118 | fi |
|---|
| 119 | fi |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | ## |
|---|
| 123 | ## CONFIGURATION |
|---|
| 124 | ## |
|---|
| 125 | if test -a $OREON_CONF ; then |
|---|
| 126 | echo "" |
|---|
| 127 | echo "------------------------------------------------------------------------" |
|---|
| 128 | echo " Detecting old Installation" |
|---|
| 129 | echo "------------------------------------------------------------------------" |
|---|
| 130 | echo "" |
|---|
| 131 | echo "" |
|---|
| 132 | echo_success "Finding Centreon configuration file '$OREON_CONF' :" "OK" |
|---|
| 133 | echo "You already seem to have to install Centreon." |
|---|
| 134 | echo "" |
|---|
| 135 | echo "Do you want use last Centreon install parameters ?" |
|---|
| 136 | echo -n "[y/n], default to [y]:" |
|---|
| 137 | read temp |
|---|
| 138 | if [ "$temp" != "y" ] && [ "$temp" != "n" ] && [ ! -z $temp ] ;then |
|---|
| 139 | while [ "$temp" != "y" ] && [ "$temp" != "n" ] && [ ! -z $temp ] |
|---|
| 140 | do |
|---|
| 141 | echo "Do you want to use last Centreon install parameters ?" |
|---|
| 142 | echo -n "[y/n], default to [y]:" |
|---|
| 143 | read temp |
|---|
| 144 | done |
|---|
| 145 | fi |
|---|
| 146 | if [ -z $temp ];then |
|---|
| 147 | temp=y |
|---|
| 148 | fi |
|---|
| 149 | |
|---|
| 150 | if [ $temp = "y" ];then |
|---|
| 151 | echo "" |
|---|
| 152 | echo_passed "Using '$OREON_CONF' :" "PASSED" |
|---|
| 153 | . $OREON_CONF |
|---|
| 154 | echo "" |
|---|
| 155 | else |
|---|
| 156 | echo "------------------------------------------------------------------------" |
|---|
| 157 | echo " First, let's talk about you !" |
|---|
| 158 | echo "------------------------------------------------------------------------" |
|---|
| 159 | echo "" |
|---|
| 160 | echo "" |
|---|
| 161 | fi |
|---|
| 162 | fi |
|---|
| 163 | if [ -z $INSTALL_DIR_NAGIOS ];then |
|---|
| 164 | INSTALL_DIR_NAGIOS="/usr/local/nagios" |
|---|
| 165 | echo "Where is installed Nagios ?" |
|---|
| 166 | echo -n "default to [$INSTALL_DIR_NAGIOS]:" |
|---|
| 167 | read temp |
|---|
| 168 | if [ -z "$temp" ]; then |
|---|
| 169 | temp="$INSTALL_DIR_NAGIOS" |
|---|
| 170 | fi |
|---|
| 171 | valueok=0 |
|---|
| 172 | while [ ! -d "$temp/" ]; do |
|---|
| 173 | echo_passed "$temp is not a directory." "CRITICAL" |
|---|
| 174 | echo "Where is installed Nagios ?" |
|---|
| 175 | echo -n "default to [$INSTALL_DIR_NAGIOS]:" |
|---|
| 176 | read temp |
|---|
| 177 | if [ -z "$temp" ]; then |
|---|
| 178 | temp="$INSTALL_DIR_NAGIOS" |
|---|
| 179 | fi |
|---|
| 180 | echo |
|---|
| 181 | done |
|---|
| 182 | INSTALL_DIR_NAGIOS="$temp" |
|---|
| 183 | #INSTALL_DIR_NAGIOS=${INSTALL_DIR_NAGIOS%/} |
|---|
| 184 | echo "" |
|---|
| 185 | fi |
|---|
| 186 | |
|---|
| 187 | if [ -z $NAGIOS_ETC ];then |
|---|
| 188 | #nagios etc directory for oreon |
|---|
| 189 | NAGIOS_ETC="$INSTALL_DIR_NAGIOS/etc" |
|---|
| 190 | echo "Where is your nagios etc directory ?" |
|---|
| 191 | echo -n "default to [$NAGIOS_ETC]:" |
|---|
| 192 | read temp |
|---|
| 193 | if [ -z "$temp" ]; then |
|---|
| 194 | temp="$NAGIOS_ETC" |
|---|
| 195 | fi |
|---|
| 196 | while [ ! -f "${temp}/nagios.cfg" ]; do |
|---|
| 197 | echo_passed "${NAGIOS_ETC}/nagios.cfg not found" "CRITICAL" |
|---|
| 198 | echo "Where is your nagios etc directory ?" |
|---|
| 199 | echo -n "default to [$NAGIOS_ETC]:" |
|---|
| 200 | read temp |
|---|
| 201 | if [ -z "$temp" ]; then |
|---|
| 202 | temp="$NAGIOS_ETC" |
|---|
| 203 | fi |
|---|
| 204 | done |
|---|
| 205 | NAGIOS_ETC="$temp" |
|---|
| 206 | echo_success "Path $NAGIOS_ETC" "OK" |
|---|
| 207 | echo "" |
|---|
| 208 | fi |
|---|
| 209 | |
|---|
| 210 | if [ -z $NAGIOS_VAR ];then |
|---|
| 211 | #nagios var directory for oreon |
|---|
| 212 | NAGIOS_VAR="$INSTALL_DIR_NAGIOS/var" |
|---|
| 213 | echo "Where is your nagios var directory ?" |
|---|
| 214 | echo -n "default to [$NAGIOS_VAR]:" |
|---|
| 215 | read temp |
|---|
| 216 | if [ -z "$temp" ]; then |
|---|
| 217 | temp="$NAGIOS_VAR" |
|---|
| 218 | fi |
|---|
| 219 | while [ ! -f "${temp}/nagios.log" ]; do |
|---|
| 220 | echo_passed "${NAGIOS_VAR}/nagios.log not found" "CRITICAL" |
|---|
| 221 | echo "Where is your nagios var directory ?" |
|---|
| 222 | echo -n "default to [$NAGIOS_VAR]:" |
|---|
| 223 | read temp |
|---|
| 224 | if [ -z "$temp" ]; then |
|---|
| 225 | temp="$NAGIOS_VAR" |
|---|
| 226 | fi |
|---|
| 227 | done |
|---|
| 228 | NAGIOS_VAR="$temp" |
|---|
| 229 | echo_success "Path $NAGIOS_VAR" "OK" |
|---|
| 230 | echo "" |
|---|
| 231 | fi |
|---|
| 232 | |
|---|
| 233 | if [ -z $NAGIOS_PLUGIN ];then |
|---|
| 234 | #nagios plugins directory for oreon |
|---|
| 235 | NAGIOS_PLUGIN="$INSTALL_DIR_NAGIOS/libexec" |
|---|
| 236 | echo "Where is your nagios plugins (libexec) directory ?" |
|---|
| 237 | echo -n "default to [$NAGIOS_PLUGIN]:" |
|---|
| 238 | read temp |
|---|
| 239 | if [ -z "$temp" ]; then |
|---|
| 240 | temp="$NAGIOS_PLUGIN" |
|---|
| 241 | fi |
|---|
| 242 | while [ ! -d "$temp" ] ; do |
|---|
| 243 | create_libexec="null" |
|---|
| 244 | valid_directory=`echo $temp | grep "^/"` |
|---|
| 245 | if [ "$valid_directory" != "" ]; then |
|---|
| 246 | echo_passed "Directory $temp does not exits." "CRITICAL" |
|---|
| 247 | while [ "$create_libexec" != "y" ] && [ "$create_libexec" != "Y" ] && [ "$create_libexec" != "n" ] && [ "$create_libexec" != "N" ]; do |
|---|
| 248 | echo "" |
|---|
| 249 | echo -n "Do you want me to create libexec directory [$temp]?[Y/n]" |
|---|
| 250 | read create_libexec |
|---|
| 251 | if [ -z "$create_libexec" ]; then |
|---|
| 252 | create_libexec="y" |
|---|
| 253 | fi |
|---|
| 254 | done |
|---|
| 255 | else |
|---|
| 256 | echo_passed "$temp is not a valid directory." "CRITICAL" |
|---|
| 257 | fi |
|---|
| 258 | if [ $create_libexec = "y" ] || [ $create_libexec = "Y" ]; then |
|---|
| 259 | mkdir -p $temp |
|---|
| 260 | if [ $? = 1 ]; then |
|---|
| 261 | echo_passed "Could not create directory" "CRITICAL" |
|---|
| 262 | echo "" |
|---|
| 263 | echo "Where is your nagios plugins (libexec) directory ?" |
|---|
| 264 | echo -n "default to [$NAGIOS_PLUGIN]:" |
|---|
| 265 | read temp |
|---|
| 266 | if [ -z "$temp" ]; then |
|---|
| 267 | temp="$NAGIOS_PLUGIN" |
|---|
| 268 | fi |
|---|
| 269 | fi |
|---|
| 270 | else |
|---|
| 271 | echo "Where is your nagios plugins (libexec) directory ?" |
|---|
| 272 | echo -n "default to [$NAGIOS_PLUGIN]:" |
|---|
| 273 | read temp |
|---|
| 274 | if [ -z "$temp" ]; then |
|---|
| 275 | temp="$NAGIOS_PLUGIN" |
|---|
| 276 | fi |
|---|
| 277 | fi |
|---|
| 278 | done |
|---|
| 279 | NAGIOS_PLUGIN="$temp" |
|---|
| 280 | echo_success "Path $NAGIOS_PLUGIN" "OK" |
|---|
| 281 | echo "" |
|---|
| 282 | fi |
|---|
| 283 | |
|---|
| 284 | if [ -z $NAGIOS_BIN ];then |
|---|
| 285 | #nagios plugins directory for oreon |
|---|
| 286 | NAGIOS_BIN="$INSTALL_DIR_NAGIOS/bin" |
|---|
| 287 | echo "Where is your nagios bin directory?" |
|---|
| 288 | echo -n "default to [$NAGIOS_BIN]:" |
|---|
| 289 | read temp |
|---|
| 290 | if [ -z "$temp" ]; then |
|---|
| 291 | temp="$NAGIOS_BIN" |
|---|
| 292 | fi |
|---|
| 293 | while [ ! -x "${temp}/nagios" ]; do |
|---|
| 294 | echo_passed "Cannot find ${temp}/nagios" "CRITICAL" |
|---|
| 295 | echo "Where is your nagios bin directory?" |
|---|
| 296 | echo -n "default to [$NAGIOS_BIN]:" |
|---|
| 297 | read temp |
|---|
| 298 | if [ -z "$temp" ]; then |
|---|
| 299 | temp="$NAGIOS_BIN" |
|---|
| 300 | fi |
|---|
| 301 | done |
|---|
| 302 | NAGIOS_BIN="$temp" |
|---|
| 303 | echo_success "Path $NAGIOS_BIN" "OK" |
|---|
| 304 | echo "" |
|---|
| 305 | fi |
|---|
| 306 | |
|---|
| 307 | if [ -z $NAGIOS_IMG ];then |
|---|
| 308 | #nagios plugins directory for oreon |
|---|
| 309 | NAGIOS_IMG="$INSTALL_DIR_NAGIOS/share/images" |
|---|
| 310 | echo "Where is your nagios image directory ?" |
|---|
| 311 | echo -n "default to [$NAGIOS_IMG]:" |
|---|
| 312 | read temp |
|---|
| 313 | if [ -z "$temp" ]; then |
|---|
| 314 | temp="$NAGIOS_IMG" |
|---|
| 315 | fi |
|---|
| 316 | while [ ! -d "$temp" ]; do |
|---|
| 317 | echo_passed "$temp is not a directory." "CRITICAL" |
|---|
| 318 | echo "Where is your nagios image directory ?" |
|---|
| 319 | echo -n "default to [$NAGIOS_IMG]:" |
|---|
| 320 | read temp |
|---|
| 321 | if [ -z "$temp" ]; then |
|---|
| 322 | temp="$NAGIOS_IMG" |
|---|
| 323 | fi |
|---|
| 324 | done |
|---|
| 325 | NAGIOS_IMG="$temp" |
|---|
| 326 | echo_success "Path $NAGIOS_IMG" "OK" |
|---|
| 327 | echo "" |
|---|
| 328 | fi |
|---|
| 329 | |
|---|
| 330 | if [ -z $INSTALL_DIR_OREON ];then |
|---|
| 331 | #setup directory for oreon |
|---|
| 332 | INSTALL_DIR_OREON="/usr/local/centreon" |
|---|
| 333 | echo "Where do I install centreon ?" |
|---|
| 334 | echo -n "default to [$INSTALL_DIR_OREON]:" |
|---|
| 335 | read temp |
|---|
| 336 | if [ -z "$temp" ]; then |
|---|
| 337 | temp="$INSTALL_DIR_OREON" |
|---|
| 338 | fi |
|---|
| 339 | while [ ! -d "$temp" ] ; do |
|---|
| 340 | create_oreon="null" |
|---|
| 341 | valid_directory=`echo $temp | grep "^/"` |
|---|
| 342 | if [ "$valid_directory" != "" ]; then |
|---|
| 343 | echo_passed "Directory $temp does not exits." "CRITICAL" |
|---|
| 344 | while [ "$create_oreon" != "y" ] && [ "$create_oreon" != "Y" ] && [ "$create_oreon" != "n" ] && [ "$create_oreon" != "N" ]; do |
|---|
| 345 | echo "" |
|---|
| 346 | echo -n "Do you want me to create this directory [$temp]?[Y/n]" |
|---|
| 347 | read create_oreon |
|---|
| 348 | if [ -z "$create_oreon" ]; then |
|---|
| 349 | create_oreon="y" |
|---|
| 350 | fi |
|---|
| 351 | done |
|---|
| 352 | else |
|---|
| 353 | echo_passed "$temp is not a valid directory." "CRITICAL" |
|---|
| 354 | fi |
|---|
| 355 | if [ $create_oreon = "y" ] || [ $create_oreon = "Y" ]; then |
|---|
| 356 | mkdir -p $temp |
|---|
| 357 | if [ $? = 1 ]; then |
|---|
| 358 | echo_passed "Could not create directory" "CRITICAL" |
|---|
| 359 | echo "" |
|---|
| 360 | echo "Where do I install Centreon ?" |
|---|
| 361 | echo -n "default to [$INSTALL_OREON_DIR]:" |
|---|
| 362 | read temp |
|---|
| 363 | if [ -z "$temp" ]; then |
|---|
| 364 | temp="$INSTALL_DIR_OREON" |
|---|
| 365 | fi |
|---|
| 366 | fi |
|---|
| 367 | else |
|---|
| 368 | echo "Where do I install Centreon ?" |
|---|
| 369 | echo -n "default to [$INSTALL_DIR_OREON]:" |
|---|
| 370 | read temp |
|---|
| 371 | if [ -z "$temp" ]; then |
|---|
| 372 | temp="$INSTALL_DIR_OREON" |
|---|
| 373 | fi |
|---|
| 374 | fi |
|---|
| 375 | done |
|---|
| 376 | INSTALL_DIR_OREON="$temp" |
|---|
| 377 | echo_success "Path $INSTALL_DIR_OREON" "OK" |
|---|
| 378 | echo "" |
|---|
| 379 | fi |
|---|
| 380 | |
|---|
| 381 | if [ -z $SUDO_FILE ];then |
|---|
| 382 | #Configuration file for sudo |
|---|
| 383 | SUDO_FILE="/etc/sudoers" |
|---|
| 384 | echo "Where is sudo configuration file?" |
|---|
| 385 | echo -n "default to [$SUDO_FILE]:" |
|---|
| 386 | read temp |
|---|
| 387 | if [ -z "$temp" ]; then |
|---|
| 388 | temp="$SUDO_FILE" |
|---|
| 389 | fi |
|---|
| 390 | while [ ! -f "$temp" ]; do |
|---|
| 391 | echo_passed "$temp if not a file." "CRITICAL" |
|---|
| 392 | echo "Where is sudo configuration file?" |
|---|
| 393 | echo -n "default to [$SUDO_FILE]:" |
|---|
| 394 | read temp |
|---|
| 395 | if [ -z "$temp" ]; then |
|---|
| 396 | temp="$SUDO_FILE" |
|---|
| 397 | fi |
|---|
| 398 | done |
|---|
| 399 | SUDO_FILE="$temp" |
|---|
| 400 | echo_success "File $SUDO_FILE" "OK" |
|---|
| 401 | echo "" |
|---|
| 402 | fi |
|---|
| 403 | # "/usr/share/pear" |
|---|
| 404 | if [ -z $RRD_PERL ];then |
|---|
| 405 | #RRDTOOL perl module directory |
|---|
| 406 | RRD_PERL="/usr/local/rrdtool/lib/perl" |
|---|
| 407 | echo "Where is installed RRD perl modules [RRDs.pm] ?" |
|---|
| 408 | echo "Just put directory, not full path." |
|---|
| 409 | echo -n "default to [$RRD_PERL]:" |
|---|
| 410 | read temp |
|---|
| 411 | if [ -z "$temp" ]; then |
|---|
| 412 | temp="$RRD_PERL" |
|---|
| 413 | fi |
|---|
| 414 | while [ ! -f "$temp/RRDs.pm" ]; do |
|---|
| 415 | echo_passed "Cannot find ${temp}/RRDs.pm." "CRITICAL" |
|---|
| 416 | echo "Where is installed RRD perl modules [RRDs.pm] ?" |
|---|
| 417 | echo "Just put directory, not full path." |
|---|
| 418 | echo -n "default to [$RRD_PERL]:" |
|---|
| 419 | read temp |
|---|
| 420 | if [ -z "$temp" ]; then |
|---|
| 421 | temp="$RRD_PERL" |
|---|
| 422 | fi |
|---|
| 423 | done |
|---|
| 424 | RRD_PERL="$temp" |
|---|
| 425 | echo_success "File $RRD_PERL" "OK" |
|---|
| 426 | echo "" |
|---|
| 427 | fi |
|---|
| 428 | |
|---|
| 429 | if [ -z $BIN_RRDTOOL ];then |
|---|
| 430 | #RRDTOOL binary path |
|---|
| 431 | BIN_RRDTOOL="/usr/bin/rrdtool" |
|---|
| 432 | echo "Where is rrdtool binary ?" |
|---|
| 433 | echo -n "default to [$BIN_RRDTOOL]:" |
|---|
| 434 | read temp |
|---|
| 435 | if [ -z "$temp" ]; then |
|---|
| 436 | temp="$BIN_RRDTOOL" |
|---|
| 437 | fi |
|---|
| 438 | while [ ! -x "$temp" ]; do |
|---|
| 439 | echo_passed "$temp is not found or is not runnable" "CRITICAL" |
|---|
| 440 | echo "Where is rrdtool binary ?" |
|---|
| 441 | echo -n "default to [$BIN_RRDTOOL]:" |
|---|
| 442 | read temp |
|---|
| 443 | if [ -z "$temp" ]; then |
|---|
| 444 | temp="$BIN_RRDTOOL" |
|---|
| 445 | fi |
|---|
| 446 | done |
|---|
| 447 | BIN_RRDTOOL="$temp" |
|---|
| 448 | echo_success "$BIN_RRDTOOL" "OK" |
|---|
| 449 | echo "" |
|---|
| 450 | fi |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | if [ -z $BIN_MAIL ];then |
|---|
| 454 | #MAIL binary path |
|---|
| 455 | BIN_MAIL="/usr/bin/mail" |
|---|
| 456 | echo "Where is mail binary ?" |
|---|
| 457 | echo -n "default to [$BIN_MAIL]:" |
|---|
| 458 | read temp |
|---|
| 459 | if [ -z "$temp" ]; then |
|---|
| 460 | temp="$BIN_MAIL" |
|---|
| 461 | fi |
|---|
| 462 | while [ ! -x "$temp" ]; do |
|---|
| 463 | echo_passed "$temp not found or not runnable" "CRITICAL" |
|---|
| 464 | echo "Where is mail binary ?" |
|---|
| 465 | echo -n " default to [$BIN_MAIL]:" |
|---|
| 466 | read temp |
|---|
| 467 | if [ -z "$temp" ]; then |
|---|
| 468 | temp="$BIN_MAIL" |
|---|
| 469 | fi |
|---|
| 470 | done |
|---|
| 471 | BIN_MAIL="$temp" |
|---|
| 472 | echo_success "$BIN_MAIL" "OK" |
|---|
| 473 | echo "" |
|---|
| 474 | fi |
|---|
| 475 | |
|---|
| 476 | if [ -z $PEAR_PATH ];then |
|---|
| 477 | PEAR_PATH="/usr/share/pear" |
|---|
| 478 | echo "Where is PEAR Path ?" |
|---|
| 479 | echo -n "default to [$PEAR_PATH]:" |
|---|
| 480 | read temp |
|---|
| 481 | test_answer PEAR_PATH $temp |
|---|
| 482 | PEAR_PATH=${PEAR_PATH%/} |
|---|
| 483 | while [ ! -f "${PEAR_PATH}/PEAR.php" ] |
|---|
| 484 | do |
|---|
| 485 | echo_passed "${PEAR_PATH}/PEAR.php not found" "CRITICAL" |
|---|
| 486 | echo "Where is PEAR Path ?" |
|---|
| 487 | PEAR_PATH="/usr/share/pear" |
|---|
| 488 | echo -n "default to [$PEAR_PATH]:" |
|---|
| 489 | read temp |
|---|
| 490 | test_answer PEAR_PATH $temp |
|---|
| 491 | PEAR_PATH=${PEAR_PATH%/} |
|---|
| 492 | done |
|---|
| 493 | echo_success "PEAR Path $PEAR_PATH" "OK" |
|---|
| 494 | echo "" |
|---|
| 495 | fi |
|---|
| 496 | |
|---|
| 497 | |
|---|
| 498 | ## |
|---|
| 499 | ## Functions |
|---|
| 500 | ## |
|---|
| 501 | |
|---|
| 502 | # When exit on error |
|---|
| 503 | |
|---|
| 504 | function error() |
|---|
| 505 | { |
|---|
| 506 | echo "ERROR" |
|---|
| 507 | exit 2 |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | # Check apache version, and configure it. Ask to restart apache server |
|---|
| 511 | # Make a copy of the original file as httpd.conf.initial |
|---|
| 512 | |
|---|
| 513 | function configure_apache() |
|---|
| 514 | { |
|---|
| 515 | echo "" |
|---|
| 516 | echo "------------------------------------------------------------------------" |
|---|
| 517 | echo " Configure Apache server" |
|---|
| 518 | echo "------------------------------------------------------------------------" |
|---|
| 519 | echo "" |
|---|
| 520 | echo "" |
|---|
| 521 | |
|---|
| 522 | # configure httpd.conf |
|---|
| 523 | if test -e $DIR_APACHE_CONF/oreon.conf ; then |
|---|
| 524 | echo "Finding Apache Centreon configuration file" |
|---|
| 525 | echo_success "'$DIR_APACHE_CONF/oreon.conf' :" "OK" |
|---|
| 526 | echo "Do you want to replace configuration file ?" |
|---|
| 527 | echo -n "[y/n], default to [y]:" |
|---|
| 528 | read temp |
|---|
| 529 | if [ "$temp" != "y" ] && [ "$temp" != "n" ] && [ ! -z $temp ] ;then |
|---|
| 530 | while [ "$temp" != "y" ] && [ "$temp" != "n" ] && [ ! -z $temp ] |
|---|
| 531 | do |
|---|
| 532 | echo "Do you want rewrite Apache configuration file ?" |
|---|
| 533 | echo -n "[y/n], default to [y]:" |
|---|
| 534 | read temp |
|---|
| 535 | done |
|---|
| 536 | fi |
|---|
| 537 | if [ -z $temp ];then |
|---|
| 538 | temp=y |
|---|
| 539 | fi |
|---|
| 540 | else |
|---|
| 541 | temp=y |
|---|
| 542 | fi |
|---|
| 543 | |
|---|
| 544 | if [ $temp = "y" ];then |
|---|
| 545 | echo "" > $DIR_APACHE_CONF/oreon.conf |
|---|
| 546 | cat << EOF >> $DIR_APACHE_CONF/oreon.conf |
|---|
| 547 | ## |
|---|
| 548 | ## Section add by Centreon Install Setup |
|---|
| 549 | ## |
|---|
| 550 | |
|---|
| 551 | AddType application/x-java-jnlp-file .jnlp |
|---|
| 552 | Alias /oreon/ $INSTALL_DIR_OREON/www/ |
|---|
| 553 | Alias /centreon/ $INSTALL_DIR_OREON/www/ |
|---|
| 554 | <Directory "$INSTALL_DIR_OREON/www"> |
|---|
| 555 | Options None |
|---|
| 556 | AllowOverride AuthConfig Options |
|---|
| 557 | Order allow,deny |
|---|
| 558 | Allow from all |
|---|
| 559 | </Directory> |
|---|
| 560 | |
|---|
| 561 | EOF |
|---|
| 562 | echo_success "Create '$DIR_APACHE_CONF/oreon.conf'" "OK" |
|---|
| 563 | echo_success "Configuring Apache" "OK" |
|---|
| 564 | else |
|---|
| 565 | echo_passed "Apache is already configurated" "PASSED" |
|---|
| 566 | fi |
|---|
| 567 | |
|---|
| 568 | # add apache user to nagios group |
|---|
| 569 | usermod_result=`usermod -G $NAGIOS_GROUP,$WEB_GROUP $WEB_USER >> $LOG_FILE 2>> $LOG_FILE; echo $?` |
|---|
| 570 | if [ $usermod_result = "0" ]; then |
|---|
| 571 | echo_success "User $WEB_USER added to nagios group" "OK" |
|---|
| 572 | echo "" |
|---|
| 573 | else |
|---|
| 574 | echo_warning "Couldn't add $WEB_USER to nagios group" "WARNING" |
|---|
| 575 | fi |
|---|
| 576 | # fi |
|---|
| 577 | #restart apache ! |
|---|
| 578 | if test -x /etc/init.d/apache ; then |
|---|
| 579 | /etc/init.d/apache restart >> $LOG_FILE 2>> $LOG_FILE |
|---|
| 580 | else if test -x /etc/init.d/httpd ; then |
|---|
| 581 | /etc/init.d/httpd restart |
|---|
| 582 | else if test -e /etc/init.d/apache2 ; then |
|---|
| 583 | /etc/init.d/apache2 restart >> $LOG_FILE 2>> $LOG_FILE |
|---|
| 584 | else |
|---|
| 585 | echo_warning "Unable to restart apache server" "WARNING" |
|---|
| 586 | fi |
|---|
| 587 | fi |
|---|
| 588 | fi |
|---|
| 589 | |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | # install Centreon interface |
|---|
| 593 | |
|---|
| 594 | function confirm_oreon() |
|---|
| 595 | { |
|---|
| 596 | if test -f $INSTALL_DIR_OREON/www/oreon.conf.php ; then |
|---|
| 597 | echo "" |
|---|
| 598 | echo "Centreon is already install on your server !" |
|---|
| 599 | |
|---|
| 600 | echo -n "Are you sure you want to install Centreon ?" |
|---|
| 601 | echo -n "[y/n], default to [n]:" |
|---|
| 602 | read answer |
|---|
| 603 | if [ "$answer" != "y" ] && [ "$answer" != "n" ] && [ ! -z $answer ] ;then |
|---|
| 604 | while [ "$answer" != "y" ] && [ "$answer" != "n" ] && [ ! -z $answer ] |
|---|
| 605 | do |
|---|
| 606 | echo "Are you sure you want to install Centreon ?" |
|---|
| 607 | echo -n "[y/n], default to [n]:" |
|---|
| 608 | read answer |
|---|
| 609 | done |
|---|
| 610 | fi |
|---|
| 611 | if [ -z $answer ];then |
|---|
| 612 | answer=n |
|---|
| 613 | fi |
|---|
| 614 | if [ $answer == 'n' ]; then |
|---|
| 615 | echo "Ok, bye bye !! " |
|---|
| 616 | exit |
|---|
| 617 | else if [ $answer == 'y' ]; then |
|---|
| 618 | install_oreon |
|---|
| 619 | install_ods |
|---|
| 620 | config_cron |
|---|
| 621 | config_sudo |
|---|
| 622 | #restart_mysql |
|---|
| 623 | else |
|---|
| 624 | echo "Please answer y or n ! " |
|---|
| 625 | confirm_oreon |
|---|
| 626 | fi |
|---|
| 627 | fi |
|---|
| 628 | else |
|---|
| 629 | install_oreon |
|---|
| 630 | install_ods |
|---|
| 631 | config_cron |
|---|
| 632 | config_sudo |
|---|
| 633 | #restart_mysql |
|---|
| 634 | fi |
|---|
| 635 | } |
|---|
| 636 | |
|---|
| 637 | ## old install_oreon |
|---|
| 638 | |
|---|
| 639 | |
|---|
| 640 | function restart_mysql() |
|---|
| 641 | { |
|---|
| 642 | # restart mysql to be sure that mysqld is running ! |
|---|
| 643 | echo "" |
|---|
| 644 | echo "------------------------------------------------------------------------" |
|---|
| 645 | echo " Restart Mysql server" |
|---|
| 646 | echo "------------------------------------------------------------------------" |
|---|
| 647 | echo "" |
|---|
| 648 | echo "" |
|---|
| 649 | if test -x /etc/init.d/mysqld ; then |
|---|
| 650 | /etc/init.d/mysqld restart |
|---|
| 651 | else if test -x /etc/init.d/mysql ; then |
|---|
| 652 | /etc/init.d/mysql restart |
|---|
| 653 | else |
|---|
| 654 | echo_failure "We didn't find Mysql server. Centreon will not run." "FAILURE" |
|---|
| 655 | exit |
|---|
| 656 | fi |
|---|
| 657 | fi |
|---|
| 658 | } |
|---|
| 659 | |
|---|
| 660 | function config_sudo(){ |
|---|
| 661 | echo "" |
|---|
| 662 | echo "------------------------------------------------------------------------" |
|---|
| 663 | echo " Configure Sudo" |
|---|
| 664 | echo "------------------------------------------------------------------------" |
|---|
| 665 | echo "" |
|---|
| 666 | echo "" |
|---|
| 667 | # Find Nagios Init Script |
|---|
| 668 | check_nagios_init_script |
|---|
| 669 | |
|---|
| 670 | sudo=`cat $SUDO_FILE | grep OREON > /dev/null; echo $?` |
|---|
| 671 | |
|---|
| 672 | if [ $sudo == '1' ]; then |
|---|
| 673 | echo "#Add by Centreon installation script" >> $SUDO_FILE |
|---|
| 674 | echo "User_Alias CENTREON= $WEB_USER" >> $SUDO_FILE |
|---|
| 675 | echo "## Nagios Restart" >> $SUDO_FILE |
|---|
| 676 | echo "CENTREON ALL = NOPASSWD: $NAGIOS_INIT_SCRIPT restart" >> $SUDO_FILE |
|---|
| 677 | echo "## Nagios reload" >> $SUDO_FILE |
|---|
| 678 | echo "CENTREON ALL = NOPASSWD: $NAGIOS_INIT_SCRIPT reload" >> $SUDO_FILE |
|---|
| 679 | # echo "## Snmptrapd Restart" >> $SUDO_FILE |
|---|
| 680 | # echo "CENTREON ALL = NOPASSWD: /etc/init.d/snmptrapd restart" >> $SUDO_FILE |
|---|
| 681 | echo "" >> $SUDO_FILE |
|---|
| 682 | echo_success "Configuring Sudo" "OK" |
|---|
| 683 | else |
|---|
| 684 | echo_passed "Sudo is already configurated" "PASSED" |
|---|
| 685 | fi |
|---|
| 686 | } |
|---|
| 687 | |
|---|
| 688 | function oreon_post_install() |
|---|
| 689 | { |
|---|
| 690 | echo "" |
|---|
| 691 | echo "------------------------------------------------------------------------" |
|---|
| 692 | echo " Centreon Post Install" |
|---|
| 693 | echo "------------------------------------------------------------------------" |
|---|
| 694 | echo "" |
|---|
| 695 | echo "" |
|---|
| 696 | #BIN_MAIL=`whereis -b mail | cut -d : -f2` |
|---|
| 697 | #BIN_MAIL=${BIN_MAIL# } |
|---|
| 698 | echo_success "Finding mail binary : $BIN_MAIL " "OK" |
|---|
| 699 | |
|---|
| 700 | #BIN_RRDTOOL=`whereis -b rrdtool | cut -d : -f2 | cut -d " " -f2` |
|---|
| 701 | #BIN_RRDTOOL=${BIN_RRDTOOL# } |
|---|
| 702 | echo_success "Finding rrdtool binary : $BIN_RRDTOOL " "OK" |
|---|
| 703 | |
|---|
| 704 | |
|---|
| 705 | INSTALL_DIR_OREON_CONF="$INSTALL_DIR_OREON/www/install/installoreon.conf.php" |
|---|
| 706 | echo "<?" > $INSTALL_DIR_OREON_CONF |
|---|
| 707 | echo "/**" >> $INSTALL_DIR_OREON_CONF |
|---|
| 708 | echo "Oreon is developped with GPL Licence 2.0 :" >> $INSTALL_DIR_OREON_CONF |
|---|
| 709 | echo "http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" >> $INSTALL_DIR_OREON_CONF |
|---|
| 710 | echo "Developped by : Julien Mathis - Romain Le Merlus - Christophe Coraboeuf" >> $INSTALL_DIR_OREON_CONF |
|---|
| 711 | echo "" >> $INSTALL_DIR_OREON_CONF |
|---|
| 712 | echo "The Software is provided to you AS IS and WITH ALL FAULTS." >> $INSTALL_DIR_OREON_CONF |
|---|
| 713 | echo "OREON makes no representation and gives no warranty whatsoever," >> $INSTALL_DIR_OREON_CONF |
|---|
| 714 | echo "whether express or implied, and without limitation, with regard to the quality," >> $INSTALL_DIR_OREON_CONF |
|---|
| 715 | echo "safety, contents, performance, merchantability, non-infringement or suitability for" >> $INSTALL_DIR_OREON_CONF |
|---|
| 716 | echo "any particular or intended purpose of the Software found on the OREON web site." >> $INSTALL_DIR_OREON_CONF |
|---|
| 717 | echo "In no event will OREON be liable for any direct, indirect, punitive, special," >> $INSTALL_DIR_OREON_CONF |
|---|
| 718 | echo "incidental or consequential damages however they may arise and even if OREON has" >> $INSTALL_DIR_OREON_CONF |
|---|
| 719 | echo "been previously advised of the possibility of such damages." >> $INSTALL_DIR_OREON_CONF |
|---|
| 720 | echo "" >> $INSTALL_DIR_OREON_CONF |
|---|
| 721 | echo "For information : contact@oreon-project.org" >> $INSTALL_DIR_OREON_CONF |
|---|
| 722 | echo " */" >> $INSTALL_DIR_OREON_CONF |
|---|
| 723 | echo "" >> $INSTALL_DIR_OREON_CONF |
|---|
| 724 | echo "\$conf_installoreon['oreon_dir'] = \"$INSTALL_DIR_OREON/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 725 | echo "\$conf_installoreon['oreon_dir_www'] = \"$INSTALL_DIR_OREON/www/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 726 | echo "\$conf_installoreon['oreon_dir_rrd'] = \"$INSTALL_DIR_OREON/rrd/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 727 | echo "\$conf_installoreon['nagios_conf'] = \"$NAGIOS_ETC/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 728 | echo "\$conf_installoreon['nagios'] = \"$INSTALL_DIR_NAGIOS/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 729 | echo "\$conf_installoreon['nagios_var'] = \"$NAGIOS_VAR/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 730 | echo "\$conf_installoreon['nagios_plugins'] = \"$NAGIOS_PLUGIN/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 731 | echo "\$conf_installoreon['nagios_bin'] = \"$NAGIOS_BIN/\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 732 | echo "\$conf_installoreon['nagios_init_script'] = \"$NAGIOS_INIT_SCRIPT\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 733 | echo "\$conf_installoreon['rrdtool_dir'] = \"$BIN_RRDTOOL\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 734 | echo "\$conf_installoreon['apache_user'] = \"$WEB_USER\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 735 | echo "\$conf_installoreon['apache_group'] = \"$WEB_GROUP\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 736 | echo "\$conf_installoreon['nagios_user'] = \"$NAGIOS_USER\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 737 | echo "\$conf_installoreon['nagios_group'] = \"$NAGIOS_GROUP\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 738 | echo "\$conf_installoreon['mail'] = \"$BIN_MAIL\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 739 | #echo "\$conf_installoreon['rrdtool_dir'] = \"$BIN_RRDTOOL\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 740 | echo "\$conf_installoreon['pear_dir'] = \"$PEAR_PATH\";" >> $INSTALL_DIR_OREON_CONF |
|---|
| 741 | |
|---|
| 742 | for fichier in `cat $NAGIOS_ETC/nagios.cfg | grep _file | grep -v \#` |
|---|
| 743 | do |
|---|
| 744 | echo -n "\$conf_installoreon['" >> $INSTALL_DIR_OREON_CONF |
|---|
| 745 | tmp=`echo "$fichier" | cut -d = |
|---|