Imported Upstream version 0.4.8
[platform/upstream/libsmi.git] / tools / smicache.in
1 #!@SH@
2 #
3 # smicache --
4 #
5 #       A simple caching method, used by the config file `cache' directive.
6 #
7 # Copyright (c) 2001 Frank Strauss, Technical University of Braunschweig.
8 #
9 # See the file "COPYING" for information on usage and redistribution
10 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 #
12 # $Id: smicache.in 8090 2008-04-18 12:56:29Z strauss $
13 #
14 # NOTE, that this script relies on wget and getopts
15 # (shell builtin like in bash or standalone).
16 #
17 # NOTE, that smicache has just been an experiment. It is NOT suggested
18 # to use it in a production environment.
19
20 WGET=@WGET@
21 GETOPTS=getopts
22 VERSION=@VERSION@
23
24 prefix=http://www.ibr.cs.tu-bs.de/projects/libsmi/smicache/
25 dir=/tmp
26
27
28
29 do_version () {
30     echo "smicache $VERSION"
31 }
32
33
34
35 do_usage () {
36     echo "Usage: smicache [-Vh] [-d dir] [-p prefix] mib"
37     echo "-V         show version and license information"
38     echo "-h         show usage information"
39     echo "-d dir     use dir as the caching directory"
40     echo "-p prefix  use prefix as the URL prefix for fetching modules"
41     echo "mib        name of the module to be fetched"
42 }
43
44
45
46 do_fetch () {
47     $WGET -q -O "$dir/$1" "$prefix/$1"
48 }
49
50
51
52 while $GETOPTS Vhd:p: c ; do
53     case $c in
54         d)      dir="$OPTARG"
55                 ;;
56         p)      prefix="$OPTARG"
57                 ;;
58         h)      do_usage
59                 exit 0
60                 ;;
61         V)      do_version
62                 exit 0
63                 ;;
64         *)      do_usage
65                 exit 1
66                 ;;
67     esac
68 done
69
70 shift `expr $OPTIND - 1`
71
72
73
74 if [ $# -eq 1 ] ; then
75     do_fetch $1
76 else 
77     do_usage
78 fi
79
80 exit 0