Author: Wolfgang <[email protected]>
Date: Sun Apr 10 11:29:48 2011 +0200
Committer: Wolfgang <[email protected]>
Commit-Date: Sun Apr 10 11:29:48 2011 +0200
ticket #407: add Solaris support to install.sh
---
install.sh | 58 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/install.sh b/install.sh
index b5a6a04..9b93ad9 100755
--- a/install.sh
+++ b/install.sh
@@ -26,11 +26,11 @@
#
###############################################################################
-# Some initializations
+# Some initialisations
###############################################################################
# Installer version
-INSTALLER_VERSION="0.2.16"
+INSTALLER_VERSION="0.2.17"
# Default action
INSTALLER_ACTION="install"
# Be quiet? (Enable/Disable confirmations)
@@ -71,7 +71,7 @@ HTML_SAMPLE="etc/apache2-nagvis.conf-sample"
# Default nagios web conf
HTML_CONF="nagvis.conf"
# Saving current timestamp for backup when updating
-DATE=`date +%s`
+DATE=`perl -e 'print time(); print "\n"'`
# Web path to the NagVis base directory
HTML_PATH=""
# Path to webserver conf
@@ -176,7 +176,7 @@ EOD
version() {
cat <<EOD
NagVis installer, version $INSTALLER_VERSION
-Copyright (C) 2004-2010 NagVis Project (Contact: [email protected])
+Copyright (C) 2004-2011 NagVis Project (Contact: [email protected])
License: GNU General Public License version 2
@@ -250,7 +250,7 @@ check_nagios_path() {
}
check_web_user() {
- if [ "`getent passwd | cut -d':' -f1 | grep \"^$WEB_USER\"`" =
"$WEB_USER" ]; then
+ if [ "`getent passwd $WEB_USER | cut -d':' -f1`" = "$WEB_USER" ]; then
return 0
else
echo "| Error: User $WEB_USER not found."
@@ -259,7 +259,7 @@ check_web_user() {
}
check_web_group() {
- if [ "`getent group | cut -d':' -f1 | grep \"^$WEB_GROUP\"`" =
"$WEB_GROUP" ]; then
+ if [ "`getent group $WEB_GROUP | cut -d':' -f1`" = "$WEB_GROUP" ]; then
return 0
else
echo "| Error: Group $WEB_GROUP not found."
@@ -366,7 +366,18 @@ log() {
# Will overwrite the NAGIOS_PATH when found some Nagios running
detect_nagios_path() {
IFS=$'\n'
- for N_PROC in `ps ax -o pid,ppid,user,command | grep 'bin/$SOURCE' |
grep -v grep`; do
+ init_id=1
+ os_type=`uname -s`
+ case $os_type in
+ SunOS) # In Solaris Zone, there's no init process (id = 1) but
zsched (random id)
+ init_id=$(ps -ef | grep " zsched$" | grep -v grep |
awk '{ print $2 }' | head -1)
+ ;;
+ esac
+ for N_PROC in `
+ case $os_type in
+ SunOS) /bin/ps -ef -o pid,ppid,user,args ;;
+ *) ps ax -o pid,ppid,user,command ;;
+ esac | grep "bin/$SOURCE" | grep -v grep`; do
IFS=" "
# 2138 1 nagios /d/nagvis-dev/nagios/bin/nagios -d
/d/nagvis-dev/nagios/etc/nagios.cfg
N_PID=`expr "$N_PROC" : ' *\([0-9]*\)'`
@@ -375,7 +386,7 @@ detect_nagios_path() {
N_CMD=`expr "$N_PROC" : ' *[0-9]* *[0-9]* *[^ ]* *\(.*\)'`
echo "$N_CMD" | grep -i " -d" >/dev/null
- if [[ $? -eq 0 && $N_PPID -eq 1 ]]; then
+ if [[ $? -eq 0 && $N_PPID -eq $init_id ]]; then
N_BIN=${N_CMD%% *}
NAGIOS_PATH=${N_BIN%%/bin/$SOURCE}
NAGIOS_PATH=${NAGIOS_PATH%/}
@@ -564,6 +575,8 @@ check_graphviz_version() {
GRAPHVIZ_VER=`$PKG -l "graphviz" | grep "graphviz" | grep ii |
awk -F' ' '{ print $3 }' | sed "s/-.*$//" | cut -d"." -f1,2`
elif [ "${PKG##/*/}" = "rpm" ]; then
GRAPHVIZ_VER=`$PKG -qa "graphviz" | sed "s/graphviz-//g" | sed
"s/-.*$//" | cut -d"." -f1,2`
+ elif [ "${PKG##/*/}" = "pkginfo" ]; then
+ GRAPHVIZ_VER=`$PKG -l "SMCgviz" | grep VERSION | awk '{print
$2}'`
else
GRAPHVIZ_VER=`$PKG list installed "graphviz" | grep "installed"
| awk -F' ' '{ print $2 }' | sed "s/-.*$//" | cut -d"." -f1,2`
fi
@@ -754,7 +767,8 @@ copy_dir_xpath() {
[ -n "$LINE" ] && DONE=`log "$LINE" done`
# Get files and directories to copy. This takes only the elements in the
# given directory.
- FILES=`find $NAGVIS_PATH_BACKUP/$2 -mindepth 1 -maxdepth 1`
+ # FILES=`find $NAGVIS_PATH_BACKUP/$2 -mindepth 1 -maxdepth 1`
+ FILES=`find $NAGVIS_PATH_BACKUP/$2/* -prune 2> /dev/null`
# Maybe exclude some files
if [ "$1" != "" ]; then
@@ -768,6 +782,7 @@ copy_dir_xpath() {
}
copy() {
+ IFS=" "$'\n'
DONE=""
# DEBUG: [ -n "$LINE" ] && line "$LINE"
@@ -783,7 +798,8 @@ copy() {
if [ -d "$NAGVIS_PATH_BACKUP/$2" -a ! -d "$3" ]; then
# Get files and directories to copy. This takes only the
elements in the
# given directory.
- FILES=`find $NAGVIS_PATH_BACKUP/$2 -mindepth 1 -maxdepth 1`
+ # FILES=`find $NAGVIS_PATH_BACKUP/$2 -mindepth 1 -maxdepth 1`
+ FILES=`find $NAGVIS_PATH_BACKUP/$2/* -prune 2> /dev/null`
# Maybe exclude some files
if [ "$1" != "" ]; then
@@ -1066,6 +1082,15 @@ if [ $FORCE -eq 1 ]; then
fi
fi
+find_bin()
+{
+ bin=$1
+ case `uname -s` in
+ SunOS) which $bin | grep -v "^no $bin in" ;;
+ *) which $bin 2> /dev/null ;;
+ esac
+}
+
{
# Print welcome message
welcome
@@ -1085,11 +1110,12 @@ if [ -z $WHICH ]; then
log "'which' not found (maybe package missing). Aborting..."
exit 1
fi
-PKG=`which rpm 2>/dev/null`
-[ -u $PKG ] && PKG=`which dpkg 2>/dev/null`
-[ -u $PKG ] && PKG=`which yum 2>/dev/null`
-if [ -u $PKG ]; then
- log "No packet manager (rpm/dpkg/yum) found. Aborting..."
+PKG=`find_bin rpm`
+[ -z "$PKG" ] && PKG=`find_bin dpkg`
+[ -z "$PKG" ] && PKG=`find_bin yum`
+[ -z "$PKG" ] && PKG=`find_bin pkginfo`
+if [ -z "$PKG" ]; then
+ log "No packet manager (rpm/dpkg/yum/pkginfo) found. Aborting..."
exit 1
fi
log "Using packet manager $PKG" $PKG
@@ -1654,7 +1680,7 @@ fi
text
line "Setting permissions..." "+"
-chown $WEB_USER:$WEB_GROUP $NAGVIS_PATH -R
+chown -R $WEB_USER:$WEB_GROUP $NAGVIS_PATH
[ -f "$NAGVIS_PATH/$NAGVIS_CONF-sample" ]&&set_perm 664
"$NAGVIS_PATH/$NAGVIS_CONF-sample"
set_perm 775 "$NAGVIS_PATH/etc"
set_perm 775 "$NAGVIS_PATH/etc/maps"
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins