lilalo

view l3config.pm @ 101:c41cc9a4b5ea

* Пофиксил ошибку с неправильной кодировкой mywi-хинтов.
* Подготовил к переходу в иерархию /l3/
** Исправил пути для стилей,
** Забацал красивый l3-cgi-lite


l3-cgi-lite пока что не доделан до нужного уровня,
но я его скоро дорисую.
Уже сейчас это намного более качественный скрипт
через уродский l3-cgi

Он, конечно, поработал в свое время,
но лучше его заменить l3-cgi-lite


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