#!/bin/bash # # Hydra Management Tool. # # Copyright (C) 2010 Sarava Group - sarava at lists.riseup.net # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Load libraries function hydra_load { local dest local base # Determine if we are in a local or system-wide install. if [ -h "$0" ]; then dest="$(readlink $0)" # Check again as the caller might be a symlink as well if [ -h "$dest" ]; then base="`dirname $dest`" dest="$(dirname $(readlink $dest))" else base="`dirname $0`" dest="`dirname $dest`" fi # Deal with relative or absolute links if [ "`basename $dest`" == "$dest" ]; then export APP_BASE="$base" else export APP_BASE="$dest" fi else export APP_BASE="`dirname $0`" fi export ACTIONS="$APP_BASE/share/$BASENAME" source $APP_BASE/lib/hydra/functions || exit 1 } # Name and basename configuration BASENAME="`basename $0`" export NAME="$BASENAME" # Adjust hydra parameter if [ "$BASENAME" == "hydra" ]; then export HYDRA="$1" export ACTION="$2" shift else export ACTION="$1" fi # Load hydra_load $* # Command-line parser if [ -z "$ACTION" ]; then hydra_action_usage exit 1 fi # Dispatch if hydra_has_action $ACTION; then hydra_dispatch $* else echo "No such action $ACTION" exit 1 fi