소스 검색

Enhancements of crea_datas scripts

prieto 7 년 전
부모
커밋
a09585d63c
2개의 변경된 파일15개의 추가작업 그리고 65개의 파일을 삭제
  1. 0
    63
      progs/create_datas
  2. 15
    2
      progs/create_datas.sh

+ 0
- 63
progs/create_datas 파일 보기

@@ -1,63 +0,0 @@
1
-#!/bin/bash
2
-
3
-host=$1
4
-instance=$2
5
-N=$3
6
-HOSTDB=localhost
7
-
8
-M=$(expr $N / 10)
9
-for i in `eval echo {1..$M}`;
10
-do
11
-    COLPUBLI=""
12
-    COLT=$(lenmax=100;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/") 
13
-    curl -A "Mozilla/5.0" -L -s -d "field_input_title=$COLT&field_input_publications=$COLPUBLI&classname=Collection" http://$host/$instance/admin/create?classname=Collection
14
-    LN=$(lenmax=20;wcount=1; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
15
-    FN=$(lenmax=20;wcount=1; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
16
-    curl -A "Mozilla/5.0" -L -s -d "field_input_lastname=$LN&field_input_firstname=$FN&classname=Person" http://$host/$instance/admin/create?classname=Person
17
-    PWD='pwgen 10'
18
-    LOGIN="${FN,,}$(printf "%d" $RANDOM)"
19
-    curl -A "Mozilla/5.0" -L -s -d "field_input_lastname=$LN&field_input_firstname=$FN&field_input_password=$PWD&field_input_login=$LOGIN&classname=User" http://$host/$instance/admin/create?classname=User
20
-done
21
-
22
-M=$(expr $N / 4)
23
-for i in `eval echo {1..$M}`;
24
-do
25
-    persons=$(printf "use lodel2_$instance\n db.Person.find({}, {lodel_id:1, _id:0}).limit(3)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
26
-    tmp=""
27
-    for i in $persons
28
-    do
29
-        if [[ ! -z $tmp ]]
30
-        then
31
-            tmp=$(printf "$tmp, $i")
32
-        else
33
-            tmp=$i
34
-        fi
35
-    done
36
-    SECLP=$tmp
37
-    SECST=$(lenmax=60;wcount=10; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
38
-    SECTTL=$(lenmax=60;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
39
-    curl -A "Mozilla/5.0" -L -s -d "field_input_linked_persons=$SECLP&field_input_subtitle=$SECSTD&field_input_title=$SECTTL&classname=Section" http://$host/$instance/admin/create?classname=Section
40
-done
41
-
42
-for i in `eval echo {1..$N}`;
43
-do
44
-    persons=$(printf "use lodel2_$instance\n db.Person.find({}, {lodel_id:1, _id:0}).limit(3)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
45
-    for i in $persons
46
-    do
47
-        if [[ ! -z $tmp ]]
48
-        then
49
-            tmp=$(printf "$tmp, $i")
50
-        else
51
-            tmp=$i
52
-        fi
53
-    done
54
-    SSSECLP=$tmp
55
-    SSSECST=$(lenmax=60;wcount=10; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
56
-    res=$(printf "use lodel2_$instance\n db.Section.find({}, {lodel_id:1, _id:0}).limit(1)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
57
-    SSSECPAR=$res
58
-    SSSECTTL=$(lenmax=60;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
59
-    res=$(printf "use lodel2_$instance\n db.Collection.find({}, {lodel_id:1, _id:0}).limit(1)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
60
-    PUBCOLLS=$res
61
-    curl -A "Mozilla/5.0" -L -s -d "field_input_linked_persons=$SSSECLP&field_input_subtitle=$SSSECST&field_input_parent=$SSSECPAR&field_input_title=$SSSECTTL&classname=Subsection" http://$host/$instance/admin/create?classname=Subsection
62
-    curl -A "Mozilla/5.0" -L -s -d "field_input_collection=$PUBCOLLS&classname=Publication" http://$host/$instance/admin/create?classname=Publication
63
-done

+ 15
- 2
progs/create_datas.sh 파일 보기

@@ -1,9 +1,22 @@
1 1
 #!/bin/bash
2 2
 
3
+usage() {
4
+	echo -e "Usage : $0 host_of_server instance_name host_of_db number_of_iterations >&2
5
+	echo -e "Example : create_datas locahost instance_00001 localhost:28015 1000"
6
+	echo -e "Example : create_datas locahost instance_00001 localhost 1000"
7
+	exit 1
8
+}
9
+
10
+if [ $# -lt 3 ]
11
+then
12
+	echo "Not enough arguments" >&2
13
+	usage
14
+fi
15
+
3 16
 host=$1
4 17
 instance=$2
5
-N=$3
6
-HOSTDB=localhost
18
+N=$4
19
+HOSTDB=$3
7 20
 
8 21
 M=$(expr $N / 10)
9 22
 for i in `eval echo {1..$M}`;

Loading…
취소
저장