0
|
1 ###
|
|
2 ### The shell script: import_local.sh
|
|
3 ###
|
|
4 ### The script copies the source file (param 1)
|
|
5 ### to the destination file (param 2, which is galaxy's dataset_NNNNN.dat).
|
|
6 ###
|
|
7 ### The extra code tries to make it as safe as possible, allowing imports only
|
|
8 ### from limited areas.
|
|
9 ###
|
|
10 ### The script can be changed from copying to linking - would be even faster.
|
|
11 ###
|
|
12 ### cpx is a C executable that copies a file from a source to a destination
|
|
13 ### only if the source file is readable by the user given in the third arg.
|
|
14 ### cpx must be setuid root, so be careful who has access to it! It can also
|
|
15 ### be allowed using sudo, if you know how to do it.
|
|
16 #!/bin/sh
|
|
17
|
|
18 INPUT="$1"
|
|
19 OUTPUT="$2"
|
|
20 EMAIL="$3"
|
|
21 USER=`echo $EMAIL | sed -e 's#@.*##'`
|
|
22
|
|
23 if [ -z "$OUTPUT" ]; then
|
|
24 echo "Usage: $0 [INPUT] [OUTPUT]" >&2
|
|
25 exit 1
|
|
26 fi
|
|
27
|
|
28 # Filter any unwanted directories
|
|
29
|
|
30 if [[ `echo $INPUT | grep -c ^/data/` -lt 1 ]] && [[ `echo $INPUT | grep -c ^/home/` -lt 1 ]] ; then
|
|
31 echo "Error: \"$INPUT\" is not allowed" >&2
|
|
32 exit 1
|
|
33 fi
|
|
34
|
|
35 # Do the deed
|
|
36 cpx $INPUT $OUTPUT "$USER"
|
|
37 if [ $? != 0 ]; then
|
|
38 echo "Error: $USER failed to copy \"$INPUT\"" >&2
|
|
39 exit 1
|
|
40 fi
|
|
41
|
|
42 echo "File \"$INPUT\" imported"
|
|
43
|
|
44 exit 0
|
|
45
|
|
46 ###
|
|
47 ###
|
|
48 ###
|
|
49
|