diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-09-01 16:39:27 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-09-01 16:39:27 -0400 |
commit | 460d19baddd2ac077d2c06f090ac1db09e1730e6 (patch) | |
tree | f5f4c9d350d32082f97a0fbef31f956dc301d89a | |
parent | d6b8d74b5a72da64fd9305004e628d582afe5235 (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-x | setsched | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | ADIR=/proc/litmus/active_plugin | 5 | ADIR=/proc/litmus/active_plugin |
6 | PDIR=/proc/litmus/plugins | 6 | PDIR=/proc/litmus/plugins |
7 | DIALOG=`which dialog` | ||
7 | 8 | ||
8 | CHOICE=$1 | 9 | CHOICE=$1 |
9 | 10 | ||
@@ -16,9 +17,15 @@ fi | |||
16 | ACTIVE=`cat $ADIR` | 17 | ACTIVE=`cat $ADIR` |
17 | 18 | ||
18 | if [ -z "$1" ]; then | 19 | if [ -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 | |||
31 | fi | 38 | fi |
32 | 39 | ||
33 | 40 | ||
34 | echo "$CHOICE" > $ADIR | 41 | echo "$CHOICE" > $ADIR 2> /dev/null || \ |
42 | echo "Error: Cannot write to $ADIR. Do you have root privileges?" | ||
35 | 43 | ||
36 | ACTIVE=`cat $ADIR` | 44 | ACTIVE=`cat $ADIR` |
37 | 45 | ||