Add grml-exec-wrapper
authorMichael Prokop <mika@grml.org>
Sat, 14 Feb 2009 18:24:41 +0000 (19:24 +0100)
committerMichael Prokop <mika@grml.org>
Sat, 14 Feb 2009 18:24:41 +0000 (19:24 +0100)
debian/changelog
usr_bin/grml-exec-wrapper [new file with mode: 0755]

index 7ab37ff..4a50ab1 100644 (file)
@@ -1,6 +1,7 @@
 grml-scripts (1.1.18) UNRELEASED; urgency=low
 
   * Add lzop to Depends. [Closes: issue613]
+  * Add new script grml-exec-wrapper.
 
  -- Michael Prokop <mika@grml.org>  Thu, 12 Feb 2009 21:04:59 +0100
 
diff --git a/usr_bin/grml-exec-wrapper b/usr_bin/grml-exec-wrapper
new file mode 100755 (executable)
index 0000000..a826be1
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+# Filename:      grml-exec-wrapper
+# Purpose:       simple but smart program execution wrapper
+# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
+# Bug-Reports:   see http://grml.org/bugs/
+# License:       This file is licensed under the GPL v2 or any later version.
+################################################################################
+
+# use Xdisplay only if present and running under X:
+display_info() {
+if type -a Xdialog 1>/dev/null 2>&1 && test -n "$DISPLAY" ; then
+    Xdialog --title "grml-exec-wrapper" --msgbox "$1" 0 0 0
+else
+    print "$1">&2
+fi
+}
+
+if [ -z "$1" ] ; then
+    display_info "Usage: $0 <program> [<arguments>]"
+    exit 1
+fi
+
+RC='0'
+PROG="$1"
+
+# make sure to support 'grml-exec-wrapper sudo wireshark' as well:
+case $PROG in
+       *sudo*) PROG="$2" ;;
+esac
+
+if type -a "$PROG" 1>/dev/null 2>&1 ; then
+    exec $@
+else
+    RC=1
+    display_info "Sorry: ${PROG} not available.
+
+Looks like the grml flavour you are using does not ship ${PROG}. :(
+
+You can search for ${PROG} executing:
+
+apt-get update && apt-cache search ${PROG}
+    "
+fi
+
+exit $RC
+
+## END OF FILE #################################################################