#!/bin/bash # ------- # File: llxcfg-disscr # Description: Simple script to disable llxcfg boot scripts # Author: Sergio Talens-Oliag # Copyright: (c) 2005 Sergio Talens-Oliag # SVN Id: $Id: llxcfg-disscr 5562 2006-03-08 08:50:38Z lgarcia $ # # 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" CONFDIR="/etc/llxcfg" SCR_AVAIL="scripts-available" AVAILDIR="$CONFDIR/$SCR_AVAIL" SCR_ENABLED="scripts-enabled" ENABLEDIR="$CONFDIR/$SCR_ENABLED" # Get the list of available scripts SCRIPTS=$(for s in `run-parts --test "$AVAILDIR"`; do basename $s; done) if [ -z "$SCRIPTS" ]; then echo "No valid scripts available!"; exit 0 fi SCRIPTS_LIST="" for s in $SCRIPTS; do SCRIPTS_LIST="$SCRIPTS_LIST $s" done # Read the script name if [ -z "$1" ]; then echo "Which script would you like to disable?" echo "Your choices are:$SCRIPTS_LIST" echo -n "Script name? " read SCR else SCR="$1" fi # Test if the script name is valid VALID="false" echo "$SCRIPTS" | grep -q "^$SCR$" && VALID="true" if [ "$VALID" = "false" ]; then # echo "The script name '$SCR' is invalid!"; # exit 1 echo "Ignoring invalid script name '$SCR'"; exit 0 fi if [ ! -e "$ENABLEDIR/$SCR" ]; then # echo "The script '$SCR' is already disabled!" # exit 1 echo "Nothing to do: The script '$SCR' is already disabled" exit 0 fi if [ ! -L "$ENABLEDIR/$SCR" ]; then # echo "The script '$SCR' is not a simbolic link!" # exit 1 echo "Nothing to do: The script '$SCR' is not a simbolic link" exit 0 fi # Disable it rm -f "$ENABLEDIR/$SCR" echo "Script '$SCR' disabled" echo "Maybe you need to run '$AVAILDIR/$SCR stop' to undo the script actions" exit 0