diff --git a/ssh-tunnel-manager.conf b/ssh-tunnel-manager.conf index 1f8a546946ae9e918c683499b8606dac7d4cfd82..8a7a613eeea709ce8f3fb8af31872b5f6ee47418 100644 --- a/ssh-tunnel-manager.conf +++ b/ssh-tunnel-manager.conf @@ -2,11 +2,13 @@ # # @author Gerhard Steinbeis (info [at] tinned-software [dot] net) # @copyright Copyright (c) 2013 +# # @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 # @package net # # Configuration file for the ssh-tunnel-manager script. Default location for -# the config file is /etc/ssh-tunnel-manager.conf +# the config file is /etc/ssh-tunnel-manager.conf or if that does not exist, +# the ssh-tunnel-manager.conf in the same directory as the script itself. # # diff --git a/ssh-tunnel-manager.sh b/ssh-tunnel-manager.sh index cb19eee29482040985b5d48ea95e899e55a94561..9d8f82562919daaedd67b3bb44ed482b97eec503 100755 --- a/ssh-tunnel-manager.sh +++ b/ssh-tunnel-manager.sh @@ -2,10 +2,14 @@ # # @author Gerhard Steinbeis (info [at] tinned-software [dot] net) # @copyright Copyright (c) 2013 -version=0.6.0 +version=0.6.1 # @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 # @package net # +# Configuration file for the ssh-tunnel-manager script. Default location for +# the config file is /etc/ssh-tunnel-manager.conf or if that does not exist, +# the ssh-tunnel-manager.conf in the same directory as the script itself. +# # # Ths TUNNEL array is used to configure the individual tunnels. Each @@ -40,7 +44,7 @@ DBG=0 # # Default configuration file to load settings from can be defined here. # -DEFAULT_CONFIG="/etc/ssh-tunnel-manager.conf" +DEFAULT_CONFIG="ssh-tunnel-manager.conf" # # Non Config values @@ -74,9 +78,14 @@ while [ $# -gt 0 ]; do # specific parameters --config) # load settings file - . $2 - CONFIG_FILE=$2 - CONFIG_LOADED=1 + if [[ -f "$2" ]]; then + . $2 + CONFIG_FILE=$2 + CONFIG_LOADED=1 + else + HELP=1 + echo "ERROR: Specified config file cound not be found." + fi shift 2 ;; @@ -115,7 +124,7 @@ while [ $# -gt 0 ]; do # undefined parameter *) - echo "Unknown option '$1'" + echo "ERROR: Unknown option '$1'" HELP=1 shift break @@ -134,9 +143,14 @@ fi # Load the default configuration file if no other configuration file is provided if [[ -z "$CONFIG_LOADED" ]]; then # Check if configuration file exists - if [[ -f "$DEFAULT_CONFIG" ]]; then - . $DEFAULT_CONFIG - CONFIG_FILE=$DEFAULT_CONFIG + if [[ -f "/etc/$DEFAULT_CONFIG" ]]; then + . /etc/$DEFAULT_CONFIG + CONFIG_FILE=/etc/$DEFAULT_CONFIG + else + if [[ -f "$SCRIPT_PATH/$DEFAULT_CONFIG" ]]; then + . $SCRIPT_PATH/$DEFAULT_CONFIG + CONFIG_FILE=$SCRIPT_PATH/$DEFAULT_CONFIG + fi fi fi