lilalo
changeset 139:f9d0d35618f8
Удалены файлы из labmaker
Удалены файлы, которые переползли в репозиторий
из проекта labmaker
Если кому-то нужны эти файлы,
они есть в старом CVS-репозитории lilalo.
Удаление лишних файлов ещё полностью
не завершено. Ещё будем удалять
Удалены файлы, которые переползли в репозиторий
из проекта labmaker
Если кому-то нужны эти файлы,
они есть в старом CVS-репозитории lilalo.
Удаление лишних файлов ещё полностью
не завершено. Ещё будем удалять
author | igor@chub.in |
---|---|
date | Mon Jul 21 12:28:13 2008 +0300 (2008-07-21) |
parents | 93e08c4b54ed |
children | da99089532ca |
files | lm lm-install lm-report lm-ssh taillast.pl |
line diff
1.1 --- a/lm Mon Jul 21 11:24:53 2008 +0300 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,555 +0,0 @@ 1.4 -#!/usr/bin/perl 1.5 - 1.6 - 1.7 -use strict; 1.8 -use Data::Dumper; 1.9 -use Switch; 1.10 -use XML::Simple; 1.11 -use Getopt::Long; 1.12 -use utf8; 1.13 - 1.14 -use lib "/usr/local/bin"; 1.15 -use l3config; 1.16 - 1.17 -our $XMLClass; 1.18 -our $XMLCourse; 1.19 -our @Labs; 1.20 - 1.21 -our %Machines; # Machines list from class.xml 1.22 -our @SelectedMachines; # Machines list given as the command line argument 1.23 - 1.24 -our $Config_File = "labmaker.conf"; 1.25 -our %Config_ = ( 1.26 - "show_host" => "no", 1.27 - 1.28 - # Вспомогательные программы 1.29 - #"l3-report" => "./lm-report", 1.30 - "l3-report" => "./l3-report", 1.31 - 1.32 - # Каталоги 1.33 - "path_lilalo" => "/var/lilalo/", 1.34 - "path_classes" => "/var/lilalo/classes/", 1.35 - "path_lablogs" => "/var/lilalo/lablogs/", 1.36 - "courses_path" => "/var/lilalo/courses/", 1.37 - "outpath" => "/var/lilalo/out/", 1.38 - "path_web" => "/var/www/l3", # Путь к web-отчётам 1.39 - "path_share" => "./share/", # Путь к web-отчётам 1.40 - 1.41 - # Файлы 1.42 - "runfile" => "lm.run", 1.43 - "logfile" => "lm.log", 1.44 - 1.45 - "class" => "class", # Имя файла класса 1.46 - "class_suffix" => ".xml", # Cуффикс файла класса 1.47 - "classfile" => "", 1.48 - 1.49 - "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub", 1.50 - "lmssh" => "./lm-ssh", 1.51 - "lminstall" => "./lm-install", 1.52 - "ssh_user" => "root", 1.53 -); 1.54 - 1.55 -our %Run = ( 1.56 - "lab" => "" 1.57 -); 1.58 - 1.59 -our %Scripts; 1.60 - 1.61 -sub load_class; 1.62 -sub load_config; 1.63 -sub load_course; 1.64 -sub load_scripts; 1.65 - 1.66 -sub lm_get; 1.67 -sub lm_next; 1.68 -sub lm_prev; 1.69 -sub lm_start; 1.70 -sub lm_stop; 1.71 -sub lm_set; 1.72 -sub lm_do; 1.73 -sub lm_report; 1.74 -sub lm_show_hosts; 1.75 -sub lm_show_email; 1.76 -sub lm_show_labs; 1.77 - 1.78 -sub load_run; 1.79 -sub save_run; 1.80 -sub print_log; 1.81 -sub print_usage_info; 1.82 -sub main(); 1.83 - 1.84 -main(); 1.85 - 1.86 -sub main() 1.87 -{ 1.88 - binmode STDOUT, ":utf8"; 1.89 - 1.90 - if (! @ARGV) { 1.91 - print_usage_info(); 1.92 - exit(0); 1.93 - } 1.94 - 1.95 - if ($ARGV[0] eq "get") { 1.96 - lm_get; 1.97 - exit(0); 1.98 - } 1.99 - 1.100 - init_config(); 1.101 - #load_config; 1.102 - load_run; 1.103 - load_scripts; 1.104 - load_class; 1.105 - load_course; 1.106 - 1.107 - my $arg = join " ", @ARGV; 1.108 - 1.109 - # Getting @SelectedMachines if any 1.110 - if ($arg =~ s/@(.*?)\s//) { 1.111 - my $machines = $1; 1.112 - my @list = split /,/, $machines; 1.113 - for my $interval (@list) { 1.114 - my ($first, $last) = split /-/, $interval; 1.115 - 1.116 - push @SelectedMachines, $first; 1.117 - while ($first < $last) { 1.118 - push @SelectedMachines, ++$first; 1.119 - } 1.120 - } 1.121 - } 1.122 - 1.123 - # Choose command to do 1.124 - switch ($arg) { 1.125 - case "next" { lm_next } 1.126 - case "prev" { lm_prev } 1.127 - case /set / { $arg =~ /set (.*)/; lm_set $1 } 1.128 - case "report" { lm_report } 1.129 - case "start" { lm_start } 1.130 - case "stop" { lm_stop } 1.131 - case "show hosts" { lm_show_hosts } 1.132 - case "show email" { lm_show_email } 1.133 - case "show labs" { lm_show_labs } 1.134 - case /do / { $arg =~ /do (.*)/; lm_do "$1" } 1.135 - else { print_usage_info() } 1.136 - } 1.137 - save_run; 1.138 - exit(0); 1.139 -} 1.140 - 1.141 -sub load_scripts 1.142 -{ 1.143 - open (SCRIPTS, "$Config{l3scripts}") 1.144 - or die "Cant open l3scripts file: ".$Config{l3scripts}.": $!\n"; 1.145 - binmode SCRIPTS, ":utf8"; 1.146 - local $/; 1.147 - $_=<SCRIPTS>; 1.148 - close(SCRIPTS); 1.149 - 1.150 - %Scripts = ("empty-element", split (/###(.*)\n/)); 1.151 - delete($Scripts{"empty-element"}); 1.152 - 1.153 -} 1.154 - 1.155 -sub load_config 1.156 -{ 1.157 - my %file_config; 1.158 - my %argv_config; 1.159 - #read_config_file(\%file_config, $Config_File); 1.160 - GetOptions(\%argv_config, map "$_=s", keys %Config); 1.161 - %Config = (%Config, %file_config, %argv_config); 1.162 -} 1.163 - 1.164 -sub load_course 1.165 -{ 1.166 - $XMLCourse = XMLin($Config{"courses_path"}.$XMLClass->{"course"}.".xml", ForceArray => 1 ) 1.167 - or die "Can't open file of the course ",$XMLClass->{"course"}," [with .xml extension]\n"; 1.168 -# print Dumper($XMLCourse); 1.169 - for my $lab (@{$XMLCourse->{"module"}}) { 1.170 - push @Labs, $lab->{"code"}; 1.171 - } 1.172 -} 1.173 - 1.174 -sub load_class 1.175 -{ 1.176 - my $classfile = 1.177 - $Config{"classfile"} || 1.178 - $Config{"path_classes"}."/".$Config{"class"}.$Config{"class_suffix"}; 1.179 - $XMLClass = XMLin($classfile , ForceArray => [ 'student' ] ) 1.180 - or die "Can't open file of the class ",$classfile,"\n"; 1.181 - 1.182 - for my $student (@{$XMLClass->{"student"}}) { 1.183 - $Machines{$student->{"host"}} = { 1.184 - "name" => "$student->{firstname} $student->{surname}", 1.185 - "firstname" => "$student->{firstname}", 1.186 - "user" => "$student->{user}", 1.187 - "email" => "$student->{email}", 1.188 - "student" => $student, 1.189 - } 1.190 - } 1.191 -# print Dumper($XMLClass); 1.192 -# print Dumper(\%Machines); 1.193 -} 1.194 - 1.195 -sub lm_get 1.196 -{ 1.197 - print "Getting class description file..."; 1.198 - if (system("cd $Config{path_classes}; rm -f class.xml ; wget xgu.ru/l3/classes/class.xml") ==0 ) 1.199 - { 1.200 - print "Ok\n"; 1.201 - } 1.202 - else { 1.203 - die "Can't load class file\n" 1.204 - } 1.205 -} 1.206 - 1.207 - 1.208 -sub lm_next 1.209 -{ 1.210 - for(my $i=0; $i<=$#Labs; $i++){ 1.211 - if ( $Labs[$i] eq $Run{"lab"} ) { 1.212 - if ($i < $#Labs) { 1.213 - lm_set($Labs[$i+1]); 1.214 - return ; 1.215 - } else { 1.216 - die "Lab ", $Run{"lab"}, " is the last. Switch to next lab is impossible" 1.217 - } 1.218 - } 1.219 - 1.220 - } 1.221 - die "Lab ", $Run{"lab"}, " not found. Don't know which is next" 1.222 -} 1.223 - 1.224 -sub lm_prev 1.225 -# Switch to previous lab 1.226 -{ 1.227 - for(my $i=0; $i<=$#Labs; $i++){ 1.228 - if ( $Labs[$i] eq $Run{"lab"} ) { 1.229 - if ($i > 0) { 1.230 - lm_set($Labs[$i-1]); 1.231 - return ; 1.232 - } else { 1.233 - die "Lab ", $Run{"lab"}, " is the first. Switch to previous lab is impossible" 1.234 - } 1.235 - } 1.236 - 1.237 - } 1.238 - die "Lab ", $Run{"lab"}, " not found. Don't know which is previous" 1.239 -} 1.240 - 1.241 -sub lm_set 1.242 -# Switch to $_[0] lab 1.243 -# FIXME 1.244 -{ 1.245 - my $lab = shift; 1.246 - print "Current lab is $lab\n"; 1.247 - $Run{"lab"} = "$lab"; 1.248 - lm_do "setlab", $lab; 1.249 -} 1.250 - 1.251 - 1.252 -sub lm_start 1.253 -# Start new training day 1.254 -{ 1.255 - print_log(`date`." STARTED\n"); 1.256 - if ($Run{"lab"}) { 1.257 - lm_next; 1.258 - } 1.259 - else 1.260 - { 1.261 - # First lab in the course 1.262 - lm_set($Labs[0]); 1.263 - } 1.264 -} 1.265 - 1.266 -sub lm_stop 1.267 -# Stop this training day 1.268 -{ 1.269 - print_log(`date`." STOPPED\n"); 1.270 -} 1.271 - 1.272 - 1.273 -sub lm_show_hosts 1.274 -# Show hosts used to run a commands 1.275 -{ 1.276 - my $i=1; 1.277 - for my $m (sort keys %Machines) { 1.278 - if (!@SelectedMachines || grep /^$i$/, @SelectedMachines) { 1.279 - print "($i)","\t",$m,"\t",$Machines{$m}->{"name"},"\n"; 1.280 - } 1.281 - $i++; 1.282 - } 1.283 -} 1.284 - 1.285 -sub lm_show_email 1.286 -# Show hosts used to run a commands 1.287 -{ 1.288 - my $i=1; 1.289 - for my $m (sort keys %Machines) { 1.290 - if (!@SelectedMachines || grep /^$i$/, @SelectedMachines) { 1.291 - print $Machines{$m}->{"email"},"\t",$Machines{$m}->{"name"},"\n"; 1.292 - } 1.293 - $i++; 1.294 - } 1.295 -} 1.296 - 1.297 -sub lm_show_labs 1.298 -# Show hosts used to run a commands 1.299 -{ 1.300 - my $i=1; 1.301 - for my $lab (@Labs) { 1.302 - print $lab; 1.303 - print "*" if $lab eq $Run{"lab"}; 1.304 - print "\n"; 1.305 - } 1.306 -} 1.307 - 1.308 -sub lm_do 1.309 -# Do the $_[0] command on all of the hosts 1.310 -{ 1.311 - my $command = shift; 1.312 - my $arg = join " ", @_; 1.313 - my $i=1; 1.314 - 1.315 - my %myenv = ( %Config, 1.316 - lab => $arg, 1.317 - center => $XMLClass->{"center"}, 1.318 - course => $XMLClass->{"course"}, 1.319 - date => $XMLClass->{"date"}, 1.320 - stopdate => $XMLClass->{"stop-date"}, 1.321 - instructor => $XMLClass->{"instructor"}->{"firstname"}." ".$XMLClass->{"instructor"}->{"surname"}, 1.322 - manager => $XMLClass->{"manager"}->{"firstname"}." ".$XMLClass->{"manager"}->{"surname"}, 1.323 - coursepath => $XMLCourse->{"path"}, 1.324 - ); 1.325 - 1.326 - if (grep { $_ eq "PRE-$command"} keys %Scripts) { 1.327 - $_=$Scripts{"PRE-$command"}; 1.328 - s/\$(\w+)/$myenv{$1}/ge; 1.329 - open(SHELL, "|/bin/sh -s"); 1.330 - binmode SHELL, ":utf8"; 1.331 - print SHELL $_; 1.332 - close (SHELL); 1.333 - } 1.334 - 1.335 - 1.336 - for my $m (sort keys %Machines) { 1.337 - if (!@SelectedMachines || grep $_ eq $i, @SelectedMachines) { 1.338 - print "$m:\n" if $Config{"show_host"} =~ /y/i; 1.339 - 1.340 - %myenv = ( %myenv, 1.341 - host => $m, 1.342 - ipaddress => $Machines{$m}->{"ipaddress"}, 1.343 - dirs => "/root /home/".$Machines{$m}->{"user"}, 1.344 - lablogs => $Config{"path_lablogs"}."/". 1.345 - $XMLClass->{"course"}."/". 1.346 - $XMLClass->{"date"}."/". 1.347 - "$m", 1.348 - email => $Machines{$m}->{"student"}->{"email"}, 1.349 - company => $Machines{$m}->{"student"}->{"company"}, 1.350 - name => $Machines{$m}->{"name"}, 1.351 - firstname => $Machines{$m}->{"firstname"}, 1.352 - ); 1.353 - if (grep { $_ eq $command} keys %Scripts) { 1.354 - $_=$Scripts{"$command"}; 1.355 - s/\$(\w+)/$myenv{$1}/ge; 1.356 - open(SHELL, "|/bin/sh -s"); 1.357 - binmode SHELL, ":utf8"; 1.358 - print SHELL $_; 1.359 - close (SHELL); 1.360 - } 1.361 - else { 1.362 - my $res = `ssh $Config{"ssh_user"}\@$m $command`; 1.363 - if ($res) { 1.364 - my $count = ($res =~ s/(^)/$m: /mg); 1.365 - print $res; 1.366 - print "\n" if ($count > 1); 1.367 - } 1.368 - } 1.369 - } 1.370 - $i++; 1.371 - } 1.372 - 1.373 - if (grep { $_ eq "POST-$command"} keys %Scripts) { 1.374 - $_=$Scripts{"POST-$command"}; 1.375 - s/\$(\w+)/$myenv{$1}/ge; 1.376 - open(SHELL, "|/bin/sh -s"); 1.377 - binmode SHELL, ":utf8"; 1.378 - print SHELL $_; 1.379 - close (SHELL); 1.380 - } 1.381 -} 1.382 - 1.383 - 1.384 - 1.385 -=cut comment 1.386 - 1.387 -lm report 1.388 - 1.389 -Построить html представление для журналов текущего класса. 1.390 -Для построения используется скрипт l3-report. 1.391 - 1.392 -=cut 1.393 - 1.394 -sub lm_report 1.395 -{ 1.396 - 1.397 - my $webdir = $Config{"path_web"}; 1.398 - my $course=$XMLClass->{"course"}; 1.399 - my $date=$XMLClass->{"date"}; 1.400 - my $encoding=$XMLClass->{"charset"}; 1.401 - 1.402 - my $center = $XMLClass->{"center"}; 1.403 - my $instructor = $XMLClass->{"instructor"}->{"firstname"}." ".$XMLClass->{"instructor"}->{"surname"}; 1.404 - my $course_name = $XMLCourse->{"fullname"}[0]; 1.405 - 1.406 - 1.407 - # Собственно журналы 1.408 - 1.409 - for my $student (@{$XMLClass->{"student"}}) { 1.410 - my $user = $student->{"user"}; 1.411 - my $hostname = $student->{"host"}; 1.412 - my $encoding = $student->{"charset"}; 1.413 - my $student_name = $student->{"firstname"}." ".$student->{"surname"}; 1.414 - 1.415 - system("mkdir -p $webdir/$date/$hostname"); 1.416 - system("cp ".$Config{"path_share"}."/*.{ico,css} $webdir/$date/$hostname"); 1.417 - system($Config{"l3-report"}. 1.418 - " --input ".$Config{"path_lablogs"}."/$course/$date/$hostname/$user". 1.419 - " --diffs ".$Config{"path_lablogs"}."/$course/$date/$hostname/$user ". 1.420 - $Config{"path_lablogs"}."/$course/$date/$hostname/root". 1.421 - " --output $webdir/$date/$hostname/$user.html". 1.422 - " --course-name '$course_name'". 1.423 - " --course-code '$course'". 1.424 - " --course-date '$date'". 1.425 - " --course-center '$center'". 1.426 - " --course-student '$student_name'". 1.427 - " --course-trainer '$instructor'". 1.428 - " --encoding $encoding" 1.429 - ); 1.430 - system($Config{"l3-report"}. 1.431 - " --input ".$Config{"path_lablogs"}."/$course/$date/$hostname/root". 1.432 - " --diffs ".$Config{"path_lablogs"}."/$course/$date/$hostname/root ". 1.433 - " --output $webdir/$date/$hostname/root.html". 1.434 - " --course-name '$course_name'". 1.435 - " --course-code '$course'". 1.436 - " --course-date '$date'". 1.437 - " --course-center '$center'". 1.438 - " --course-student '$student_name'". 1.439 - " --course-trainer '$instructor'". 1.440 - " --encoding $encoding" 1.441 - ); 1.442 - } 1.443 - 1.444 - # Индекс для данного класса 1.445 - 1.446 - my $head; 1.447 - 1.448 - $head="Журналы лабораторных работ"; 1.449 - open(HTML, ">$webdir/$date/index.html") 1.450 - or die "Can't open $webdir/$date/index.html for writing"; 1.451 - binmode HTML, ":utf8"; 1.452 - print HTML <<HEAD; 1.453 - <html> 1.454 - <head> 1.455 - <meta content='text/html; charset=utf-8' http-equiv='Content-Type' /> 1.456 - <title>$head</title> 1.457 - </head> 1.458 - <body> 1.459 - <h1>$head</h1> 1.460 - <p> 1.461 - Курс: $course_name ($course)<br/> 1.462 - Начало: $date<br/> 1.463 - Учебный центр: $center <br/> 1.464 - Инструктор: $instructor <br/> 1.465 - </p> 1.466 - <table> 1.467 -HEAD 1.468 - for my $student (@{$XMLClass->{"student"}}) { 1.469 - my $user = $student->{"user"}; 1.470 - my $hostname = $student->{"host"}; 1.471 - print HTML "<tr>\n"; 1.472 - print HTML "<td>",$student->{"firstname"}," ",$student->{"surname"},"</td>\n"; 1.473 - print HTML "<td>",$hostname,"</td>\n"; 1.474 - print HTML "<td><a href=\"$hostname/$user.html\">",$user,"</td>\n"; 1.475 - print HTML "<td><a href=\"$hostname/root.html\">","root","</td>\n"; 1.476 - print HTML "</tr>\n"; 1.477 - } 1.478 - print HTML <<TAIL; 1.479 - </table> 1.480 - </html> 1.481 -TAIL 1.482 - close (HTML); 1.483 - 1.484 - 1.485 - 1.486 -} 1.487 - 1.488 -sub load_run 1.489 -{ 1.490 - my $runfile = $Config{"path_labmaker"}."/".$Config{"path_runfile"}; 1.491 - open (RUN, $runfile) 1.492 - or return; 1.493 - while (<RUN>) { 1.494 - chomp; 1.495 - my ($var, $val) = split /\s+/,$_,2; 1.496 - $Run{$var}=$val; 1.497 - } 1.498 - close (RUN); 1.499 -} 1.500 - 1.501 -sub save_run 1.502 -{ 1.503 - my $runfile = $Config{"path_labmaker"}."/".$Config{"path_runfile"}; 1.504 - open (RN, "$runfile") 1.505 - or die "Can't save running state to $runfile"; 1.506 - for my $var (keys %Run) { 1.507 - print RN $var,"\t",$Run{$var},"\n"; 1.508 - } 1.509 - close (RN); 1.510 -} 1.511 - 1.512 -sub print_log 1.513 -{ 1.514 - my $logfile = $Config{"path_labmaker"}."/".$Config{"path_logfile"}; 1.515 - open (LOG, ">>$logfile") 1.516 - or die "Can't open logfile $logfile for writing"; 1.517 - print LOG @_; 1.518 - close (LOG); 1.519 -} 1.520 - 1.521 - 1.522 -sub print_usage_info 1.523 -{ 1.524 - print "Usage:\n\n\t$0 [host-list] command\n"; 1.525 - print <<'USAGE'; 1.526 - 1.527 -Commands: 1.528 - 1.529 - next -- next lab 1.530 - prev -- prev lab 1.531 - set LAB -- set current lab to LAB 1.532 - start -- start this day training 1.533 - stop -- stop this day training 1.534 - show hosts -- show available hosts in the class 1.535 - show labs -- show available labs in the course 1.536 - do COMMAND -- do specified command on the hosts of hostlist 1.537 - report -- generate XML/HTML reports 1.538 - 1.539 - 1.540 -do commands: 1.541 - 1.542 - install [PROFILE] -- install profile 1.543 - 1.544 -Host list: 1.545 - 1.546 - @N -- machine N 1.547 - @N1-N2 -- all of the machines from N1 to N2 1.548 - @N1,N2,N3 -- machine N1, N2 and N3 1.549 - 1.550 - N* is numbers or domain names of the machines. 1.551 - 1.552 - If host list is not specified, 1.553 - command is executed on all of the machines 1.554 - 1.555 -USAGE 1.556 -} 1.557 - 1.558 -
2.1 --- a/lm-install Mon Jul 21 11:24:53 2008 +0300 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,258 +0,0 @@ 2.4 -#!/bin/sh 2.5 - 2.6 -# Use -d to deinstall labmaker 2.7 -# You can specify directory list to install LabMaker as command line parameters 2.8 -# or set it in $users_to_install variable 2.9 - 2.10 -# CONFIGURABLE SECTION start 2.11 -#users_to_install="/home/your-user-here /root" 2.12 -# CONFIGURABLE SECTION stop 2.13 - 2.14 -first_lab=T1 2.15 -editors_to_install='/bin/vi /usr/bin/vi /usr/bin/vim /bin/ee /usr/bin/ee /usr/bin/pico /usr/bin/nano /usr/local/bin/vim' 2.16 -temp_file=/tmp/lm-install-$$ 2.17 -arg=$@ 2.18 - 2.19 -show_usage() 2.20 -{ 2.21 - cat << USAGE 2.22 - 2.23 -$0 [-d] path... 2.24 - 2.25 - * Use -d to deinstall labmaker 2.26 - * You can specify directory list to install LabMaker as command line parameters 2.27 - or set it in \$users_to_install variable in the script 2.28 - 2.29 -Example: 2.30 - 2.31 - Command 2.32 - # $0 /root /home/user 2.33 - installs labmaker to /root and /home/user directories 2.34 - 2.35 -USAGE 2.36 -} 2.37 - 2.38 -install_to_profile() 2.39 -{ 2.40 - profile=$1 2.41 - cat <<'LM_bash_profile' > $temp_file 2.42 -# LabMaker:START 2.43 -/usr/local/bin/l3-agent 2.44 -# LabMaker:END 2.45 -LM_bash_profile 2.46 - cat $profile \ 2.47 - | sed '/LabMaker:START/,/LabMaker:END/ d' \ 2.48 - >> $temp_file 2.49 - cat $temp_file > $profile 2.50 - rm $temp_file 2.51 -} 2.52 - 2.53 -uninstall_from_profile() 2.54 -{ 2.55 - profile=$1 2.56 - cat $profile \ 2.57 - | sed '/LabMaker:START/,/LabMaker:END/ d' \ 2.58 - > $temp_file 2.59 - cat $temp_file > $profile 2.60 - rm $temp_file 2.61 -} 2.62 - 2.63 -install_to_bashrc() 2.64 -{ 2.65 - profile=$1 2.66 - cat $profile \ 2.67 - | sed '/LabMaker:START/,/LabMaker:END/ d' \ 2.68 - > $temp_file 2.69 - cat <<'LM_bash_profile' >> $temp_file 2.70 -# LabMaker:START 2.71 -LMHOME=~/.lilalo 2.72 -mkdir -p ${LMHOME} 2.73 - 2.74 -uname -a | grep -qi bsd && bsd=yes 2.75 -flush="-f" #linux 2.76 -[ -n "$bsd" ] && flush="-t 0" #freebsd 2.77 - 2.78 -tty=`tty` 2.79 -this_term=`w | grep "${tty##/dev/}" | awk '{print $8;}'` 2.80 -# freeBSD: 2.81 -[ -n "$bsd" ] && this_term=`w | grep "${tty##/dev/tty}" | awk '{print $6;}'` 2.82 - 2.83 - 2.84 -export PS1='\[` 2.85 - a="$?"; 2.86 - HIDDEN=$([ "$a" = 0 ] || echo -n ^"$a")$(echo -n _${UID}_)$(echo -n _$$_)$(date\ 2.87 - +"%j$(cat ${LMHOME}/lab 2>/dev/null) %H:%M:%S"); 2.88 - echo $HIDDEN`\033[50D\033[K\][\u@\h:\W]\$ ' 2.89 - 2.90 -if [ -n "$this_term" ] && echo $this_term | grep -qv script 2.91 -then 2.92 - session_id=${tty##*/}-$$ 2.93 - parent=`cat /proc/$PPID/cmdline 2> /dev/null` 2.94 - system=`uname -rs` 2.95 - login_from=`who | grep "${tty##/dev/}" | awk '{print $6;}' | tr -d '()'` 2.96 - #[ -n "$bsd" ] && login_from="" #FIXME! 2.97 - start_time=`date +%s` 2.98 - hostname=`hostname -f 2> /dev/null` 2.99 - [ -n "$bsd" ] && hostname=`hostname` 2.100 - 2.101 - cat <<INFO > $LMHOME/${session_id}.info 2.102 -<session> 2.103 -<local_session_id>$session_id</local_session_id> 2.104 -<hostname>$hostname</hostname> 2.105 -<user>$USER</user> 2.106 -<uid>$UID</uid> 2.107 -<login_from>$login_from</login_from> 2.108 -<tty>$tty</tty> 2.109 -<system>$system</system> 2.110 -<parent>$parent</parent> 2.111 -<ppid>$PPID</ppid> 2.112 -<pid>$$</pid> 2.113 -<start_time>$start_time</start_time> 2.114 -</session> 2.115 -INFO 2.116 - 2.117 - exec script $flush -q $LMHOME/${session_id}.script 2.118 -fi 2.119 -# LabMaker:END 2.120 -LM_bash_profile 2.121 - cat $temp_file > $profile 2.122 - rm $temp_file 2.123 -} 2.124 - 2.125 -uninstall_from_bashrc() 2.126 -{ 2.127 - profile=$1 2.128 - cat $profile \ 2.129 - | sed '/LabMaker:START/,/LabMaker:END/ d' \ 2.130 - > $temp_file 2.131 - cat $temp_file > $profile 2.132 - rm $temp_file 2.133 -} 2.134 - 2.135 -install_editor() 2.136 -{ 2.137 -editor=$1 2.138 -[ -e $editor.orig ] && cp $editor.orig $editor 2.139 -cp $editor $editor.orig 2.140 -cat <<'editor_wrapper' | sed "s@EDITOR@$editor@" > $editor 2.141 -#!/bin/sh 2.142 - 2.143 -LMHOME=~/.lilalo 2.144 -if [ "${1#-}" = "$1" -a -d "$LMHOME" ] 2.145 -then 2.146 - LAB=`cat $LMHOME/lab` 2.147 - TIME="`date +%j${LAB}_%H:%M:%S`" 2.148 - DIR="" 2.149 - [ "${1#/}" = "$1" ] && DIR=$PWD/ 2.150 - DIFFNAME=$PPID_${TIME}_`echo $DIR$1| sed s@_@__@ | sed 's@/@_@g'`.diff 2.151 - tmp="/tmp/lm-saved-$$" 2.152 - touch $1 2.153 - cp -- "$1" $tmp 2> /dev/null 2.154 - EDITOR.orig "$@" || ERR=1 2.155 - diff $tmp $1 > $LMHOME/$DIFFNAME 2> /dev/null 2.156 - rm $tmp 2> /dev/null 2.157 - if [ "$ERR" = 1 ] 2.158 - then 2.159 - false 2.160 - else 2.161 - true 2.162 - fi 2.163 -else 2.164 - exec EDITOR.orig "$@" 2.165 -fi 2.166 -editor_wrapper 2.167 - 2.168 -} 2.169 - 2.170 - 2.171 -uninstall_editor() 2.172 -{ 2.173 - editor=$1 2.174 - [ -e $editor.orig ] && mv $editor.orig $editor 2.175 -} 2.176 - 2.177 -if [ "$1" != "-d" ] 2.178 -then 2.179 - # INSTALLING LM 2.180 - if [ $# -gt 0 ] 2.181 - then 2.182 - users_to_install="$*" 2.183 - fi 2.184 - 2.185 - if [ -z "$users_to_install" ] 2.186 - then 2.187 - show_usage 2.188 - exit 2.189 - fi 2.190 - 2.191 - for home in $users_to_install 2.192 - do 2.193 - # fix this! 2.194 - user=${home%/} 2.195 - user=${user##*/} 2.196 - mkdir -p $home/.lilalo 2.197 - echo $first_lab > $home/.lilalo/lab 2.198 - chown -R $user $home/.lilalo 2.199 - 2.200 - #if [ ! -e $home/.bash_profile ] 2.201 - #then 2.202 - # echo '. ~/.bashrc' >> ~/.bash_profile 2.203 - #fi 2.204 - #[ -e $home/.bash_profile ] \ 2.205 - # && install_to_profile $home/.bash_profile \ 2.206 - # && echo LabMaker is installed to $home/.bash_profile 2.207 - 2.208 - echo Don\'t forget to check .bash_profile for .bashrc call 2.209 - 2.210 - [ -e $home/.bash_profile ] && install_to_profile $home/.bash_profile \ 2.211 - && install_to_profile $home/.bash_profile \ 2.212 - && echo LabMaker is installed to $home/.bash_profile 2.213 - 2.214 - touch $home/.bashrc 2.215 - [ -e $home/.bashrc ] && install_to_bashrc $home/.bashrc \ 2.216 - && install_to_bashrc $home/.bashrc \ 2.217 - && echo LabMaker is installed to $home/.bashrc 2.218 - done 2.219 - 2.220 - for editor in $editors_to_install 2.221 - do 2.222 - [ -e $editor ] \ 2.223 - && install_editor $editor \ 2.224 - && echo LabMaker is installed to $editor 2.225 - done 2.226 -else 2.227 -# UNINSTALLING LM 2.228 - shift 2.229 - users_to_install="$*" 2.230 - for user in $users_to_install 2.231 - do 2.232 - home=$user 2.233 - mkdir -p $home/.lilalo 2.234 - echo $first_lab > $home/.lilalo/lab 2.235 - chown -R ${user##*/} $home/.lilalo 2.236 - 2.237 - #if [ ! -e $home/.bash_profile ] 2.238 - #then 2.239 - # echo '. ~/.bashrc' >> ~/.bash_profile 2.240 - #fi 2.241 - #[ -e $home/.bash_profile ] \ 2.242 - # && uninstall_from_profile $home/.bash_profile \ 2.243 - # && echo LabMaker is uninstalled from $home/.bash_profile 2.244 - 2.245 - [ -e $home/.profile ] && uninstall_from_profile $home/.profile \ 2.246 - && uninstall_from_profile $home/.profile \ 2.247 - && echo LabMaker is uninstalled from $home/.profile 2.248 - 2.249 - touch $home/.bashrc 2.250 - [ -e $home/.bashrc ] && uninstall_from_bashrc $home/.bashrc \ 2.251 - && uninstall_from_bashrc $home/.bashrc \ 2.252 - && echo LabMaker is uninstalled from $home/.bashrc 2.253 - done 2.254 - 2.255 - for editor in $editors_to_install 2.256 - do 2.257 - [ -e $editor ] \ 2.258 - && uninstall_editor $editor \ 2.259 - && echo LabMaker is uninstalled from $editor 2.260 - done 2.261 -fi
3.1 --- a/lm-report Mon Jul 21 11:24:53 2008 +0300 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,1186 +0,0 @@ 3.4 -#!/usr/bin/perl -w 3.5 - 3.6 -# 3.7 -# (c) Igor Chubin, imchubin@mail.ru, 2004-2005 3.8 -# 3.9 - 3.10 -use strict; 3.11 -use Getopt::Long; 3.12 -use Term::VT102; 3.13 -use Text::Iconv; 3.14 -use Data::Dumper; 3.15 - 3.16 -our $Config_File = "labmaker.conf"; 3.17 -our %Config = ( 3.18 - "skip_empty" => "yes", 3.19 - "skip_interrupted" => "no", 3.20 - "skip_wrong" => "no", 3.21 - "editors" => ["vi", "pico", "ee", "vim"], 3.22 - "pagers" => ["more", "less", "zmore", "zless", "info", 3.23 - "man", "mc", "trafshow", "screen", "cfdisk", 3.24 - "trafshow-bsd", "yes", "lynx", "links", "centericq" 3.25 - ], 3.26 - "terminal" => ["mc"], 3.27 - "suppress_editors" => "yes", 3.28 - "suppress_pagers" => "yes", 3.29 - "suppress_terminal" => "yes", 3.30 - 3.31 - "terminal_width" => 100, 3.32 - "terminal_height" => 100, 3.33 - "verbose" => "yes", 3.34 - 3.35 - "head_lines" => 5, 3.36 - "tail_lines" => 5, 3.37 - "skip_text" => "...", 3.38 - "show_time" => "yes", 3.39 - "show_diffs" => "yes", 3.40 - "show_comments" => "yes", 3.41 - 3.42 - "input" => "/root/.labmaker", 3.43 - "diffs" => "", 3.44 - "input_mask" => "*.script", 3.45 - "encoding" => "utf-8", 3.46 - 3.47 - "output" => "/var/www/lm/reportINDEX.html", 3.48 - #"output" => "report.xml", 3.49 - "output_mask" => "INDEX", 3.50 - "output_format" => "html", 3.51 - 3.52 - "signature" => "#lm:", 3.53 - "from" => "", 3.54 - "to" => "", 3.55 - "lab" => "", 3.56 - "keywords" => "linux command", 3.57 - "files_keywords" => "linux file", 3.58 - 3.59 - comment_width => "300", 3.60 - time_width => "60", 3.61 - 3.62 - "course-name" => "", 3.63 - "course-code" => "", 3.64 - "course-date" => "", 3.65 - "course-center" => "", 3.66 - "course-trainer" => "", 3.67 - "course-student" => "", 3.68 - 3.69 - ); 3.70 - 3.71 -our @Command_Lines; 3.72 -our @Command_Lines_Index; 3.73 -our @Diffs; 3.74 - 3.75 -our %Commands_Stat; # Statistics about commands usage 3.76 -our %Files_Stat; # Statistics about commands usage 3.77 - 3.78 -our %Search_Machines = ( 3.79 - "google" => { "query" => "http://www.google.com/search?q=" , 3.80 - "icon" => "google.ico" }, 3.81 - "freebsd" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=", 3.82 - "icon" => "freebsd.ico" }, 3.83 - "linux" => { "query" => "http://man.he.net/?topic=", 3.84 - "icon" => "linux.ico"}, 3.85 - "opennet" => { "query" => "http://www.opennet.ru/search.shtml?words=", 3.86 - "icon" => "opennet.ico"}, 3.87 - "local" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=", 3.88 - "icon" => "freebsd.ico" }, 3.89 - 3.90 - ); 3.91 - 3.92 -our %Elements_Visibility = ( 3.93 - "note" => "замечания", 3.94 - "diff" => "редактор", 3.95 - "time" => "время", 3.96 - "ttychange" => "терминал", 3.97 - "wrong_output wrong_cline wrong_root_output wrong_root_cline" 3.98 - => "команды с ошибками", 3.99 - "interrupted_output interrupted_cline interrupted_root_output interrupted_root_cline" 3.100 - => "прерванные команды", 3.101 - "tab_completion_output tab_completion_cline" 3.102 - => "продолжение с помощью tab" 3.103 -); 3.104 - 3.105 -sub init_variables; 3.106 -our $Html_Help; 3.107 -our $Html_About; 3.108 - 3.109 - 3.110 -sub load_diff_files 3.111 -{ 3.112 - my @pathes = @_; 3.113 - 3.114 - for my $path (@pathes) { 3.115 - my $template = "*.diff"; 3.116 - my @files = <$path/$template>; 3.117 - my $i=0; 3.118 - for my $file (@files) { 3.119 - my %diff; 3.120 - 3.121 - $diff{"path"}=$path; 3.122 - $diff{"uid"}="SET THIS"; 3.123 - 3.124 -# Сейчас UID определяется из названия каталога 3.125 -# откуда берутся diff-файлы 3.126 -# Это неправильно 3.127 -# 3.128 -# ВАРИАНТ: 3.129 -# К файлам жураналам должны прилагаться ситемны файлы, 3.130 -# мз которых и будет определяться соответствие 3.131 -# имён пользователей их uid'ам 3.132 -# 3.133 - $diff{"uid"} = 0 if $path =~ m@/root/@; 3.134 - 3.135 - $diff{"bind_to"}=""; 3.136 - $diff{"time_range"}=-1; 3.137 - 3.138 - next if not $file=~m@/(D?[0-9][0-9]?[0-9]?)[^/]*?([0-9]*):([0-9]*):?([0-9]*)@; 3.139 - $diff{"day"}=$1 || ""; 3.140 - $diff{"hour"}=$2; 3.141 - $diff{"min"}=$3; 3.142 - $diff{"sec"}=$4 || 0; 3.143 - 3.144 - $diff{"index"}=$i; 3.145 - 3.146 - print "diff loaded: $diff{day} $diff{hour}:$diff{min}:$diff{sec}\n"; 3.147 - 3.148 - local $/; 3.149 - open (F, "$file") 3.150 - or return "Can't open file $file ($_[0]) for reading"; 3.151 - my $text = <F>; 3.152 - if ($Config{"encoding"} && $Config{"encoding"} !~ /^utf-8$/i) { 3.153 - my $converter = Text::Iconv->new($Config{"encoding"}, "utf-8"); 3.154 - $text = $converter->convert($text); 3.155 - } 3.156 - close(F); 3.157 - $diff{"text"}=$text; 3.158 - #print "$file loaded ($diff{day})\n"; 3.159 - 3.160 - push @Diffs, \%diff; 3.161 - $i++; 3.162 - } 3.163 - } 3.164 -} 3.165 - 3.166 - 3.167 -sub bind_diff 3.168 -{ 3.169 -# my $path = shift; 3.170 -# my $pid = shift; 3.171 -# my $day = shift; 3.172 -# my $lab = shift; 3.173 - 3.174 - print "Trying to bind diff...\n"; 3.175 - 3.176 - my $cl = shift; 3.177 - my $hour = $cl->{"hour"}; 3.178 - my $min = $cl->{"min"}; 3.179 - my $sec = $cl->{"sec"}; 3.180 - 3.181 - my $min_dt = 10000; 3.182 - 3.183 - for my $diff (@Diffs) { 3.184 - # Check here date, time and user 3.185 - next if ($diff->{"day"} && $cl->{"day"} && ($cl->{"day"} ne $diff->{"day"})); 3.186 - #next if (!$diff->{"uid"} && $cl->{"euid"} != $diff->{"uid"}); 3.187 - 3.188 - my $dt=($diff->{"hour"}-$hour)*3600 +($diff->{"min"}-$min)*60 + ($diff->{"sec"}-$sec); 3.189 - if ($dt >0 && $dt < $min_dt && ($diff->{"time_range"} <0 || $dt < $diff->{"time_range"})) { 3.190 - print "Approppriate diff found: dt=$dt\n"; 3.191 - if ($diff->{"bind_to"}) { 3.192 - undef $diff->{"bind_to"}->{"diff"}; 3.193 - }; 3.194 - $diff->{"time_range"}=$dt; 3.195 - $diff->{"bind_to"}=$cl; 3.196 - 3.197 - $cl->{"diff"} = $diff->{"index"}; 3.198 - $min_dt = $dt; 3.199 - } 3.200 - 3.201 - } 3.202 -} 3.203 - 3.204 - 3.205 -sub extract_from_cline 3.206 -# Разобрать командную строку $_[1] и возвратить хэш, содержащий 3.207 -# номер первого появление команды в строке: 3.208 -# команда => первая позиция 3.209 -{ 3.210 - my $what = $_[0]; 3.211 - my $cline = $_[1]; 3.212 - my @lists = split /\;/, $cline; 3.213 - 3.214 - 3.215 - my @commands = (); 3.216 - for my $list (@lists) { 3.217 - push @commands, split /\|/, $list; 3.218 - } 3.219 - 3.220 - my %commands; 3.221 - my %files; 3.222 - my $i=0; 3.223 - for my $command (@commands) { 3.224 - $command =~ /\s*(\S+)\s*(.*)/; 3.225 - if ($1 && $1 eq "sudo" ) { 3.226 - $commands{"$1"}=$i++; 3.227 - $command =~ s/\s*sudo\s+//; 3.228 - } 3.229 - $command =~ /\s*(\S+)\s*(.*)/; 3.230 - if ($1 && !defined $commands{"$1"}) { 3.231 - $commands{"$1"}=$i++; 3.232 - }; 3.233 - if ($2) { 3.234 - my $args = $2; 3.235 - my @args = split (/\s+/, $args); 3.236 - for my $a (@args) { 3.237 - $files{"$a"}=$i++ 3.238 - if !defined $files{"$a"}; 3.239 - }; 3.240 - 3.241 - 3.242 - } 3.243 - } 3.244 - 3.245 - if ($what eq "commands") { 3.246 - return %commands; 3.247 - } else { 3.248 - return %files; 3.249 - } 3.250 - 3.251 -} 3.252 - 3.253 -sub load_command_lines 3.254 -{ 3.255 - my $lab_scripts_path = $_[0]; 3.256 - my $lab_scripts_mask = $_[1]; 3.257 - 3.258 - my $cline_re_base = qq' 3.259 - (?:\\^?([0-9]*C?)) # exitcode 3.260 - (?:_([0-9]+)_)? # uid 3.261 - (?:_([0-9]+)_) # pid 3.262 - (...?) # day 3.263 - (.?.?) # lab 3.264 - \\s # space separator 3.265 - ([0-9][0-9]):([0-9][0-9]):([0-9][0-9]) # time 3.266 - .\\[50D.\\[K # killing symbols 3.267 - (.*?([\$\#]\\s?)) # prompt 3.268 - (.*) # command line 3.269 - '; 3.270 - #my $cline_re = qr/$cline_re_base(?:$cline_re_base|$)/x; 3.271 - #my $cline_re = qr/(?:$cline_re_base)*$cline_re_base$/x; 3.272 - my $cline_re = qr/$cline_re_base/sx; 3.273 - my $cline_re1 = qr/$cline_re_base\x0D/sx; 3.274 - my $cline_re2 = qr/$cline_re_base$/sx; 3.275 - 3.276 - my $vt = Term::VT102->new ( 'cols' => $Config{"terminal_width"}, 3.277 - 'rows' => $Config{"terminal_height"}); 3.278 - my $cline_vt = Term::VT102->new ('cols' => $Config{"terminal_width"}, 3.279 - 'rows' => $Config{"terminal_height"}); 3.280 - 3.281 - my $converter = Text::Iconv->new($Config{"encoding"}, "utf-8") 3.282 - if ($Config{"encoding"} && $Config{"encoding"} !~ /^utf-8$/i); 3.283 - 3.284 - print "Loading lm-scripts...\n" if $Config{"verbose"} =~ /y/; 3.285 - 3.286 - my @lab_scripts = <$lab_scripts_path/$lab_scripts_mask>; 3.287 - my $file; 3.288 - my $files_number = $#lab_scripts; 3.289 - my $ii = 0; 3.290 - my $skip_info; 3.291 - 3.292 - my $commandlines_loaded =0; 3.293 - my $commandlines_processed =0; 3.294 - 3.295 - for $file (@lab_scripts){ 3.296 - #printf "\t%i %3.2f\n", $ii, (100*$ii++/$files_number) if $Config{"verbose"} =~ /y/; 3.297 - 3.298 - open (FILE, "$file"); 3.299 - binmode FILE; 3.300 - $file =~ m@.*/(.*?)-.*@; 3.301 - 3.302 - my $tty = $1; 3.303 - my $first_pass = 1; 3.304 - my %cl; 3.305 - my $last_output_length=0; 3.306 - while (<FILE>) { 3.307 - $commandlines_processed++; 3.308 - # time 3.309 - 3.310 - if (/[0-9][0-9]:[0-9][0-9]:[0-9][0-9].\[[0-9][0-9]D.\[K/ && m/$cline_re/) { 3.311 - s/.*\x0d(?!\x0a)//; 3.312 - # print "!!!",$_,"!!!\n"; 3.313 - # next; 3.314 - # while (m/$cline_re1/gs) { 3.315 - # } 3.316 - m/$cline_re2/gs; 3.317 - 3.318 - $commandlines_loaded++; 3.319 - $last_output_length=0; 3.320 - 3.321 - # Previous command 3.322 - my %last_cl = %cl; 3.323 - my $err = $1 || ""; 3.324 - 3.325 - 3.326 -=cut 3.327 - 3.328 -ТАБЛИЦА КОМАНД 3.329 - 3.330 - uid 3.331 - Идентификатор пользователя 3.332 - 3.333 - tty 3.334 - Идентификатор терминала, на котором была вызвана команда 3.335 - 3.336 - pid 3.337 - PID-процесса командного интерпретатора, 3.338 - в котором была вызвана команда 3.339 - 3.340 - lab 3.341 - лабораторная работа, к которой относится команда. 3.342 - Идентификатор текущей лабораторной работы 3.343 - хранится в файле ~/.labmaker/lab 3.344 - 3.345 - pwd (!) 3.346 - текущий каталог, из которого была вызвана команда 3.347 - 3.348 - day 3.349 - время вызова, день 3.350 - В действительности здесь хранится не время вызова команды, 3.351 - а с момента появления приглашения командного интерпретатора 3.352 - для ввода команды 3.353 - 3.354 - 3.355 - hour 3.356 - время вызова, час 3.357 - 3.358 - min 3.359 - время вызова, минута 3.360 - 3.361 - sec 3.362 - время вызова, секунда 3.363 - 3.364 - time (!) 3.365 - время вызова команды в Unix-формате. 3.366 - Предпочтительнее использовать этот формат чем hour:min:sec, 3.367 - использовавшийся в Labmaker 3.368 - 3.369 - fullprompt 3.370 - Приглашение командной строки 3.371 - 3.372 - prompt 3.373 - Сокращённое приглашение командной строки 3.374 - 3.375 - cline 3.376 - Командная строка 3.377 - 3.378 - output 3.379 - Результат выполнения команды 3.380 - 3.381 - diff 3.382 - Указатель на ассоциированный с командой diff 3.383 - 3.384 - note (!) 3.385 - Текстовый комментарий к команде. 3.386 - Может генерироваться из самого лога с помощью команд 3.387 - #^ Комментарий 3.388 - #v Комментарий 3.389 - в том случае, если для комментирования достаточно одной строки, 3.390 - или с помощью команд 3.391 - cat > /dev/null #^ Заголовок 3.392 - Текст 3.393 - ^D 3.394 - в том случае, если комментарий развёрнутый. 3.395 - В последнем случае комментарий может содержать 3.396 - заголовок, абзацы и несложное форматирование. 3.397 - 3.398 - Символ ^ или v после знака комментария # обозначает, 3.399 - к какой команде относится комментарий: 3.400 - к предыдущей (^) или последующей (v) 3.401 - 3.402 - err 3.403 - Код завершения командной строки 3.404 - 3.405 - histnum (!) 3.406 - Номер команды в истории командного интерпретатора 3.407 - 3.408 - status (!) 3.409 - Является ли данная команда вызванной (r), запомненной (s) 3.410 - или это подсказка completion (c). 3.411 - 3.412 - Команды, которые были вызваны и обработаны интерпретатором 3.413 - имеют состояние "r". К таким командам относится большинство 3.414 - команд вводимых в интерпретатор. 3.415 - 3.416 - Если команда набрана, но вызывать её по какой-либо причине 3.417 - не хочется (например, команда может быть не полной, вредоносной 3.418 - или просто бессмысленной в текущих условиях), 3.419 - её можно сбросить с помощью комбинации клавиш Ctrl-C 3.420 - (не путайте с прерыванием работающей команды! здесь она даже 3.421 - не запускается!). 3.422 - В таком случае она не выполняется, но попадает в журнал 3.423 - со статусом "s". 3.424 - 3.425 - Если команда появилась в журнале благодаря автопроолжению 3.426 - -- когда было показано несколько вариантов -- 3.427 - она имеет статус "c". 3.428 - 3.429 - euid 3.430 - Идентификатор пользователя от имени которого будет 3.431 - выполняться команда. 3.432 - Может отличаться от реального uid в том случае, 3.433 - если вызывается с помощью sudo 3.434 - 3.435 - 3.436 - version (!) 3.437 - Версия lilalo-prompt использовавшаяся при записи 3.438 - команды. 3.439 - 3.440 - 0 - версия использовавшая в labmaker. 3.441 - Отсутствует информация о текущем каталоге и номере в истории. 3.442 - Информация о версии также не указана в приглашении. 3.443 - 3.444 - 3.445 - 1 - версия использующаяся в lilalo 3.446 - 3.447 - raw_file (*) 3.448 - Имя файла, в котором находится бинарное представление журнала. 3.449 - Может содержать ключевое слово HERE, 3.450 - обозначающее что бинарное представление хранится 3.451 - непосредственно в базе данных в атрибуте raw_data 3.452 - 3.453 - raw_start (*) 3.454 - Начало блока командной строки в файле бинарного представления 3.455 - 3.456 - raw_end (*) 3.457 - Конец блока командной строки в файле бинарного представления 3.458 - 3.459 - raw_cline (*) 3.460 - Необработанная командная строка в бинарном виде 3.461 - 3.462 - raw_data (*) 3.463 - Бинарное представление команды и результатов её выполнения 3.464 - 3.465 - 3.466 - 3.467 - 3.468 -ТАБЛИЦА SESSION 3.469 - 3.470 - Информация о сеансах 3.471 - 3.472 - 3.473 - 3.474 - 3.475 -=cut 3.476 - 3.477 - # Parse new command 3.478 - $cl{"uid"} = $2; 3.479 - $cl{"euid"} = $cl{"uid"}; # Если в команде обнаружится sudo, euid поменяем на 0 3.480 - $cl{"pid"} = $3; 3.481 - $cl{"day"} = $4; 3.482 - $cl{"lab"} = $5; 3.483 - $cl{"hour"} = $6; 3.484 - $cl{"min"} = $7; 3.485 - $cl{"sec"} = $8; 3.486 - $cl{"fullprompt"} = $9; 3.487 - $cl{"prompt"} = $10; 3.488 - $cl{"raw_cline"} = $11; 3.489 - 3.490 - $cl{"err"} = 0; 3.491 - $cl{"output"} = ""; 3.492 - $cl{"tty"} = $tty; 3.493 - 3.494 - $cline_vt->process($cl{"raw_cline"}."\n"); 3.495 - $cl{"cline"} = $cline_vt->row_plaintext (1); 3.496 - $cl{"cline"} =~ s/\s*$//; 3.497 - $cline_vt->reset(); 3.498 - 3.499 - my %commands = extract_from_cline("commands", $cl{"cline"}); 3.500 - $cl{"euid"}=0 if defined $commands{"sudo"}; 3.501 - my @comms = sort { $commands{$a} cmp $commands{$b} } keys %commands; 3.502 - $cl{"last_command"} = $comms[$#comms] || "";