Rev 17811 | 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 | |
17847 | obado | 38 | # Any classes which will expire in one month? |
6930 | bpr | 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 | |
17847 | obado | 64 | To get an archive file of the contents of this class, follow this link: |
6930 | bpr | 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) |
17847 | obado | 94 | is stored in an archive file, which can be recovered upon request |
3 | reyssat | 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 | |
17847 | obado | 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; |
||
17809 | bpr | 166 | sed -i '/anonymous/d' $cls/.userlist 2>/dev/null; |
17806 | bpr | 167 | rm -f $cls/.userlist_external 2>/dev/null; |
168 | rm -f $cls/.usernextlist 2>/dev/null; |
||
169 | rm -f $cls/.userprevlist 2>/dev/null; |
||
170 | rm -f $cls/freelogin 2>/dev/null; |
||
10811 | bpr | 171 | done |
172 | |||
7644 | bpr | 173 | # calculate the size of the classes |
174 | cd $WIMS_HOME/log/classes |
||
175 | for cls in [0-9]* |
||
176 | do |
||
177 | du -ks $cls > $cls/.du |
||
178 | done; |
||
179 | |||
8230 | bpr | 180 | # cleanup the *.bin in score |
181 | cd $WIMS_HOME/log/classes |
||
182 | find . -type f -name "*.bin" -exec rm -v "{}" ";" 1>/dev/null |
||
8247 | bpr | 183 | ## enlever les scoreavg aussi |
8230 | bpr | 184 | |
3702 | bpr | 185 | # check if all compulsory directories are here (only in non example classes) |
186 | cd $WIMS_HOME/log/classes |
||
10902 | bpr | 187 | list=`find [0-9][0-9][0-9][0-9][0-9]* -maxdepth 0 -type d` ; |
3702 | bpr | 188 | for s in $list ; do |
15997 | guerimand | 189 | for d in .users sheets exams doc score noscore vote cdt src def livret seq tool ; do |
7644 | bpr | 190 | mkdir -p $s/$d |
3702 | bpr | 191 | done |
3694 | bpr | 192 | done |
3 | reyssat | 193 | # Sheet expiration management. This should be activated during summer vacation. |
1318 | reyssat | 194 | for s in `find . -path '*/sheets/.sheets' -type f`; do |
17847 | obado | 195 | # quick test: any sheet to expire now? |
1318 | reyssat | 196 | test=`awk 'BEGIN {a=0}; |
197 | a==1 {a=0; if($1<'$today' && b==1) {print "Z"; exit}} |
||
198 | substr($1,1,1)==":" {a=1;b=substr($1,2,1)};' $s` |
||
199 | # if test then change status code to 2 for sheets to expire |
||
200 | # in temporary file, then overwrite old file with new one |
||
201 | if [ ! -z "$test" ]; then |
||
202 | awk 'BEGIN {a=0; v=0}; |
||
3543 | bpr | 203 | a==1 {a=0; if($1>='$today' || v!=1) {print t} else {print ":2"};} |
1318 | reyssat | 204 | substr($1,1,1)!=":" {print}; |
205 | substr($1,1,1)==":" {a=1; t=$1; v=substr(t,2)};' $s >.sheets |
||
206 | mv -f .sheets $s |
||
207 | fi |
||
208 | done |
||
3 | reyssat | 209 | |
15998 | guerimand | 210 | # Sequence auto hide/show management. |
16143 | guerimand | 211 | #for s in `find . -path '*/seq/.sequence[0-9]*' -type f`; do |
17847 | obado | 212 | # quick test: any sequence to hide now? |
16143 | guerimand | 213 | # test=`sed -n 5p $s` |
214 | # if [ "$today" = "$test" ]; then |
||
215 | # awk 'BEGIN {cpt=0}; |
||
216 | # {a+=1; if(a==4) {print "0"} else {print $0};}' $s >.tmp |
||
217 | # mv -f .tmp $s |
||
218 | # fi |
||
17847 | obado | 219 | # quick test: any sequence to show now? |
16143 | guerimand | 220 | # test=`sed -n 6p $s` |
221 | # if [ "$today" = "$test" ]; then |
||
222 | # awk 'BEGIN {cpt=0}; |
||
223 | # {a+=1; if(a==4) {print "1"} else {print $0};}' $s >.tmp |
||
224 | # mv -f .tmp $s |
||
225 | # fi |
||
226 | #done |
||
15998 | guerimand | 227 | |
3 | reyssat | 228 | # Build class index file |
7644 | bpr | 229 | rm -f .lockindex |
3 | reyssat | 230 | ./.build-index |
231 | |||
10315 | bpr | 232 | ##destroy the oldclasses which have been expired since more than $backup_delete days |
233 | ## if backup_delete has a numeric value all the first day of months |
||
234 | cd $WIMS_HOME |
||
235 | backup_delete=`awk -F'=' '$1=="backup_delete" {print $2; exit}' $WIMS_HOME/log/wims.conf` |
||
236 | if [ "$backup_delete" ]; then |
||
10322 | bpr | 237 | if test "$backup_delete" -eq "$backup_delete" 2>/dev/null; then |
238 | today1=`date +%d` |
||
239 | if [ "$today1" -eq "01" ]; then |
||
10902 | bpr | 240 | find $WIMS_HOME/backup/oldclasses/[0-9]* -mtime +$backup_delete -exec rm '{}' ';' 2>/dev/null |
241 | find $WIMS_HOME/backup2/oldclasses/[0-9]* -mtime +$backup_delete -exec rm '{}' ';' 2>/dev/null |
||
13455 | bpr | 242 | find $WIMS_HOME/backuprestore/oldclasses/[0-9]* -mtime +$backup_delete -exec rm '{}' ';' 2>/dev/null |
10322 | bpr | 243 | fi |
10315 | bpr | 244 | fi |
245 | fi |
||
246 | |||
3 | reyssat | 247 | cd $WIMS_HOME/log |
248 | |||
249 | if [ -d ccaccount ]; then |
||
250 | for c in `cd ccaccount; ls -d [0-9]* 2>/dev/null`; do |
||
251 | if [ ! -d classes/$c ]; then rm -rf ccaccount/$c; fi |
||
252 | done |
||
253 | fi |
||
254 | |||
7022 | bpr | 255 | # |
256 | |||
257 | rm -f $WIMS_HOME/public_html/scripts/model/*/list |
||
258 | |||
15785 | guerimand | 259 | # make stat of server |
260 | $WIMS_HOME/bin/statserver.sh |
||
261 | |||
3 | reyssat | 262 | # possible local housekeeping script |
263 | cd $WIMS_HOME |
||
264 | [ -x log/housekeep.local ] && log/housekeep.local |