Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
3 reyssat 1
#! /bin/sh
2
 
3
# Home directory of wims.
4
cd `dirname $0`/..
5
WIMS_HOME=`pwd`
6
 
7
today=`date '+%Y%m%d'`
8
weekday=`date '+%w'`
9
thisyear=`date '+%Y'`
10
 
15331 obado 11
site_hostname=`awk -F'=' '$1=="site_hostname" {print $2; exit}' $WIMS_HOME/log/wims.conf`
12
if [ -z $site_hostname ]; then
13
  site_hostname=`hostname`
14
fi
15
 
3 reyssat 16
# Forum management
17
cd log/forums
18
./.build-index
19
cd $WIMS_HOME
20
 
21
if [ "$site_accounting" = "yes" ]; then bin/account.sh; fi
22
sleep 10
23
cd $WIMS_HOME
24
 
25
# TeX pictures and fonts since 90 days: atime can no longer be used.
10902 bpr 26
find public_html/w/instex -name '*.gif' -mtime +90 -exec rm '{}' ';' 2>/dev/null
3 reyssat 27
find public_html/w/instex -type d -empty -exec rm '{}' 2>/dev/null \;
10902 bpr 28
find public_html/w/texgif -name '*.font' -mtime +90 -exec rm '{}' ';' 2>/dev/null
3 reyssat 29
# Clean tmp directory
10902 bpr 30
find tmp -maxdepth 1 -type f -mtime +2 -exec rm '{}' ';' 2>/dev/null
31
find tmp/forall -mindepth 1 -mtime +2 -exec rm '{}' ';' 2>/dev/null
3 reyssat 32
mkdir -p tmp/forall
33
chmod a+rwx tmp/forall
11347 guerimand 34
# clean tmp/whoconnect
35
rm -rf tmp/whoconnect 2>/dev/null
36
mkdir -p tmp/whoconnect
3 reyssat 37
 
6930 bpr 38
# Any classes which will expire in one month ?
39
cd $WIMS_HOME/log/classes
40
for cls in [0-9]*
41
do
42
exp=`awk -F'=' '$1=="!set class_expiration" {print $2; exit}' $cls/.def`
43
 
7644 bpr 44
# exp is the expiration date minus one month (-100 if the month is different
6930 bpr 45
# from january , -8900 else)
46
exp1=`expr "$exp" : "....\(.*\).."`;
10297 bpr 47
if [ "$exp1" -eq "01" ]; then exp=`expr $exp - 8900`; else exp=`expr $exp - 100`; fi
6930 bpr 48
if [ "$exp" -eq "$today" ]; then
49
email=`awk -F'=' '$1=="!set class_email" {print $2; exit}' $cls/.def`
50
inst=`awk -F'=' '$1=="!set class_institution" {print $2; exit}' $cls/.def`
51
desc=`awk -F'=' '$1=="!set class_description" {print $2; exit}' $cls/.def`
15331 obado 52
 
6930 bpr 53
mail $w_mail_opt -s "WIMS virtual class will expire in 30 days" "$email" <<@
54
 
55
You have created a virtual class
56
 
57
$inst, $desc
58
 
15331 obado 59
(code $cls) on the site $site_hostname. This class will be closed in
8052 bpr 60
one month because it will reach its expiration date.
61
You should download a archive file of your class and
62
upload its content or part of it into another class.
6930 bpr 63
 
64
To get an archive file of the contents of this class, follow this link :
65
 
66
--- WIMS (WWW Interactive Multipurpose Server)
15331 obado 67
http://$site_hostname/wims/wims.cgi?module=adm/class/classes&+type=authsupervisor&+class=$cls
6930 bpr 68
 
69
@
70
echo "$today housekeep class-advertising $cls: $email" >>$WIMS_HOME/log/mail.log
71
fi
72
 
73
done
74
 
3 reyssat 75
# Any expired classes?
6930 bpr 76
cd $WIMS_HOME/log/classes
3 reyssat 77
for cls in [0-9]*
78
do
79
 exp=`awk -F'=' '$1=="!set class_expiration" {print $2; exit}' $cls/.def`
80
 if [ -z "$exp" ] || [ "$exp" -lt "$today" ]; then
81
  email=`awk -F'=' '$1=="!set class_email" {print $2; exit}' $cls/.def`
82
  inst=`awk -F'=' '$1=="!set class_institution" {print $2; exit}' $cls/.def`
83
  desc=`awk -F'=' '$1=="!set class_description" {print $2; exit}' $cls/.def`
901 bpr 84
  mail $w_mail_opt -s "WIMS virtual class expired" "$email" <<@
3 reyssat 85
 
86
You have created a virtual class
87
 
88
	$inst, $desc
89
 
15331 obado 90
(code $cls) on the site $site_hostname. This class is now closed,
3 reyssat 91
because it has reached its expiration date.
92
 
7644 bpr 93
The complete registry of this class (user list and activity history)
3 reyssat 94
is stored in an archive file, which can be sent to you upon request
95
to the webmaster of this site.
96
 
