]> git.uio.no Git - u/mrichter/AliRoot.git/blob - share/alifs
Bug fix (C.Cheshkov)
[u/mrichter/AliRoot.git] / share / alifs
1 #!/bin/sh
2 #############################################################################
3 # alifs - a front-end shell for CASTOR and SHIFT
4 #############################################################################
5 #
6 # modification history
7 # $Log$
8 # Revision 1.1  2001/02/23 17:33:40  buncic
9 # Added alifs wrapper for CASTOR and alirun modified accordingly.
10 #
11 #
12 # SYNOPSIS
13 # alifs [flags] <command [options]>
14 #
15 # File System implementation:
16 #              ls [-cdilRu] path
17 #              mv oldname newname...                   
18 #              rm [-f] [-i] [-r] dirname...            
19 #              mkdir [-m absolute_mode] [-p] dirname...
20 #              cp f1 f2                   
21 #              cp f1 <dir2>                            
22 #
23 # CASTOR implementation:
24 #              ls [-cdilRTu] [--class] [--comment] path
25 #              mv oldname newname...                   
26 #              rm [-f] [-i] [-r] dirname...            
27 #              mkdir [-m absolute_mode] [-p] dirname...
28 #              cp [-s maxsize] f1 f2                   
29 #              cp f1 <dir2>                            
30 #
31 # DESCRIPTION
32 # This is an interface script to underlying mass storage manager. At present it supports CASTOR on RH6.1 and offers some basic Unix like commands:
33 #
34 # o) list directory
35 #       alifs ls [-cdilRTu] [--class] [--comment] path 
36 #
37 # o) move (rename) file or directory
38 #       alifs mv oldname newname...
39 #
40 # o) remove file or directory
41 #       alifs rm [-f] [-i] [-r] dirname... 
42 #
43 # o) create directory
44 #       alifs mkdir [-m absolute_mode] [-p] dirname...
45
46 # o) copy files
47 #       alifs cp [-s maxsize] f1 f2
48 #       alifs cp f1 <dir2>
49
50 #  CASTOR file system is accessible via RFIO (root must be configured configured with --enable-rfio switch and linked with appropriate libshift.a library). It provides experiment topl level directory (/castor/cern.ch/alice) and user directories following the AFS naming scheeme (like /castor/cern.ch/user/b/buncic).
51 #For more info on CASTOR commands, see related man pages (nsls, nsrename, nsrm, nsmkdir,rfcp,rfstat).
52 #   
53 #
54 # AUTHOR:
55 # Predrag Buncic, e-mail: Predrag.Buncic@cern.ch 
56 #
57 # CREATION DATE:
58 # 15-Feb-2001
59 #C<
60 ###########################################################################
61 ALIFSDIR=`dirname $0`; export ALIFSDIR
62 ###########################################################################
63 Configure()
64 {
65   case "$ALICE_MSS" in
66      CASTOR)
67         if [ -f $ALIFSDIR/castor.sh ]
68         then
69           . $ALIFSDIR/castor.sh
70         else
71           printf "Cannot find %s file. Terminating..." $ALIFSDIR/castor.sh
72           exit 1
73         fi
74         ;;
75      HPSS|RFIO)
76         if [ -f $ALIFSDIR/rfio.sh ]
77         then
78           . $ALIFSDIR/rfio.sh
79         else
80           printf "Cannot find %s file. Terminating...\n" $ALIFSDIR/rfio.sh
81           exit 1
82         fi
83         ;;
84       *) 
85         ;;
86   esac 
87
88   if [ "$EXEC_SHELL" = "" ]
89   then
90     EXEC_SHELL=bin/sh
91     for shell in bash zsh ksh
92     do
93       for dir in /bin /usr/bin /usr/local/bin
94       do
95         if [ -x $dir/$shell ]
96         then
97           EXEC_SHELL=$dir/$shell
98           break 2
99         fi
100       done
101     done
102     export EXEC_SHELL 
103     exec $EXEC_SHELL -norc  -noprofile $0 $*
104   fi
105 }
106 ###########################################################################
107 ALIFS_Usage()
108 {
109    printf "\nFile System Implementation:\n\n"
110    printf "Usage: alifs [-help][-p <pool>] <command [options]>   \n"
111    printf "              [-cdilRu] path                          \n" 
112    printf "              mv oldname newname...                   \n"
113    printf "              rm [-f] [-i] [-r] dirname...            \n"
114    printf "              mkdir [-m absolute_mode] [-p] dirname...\n"
115    printf "              cp f1 f2                                \n" 
116    printf "              cp f1 <dir2>                            \n"
117    exit
118 }
119 ###########################################################################
120 ALIFS_Makeman()
121 ###########################################################################
122 {
123    mandir=../man/man4 
124    ./mangen -n tool $0
125    if [ $? -eq 0 ]
126    then
127      [ ! -d $mandir ]  && mkdir -p $mandir
128      mv `basename $0`.? $mandir
129      exit
130    fi
131 }
132 ###########################################################################
133 ALIFS_ls()
134 {
135    ls $*
136 }
137 ###########################################################################
138 ALIFS_mkdir()
139 {
140    mkdir $*
141 }
142 ###########################################################################
143 ALIFS_mv()
144 {
145    mv $*
146 }
147 ###########################################################################
148 ALIFS_rm()
149 {
150    rm $*
151 }
152 ###########################################################################
153 ALIFS_cp()
154 {
155    cp $*
156 }
157 ###########################################################################
158 Configure $*
159 ###########################################################################
160 ALIFS()
161 {
162   cmd=$1; shift 1
163
164   case `type -t ALIFS_$cmd` in
165      function)
166               ALIFS_$cmd $*
167               ;;
168             *) 
169               ALIFS_Usage;
170               ;;
171   esac 
172
173   exit
174 }
175 ###########################################################################
176
177 ###########################################################################
178
179 for param in $*
180 do
181     case $param in
182         -trace)
183             shift 1
184             set -vx
185             ;;
186         -echo)
187             shift 1
188             ECHO="echo "
189             ;;
190         -makeman)
191             shift 1
192             ALIFS_Makeman
193             ;;
194         -help)
195             ALIFS_Usage
196             ;;
197         -p)
198             shift 1
199             POOL=$1; shift 1
200             ;;
201         *)
202             ALIFS $*
203             ;;
204     esac
205 done
206
207 ###########################################################################
208 ALIFS_Usage
209 ###########################################################################
210
211
212