Subversion Repositories wimsdev

Rev

Rev 2497 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 reyssat 1
oldcrontab=!sh crontab -l 2>/dev/null
2
checkline=# Online-installed crontab
3
server_base=!replace internal /public_html*** by $ in $httpd_PWD***
4
backuper=$server_base/bin/backup
5
accounter=$server_base/log/account.sh
6
 
7
!if $oldcrontab!=$empty and $checkline notin $oldcrontab
15421 bpr 8
  error=manual
9
  !exit
23 reyssat 10
!endif
11
 
12
tt=!char 1 of $server_base
13
!if $tt!=/
14
 error=bad_base
15
 !exit
16
!endif
17
 
18
:readcron
19
oldcrontab=!nonempty lines $oldcrontab
20
n=!linecnt $oldcrontab
21
oldsave=
22
oldaccount=no
23
oldbackup_h=-1
24
oldbackup_m=
25
!for i=1 to $n
15421 bpr 26
  l=!line $i of $oldcrontab
27
  l=!trim $l
28
  c=!char 1 of $l
29
  !if $c!=#
30
    !distribute words $l into w1,w2,w3,w4,w5,w6,w7
31
    !if $w3=* and $w4=* and $w5=* and $w6 iswordof \
32
       $backuper $accounter
33
      !if $w6=$backuper
34
        oldbackup_h=$[$w2]
35
        oldbackup_m=$[$w1]
36
      !endif
37
      !if $w6=$accounter
38
        oldaccount=yes
39
      !endif
40
    !else
41
      !if bin/backup notin $l and log/account.sh notin $l
42
        oldsave=!append line $l to $oldsave
43
      !endif
44
    !endif
23 reyssat 45
  !endif
46
!next i
47
 
48
 
49
!if $job2=second and $abandon=$empty
15421 bpr 50
  !bound crontab_backup_h between integer -1 and 23 default -1
51
  !bound crontab_backup_m between integer 0 and 59 default $[randint(59)]
52
  !bound crontab_account among yes,no default no
53
  newcron=$checkline
54
  !if $crontab_backup_h>=0
55
    newcron=$newcron\
23 reyssat 56
\
57
# Daily backup\
58
$crontab_backup_m $crontab_backup_h * * * $backuper >/dev/null
15421 bpr 59
  !endif
60
  !if $crontab_account=yes
61
    newcron=$newcron\
23 reyssat 62
\
63
# Activity accounting\
64
16 0 * * * $accounter >/dev/null
15421 bpr 65
  !endif
66
  newcron=$newcron\
23 reyssat 67
\
68
# Saved from old (manual?) crontab\
69
$oldsave
70
 !sh cat >../tmp/crontab <<@\
71
$newcron\
72
@\
73
crontab ../tmp/crontab
15421 bpr 74
  job2=
75
  oldcrontab=!sh crontab -l 2>/dev/null
76
  !goto readcron
23 reyssat 77
!endif