97
--- WIMS (WWW Interactive Multipurpose Server)
15331 obado 98
    http://$site_hostname/
3 reyssat 99
 
100
@
101
  echo "$today housekeep class-expire $cls: $email" >>$WIMS_HOME/log/mail.log
102
  rm -R $cls/.parmreg >/dev/null 2>&1
103
  if [ -d $WIMS_HOME/log/ccaccount/$cls ]; then
104
   tar -cf $cls/account.tar -C $WIMS_HOME/log ccaccount/$cls 2>/dev/null
105
   rm -R $WIMS_HOME/log/ccaccount/$cls 2>/dev/null
106
  fi
107
  mkdir -p $WIMS_HOME/backup/oldclasses/$thisyear
108
  tar -czf $WIMS_HOME/backup/oldclasses/$thisyear/$cls.tgz $cls
109
  rm -R $cls >/dev/null 2>&1
110
  # clean resource sharing links
111
  find . -maxdepth 2 -type l -lname '*/$cls/*' -exec rm '{}' \;
112
 fi
113
done
114
 
115
# Clean up remaining classes.
15842 guerimand 116
## the number of exams is the number of sessions exams.
117
examlog_lim2=`awk -F'=' '$1=="examlog_limit" {print $2; exit}' $WIMS_HOME/log/wims.conf`
118
if [ -z $examlog_lim2 ]; then
119
  examlog_lim2=`awk -F'=' '$1=="DF_examlog_limit" {print $2; exit}' $WIMS_HOME/public_html/bases/sys/defaults.conf`
120
fi
121
examlog_lim2=$(expr $examlog_lim2 + 1)
3 reyssat 122
cd $WIMS_HOME/log/classes
123
find . -path '*/.parmreg/*' -type f -exec rm -f '{}' \;
124
for l in `find . -name examlog -type d`; do
125
 for d in $l/*; do
15842 guerimand 126
   list=`ls -dt $d/* | tail -n +$examlog_lim2`
127
   if [ -n "$list" ]; then rm -Rf $list; fi
3 reyssat 128
 done
129
done
7644 bpr 130
 
8841 bpr 131
# is the class number limit or the user number limit reached ?
132
# do it each 01 of month !
8931 bpr 133
today1=`date +%d`
134
if [ "$today1" -eq "01" ]; then
8841 bpr 135
 cd $WIMS_HOME/log/classes
136
 site_manager=`awk -F'=' '$1=="site_manager" {print $2; exit}' $WIMS_HOME/log/wims.conf`
137
 user_limit=`awk -F'=' '$1=="user_limit" {print $2; exit}' $WIMS_HOME/log/wims.conf`
138
 if [ -z $user_limit ]; then
139
  user_limit=`awk -F'=' '$1=="DF_user_limit" {print $2; exit}' $WIMS_HOME/public_html/bases/sys/defaults.conf`
140
 fi
141
 class_limit=`awk -F'=' '$1=="class_limit" {print $2; exit}' $WIMS_HOME/log//wims.conf`
142
 if [ -z $class_limit ]; then
143
  class_limit=`awk -F'=' '$1=="DF_class_limit" {print $2; exit}' $WIMS_HOME/public_html/bases/sys/defaults.conf`
144
 fi
145
 nclass=`cat .index | wc -l`
146
 cl=`awk -F, 'NF>2 {print substr($1,2) "/.userlist"}' .index`
147
 nuser=`cat $cl | grep -c '^:'`
148
 if [ $class_limit -lt $nclass ] || [ $user_limit -lt $nuser ] ; then
149
  mail $w_mail_opt -s "WIMS virtual class limit" "$site_manager" <<@
150
 
151
The server WIMS has reached the limit of classes.
152
 
153
@
154
 echo "$today housekeep class_limit or user_limit: $email" >>$WIMS_HOME/log/mail.log
155
 fi
156
fi
157
 
10811 bpr 158
# delete .anonymous in example classes
159
cd $WIMS_HOME/log/classes
160
clist=`ls -d [1-9][0-9][0-9][0-9]`
161
for cls in $clist; do
17806 bpr 162
  rm -f $cls/motd/.anonymous 2>/dev/null
163
  find $cls/.users -name "anonymous[1-9]*" -type f -delete 2>/dev/null;
164
  find $cls/score -name "anonymous[1-9]*" -type f -delete 2>/dev/null;
165
  find $cls/noscore -name "anonymous[1-9]*" -type f -delete 2>/dev/null;
166
  find $cls/score -name "anonymous*" -type f -delete 2>/dev/null;
167
  find $cls/noscore -name "anonymous*" -type f -delete 2>/dev/null;
17809 bpr 168
  sed -i '/anonymous/d' $cls/.userlist 2>/dev/null;
17806 bpr 169
  rm -f $cls/.userlist_external 2>/dev/null;
170
  rm -f $cls/.usernextlist 2>/dev/null;
171
  rm -f $cls/.userprevlist 2>/dev/null;
172
  rm -f $cls/freelogin 2>/dev/null;
10811 bpr 173
done
174
 
7644 bpr 175
# calculate the size of the classes
176
cd $WIMS_HOME/log/classes
177
for cls in [0-9]*
178
do
179
 du -ks $cls > $cls/.du
180
done;
181
 
8230 bpr 182
# cleanup the *.bin in score
183
cd $WIMS_HOME/log/classes
184
find . -type f -name "*.bin" -exec rm -v "{}" ";" 1>/dev/null
8247 bpr 185
## enlever les scoreavg aussi
8230 bpr 186
 
3702 bpr 187
# check if all compulsory directories are here (only in non example classes)
188
cd $WIMS_HOME/log/classes
10902 bpr 189
list=`find [0-9][0-9][0-9][0-9][0-9]* -maxdepth 0 -type d` ;
3702 bpr 190
for s in $list ; do
15997 guerimand 191
   for d in .users sheets exams doc score noscore vote cdt src def livret seq tool ; do
7644 bpr 192
    mkdir -p $s/$d
3702 bpr 193
   done
3694 bpr 194
done
3 reyssat 195
# Sheet expiration management. This should be activated during summer vacation.
1318 reyssat 196
for s in `find . -path '*/sheets/.sheets' -type f`; do
197
# quick test : any sheet to expire now ?
198
   test=`awk 'BEGIN {a=0};
199
	a==1 {a=0; if($1<'$today' && b==1) {print "Z"; exit}}
200
	substr($1,1,1)==":" {a=1;b=substr($1,2,1)};' $s`
