Permalink
Browse files

Clean-up shell-scripts.

* Use /bin/sh when no bash-features are required.
* Update Copyright year to 2012 where appropriate.
* Quote all variables containing paths (as they may contain spaces).
* Replace back-tick command substitution by $(...) (which AFAIK is
  POSIX-conformant).
* Use same path for commandfile in all external_commands.
* Use `exec` instead of plenty of redirects.
  • Loading branch information...
1 parent f1b051d commit 73e629115e68572eefc42ede452d11db037e6ccd @htgoebel htgoebel committed Jul 15, 2012
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,16 +22,16 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-echo "Going to dir" $DIR
+DIR="$(cd $(dirname "$0"); pwd)"
+echo "Going to dir $DIR"
-cd $DIR/..
+cd "$DIR"/..
export LANG=us_US.UTF-8
-$DIR/launch_scheduler.sh
-$DIR/launch_poller.sh
-$DIR/launch_reactionner.sh
-$DIR/launch_broker.sh
-$DIR/launch_receiver.sh
-$DIR/launch_arbiter.sh
+"$DIR"/launch_scheduler.sh
+"$DIR"/launch_poller.sh
+"$DIR"/launch_reactionner.sh
+"$DIR"/launch_broker.sh
+"$DIR"/launch_receiver.sh
+"$DIR"/launch_arbiter.sh
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,16 +22,16 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-echo $DIR
+DIR="$(cd $(dirname "$0"); pwd)"
+echo "$DIR"
-cd $DIR/..
+cd "$DIR/.."
export LANG=us_US.UTF-8
-$DIR/launch_scheduler_debug.sh
-$DIR/launch_poller_debug.sh
-$DIR/launch_reactionner_debug.sh
-$DIR/launch_broker_debug.sh
-$DIR/launch_receiver_debug.sh
-$DIR/launch_arbiter_debug.sh
+"$DIR"/launch_scheduler_debug.sh
+"$DIR"/launch_poller_debug.sh
+"$DIR"/launch_reactionner_debug.sh
+"$DIR"/launch_broker_debug.sh
+"$DIR"/launch_receiver_debug.sh
+"$DIR"/launch_arbiter_debug.sh
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,11 +22,13 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
-# needed because arbiter doesn't have a default 'workdir' "properties" attribute:
+# Need to change directory to .../var because arbiter doesn't have a
+# default 'workdir' "properties" attribute:.
cd "$DIR/../var"
+
echo "Launching Arbiter (which reads configuration and dispatches it)"
-$BIN/shinken-arbiter -d -c $ETC/nagios.cfg -c $ETC/shinken-specific.cfg
+"$BIN"/shinken-arbiter -d -c "$ETC"/nagios.cfg -c "$ETC"/shinken-specific.cfg
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,14 +22,18 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
DEBUG_PATH="/tmp/arbiter.debug"
-# needed because arbiter doesn't have a default 'workdir' "properties" attribute:
-cd "$DIR/../var"
-echo "Launching Arbiter (which reads configuration and dispatches it) in debug mode to the file $DEBUG_PATH"
-$BIN/shinken-arbiter -d -c $ETC/nagios.cfg -c $ETC/shinken-specific.cfg -c $ETC/sample.cfg --debug $DEBUG_PATH -p /tmp/arbiter.profile
+# Need to change directory to .../var because arbiter doesn't have a
+# default 'workdir' "properties" attribute:.
+cd "$DIR"/../var
+echo "Launching Arbiter (which reads configuration and dispatches it) " \
+ "in debug mode to the file $DEBUG_PATH"
+"$BIN"/shinken-arbiter -d \
+ -c "$ETC"/nagios.cfg -c "$ETC"/shinken-specific.cfg -c "$ETC"/sample.cfg \
+ --debug "$DEBUG_PATH" -p /tmp/arbiter.profile
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,9 +22,9 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
echo "Launching Broker (which exports all data)"
-$BIN/shinken-broker -d -c $ETC/brokerd.ini
+"$BIN"/shinken-broker -d -c "$ETC"/brokerd.ini
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,10 +22,10 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
DEBUG_PATH="/tmp/broker.debug"
echo "Launching Broker (which exports all data) in debug mode to the file $DEBUG_PATH"
-$BIN/shinken-broker -d -c $ETC/brokerd.ini --debug $DEBUG_PATH
+"$BIN"/shinken-broker -d -c "$ETC"/brokerd.ini --debug "$DEBUG_PATH"
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,9 +22,9 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
echo "Launching Poller (which launches checks)"
-$BIN/shinken-poller -d -c $ETC/pollerd.ini
+"$BIN"/shinken-poller -d -c "$ETC"/pollerd.ini
View
@@ -1,7 +1,6 @@
-#!/bin/bash
-
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -23,10 +22,10 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
DEBUG_PATH="/tmp/poller.debug"
echo "Launching Poller (which launches checks) in debug mode to the file $DEBUG_PATH"
-$BIN/shinken-poller -d -c $ETC/pollerd.ini --debug $DEBUG_PATH
+"$BIN"/shinken-poller -d -c "$ETC"/pollerd.ini --debug "$DEBUG_PATH"
View
@@ -1,7 +1,6 @@
-#!/bin/bash
-
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -23,9 +22,9 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
echo "Launching Reactionner (which sends notifications)"
-$BIN/shinken-reactionner -d -c $ETC/reactionnerd.ini
+"$BIN"/shinken-reactionner -d -c "$ETC"/reactionnerd.ini
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,10 +22,10 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
DEBUG_PATH="/tmp/reactionner.debug"
echo "Launching Reactionner (which sends notifications) in debug mode to the file $DEBUG_PATH"
-$BIN/shinken-reactionner -d -c $ETC/reactionnerd.ini --debug $DEBUG_PATH
+"$BIN"/shinken-reactionner -d -c "$ETC"/reactionnerd.ini --debug "$DEBUG_PATH"
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,9 +22,9 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
echo "Launching Receiver (which manages passive data)"
-$BIN/shinken-receiver -d -c $ETC/receiverd.ini
+"$BIN"/shinken-receiver -d -c "$ETC"/receiverd.ini
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,10 +22,10 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
DEBUG_PATH="/tmp/receiver.debug"
echo "Launching receiver (which manages passive data) in debug mode to the file $DEBUG_PATH"
-$BIN/shinken-receiver -d -c $ETC/receiverd.ini --debug $DEBUG_PATH
+"$BIN"/shinken-receiver -d -c "$ETC"/receiverd.ini --debug "$DEBUG_PATH"
View
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,9 +22,9 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
echo "Launching Scheduler (that is only in charge of scheduling)"
-$BIN/shinken-scheduler -d -c $ETC/schedulerd.ini
+"$BIN"/shinken-scheduler -d -c "$ETC"/schedulerd.ini
@@ -1,6 +1,6 @@
-#!/bin/bash
-
-# Copyright (C) 2009-2011:
+#!/bin/sh
+#
+# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
@@ -22,10 +22,10 @@
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
-DIR=$(cd $(dirname "$0"); pwd)
-BIN=$DIR"/../bin"
-ETC=$DIR"/../etc"
+DIR="$(cd $(dirname "$0"); pwd)"
+BIN="$DIR"/../bin
+ETC="$DIR"/../etc
DEBUG_PATH="/tmp/scheduler.debug"
echo "Launching Scheduler (that is only in charge of scheduling) in debug mode to the file $DEBUG_PATH"
-$BIN/shinken-scheduler -d -c $ETC/schedulerd.ini --debug $DEBUG_PATH
+"$BIN"/shinken-scheduler -d -c "$ETC"/schedulerd.ini --debug "$DEBUG_PATH"
Oops, something went wrong.

0 comments on commit 73e6291

Please sign in to comment.