lilalo

view l3config.pm @ 129:34a84028ddea

File list cleaned up
author Igor Chubin <igor@chub.in>
date Fri Jul 04 17:40:51 2008 +0300 (2008-07-04)
parents 53b890d1ae90
children a92b17c77b57
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" => "xgu.ru",
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 "commands_to_show_at_a_go" => "100",
149 "start_from_command" => "0",
150 );
152 sub read_config_file
153 {
154 my $config = $_[0];
155 my $filename = $_[1];
156 open(CONFIG, "$filename")
157 or return;
158 while (<CONFIG>) {
159 chomp;
160 s/#.*//;
161 next if /^\s*$/;
162 my ($var, $val) = split /\s*=\s*/, $_, 2;
163 $var =~ s/\s*//;
164 $config->{$var} = $val;
165 }
166 close(CONFIG);
167 }
170 sub init_config
171 {
172 my %argv_config;
173 my %file_config;
174 read_config_file(\%file_config, $System_Config_File);
175 read_config_file(\%file_config, $User_Config_File);
176 GetOptions(\%argv_config, map "$_=s", keys %Config);
177 %Config = (%Config, %file_config, %argv_config);
178 for my $key (keys %Config) {
179 utf8::decode($Config{$key});
180 }
181 }