- syntactical sugar
[peacs] / start.sh
1 #!/bin/bash
2 #
3 # peaCS - Performance and Efficiency Analysis for Cloud Storage
4
5 mkdir -p output/temp
6 mkdir -p output/logs
7
8 #initialize all variables
9 syslog=output/logs/syslog
10 if [ $(sed -ne "$(grep -n nubisavelog conf | cut -d : -f 1) p" conf | sed 's/nubisavelog = //g') == on ]
11 then
12 nubisavelog=output/logs/nubisavelog
13 else
14 nubisavelog=/dev/null
15 fi
16
17 qtystart=$(sed -ne "$(($(grep -n '\[redundancytest\]' conf | cut -d : -f 1)+5)) p" conf | sed 's/startbystorage = //g')
18 storagetype=$(sed -ne "$(($(grep -n '\[redundancytest\]' conf | cut -d : -f 1)+10)) p" conf | sed 's/storagetype = //g')
19 sed "s/startbystorage = .*/startbystorage = $qtystart/g" conf > output/temp/scriptconftmp
20 cp output/temp/scriptconftmp conf
21
22 test_samplefiles_state=$(sed -ne "$(($(grep -n '\[samplefiles\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
23 test_sampledirectories_state=$(sed -ne "$(($(grep -n '\[sampledirectories\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
24 test_samplewebdavs_state=$(sed -ne "$(($(grep -n '\[samplewebdavs\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
25 test_redundancytest_state=$(sed -ne "$(($(grep -n '\[redundancytest\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
26 test_directorytest_state=$(sed -ne "$(($(grep -n '\[directorytest\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
27 test_availabilitytest_state=$(sed -ne "$(($(grep -n '\[availabilitytest\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
28 test_iozone_state=$(sed -ne "$(($(grep -n '\[iozonetest\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
29 plot_state=$(sed -ne "$(($(grep -n '\[plot\]' conf | cut -d : -f 1)+1)) p" conf | sed 's/state = //g')
30 qtymax=$(($(sed -ne "$(($(grep -n '\[redundancytest\]' conf | cut -d : -f 1)+4)) p" conf | sed 's/quantityofstorages = //g')+2))
31 ismounted=$(($(sed -ne "$(($(grep -n '\[redundancytest\]' conf | cut -d : -f 1)+5)) p" conf | sed 's/startbystorage = //g')+1))
32 mountiteration=1
33
34 #init git
35 if [ ! -d ".git" ]
36  then
37     echo "create git repository"
38     git init
39 fi
40
41 #writes system information in a logfile
42 echo "saving sys info"
43 echo "##################################################################################################" >> $syslog
44 cat /proc/cpuinfo >> $syslog
45 free >> $syslog
46 echo "User:$(whoami)" >> $syslog
47 date >> $syslog
48 echo $(lsb_release -a) >> $syslog
49 echo $(getconf LONG_BIT) "Bit" >> $syslog
50 uname -a >> $syslog
51 java -version >> $syslog 2>&1
52 echo "##################################################################################################" >> $syslog
53
54 clear
55
56 #checks the state of the test in configfile
57 if  [ $test_samplefiles_state == on ]
58 then
59 sh scripts/createsamplefiles.sh
60 else
61 echo
62 fi
63
64 if  [ $test_sampledirectories_state == on ]
65 then
66 sh scripts/generate_directory_storages.sh
67 else
68 echo
69 fi
70
71 if  [ $test_samplewebdavs_state == on ]
72 then
73 sh scripts/generate_webdav_storages.sh
74 else
75 echo
76 fi
77
78 #redundancytest begin
79 if  [ $test_redundancytest_state == on ]
80 then
81 while [ "$ismounted" -lt "$qtymax" ]
82 do
83 sh scripts/nubiclean.sh > $nubisavelog
84 sleep 5
85 mkdir -p "$HOME/.nubisave/db/splitter_configuration"
86 while [ "$mountiteration" -lt "$ismounted" ]
87 do
88 echo $mountiteration
89 echo $ismounted
90 cp "output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration" $HOME/.nubisave/db/splitter_configuration
91
92 if [ $storagetype == directory ]
93 then
94
95 #mount directories with the require parameters for mount_directory.sh
96 sh /usr/share/nubisave/splitter/mountscripts/mount_$storagetype.sh "$HOME/.nubisave/storages/$storagetype$mountiteration" "$HOME/storages/mydir$mountiteration"
97 else
98 #mount webdavs with the require parameters for mount_fusedav.sh
99 sh /usr/share/nubisave/splitter/mountscripts/mount_$storagetype.sh $(sed -ne "$(grep -n 'user =' output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration | cut -d : -f 1) p" output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration | sed 's/user = //g') $(sed -ne "$(grep -n 'password =' output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration | cut -d : -f 1) p" output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration | sed 's/password = //g') $(sed -ne "$(grep -n 'davurl =' output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration | cut -d : -f 1) p" output/sampledata/samplestorages/sample$storagetype/$storagetype$mountiteration | sed 's/davurl = //g') "$HOME/.nubisave/storages/$storagetype$mountiteration"
100 fi
101 echo $storagetype$mountiteration
102 cp -rf "$HOME/.nubisave/db/splitter_configuration/$storagetype$mountiteration" "$HOME/.nubisave/nubisavemount/config/"
103 cat "$HOME/.nubisave/db/splitter_configuration/$storagetype$mountiteration" > "$HOME/.nubisave/storages/$storagetype$mountiteration/config/config"
104 mountiteration=$(($mountiteration+1))
105 sleep 2
106 done
107 bash scripts/redundancy_test.sh
108
109 sed "s/startbystorage = .*/startbystorage = $mountiteration/g" conf > output/temp/scriptconftmp
110 cp output/temp/scriptconftmp conf
111 mountiteration=1
112 ismounted=$(($(sed -ne "$(($(grep -n '\[redundancytest\]' conf | cut -d : -f 1)+5)) p" conf | sed 's/startbystorage = //g')+1))
113 done
114
115 else
116 echo
117 fi
118 #redundancytest end
119
120 if  [ $test_availabilitytest_state == on ]
121 then
122 sh scripts/nubiclean.sh > $nubisavelog
123 sleep 5
124 sh scripts/availability_test.sh
125 else
126 echo
127 fi
128
129 if  [ $test_iozone_state == on ]
130 then
131 sh scripts/iozone_test.sh
132 sleep 5
133 #sh scripts/nubiclean.sh > $nubisavelog
134 else
135 echo
136 fi
137
138 if  [ $test_directorytest_state == on ]
139 then
140 sh scripts/nubiclean.sh > $nubisavelog
141 sleep 5
142 sh scripts/directory_test.sh
143 else
144 echo
145 fi
146
147 if  [ $plot_state == on ]
148 then
149 bash scripts/plot.sh
150 else
151 echo
152 fi
153
154 git add output/logs/*
155 git add output/results/*
156 git commit -m "Test $(date)"