aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-01 16:39:27 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-01 16:39:27 -0400
commit460d19baddd2ac077d2c06f090ac1db09e1730e6 (patch)
treef5f4c9d350d32082f97a0fbef31f956dc301d89a
parentd6b8d74b5a72da64fd9305004e628d582afe5235 (diff)
setsched: check for presence of dialog
Make setsched error out when the dialog binary is not found in the path. Ubuntu does not install dialog by default and people are tripping over it.
-rwxr-xr-xsetsched12
1 files changed, 10 insertions, 2 deletions
diff --git a/setsched b/setsched
index 4b7160f..d2397b0 100755
--- a/setsched
+++ b/setsched
@@ -4,6 +4,7 @@
4 4
5ADIR=/proc/litmus/active_plugin 5ADIR=/proc/litmus/active_plugin
6PDIR=/proc/litmus/plugins 6PDIR=/proc/litmus/plugins
7DIALOG=`which dialog`
7 8
8CHOICE=$1 9CHOICE=$1
9 10
@@ -16,9 +17,15 @@ fi
16ACTIVE=`cat $ADIR` 17ACTIVE=`cat $ADIR`
17 18
18if [ -z "$1" ]; then 19if [ -z "$1" ]; then
20 # Check for presence of dialog, some distros don't install it by default.
21 if [ -z "$DIALOG" ]; then
22 echo "Error: The dialog utility cannot be found."
23 echo " Please install the required package (dialog on Ubuntu)."
24 exit 2
25 fi
19 TMP=`mktemp` 26 TMP=`mktemp`
20 (awk "{print \$1 \" 'Plugin'\"}" $PDIR | \ 27 (awk "{print \$1 \" 'Plugin'\"}" $PDIR | \
21 xargs dialog --title "Select Plugin" --backtitle "Current: $ACTIVE" \ 28 xargs $DIALOG --title "Select Plugin" --backtitle "Current: $ACTIVE" \
22 --cancel-label "Cancel" --ok-label "Select Plugin" \ 29 --cancel-label "Cancel" --ok-label "Select Plugin" \
23 --menu "Select a new plugin to run: " 15 60 6) 2> $TMP 30 --menu "Select a new plugin to run: " 15 60 6) 2> $TMP
24 OK=$? 31 OK=$?
@@ -31,7 +38,8 @@ if [ -z "$1" ]; then
31fi 38fi
32 39
33 40
34echo "$CHOICE" > $ADIR 41echo "$CHOICE" > $ADIR 2> /dev/null || \
42 echo "Error: Cannot write to $ADIR. Do you have root privileges?"
35 43
36ACTIVE=`cat $ADIR` 44ACTIVE=`cat $ADIR`
37 45