Provide usage information without being root or executing script
authorMichael Prokop <devnull@localhost>
Sun, 17 Aug 2008 11:20:04 +0000 (13:20 +0200)
committerMichael Prokop <devnull@localhost>
Sun, 17 Aug 2008 11:20:04 +0000 (13:20 +0200)
debian/changelog
grml-live

index 0871c37..ecffab1 100644 (file)
@@ -25,8 +25,10 @@ grml-live (0.9) unstable; urgency=low
   * Improve look and feel of booting message (being
     /etc/grml/fai/live-initramfs/grml-script.init-top).
   * Display SQUASHFS_OPTIONS in configuration overview.
+  * Make sure it's possible to get usage information without being
+    root or actually executing the script.
 
- -- Michael Prokop <mika@grml.org>  Sun, 17 Aug 2008 13:03:14 +0200
+ -- Michael Prokop <mika@grml.org>  Sun, 17 Aug 2008 13:19:24 +0200
 
 grml-live (0.8) unstable; urgency=low
 
index e4b6aef..f432721 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -4,7 +4,7 @@
 # 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.
-# Latest change: Sun Aug 17 13:02:22 CEST 2008 [mika]
+# Latest change: Sun Aug 17 13:19:16 CEST 2008 [mika]
 ################################################################################
 
 # read configuration files, set some misc variables {{{
@@ -16,9 +16,47 @@ export LC_ALL=C
 set -e
 
 GRML_LIVE_VERSION='0.9'
+PN="$(basename $0)"
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
 
+# usage information {{{
+usage()
+{
+  echo "
+$PN - build process script for generating a (grml based) Linux Live-ISO
+
+Usage: $PN [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] \\
+                 [-i <iso_name> ] [-o <output_directory>] [-s <suite>] \\
+                 [-t <template_directory>] [-s <suite>] \\
+                 [-v <version_number>] [-bFVhu]
+
+Usage examples:
+
+    $PN
+    $PN -c GRMLBASE,GRML_SMALL,I386 -o /grml/
+    $PN -c GRMLBASE,GRML_MEDIUM,I386 -o /dev/shm/grml
+    $PN -c GRMLBASE,GRML_SMALL,I386 -g grml-small -v 1.0
+    $PN -c GRMLBASE,GRML_FULL,I386 -i grml_0.0-1.iso -v 0.0-1
+    $PN -c GRMLBASE,GRML_FULL,I386 -s sid -V -r 'grml-live rocks'
+
+More details: man grml-live
+              /usr/share/doc/grml-live/grml-live.html
+
+Please send your bug reports, feedback,.. to the grml-team.
+http://grml.org/bugs/
+"
+}
+
+# make sure it's possible to get usage information without being
+# root or actually executing the script
+if [ "$1" = '-h' -o "$1" = '--help' ] ; then
+   usage
+   [ "$(id -u 2>/dev/null)" != 0 ] && echo "Please notice that this script requires root permissions."
+   exit 0
+fi
+# }}}
+
 # we need root permissions for the build-process:
 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
    echo "Error: please run this script with uid 0 (root)." >&2
@@ -58,7 +96,6 @@ fi
 LIVE_CONF=/etc/grml/grml-live.conf
 . $LIVE_CONF
 
-PN=$(basename $0)
 # }}}
 
 # clean exit {{{
@@ -148,35 +185,6 @@ extend_string_end() {
 }
 # }}}
 
-# usage information {{{
-usage()
-{
-  echo "
-$PN - build process script for generating a (grml based) Linux Live-ISO
-
-Usage: $PN [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] \\
-                 [-i <iso_name> ] [-o <output_directory>] [-s <suite>] \\
-                 [-t <template_directory>] [-s <suite>] \\
-                 [-v <version_number>] [-bFVhu]
-
-Usage examples:
-
-    $PN
-    $PN -c GRMLBASE,GRML_SMALL,I386 -o /grml/
-    $PN -c GRMLBASE,GRML_MEDIUM,I386 -o /dev/shm/grml
-    $PN -c GRMLBASE,GRML_SMALL,I386 -g grml-small -v 1.0
-    $PN -c GRMLBASE,GRML_FULL,I386 -i grml_0.0-1.iso -v 0.0-1
-    $PN -c GRMLBASE,GRML_FULL,I386 -s sid -V -r 'grml-live rocks'
-
-More details: man grml-live
-              /usr/share/doc/grml-live/grml-live.html
-
-Please send your bug reports, feedback,.. to the grml-team.
-http://grml.org/bugs/
-"
-}
-# }}}
-
 # read local (non-packaged) configuration {{{
 LOCAL_CONFIG=/etc/grml/grml-live.local
 if [ -r "$LOCAL_CONFIG" ] ; then