Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
10 reyssat 1
/*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
2
 *
3
 *  This program is free software; you can redistribute it and/or modify
4
 *  it under the terms of the GNU General Public License as published by
5
 *  the Free Software Foundation; either version 2 of the License, or
6
 *  (at your option) any later version.
7
 *
8
 *  This program is distributed in the hope that it will be useful,
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 *  GNU General Public License for more details.
12
 *
13
 *  You should have received a copy of the GNU General Public License
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
17
 
8155 bpr 18
/* Daily housekeeping jobs. */
8185 bpr 19
 
20
#include "wimslogd.h"
21
 
10 reyssat 22
void housekeep(void)
23
{
12474 bpr 24
  char fname[1024];
25
  FILE *keeplog;
8155 bpr 26
 
12474 bpr 27
  if(strncmp(keepdate,nowstr,8)==0) return;
28
  snprintf(fname,sizeof(fname),"%s/keepdate",tmpd);
29
  keeplog=fopen(fname,"r");
30
  if(keeplog==NULL) goto dokeep;
31
  (void)fread(keepdate,8,1,keeplog); keepdate[8]=0; fclose(keeplog);
32
  if(strncmp(keepdate,nowstr,8)==0) return;
33
  dokeep:
34
  keeplog=fopen(fname,"w");
35
  if(keeplog!=NULL) {
36
    fwrite(nowstr,8,1,keeplog);fclose(keeplog);
37
  }
38
  call_ssh(0,"bin/housekeep.daily &>%s/housekeep.log",tmpd);
10 reyssat 39
}
40
 
8155 bpr 41
/* module update */
10 reyssat 42
void modupdate(void)
43
{
12474 bpr 44
  char fname[1024];
45
  FILE *muplog;
8155 bpr 46
 
12474 bpr 47
  if(strncmp(mupdate,nowstr,8)==0) return;
48
  snprintf(fname,sizeof(fname),"%s/mupdate",tmpd);
49
  muplog=fopen(fname,"r");
50
  if(muplog==NULL) goto domup;
51
  (void)fread(mupdate,8,1,muplog); mupdate[8]=0; fclose(muplog);
52
  if(strncmp(mupdate,nowstr,8)==0) return;
53
  domup:
54
  muplog=fopen(fname,"w");
55
  if(muplog!=NULL) {
56
    fwrite(nowstr,8,1,muplog);fclose(muplog);
57
  }
58
  call_ssh(0,"bin/modupdate.auto &>%s/modupdate.log",tmpd);
10 reyssat 59
}
60
 
8155 bpr 61
/* Daily backup. */
10 reyssat 62
void backup(void)
63
{
12474 bpr 64
  FILE *backlog;
8155 bpr 65
 
12474 bpr 66
  if(strncmp(backdate,nowstr,8)==0) return;
67
  backlog=fopen("backup/backdate","r");
68
  if(backlog==NULL) goto dobackup;
69
  (void)fread(backdate,8,1,backlog); backdate[8]=0; fclose(backlog);
70
  if(strncmp(backdate,nowstr,8)==0) return;
71
  dobackup:
72
  call_ssh(0,"bin/backup &>%s/backup.log",tmpd);
10 reyssat 73
}