lilalo

annotate l3config.pm @ 109:3cd466f35ad6

* Добавлено разбиения журнала на блоки
* Оптимизирована генерация всплывающих подсказок
* В заголовке указывается дата
* Переделано взаимодействие с mywi: код mywi интегрирован в lilalo
* Изменён способ вывода таблицы, теперь она лушче показывается в Opera и IE
* Изменён формат diff'а, теперь diff -u
author igor
date Wed Feb 13 02:41:57 2008 +0200 (2008-02-13)
parents 53b890d1ae90
children a92b17c77b57
rev   line source
devi@23 1 package l3config;
devi@23 2
devi@89 3 use utf8;
devi@23 4 use Exporter;
devi@30 5 use vars qw(@ISA @EXPORT $VERSION);
devi@23 6 use Getopt::Long;
devi@23 7
devi@23 8 @ISA = ('Exporter');
devi@23 9 @EXPORT = qw(%Config &init_config);
devi@23 10
devi@32 11 our $System_Config_File = "/etc/lilalo.conf";
devi@98 12 our $User_Config_File = "$ENV{HOME}/.l3rc";
devi@32 13 $ENV{HOME} ||= "/tmp";
devi@32 14
devi@32 15
devi@23 16 our %Config = (
devi@69 17 "skip_empty" => "yes",
devi@69 18 "skip_interrupted" => "no",
devi@69 19 "skip_wrong" => "no",
devi@69 20 "editors" => ["vi", "pico", "ee", "vim", "nano"],
devi@69 21 "pagers" => ["more", "less", "zmore", "zless", "info",
devi@69 22 "man", "mc", "trafshow", "screen", "cfdisk",
devi@69 23 "trafshow-bsd", "yes", "lynx", "links", "centericq"
devi@69 24 ],
devi@69 25 "full_output_commands" => ["cat"],
devi@69 26 "terminal" => ["mc"],
devi@69 27 "suppress_editors" => "yes",
devi@69 28 "suppress_pagers" => "yes",
devi@69 29 "suppress_terminal" => "yes",
devi@23 30
devi@69 31 "terminal_width" => 400,
devi@81 32 "terminal_height" => 300,
devi@69 33 "verbose" => "yes",
devi@23 34
devi@82 35 "head_lines" => 10,
devi@82 36 "tail_lines" => 10,
devi@82 37 "cache_head_lines" => 250,
devi@82 38 "cache_tail_lines" => 250,
devi@69 39 "skip_text" => "...",
devi@69 40 "show_time" => "yes",
devi@69 41 "show_diffs" => "yes",
devi@81 42 "show_screenshots" => "yes",
devi@69 43 "show_comments" => "yes",
devi@69 44 "show_notes" => "yes",
devi@23 45
devi@69 46 "input" => "$ENV{HOME}/.lilalo",
devi@69 47 "diffs" => "",
devi@69 48 "input_mask" => "*.script",
devi@69 49 "encoding" => "utf-8",
devi@23 50
devi@69 51 "cache" => "$ENV{HOME}/.lilalo/report.xml",
devi@69 52 "cache_stat" => "$ENV{HOME}/.lilalo/.report.dat",
devi@23 53
devi@69 54 "output" => "/tmp/report.html",
devi@69 55 "output_mask" => "INDEX",
devi@69 56 "output_format" => "html",
devi@101 57 "cgi_path" => "/l3",
devi@101 58 "frontend_files" => "/l3files",
devi@101 59 "frontend_css" => "/l3files/l3.css",
devi@81 60 "l3shot_path" => "/l3shot/",
devi@81 61 "l3shot_suffix" => ".png",
devi@69 62 "frontend_google_ico" => "/l3/google.ico",
devi@69 63 "frontend_linux_ico" => "/l3/linux.ico",
devi@69 64 "frontend_freebsd_ico" => "/l3/freebsd.ico",
devi@69 65 "frontend_opennet_ico" => "/l3/opennet.ico",
devi@69 66 "frontend_local_ico" => "/l3/freebsd.ico",
devi@23 67
devi@69 68 "mywi_server" => "127.0.0.1",
devi@69 69 "mywi_port" => "19801",
devi@31 70
devi@69 71 "stat_inactivity_interval" => "1800",
devi@23 72
devi@69 73 "signature" => "#lm:",
devi@69 74 "from" => "",
devi@69 75 "to" => "",
devi@69 76 "lab" => "",
devi@69 77 "keywords" => "linux command",
devi@69 78 "files_keywords" => "linux file",
devi@27 79
devi@69 80 comment_width => "300",
devi@85 81 note_width => "500",
devi@85 82 time_width => "6em",
devi@30 83
devi@85 84 "mode" => "daemon", # daemon | normal
devi@69 85 "daemon_sleep_interval" => "10",
devi@85 86 "detach" => "yes",
devi@69 87 "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid",
devi@30 88
devi@106 89 "backend_address" => "xgu.ru",
devi@69 90 "backend_port" => "18030",
devi@69 91 "backend_pidfile" => "/tmp/l3-backend.pid",
devi@69 92 "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml",
devi@98 93 "backend_datadir" => "/var/lilalo/lablogs-xml/",
devi@30 94
devi@85 95 "l3-agent" => "l3-agent",
devi@69 96 "l3-backend" => "l3-backend",
devi@30 97
devi@69 98 "course-name" => "",
devi@69 99 "course-code" => "",
devi@85 100 "course-date" => "",
devi@69 101 "course-center" => "",
devi@69 102 "course-trainer" => "",
devi@69 103 "course-student" => "",
devi@30 104
devi@85 105 "filter" => "",
devi@58 106 #lm
devi@69 107 "show_host" => "no",
devi@30 108
devi@98 109 "l3cd" => "", # Текущий контекст перехваченных команд
devi@98 110 # Возможные варианты:
devi@98 111 # КУРС/ДАТА-НАЧАЛА/МАШИНА/ПОЛЬЗОВАТЕЛЬ
devi@98 112 # ДАТА-НАЧАЛА/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
devi@98 113 # УНИКАЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
devi@98 114
devi@58 115 # Вспомогательные программы
devi@69 116 #"l3-report" => "./lm-report",
devi@85 117 "l3-report" => "./l3-report",
devi@40 118
devi@58 119 # Каталоги
devi@69 120 "path_lilalo" => "/var/lilalo/",
devi@69 121 "path_classes" => "/var/lilalo/classes/",
devi@69 122 "path_lablogs" => "/var/lilalo/lablogs/",
devi@69 123 "courses_path" => "/var/lilalo/courses/",
devi@85 124 "outpath" => "/var/lilalo/out/",
devi@85 125 "path_web" => "/var/www/l3", # Путь к web-отчётам
devi@69 126 "path_share" => "./share/", # Путь к web-отчётам
devi@48 127
devi@58 128 # Файлы
devi@85 129 "runfile" => "lm.run",
devi@85 130 "logfile" => "lm.log",
devi@58 131
devi@85 132 "class" => "class", # Имя файла класса
devi@69 133 "class_suffix" => ".xml", # Cуффикс файла класса
devi@85 134 "classfile" => "",
devi@58 135
devi@85 136 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub",
devi@85 137 "lmssh" => "./lm-ssh",
devi@85 138 "lminstall" => "./lm-install",
devi@96 139 "ssh_user" => "root",
devi@58 140
devi@85 141 "l3scripts" => "l3scripts",
devi@58 142
devi@58 143
devi@69 144 "cgi_path_info" => "",
devi@85 145 "cgi2file" => "",
devi@58 146
devi@85 147 "year" => "2006",
igor@109 148 "commands_to_show_at_a_go" => "100",
igor@109 149 "start_from_command" => "0",
devi@58 150 );
devi@23 151
devi@23 152 sub read_config_file
devi@23 153 {
devi@23 154 my $config = $_[0];
devi@23 155 my $filename = $_[1];
devi@23 156 open(CONFIG, "$filename")
devi@23 157 or return;
devi@23 158 while (<CONFIG>) {
devi@98 159 chomp;
devi@23 160 s/#.*//;
devi@23 161 next if /^\s*$/;
devi@23 162 my ($var, $val) = split /\s*=\s*/, $_, 2;
devi@23 163 $var =~ s/\s*//;
devi@23 164 $config->{$var} = $val;
devi@23 165 }
devi@23 166 close(CONFIG);
devi@23 167 }
devi@23 168
devi@23 169
devi@23 170 sub init_config
devi@23 171 {
devi@23 172 my %argv_config;
devi@23 173 my %file_config;
devi@32 174 read_config_file(\%file_config, $System_Config_File);
devi@32 175 read_config_file(\%file_config, $User_Config_File);
devi@23 176 GetOptions(\%argv_config, map "$_=s", keys %Config);
devi@23 177 %Config = (%Config, %file_config, %argv_config);
devi@89 178 for my $key (keys %Config) {
devi@89 179 utf8::decode($Config{$key});
devi@89 180 }
devi@23 181 }
devi@23 182