#!/bin/bash # ------- # File: llxcfg-script # Description: Script to manage llxcfg scripts # Author: Luis Garcia Gisbert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) 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 General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- set -e PATH="/usr/sbin:/usr/bin:/sbin:/bin" # --------- # variables # --------- # library LLX_COMMONLIB="/usr/share/lliurex/llxcfg-common/llxcfg-common.sh" [ -f "${LLX_COMMONLIB}" ] || exit 1 . ${LLX_COMMONLIB} usage(){ CMD_NAME="$(basename "$0")" echo "Usage: $CMD_NAME [OPTIONS] {SCR_TYPE} run [ACTION ...]" >&2 echo " $CMD_NAME {SCR_TYPE} {enable|disable} SCRIPT_NAME [RUN_ORDER]" >&2 echo " $CMD_NAME {SCR_TYPE} {allow|deny} SCRIPT_NAME" >&2 echo " OPTIONS: --stop-on-error, --log-dir=LOG_DIRECTORY" >&2 return 0 } # ---- # main # ---- while echo "$1" |grep -q "^--" ; do case "$1" in --stop-on-error) LLXSCR_STOP_ON_ERROR="Y" ;; --log-dir=*) LLXSCR_LOG_DIR="${1#*=}" [ -d "$LLXSCR_LOG_DIR" ] || LLXSCR_LOG_DIR="" ;; esac shift done SCRTYPE="$1" if ! llxscr_typetest "$SCRTYPE" ; then usage exit 1 fi shift case "$1" in run) shift llxscr_run "$SCRTYPE" "$@" || exit $? ;; enable) rc=0 if [ "$2" ] ; then llxscr_enable "$SCRTYPE" "$2" $3 || rc=$? else usage fi exit $rc ;; disable) rc=0 if [ "$2" ] ; then llxscr_disable "$SCRTYPE" "$2" || rc=$? else usage fi exit $rc ;; allow) rc=0 if [ "$2" ] ; then llxscr_allow "$SCRTYPE" "$2" || rc=$? else usage fi exit $rc ;; deny) rc=0 if [ "$2" ] ; then llxscr_deny "$SCRTYPE" "$2" || rc=$? else usage fi exit $rc ;; *) usage exit 1 ;; esac exit 0