4371 |
26 Oct 12 |
olle |
#!/bin/bash |
4093 |
12 Jan 11 |
gregory |
2 |
# |
4093 |
12 Jan 11 |
gregory |
# This script creates a project and registers files for one given user |
4093 |
12 Jan 11 |
gregory |
4 |
# |
4093 |
12 Jan 11 |
gregory |
# The user has to be created manually prior to executing this script |
4093 |
12 Jan 11 |
gregory |
6 |
server="localhost:8080" |
4093 |
12 Jan 11 |
gregory |
7 |
usr="root" |
4093 |
12 Jan 11 |
gregory |
8 |
pwd="root" |
4093 |
12 Jan 11 |
gregory |
9 |
imp=$1 |
4093 |
12 Jan 11 |
gregory |
10 |
pfile="/tmp/project.tsv" |
4093 |
12 Jan 11 |
gregory |
11 |
ffile="./files.tsv" |
4093 |
12 Jan 11 |
gregory |
12 |
pname="${imp}s Course Project 2010-10-18_a" |
4093 |
12 Jan 11 |
gregory |
13 |
authstr="username=$usr&password=$pwd&impersonate=$imp" |
4093 |
12 Jan 11 |
gregory |
14 |
|
4093 |
12 Jan 11 |
gregory |
15 |
|
4093 |
12 Jan 11 |
gregory |
# Impersonate user $imp |
4093 |
12 Jan 11 |
gregory |
17 |
if [ "$imp" != "" ]; then |
4093 |
12 Jan 11 |
gregory |
18 |
|
4093 |
12 Jan 11 |
gregory |
# Clean up files from previous run |
4093 |
12 Jan 11 |
gregory |
20 |
if [ -e $pfile ]; then |
4093 |
12 Jan 11 |
gregory |
21 |
rm $pfile |
4093 |
12 Jan 11 |
gregory |
22 |
fi |
4093 |
12 Jan 11 |
gregory |
23 |
touch $pfile |
4093 |
12 Jan 11 |
gregory |
24 |
|
4093 |
12 Jan 11 |
gregory |
25 |
if [ -e .err ]; then |
4093 |
12 Jan 11 |
gregory |
26 |
rm .err |
4093 |
12 Jan 11 |
gregory |
27 |
fi |
4093 |
12 Jan 11 |
gregory |
28 |
|
4093 |
12 Jan 11 |
gregory |
# Create project |
4093 |
12 Jan 11 |
gregory |
30 |
echo -e "Name\tProjectType" >> $pfile |
4093 |
12 Jan 11 |
gregory |
31 |
echo -e "$pname\t2" >> $pfile |
4093 |
12 Jan 11 |
gregory |
32 |
|
4093 |
12 Jan 11 |
gregory |
# Create project in proteios |
4093 |
12 Jan 11 |
gregory |
34 |
curl -T $pfile "http://proteios.immunoprot.lth.se:8080/proteios/resource/projects?$authstr" 1>.err |
4093 |
12 Jan 11 |
gregory |
35 |
|
4093 |
12 Jan 11 |
gregory |
36 |
if [ ! -z .err ]; then |
4093 |
12 Jan 11 |
gregory |
37 |
echo "Failed to create project $pname, see .err"; |
4093 |
12 Jan 11 |
gregory |
38 |
exit 1; |
4093 |
12 Jan 11 |
gregory |
39 |
fi |
4093 |
12 Jan 11 |
gregory |
40 |
|
4093 |
12 Jan 11 |
gregory |
# Get project id |
4093 |
12 Jan 11 |
gregory |
42 |
if [ -e .tmp ]; then |
4093 |
12 Jan 11 |
gregory |
43 |
rm .tmp |
4093 |
12 Jan 11 |
gregory |
44 |
fi |
4093 |
12 Jan 11 |
gregory |
45 |
curl -s -o .tmp "http://proteios.immunoprot.lth.se:8080/proteios/resource/projects?$authstr&select=Id,Name" 1>>.err |
4093 |
12 Jan 11 |
gregory |
46 |
|
4093 |
12 Jan 11 |
gregory |
47 |
if [ -e .tmp ]; then |
4093 |
12 Jan 11 |
gregory |
48 |
pid=`tail -n1 .tmp|awk '{print $1}'` |
4093 |
12 Jan 11 |
gregory |
49 |
echo $pid |
4093 |
12 Jan 11 |
gregory |
50 |
fi |
4093 |
12 Jan 11 |
gregory |
51 |
|
4093 |
12 Jan 11 |
gregory |
# Register files |
4093 |
12 Jan 11 |
gregory |
53 |
curl -T ./files.tsv "http://localhost:8080/proteios/resource/projects/$pid/files/?$authstr" |
4093 |
12 Jan 11 |
gregory |
54 |
|
4093 |
12 Jan 11 |
gregory |
55 |
fi |