Subversion Repositories wimsdev

Rev

Rev 11606 | Rev 16233 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4249 guerimand 1
#! /bin/sh
2
#
7066 bpr 3
# script to look at each example class and copy sheet in public_html/bases/sheet/$class_lang/$class_sheetadress/$class_number/
4249 guerimand 4
# to be execute at before each realize of a wims package.
5
#
7066 bpr 6
# authors : F. Guerimand, bpr
4249 guerimand 7
# mail : fwguerima@free.fr
7066 bpr 8
# this script is launch by mkindex. Do not use it directly
10454 obado 9
#
4249 guerimand 10
 
6955 bpr 11
## level, lang, supervisor, email are those of the class
12
## if information is in the file .sheet$i, take it
13
## if not, take the information in the file .sheets
14
## if not, make something by default
15
 
4249 guerimand 16
whome="$1"
17
if [ -z "$whome" ]; then
18
 echo "don't use this script directly. execute mkindex";
19
 exit
20
fi;
21
target="$whome/public_html/bases/sheet";
11606 bpr 22
mkdir -p $target;
4249 guerimand 23
cd $whome/log/classes/;
24
clist=`ls -d [0-9]*`;
25
for cls in $clist; do
4255 bpr 26
 if [ $cls -lt 9000 ]; then
4249 guerimand 27
  level=`awk -F'=' '$1=="!set class_level" {print $2; exit}' ./$cls/.def`;
5080 guerimand 28
  slevel=`awk -F'=' '$1=="!set class_slevel" {print $2; exit}' ./$cls/.def`;
4249 guerimand 29
  lang=`awk -F'=' '$1=="!set class_lang" {print $2; exit}' ./$cls/.def`;
30
  sup=`awk -F'=' '$1=="!set class_supervisor" {print $2; exit}' ./$cls/.def`;
31
  email=`awk -F'=' '$1=="!set class_email" {print $2; exit}' ./$cls/.def`;
6955 bpr 32
  domain=`awk -F'=' '$1=="!set class_domain" {print $2; exit}' ./$cls/.def`;
7066 bpr 33
  sheetadress=`awk -F'=' '$1=="!set class_sheetadress" {print $2; exit}' ./$cls/.def`;
34
  if [ -n "$sheetadress" -a -n "$lang" ]; then
4249 guerimand 35
   cd $cls/sheets/;
4281 bpr 36
  # echo "--------------- $cls ; $level ; $lang"
4249 guerimand 37
   slist=`ls .sheet[0-9]*`;
7066 bpr 38
   tmptarget="$target/$lang/$sheetadress/$cls";
4249 guerimand 39
   mkdir -p $tmptarget;
40
   for sh in $slist; do
41
    num=${sh##.sheet};
42
    # test if statut of sheet is non 0
43
    statut=`awk -v no="$num" 'BEGIN{cpt=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){print($0);exit;}}' .sheets`;
44
    if [ "$statut" != ":0" ]; then
45
     entete=`awk '{a=substr($0,1,1); if(a==":")exit; else print($0);}' $sh`;
46
     namesh=${sh##.};
47
     if [ -n "$entete" ]; then
48
      #First case : information is in file .sheet$i : keep it (but not title and desc)
6955 bpr 49
      # echo "$sh : direct copy";
4249 guerimand 50
      title=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==3){print($0);exit;}} }' .sheets`;
51
      desc=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==4){print($0);exit;}} }' .sheets`;
52
      echo "$title
53
$desc" >$tmptarget/$namesh.def;
54
      awk 'FNR>2{print $0}' $sh >>$tmptarget/$namesh.def;
55
     else
56
      #second case : information not in file .sheet$i : make it with files .sheets and .def.
57
      dt=`perl -e 'for (@ARGV) {@S=stat($_); print scalar(localtime($S[9]))}' $sh`
58
      dt=${dt##* };
59
      title=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==3){print($0);exit;}} }' .sheets`;
60
      desc=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==4){print($0);exit;}} }' .sheets`;
61
      keyword=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==6){print($0);exit;}} }' .sheets`;
6955 bpr 62
      domain1=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==5){print($0);exit;}} }' .sheets`;
4471 bpr 63
      ## if keyword is empty, take the level (only for H)
11606 bpr 64
      if [ ! -n "$keyword" ]; then
65
       if [ -n "$slevel" ]; then
5080 guerimand 66
        keyword=`echo "$slevel"`;
67
       else
6955 bpr 68
        keyword=`echo "level$level"`;
5080 guerimand 69
       fi ;
70
      fi;
6963 bpr 71
     # echo "$sh : make presentation"; leave the empty line after email for description
72
     # of the sheet in the search engine
4249 guerimand 73
      echo "$title
74
$desc
75
??,$dt
76
2
77
$level
6955 bpr 78
$domain, $domain1
4249 guerimand 79
$keyword
80
$sup
6963 bpr 81
$email
82
 
83
" > $tmptarget/$namesh.def;
4249 guerimand 84
      cat $sh >> $tmptarget/$namesh.def;
85
     fi;
4281 bpr 86
   # else
87
   #  echo "$sh : EMPTY sheet";
4249 guerimand 88
    fi;
89
   done;
90
   cd ../..;
4281 bpr 91
 # else
92
 # echo "-----------------------NOTHING ---------- $cls ; $level ; $lang";
4249 guerimand 93
  fi;
94
 fi;
95
done;