#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/doc - ask user for doc view # # Copyright (c) 2003-2004 Frank Meyer # # Creation: 2003-08-28 fm # Last Update: $Id$ # # /var/install/bin/doc # ==================== # # Zeigt den Inhalt einer Datei, vorzugsweise die Dokumentation eines # Paketes an. # # Es gelten folgende Regeln für den Aufruf: # # doc Angezeigt wird die Datei # /usr/share/doc/$PACKAGE/$PACKAGE.txt # $PACKAGE ist im Menüsystem über den # -Tag definiert. # # doc file Ist file ein Dateiname ohne Pfadangabe # (z.B. dokument.txt), und ist $PACKAGE # definiert, so wird die Datei # /usr/share/doc/$PACKAGE/file # angezeigt. # # doc file Ist file ein absoluter Dateiname z.B. # /usr/local/squidGuard/log/squidGuard.log # so wird genau diese Datei angezeigt. # # doc file message # # file Dateiname der Dokumentationsdatei # message Kopfzeile im Menü # # Beispiele: # # /var/install/bin/doc /usr/share/doc/foo/foo.txt "View foo documentation" # # PACKAGE=squid # export PACKAGE # /var/install/bin/doc # # Als Programm für die Anzeige wird das Programm aus der # Environmentvariablen PAGER genutzt. Ist PAGER nicht # gesetzt, so wird das Programm less genutzt. # # PAGER wird normalerweise über den Eintrag PAGER= in # der Datei /etc/config.d/environment besetzt. # # Rückgabewert # 0 pager wurde gestartet # 1 pager wurde nicht gestartet # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib docfile=$1 if [ "$docfile" = "" ] then docfile="/usr/share/doc/$PACKAGE/$PACKAGE.txt" elif [ "`dirname "$docfile"`" = "." -a "$PACKAGE" != "" ] then docfile="/usr/share/doc/$PACKAGE/$docfile" fi if [ $# -eq 2 ] then title="$2" clrhome mecho -info "$title" mecho fi pager=$PAGER if [ "$pager" = "" ] then pager=less fi mecho mecho mecho "The document will be shown using '$PAGER'" case $pager in *less) mecho "You can get help by typing the key 'h', 'q' to quit.";; *more*) mecho "You can get help by typing the key 'h', 'q' to quit.";; *vi|*view ) mecho "You can get help by typing :h, :q to quit.";; *) true;; esac mecho rtc=1 if /var/install/bin/ask "Continue" "yes" then if [ -f $docfile -a -s $docfile ] then export LESSCHARSET=latin1 $pager $docfile if [ $? -ne 0 ] then mecho -error "Pager $PAGER is invalid!" mecho -error "Check environment variable PAGER." anykey else rtc=0 fi else if [ ! -f $docfile ] then mecho -warn "Could not find document $docfile!" else if [ ! -s $docfile ] then mecho -warn "Document $docfile is empty" fi fi anykey fi fi exit $rtc