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,
|
igor@152
|
32 "terminal_height" => 1000,
|
devi@69
|
33 "verbose" => "yes",
|
devi@23
|
34
|
devi@82
|
35 "head_lines" => 10,
|
devi@82
|
36 "tail_lines" => 10,
|
igor@152
|
37 "cache_head_lines" => 2500,
|
igor@152
|
38 "cache_tail_lines" => 2500,
|
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/",
|
igor@135
|
94 "upload_dir" => "/var/www/l3shot",
|
devi@30
|
95
|
devi@85
|
96 "l3-agent" => "l3-agent",
|
devi@69
|
97 "l3-backend" => "l3-backend",
|
devi@30
|
98
|
devi@69
|
99 "course-name" => "",
|
devi@69
|
100 "course-code" => "",
|
devi@85
|
101 "course-date" => "",
|
devi@69
|
102 "course-center" => "",
|
devi@69
|
103 "course-trainer" => "",
|
devi@69
|
104 "course-student" => "",
|
devi@30
|
105
|
devi@85
|
106 "filter" => "",
|
devi@58
|
107 #lm
|
devi@69
|
108 "show_host" => "no",
|
devi@30
|
109
|
devi@98
|
110 "l3cd" => "", # Текущий контекст перехваченных команд
|
devi@98
|
111 # Возможные варианты:
|
devi@98
|
112 # КУРС/ДАТА-НАЧАЛА/МАШИНА/ПОЛЬЗОВАТЕЛЬ
|
devi@98
|
113 # ДАТА-НАЧАЛА/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
|
devi@98
|
114 # УНИКАЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
|
devi@98
|
115
|
devi@58
|
116 # Вспомогательные программы
|
devi@69
|
117 #"l3-report" => "./lm-report",
|
devi@85
|
118 "l3-report" => "./l3-report",
|
devi@40
|
119
|
devi@58
|
120 # Каталоги
|
devi@69
|
121 "path_lilalo" => "/var/lilalo/",
|
devi@69
|
122 "path_classes" => "/var/lilalo/classes/",
|
devi@69
|
123 "path_lablogs" => "/var/lilalo/lablogs/",
|
devi@69
|
124 "courses_path" => "/var/lilalo/courses/",
|
devi@85
|
125 "outpath" => "/var/lilalo/out/",
|
devi@85
|
126 "path_web" => "/var/www/l3", # Путь к web-отчётам
|
devi@69
|
127 "path_share" => "./share/", # Путь к web-отчётам
|
devi@48
|
128
|
devi@58
|
129 # Файлы
|
devi@85
|
130 "runfile" => "lm.run",
|
devi@85
|
131 "logfile" => "lm.log",
|
devi@58
|
132
|
devi@85
|
133 "class" => "class", # Имя файла класса
|
devi@69
|
134 "class_suffix" => ".xml", # Cуффикс файла класса
|
devi@85
|
135 "classfile" => "",
|
devi@58
|
136
|
devi@85
|
137 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub",
|
devi@85
|
138 "lmssh" => "./lm-ssh",
|
devi@85
|
139 "lminstall" => "./lm-install",
|
devi@96
|
140 "ssh_user" => "root",
|
devi@58
|
141
|
devi@85
|
142 "l3scripts" => "l3scripts",
|
devi@58
|
143
|
devi@58
|
144
|
devi@69
|
145 "cgi_path_info" => "",
|
devi@85
|
146 "cgi2file" => "",
|
devi@58
|
147
|
devi@85
|
148 "year" => "2006",
|
igor@109
|
149 "commands_to_show_at_a_go" => "100",
|
igor@109
|
150 "start_from_command" => "0",
|
devi@58
|
151 );
|
devi@23
|
152
|
devi@23
|
153 sub read_config_file
|
devi@23
|
154 {
|
devi@23
|
155 my $config = $_[0];
|
devi@23
|
156 my $filename = $_[1];
|
devi@23
|
157 open(CONFIG, "$filename")
|
devi@23
|
158 or return;
|
devi@23
|
159 while (<CONFIG>) {
|
devi@98
|
160 chomp;
|
devi@23
|
161 s/#.*//;
|
devi@23
|
162 next if /^\s*$/;
|
devi@23
|
163 my ($var, $val) = split /\s*=\s*/, $_, 2;
|
devi@23
|
164 $var =~ s/\s*//;
|
devi@23
|
165 $config->{$var} = $val;
|
devi@23
|
166 }
|
devi@23
|
167 close(CONFIG);
|
devi@23
|
168 }
|
devi@23
|
169
|
devi@23
|
170
|
devi@23
|
171 sub init_config
|
devi@23
|
172 {
|
devi@23
|
173 my %argv_config;
|
devi@23
|
174 my %file_config;
|
devi@32
|
175 read_config_file(\%file_config, $System_Config_File);
|
devi@32
|
176 read_config_file(\%file_config, $User_Config_File);
|
devi@23
|
177 GetOptions(\%argv_config, map "$_=s", keys %Config);
|
devi@23
|
178 %Config = (%Config, %file_config, %argv_config);
|
devi@89
|
179 for my $key (keys %Config) {
|
devi@89
|
180 utf8::decode($Config{$key});
|
devi@89
|
181 }
|
devi@23
|
182 }
|
devi@23
|
183
|