#!/bin/bash # toolsched.d v0.17 by Con Kolivas # Check we're only calling this as a symbolic link if [ ! -h $0 ]; then echo "Calling toolsched.n directly, aborting!" echo "toolsched should only be called as a symbolic link." echo "Make sure you only have one copy of toolsched in your PATH." exit 1 fi # cmd is the application we're trying to call cmd=`basename $0` # scriptcmd should resolve to this actual script scriptcmd=`which $cmd 2>&1` #find the command we're trying to run for i in `which -a $cmd 2>&1` do if [[ $i != $scriptcmd ]]; then command=$i; break fi done # Break out if command doesn't exist if [ ! $command ]; then echo "$cmd: command not found" exit 1 fi # Check for presence of schedtool in path. # If not found just execute command schedtool=`which schedtool 2>&1` if [ ! $schedtool ]; then exec $command "$@" exit_status=$? exit $exit_status fi # make this script run nice 19 thus if it succeeds the command will also # run nice 19. $schedtool -n 19 $$ >/dev/null 2>&1 # run the command, returning its exit status exec $command "$@" exit_status=$? exit $exit_status