lilalo
view l3config.pm @ 128:56cd2abd3e8a
l3-upload dir is read from config file
author | igor@chub.in |
---|---|
date | Fri Jul 04 17:49:17 2008 +0300 (2008-07-04) |
parents | 3cd466f35ad6 |
children | 31ebdfe9797d |
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/",
94 "upload_dir" => "/var/www/xguru/l3shot",
96 "l3-agent" => "l3-agent",
97 "l3-backend" => "l3-backend",
99 "course-name" => "",
100 "course-code" => "",
101 "course-date" => "",
102 "course-center" => "",
103 "course-trainer" => "",
104 "course-student" => "",
106 "filter" => "",
107 #lm
108 "show_host" => "no",
110 "l3cd" => "", # Текущий контекст перехваченных команд
111 # Возможные варианты:
112 # КУРС/ДАТА-НАЧАЛА/МАШИНА/ПОЛЬЗОВАТЕЛЬ
113 # ДАТА-НАЧАЛА/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
114 # УНИКАЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
116 # Вспомогательные программы
117 #"l3-report" => "./lm-report",
118 "l3-report" => "./l3-report",
120 # Каталоги
121 "path_lilalo" => "/var/lilalo/",
122 "path_classes" => "/var/lilalo/classes/",
123 "path_lablogs" => "/var/lilalo/lablogs/",
124 "courses_path" => "/var/lilalo/courses/",
125 "outpath" => "/var/lilalo/out/",
126 "path_web" => "/var/www/l3", # Путь к web-отчётам
127 "path_share" => "./share/", # Путь к web-отчётам
129 # Файлы
130 "runfile" => "lm.run",
131 "logfile" => "lm.log",
133 "class" => "class", # Имя файла класса
134 "class_suffix" => ".xml", # Cуффикс файла класса
135 "classfile" => "",
137 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub",
138 "lmssh" => "./lm-ssh",
139 "lminstall" => "./lm-install",
140 "ssh_user" => "root",
142 "l3scripts" => "l3scripts",
145 "cgi_path_info" => "",
146 "cgi2file" => "",
148 "year" => "2006",
149 "commands_to_show_at_a_go" => "100",
150 "start_from_command" => "0",
151 );
153 sub read_config_file
154 {
155 my $config = $_[0];
156 my $filename = $_[1];
157 open(CONFIG, "$filename")
158 or return;
159 while (<CONFIG>) {
160 chomp;
161 s/#.*//;
162 next if /^\s*$/;
163 my ($var, $val) = split /\s*=\s*/, $_, 2;
164 $var =~ s/\s*//;
165 $config->{$var} = $val;
166 }
167 close(CONFIG);
168 }
171 sub init_config
172 {
173 my %argv_config;
174 my %file_config;
175 read_config_file(\%file_config, $System_Config_File);
176 read_config_file(\%file_config, $User_Config_File);
177 GetOptions(\%argv_config, map "$_=s", keys %Config);
178 %Config = (%Config, %file_config, %argv_config);
179 for my $key (keys %Config) {
180 utf8::decode($Config{$key});
181 }
182 }