201
# if test then change status code to 2 for sheets to expire
202
# in temporary file, then overwrite old file with new one
203
   if [ ! -z "$test" ]; then
204
    awk 'BEGIN {a=0; v=0};
3543 bpr 205
	a==1 {a=0; if($1>='$today' || v!=1) {print t} else {print ":2"};}
1318 reyssat 206
	substr($1,1,1)!=":" {print};
207
	substr($1,1,1)==":" {a=1; t=$1; v=substr(t,2)};' $s >.sheets
208
    mv -f .sheets $s
209
   fi
210
done
3 reyssat 211
 
15998 guerimand 212
# Sequence auto hide/show management.
16143 guerimand 213
#for s in `find . -path '*/seq/.sequence[0-9]*' -type f`; do
15998 guerimand 214
# quick test : any sequence to hide now ?
16143 guerimand 215
#   test=`sed -n 5p $s`
216
#   if [ "$today" = "$test" ]; then
217
#    awk 'BEGIN {cpt=0};
218
#	{a+=1; if(a==4) {print "0"} else {print $0};}' $s >.tmp
219
#    mv -f .tmp $s
220
#   fi
15998 guerimand 221
# quick test : any sequence to show now ?
16143 guerimand 222
#   test=`sed -n 6p $s`
223
#   if [ "$today" = "$test" ]; then
224
#    awk 'BEGIN {cpt=0};
225
#	{a+=1; if(a==4) {print "1"} else {print $0};}' $s >.tmp
226
#    mv -f .tmp $s
227
#   fi
228
#done
15998 guerimand 229
 
3 reyssat 230
# Build class index file
7644 bpr 231
rm -f .lockindex
3 reyssat 232
./.build-index
233
 
10315 bpr 234
##destroy the oldclasses which have been expired since more than $backup_delete days
235
## if backup_delete has a numeric value all the first day of months
236
cd $WIMS_HOME
237
backup_delete=`awk -F'=' '$1=="backup_delete" {print $2; exit}' $WIMS_HOME/log/wims.conf`
238
if [ "$backup_delete" ]; then
10322 bpr 239
  if test "$backup_delete" -eq "$backup_delete" 2>/dev/null; then
240
   today1=`date +%d`
241
   if [ "$today1" -eq "01" ]; then
10902 bpr 242
    find $WIMS_HOME/backup/oldclasses/[0-9]* -mtime +$backup_delete -exec rm '{}' ';' 2>/dev/null
243
    find $WIMS_HOME/backup2/oldclasses/[0-9]* -mtime +$backup_delete -exec rm '{}' ';' 2>/dev/null
13455 bpr 244
    find $WIMS_HOME/backuprestore/oldclasses/[0-9]* -mtime +$backup_delete -exec rm '{}' ';' 2>/dev/null
10322 bpr 245
   fi
10315 bpr 246
  fi
247
fi
248
 
3 reyssat 249
cd $WIMS_HOME/log
250
 
251
if [ -d ccaccount ]; then
252
 for c in `cd ccaccount; ls -d [0-9]* 2>/dev/null`; do
253
  if [ ! -d classes/$c ]; then rm -rf ccaccount/$c; fi
254
 done
255
fi
256
 
7022 bpr 257
#
258
 
259
rm -f $WIMS_HOME/public_html/scripts/model/*/list
260
 
15785 guerimand 261
# make stat of server
262
$WIMS_HOME/bin/statserver.sh
263
 
3 reyssat 264
# possible local housekeeping script
265
cd $WIMS_HOME
266
[ -x log/housekeep.local ] && log/housekeep.local