lilalo

view l3config.pm @ 46:f13cd5b4f2d0

Исправления
author devi
date Tue Nov 22 23:54:49 2005 +0200 (2005-11-22)
parents 34f3ce44c365
children 568bab7090fc
line source
2 package l3config;
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}/.lilalo.conf";
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 "terminal" => ["mc"],
26 "suppress_editors" => "yes",
27 "suppress_pagers" => "yes",
28 "suppress_terminal" => "yes",
30 "terminal_width" => 400,
31 "terminal_height" => 100,
32 "verbose" => "yes",
34 "head_lines" => 5,
35 "tail_lines" => 5,
36 "cache_head_lines" => 50,
37 "cache_tail_lines" => 50,
38 "skip_text" => "...",
39 "show_time" => "yes",
40 "show_diffs" => "yes",
41 "show_comments" => "yes",
42 "show_notes" => "yes",
44 "input" => "$ENV{HOME}/.lilalo",
45 "diffs" => "",
46 "input_mask" => "*.script",
47 "encoding" => "utf-8",
49 "cache" => "$ENV{HOME}/.lilalo/report.xml",
50 "cache_stat" => "$ENV{HOME}/.lilalo/.report.dat",
52 "output" => "/tmp/report.html",
53 "output_mask" => "INDEX",
54 "output_format" => "html",
55 "frontend_css" => "/l3/l3.css",
56 "frontend_google_ico" => "/l3/google.ico",
57 "frontend_linux_ico" => "/l3/linux.ico",
58 "frontend_freebsd_ico" => "/l3/freebsd.ico",
59 "frontend_opennet_ico" => "/l3/opennet.ico",
60 "frontend_local_ico" => "/l3/freebsd.ico",
62 "mywi_server" => "127.0.0.1",
63 "mywi_port" => "19800",
65 "stat_inactivity_interval" => "1800",
67 "signature" => "#lm:",
68 "from" => "",
69 "to" => "",
70 "lab" => "",
71 "keywords" => "linux command",
72 "files_keywords" => "linux file",
74 comment_width => "300",
75 note_width => "500",
76 time_width => "60",
78 "mode" => "daemon", # daemon | normal
79 "daemon_sleep_interval" => "1",
80 "detach" => "yes",
81 "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid",
83 "backend_address" => "192.168.15.254",
84 "backend_port" => "18030",
85 "backend_pidfile" => "/tmp/l3-backend.pid",
86 "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml",
88 "l3-agent" => "l3-agent",
89 "l3-backend" => "l3-backend",
91 "course-name" => "",
92 "course-code" => "",
93 "course-date" => "",
94 "course-center" => "",
95 "course-trainer" => "",
96 "course-student" => "",
98 "filter" => "",
99 #lm
100 "show_host" => "no",
102 # Вспомогательные программы
103 #"l3-report" => "./lm-report",
104 "l3-report" => "./l3-report",
106 # Каталоги
107 "path_lilalo" => "/var/lilalo/",
108 "path_classes" => "/var/lilalo/classes/",
109 "path_lablogs" => "/var/lilalo/lablogs/",
110 "courses_path" => "/var/lilalo/courses/",
111 "outpath" => "/var/lilalo/out/",
112 "path_web" => "/var/www/l3", # Путь к web-отчётам
113 "path_share" => "./share/", # Путь к web-отчётам
115 # Файлы
116 "runfile" => "lm.run",
117 "logfile" => "lm.log",
119 "class" => "class", # Имя файла класса
120 "class_suffix" => ".xml", # Cуффикс файла класса
121 "classfile" => "",
123 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub",
124 "lmssh" => "./lm-ssh",
125 "lminstall" => "./lm-install",
126 "ssh_user" => "root",
128 "l3scripts" => "l3scripts",
130 );
132 sub read_config_file
133 {
134 my $config = $_[0];
135 my $filename = $_[1];
136 open(CONFIG, "$filename")
137 or return;
138 while (<CONFIG>) {
139 s/#.*//;
140 next if /^\s*$/;
141 my ($var, $val) = split /\s*=\s*/, $_, 2;
142 $var =~ s/\s*//;
143 $config->{$var} = $val;
144 }
145 close(CONFIG);
146 }
149 sub init_config
150 {
151 my %argv_config;
152 my %file_config;
153 read_config_file(\%file_config, $System_Config_File);
154 read_config_file(\%file_config, $User_Config_File);
155 GetOptions(\%argv_config, map "$_=s", keys %Config);
156 %Config = (%Config, %file_config, %argv_config);
157 }