From 67e46066e8c2e5a1705ecf087382ed07ac8d50e1 Mon Sep 17 00:00:00 2001 From: jsatoh Date: Tue, 29 Jun 2010 01:19:44 +0000 Subject: [PATCH] 2010-06-29 Junichi Satoh * pandora_console_install: Added support for FreeBSD and RHEL/CentOS. * install.php: Added support for FreeBSD. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2930 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++ pandora_console/install.php | 6 +- pandora_console/pandora_console_install | 107 ++++++++++++++++++++---- 3 files changed, 100 insertions(+), 19 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d9b3144d87..022e705b5e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-06-29 Junichi Satoh + + * pandora_console_install: Added support for FreeBSD and RHEL/CentOS. + + * install.php: Added support for FreeBSD. + 2010-06-28 Sergio Martin * include/functions_db.php: Fixed the get_agent_modules diff --git a/pandora_console/install.php b/pandora_console/install.php index 59602e62e0..5effae6319 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -307,7 +307,11 @@ function install_step2() { $res += check_include("PEAR.php","PEAR PHP Library"); $res += check_include("DB.php","PEAR:DB PHP Library"); $res += check_include("XML/RPC.php","PEAR::XML_RPC PHP Library"); - $res += check_exists ("/usr/bin/twopi","Graphviz Binary"); + if (PHP_OS == "FreeBSD") { + $res += check_exists ("/usr/local/bin/twopi","Graphviz Binary"); + } else { + $res += check_exists ("/usr/bin/twopi","Graphviz Binary"); + } echo ""; echo ""; diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install index 2885f20a0d..cd53d84d77 100755 --- a/pandora_console/pandora_console_install +++ b/pandora_console/pandora_console_install @@ -1,7 +1,8 @@ -#!/bin/bash +#!/bin/sh # Pandora FMS Console Installer (c) 2008-2010 Artica ST -# Linux Version (generic), for SuSe and Debian/Ubuntu only +# Linux/FreeBSD Version (generic), for SuSe, Debian/Ubuntu, RHEL/CentOS and +# FreeBSD only # other Linux distros could not work properly without modifications # Please see http://www.pandorafms.org # v3.0 Build 091224 @@ -16,6 +17,8 @@ MODE=$1 get_distro () { + OS_NAME=`uname -s` + # Get Linux Distro type and version if [ -f "/etc/SuSE-release" ] then @@ -40,8 +43,18 @@ get_distro () { OS_VERSION="FEDORA $OS_VERSION" LINUX_DISTRO=FEDORA else - LINUX_DISTRO=GENERIC - OS_VERSION=`uname -r` + if [ -f "/etc/redhat-release" ] + then + LINUX_DISTRO=RHEL_CENTOS + else + if [ "$OS_NAME" = "FreeBSD" ] + then + LINUX_DISTRO=FreeBSD + else + LINUX_DISTRO=GENERIC + fi + OS_VERSION=`uname -r` + fi fi fi fi @@ -50,6 +63,25 @@ get_distro () { } uninstall () { + DISTRO=`get_distro` + + if [ "$DISTRO" = "UBUNTU" ] + then + PANDORA_HOME=/var/www/pandora + else + if [ "$DISTRO" = "RHEL_CENTOS" ] + then + PANDORA_HOME=/var/www/html/pandora_console + else + if [ "$DISTRO" = "FreeBSD" ] + then + PANDORA_HOME="/usr/local/www/data/pandora_console /usr/local/www/apache22/data/pandora_console" + else + PANDORA_HOME=/srv/www/htdocs/pandora + fi + fi + fi + echo "Removing Pandora FMS Console" rm -Rf $PANDORA_HOME echo "You need to manually drop pandora database from your Database server" @@ -61,16 +93,33 @@ install () { DISTRO=`get_distro` OLDFILENAMETMP=`date +"%Y-%m-%d"` - if [ "$DISTRO" == "UBUNTU" ] + if [ "$DISTRO" = "UBUNTU" ] then PANDORA_HOME=/var/www/pandora PANDORA_CONF=$PANDORA_HOME/include/config.php else - PANDORA_HOME=/srv/www/htdocs/pandora - PANDORA_CONF=$PANDORA_HOME/include/config.php + if [ "$DISTRO" = "RHEL_CENTOS" ] + then + PANDORA_HOME=/var/www/html/pandora_console + PANDORA_CONF=$PANDORA_HOME/include/config.php + else + if [ "$DISTRO" = "FreeBSD" ] + then + if [ -d /usr/local/www/apache22 ] + then + PANDORA_HOME=/usr/local/www/apache22/data/pandora_console + else + PANDORA_HOME=/usr/local/www/data/pandora_console + fi + PANDORA_CONF=$PANDORA_HOME/include/config.php + else + PANDORA_HOME=/srv/www/htdocs/pandora + PANDORA_CONF=$PANDORA_HOME/include/config.php + fi + fi fi - echo "Detecting Linux distribution: $DISTRO" + echo "Detecting operating system: $DISTRO" if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ] then @@ -83,7 +132,7 @@ install () { # Create directories echo "Creating Pandora FMS Console home directory at $PANDORA_HOME ..." - mkdir $PANDORA_HOME 2> /dev/null + mkdir -p $PANDORA_HOME 2> /dev/null # Copying Pandora FMS console echo "Copying Pandora FMS Console to $PANDORA_HOME.." @@ -92,27 +141,49 @@ install () { # Creating 'pandora' user - id pandora + id pandora 2> /dev/null if [ $? -eq 0 ]; then echo " " echo "User pandora does exist, skipping this step" else echo "Creating 'pandora' user" - useradd pandora - mkdir /home/pandora 2> /dev/null - mkdir /home/pandora/.ssh 2> /dev/null - chown -R pandora /home/pandora + if [ "$DISTRO" = "FreeBSD" ] + then + echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null + else + useradd pandora + mkdir /home/pandora 2> /dev/null + mkdir /home/pandora/.ssh 2> /dev/null + chown -R pandora /home/pandora + fi + fi + + if [ ! -d /var/spool/pandora ] + then + mkdir -p /var/spool/pandora fi #Ownership - if [ "$DISTRO" == "UBUNTU" ] + if [ "$DISTRO" = "UBUNTU" ] then chown -R www-data:root $PANDORA_HOME chown -R pandora:www-data /var/spool/pandora/ else - # Assuming SUSE - chown -R wwwrun:root $PANDORA_HOME - chown -R pandora:www /var/spool/pandora/ + if [ "$DISTRO" = "RHEL_CENTOS" ] + then + chown -R apache:apache $PANDORA_HOME + chown -R pandora:apache /var/spool/pandora/ + else + if [ "$DISTRO" = "FreeBSD" ] + then + chown -R www:www $PANDORA_HOME + chown -R pandora:www /var/spool/pandora/ + else + # Assuming SUSE + chown -R wwwrun:root $PANDORA_HOME + chown -R pandora:www /var/spool/pandora/ + fi + fi fi echo "Setting secure permissions for Pandora FMS spool dir..."