Skip to content
Snippets Groups Projects
Commit 2f84d419 authored by Hernán Asorey's avatar Hernán Asorey
Browse files

Include automatic data transfer

parent 5a812993
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@
@parameters=();
# Parameters
# If you need to add more question, just add them in four rows:
# If you need to add more questions, just add them in four rows:
# 1) Parameter Id
# 2) Question you need to ask to user
# 3) Number(1), string(0), bool(2) parameter?
......@@ -249,7 +249,7 @@ push @parameters,
2,
"n",
# SENSORS 168-193
# SENSORS 168-195
"hasGPS",
"Is GPS module installed (y/n)",
2,
......@@ -277,7 +277,25 @@ push @parameters,
"racimo",
"Is this a RACIMO station",
2,
"n";
"n",
# TRANSFER 196-211
"autoTransfer",
"Should I automatically transfer data to the central repository?",
2,
"y",
"hourInterval",
"Time interval in hours between two sucesive transfers trials (if 24, once per day at 05h50m local time)",
1,
24,
"remoteUser",
"User name at central repository?",
0,
"",
"remoteIP",
"IP of the central repository (remote)",
0,
"200.16.117.76";
sub get {
my $question = $_[0];
......@@ -520,6 +538,12 @@ $blockN=4; # SENSORS
$block="# BLOCK\t\tSENSORS";
ask(168,193,$block,$blockN);
print "$parameters[196]";
$blockN=5; # TRANSFER
$block="# BLOCK\t\tDATA TRANSFER";
ask(196,211,$block,$blockN);
# not asking values (backward compatibility)
$now=time;
print $fh "work=\"$configs{$parameters[0]}\"\n";
......@@ -531,32 +555,27 @@ cmd("mv lago-configs-tmp lago-configs");
# now, modify crontab.run
$bash=`which bash`;
chomp($bash);
# hours to transfer
$trf="# # END OF LAGO CRONTAB";
$hour="5";
if ($configs{"autoTransfer"}) {
$itr=$configs{"hourInterval"};
if ($itr==1) {
$hour="*";
} elsif ($itr>1 && $itr<24) {
$hour="*/$itr";
}
$trf="50 $hour * * * $bash -ic $configs{$parameters[0]}/lago-trfs.sh >> $configs{$parameters[0]}/lago-daq.log 2>&1
# # END OF LAGO CRONTAB";
}
open($fh, "> crontab.run") or die "# ERROR:\t\tCan't open crontab.run: $!\n";
print $fh "# Edit this file to introduce tasks to be run by cron.
# #
# # Each task to run has to be defined through a single line
# # indicating with different fields when the task will be run
# # and what command to run for the task
# #
# # To define the time you can provide concrete values for
# # minute (m), hour (h), day of month (dom), month (mon),
# # and day of week (dow) or use '*' in these fields (for 'any').#
# # Notice that tasks will be started based on the cron's system
# # daemon's notion of time and timezones.
# #
# # Output of the crontab jobs (including errors) is sent through
# # email to the user the crontab file belongs to (unless redirected).
# #
# # For example, you can run a backup of all your user accounts
# # at 5 a.m every week with:
# # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# #
# # For more information see the manual pages of crontab(5) and cron(8)
# #
# # m h dom mon dow command
print $fh "# # CRONTAB AUTOMATICALLY GENERATED BY LAGO ACQUA
# # PLEASE DON'T MODIFY
*/5 * * * * $bash -ic $configs{$parameters[0]}/lago-start.sh > $configs{$parameters[0]}/lago-daq.log 2>&1
10 * * * * $bash -ic $configs{$parameters[0]}/lago-proc.sh
# eventually some rsync.sh to transfer files to the repository
$trf
";
close($fh);
......@@ -584,6 +603,8 @@ print $fh "# Edit this file to introduce tasks to be run by cron.
# # For more information see the manual pages of crontab(5) and cron(8)
# #
# # m h dom mon dow command
10 * * * * $bash -ic $configs{$parameters[0]}/lago-proc.sh
$trf
";
close($fh);
......
#!/bin/bash
source ${LAGO_DAQ}/lago-configs
cd ${work}
datadir=${work}
if ($hasUSB); then
datadir=${usb}
fi
rsync -aPv $datadir/*.bz2 ${remoteUser}@${remoteIP}:~/lago/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment