/
update-documentation.sh
executable file
·80 lines (71 loc) · 2.24 KB
/
update-documentation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
#
#PBS -l walltime=00:05:00
#PBS -l mem=100Mb
#
# this script is started either from a cronjob or a webhook and it updates
# http://www.fieldtriptoolbox.org/reference/
# http://www.fieldtriptoolbox.org/reference/configuration
LOCKFILE=$HOME/documentation.lock
LOGFILE=$HOME/documentation.log
# prevent concurrent builds
while [[ -e $LOCKFILE ]] ; do
LOCKTIME=$(( $(date +"%s") - $(stat -c "%Y" $LOCKFILE) ))
if [ "$LOCKTIME" -gt "300" ]; then
echo removing stale lock
rm $LOCKFILE
else
echo waiting for previous build to complete
sleep 10
fi
done
# make sure that these exist
[[ -e $LOGFILE ]] || touch $LOGFILE
[[ -e $LOCKFILE ]] || touch $LOCKFILE
TRUNK=$HOME/fieldtrip/release/fieldtrip
TARGETDIR=$HOME/fieldtrip/release/website
MATLABSCRIPT=$HOME/fieldtrip_reference.m
# create the MATLAB script
cat > $MATLABSCRIPT << EOF
try,
% set up the path
restoredefaultpath
addpath('$TRUNK');
addpath('$TRUNK/connectivity');
addpath('$TRUNK/contrib/misc');
addpath('$TRUNK/contrib/nutmegtrip');
addpath('$TRUNK/contrib/spike');
addpath('$TRUNK/engine');
addpath('$TRUNK/external/artinis');
addpath('$TRUNK/fileio');
addpath('$TRUNK/forward');
addpath('$TRUNK/inverse');
addpath('$TRUNK/peer');
addpath('$TRUNK/plotting');
addpath('$TRUNK/preproc');
addpath('$TRUNK/qsub');
addpath('$TRUNK/realtime/example');
addpath('$TRUNK/realtime/online_eeg');
addpath('$TRUNK/realtime/online_meg');
addpath('$TRUNK/realtime/online_mri');
addpath('$TRUNK/specest');
addpath('$TRUNK/statfun');
addpath('$TRUNK/trialfun');
addpath('$TRUNK/utilities');
ft_defaults
% create the reference documentation
system('cd $TARGETDIR && git pull');
% system('rm $TARGETDIR/reference/*.md');
% ft_documentationreference('$TARGETDIR/reference');
% system('cd $TARGETDIR && git add reference/*.md && git commit -m "updated reference documentation"');
ft_documentationconfiguration('$TARGETDIR/configuration.md');
system('cd $TARGETDIR && git add configuration.md && git commit -m "updated configuration index"');
system('cd $TARGETDIR && git push');
end % try
exit
EOF
# schedule the MATLAB script for execution
# note that it uses my own matlab_sub, which deals with mem and time
$HOME/bin/matlab_sub --walltime 8:00:00 --mem 4gb $MATLABSCRIPT
date > $LOGFILE
rm $LOCKFILE