lilalo

annotate l3config.pm @ 156:a0daf0c3fa52

bsd fix
author Igor Chubin <igor@chub.in>
date Mon Nov 28 13:15:16 2011 +0200 (2011-11-28)
parents a2bd59599719
children
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');
igor@155 9 @EXPORT = qw(%Config &init_config &init_config_without_command_line_processing);
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",
igor@155 52 "cache_sqlite" => "$ENV{HOME}/.lilalo/report.sqlite",
devi@69 53 "cache_stat" => "$ENV{HOME}/.lilalo/.report.dat",
devi@23 54
devi@69 55 "output" => "/tmp/report.html",
devi@69 56 "output_mask" => "INDEX",
devi@69 57 "output_format" => "html",
devi@101 58 "cgi_path" => "/l3",
devi@101 59 "frontend_files" => "/l3files",
devi@101 60 "frontend_css" => "/l3files/l3.css",
devi@81 61 "l3shot_path" => "/l3shot/",
devi@81 62 "l3shot_suffix" => ".png",
devi@69 63 "frontend_google_ico" => "/l3/google.ico",
devi@69 64 "frontend_linux_ico" => "/l3/linux.ico",
devi@69 65 "frontend_freebsd_ico" => "/l3/freebsd.ico",
devi@69 66 "frontend_opennet_ico" => "/l3/opennet.ico",
devi@69 67 "frontend_local_ico" => "/l3/freebsd.ico",
devi@23 68
devi@69 69 "mywi_server" => "127.0.0.1",
devi@69 70 "mywi_port" => "19801",
devi@31 71
devi@69 72 "stat_inactivity_interval" => "1800",
devi@23 73
devi@69 74 "signature" => "#lm:",
devi@69 75 "from" => "",
devi@69 76 "to" => "",
devi@69 77 "lab" => "",
devi@69 78 "keywords" => "linux command",
devi@69 79 "files_keywords" => "linux file",
devi@27 80
devi@69 81 comment_width => "300",
devi@85 82 note_width => "500",
devi@85 83 time_width => "6em",
devi@30 84
devi@85 85 "mode" => "daemon", # daemon | normal
devi@69 86 "daemon_sleep_interval" => "10",
devi@85 87 "detach" => "yes",
devi@69 88 "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid",
devi@30 89
devi@106 90 "backend_address" => "xgu.ru",
devi@69 91 "backend_port" => "18030",
devi@69 92 "backend_pidfile" => "/tmp/l3-backend.pid",
devi@69 93 "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml",
devi@98 94 "backend_datadir" => "/var/lilalo/lablogs-xml/",
igor@135 95 "upload_dir" => "/var/www/l3shot",
devi@30 96
devi@85 97 "l3-agent" => "l3-agent",
devi@69 98 "l3-backend" => "l3-backend",
devi@30 99
devi@69 100 "course-name" => "",
devi@69 101 "course-code" => "",
devi@85 102 "course-date" => "",
devi@69 103 "course-center" => "",
devi@69 104 "course-trainer" => "",
devi@69 105 "course-student" => "",
devi@30 106
devi@85 107 "filter" => "",
devi@58 108 #lm
devi@69 109 "show_host" => "no",
devi@30 110
devi@98 111 "l3cd" => "", # Текущий контекст перехваченных команд
devi@98 112 # Возможные варианты:
devi@98 113 # КУРС/ДАТА-НАЧАЛА/МАШИНА/ПОЛЬЗОВАТЕЛЬ
devi@98 114 # ДАТА-НАЧАЛА/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
devi@98 115 # УНИКАЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ
devi@98 116
devi@58 117 # Вспомогательные программы
devi@69 118 #"l3-report" => "./lm-report",
devi@85 119 "l3-report" => "./l3-report",
devi@40 120
devi@58 121 # Каталоги
devi@69 122 "path_lilalo" => "/var/lilalo/",
devi@69 123 "path_classes" => "/var/lilalo/classes/",
devi@69 124 "path_lablogs" => "/var/lilalo/lablogs/",
devi@69 125 "courses_path" => "/var/lilalo/courses/",
devi@85 126 "outpath" => "/var/lilalo/out/",
devi@85 127 "path_web" => "/var/www/l3", # Путь к web-отчётам
devi@69 128 "path_share" => "./share/", # Путь к web-отчётам
devi@48 129
devi@58 130 # Файлы
devi@85 131 "runfile" => "lm.run",
devi@85 132 "logfile" => "lm.log",
devi@58 133
devi@85 134 "class" => "class", # Имя файла класса
devi@69 135 "class_suffix" => ".xml", # Cуффикс файла класса
devi@85 136 "classfile" => "",
devi@58 137
devi@85 138 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub",
devi@85 139 "lmssh" => "./lm-ssh",
devi@85 140 "lminstall" => "./lm-install",
devi@96 141 "ssh_user" => "root",
devi@58 142
devi@85 143 "l3scripts" => "l3scripts",
devi@58 144
devi@58 145
devi@69 146 "cgi_path_info" => "",
devi@85 147 "cgi2file" => "",
devi@58 148
devi@85 149 "year" => "2006",
igor@109 150 "commands_to_show_at_a_go" => "100",
igor@109 151 "start_from_command" => "0",
devi@58 152 );
devi@23 153
devi@23 154 sub read_config_file
devi@23 155 {
igor@155 156 my $config = $_[0];
igor@155 157 my $filename = $_[1];
igor@155 158 open(CONFIG, "$filename")
igor@155 159 or return;
igor@155 160 while (<CONFIG>) {
devi@98 161 chomp;
igor@155 162 s/#.*//;
igor@155 163 next if /^\s*$/;
igor@155 164 my ($var, $val) = split /\s*=\s*/, $_, 2;
igor@155 165 $var =~ s/\s*//;
igor@155 166 $config->{$var} = $val;
igor@155 167 }
igor@155 168 close(CONFIG);
devi@23 169 }
devi@23 170
devi@23 171
devi@23 172 sub init_config
devi@23 173 {
igor@155 174 my %argv_config;
igor@155 175 my %file_config;
igor@155 176 read_config_file(\%file_config, $System_Config_File);
igor@155 177 read_config_file(\%file_config, $User_Config_File);
igor@155 178 GetOptions(\%argv_config, map "$_=s", keys %Config);
igor@155 179 %Config = (%Config, %file_config, %argv_config);
devi@89 180 for my $key (keys %Config) {
devi@89 181 utf8::decode($Config{$key});
devi@89 182 }
devi@23 183 }
devi@23 184
igor@155 185 sub init_config_without_command_line_processing
igor@155 186 {
igor@155 187 my %argv_config;
igor@155 188 my %file_config;
igor@155 189 read_config_file(\%file_config, $System_Config_File);
igor@155 190 read_config_file(\%file_config, $User_Config_File);
igor@155 191 %Config = (%Config, %file_config);
igor@155 192 for my $key (keys %Config) {
igor@155 193 utf8::decode($Config{$key});
igor@155 194 }
igor@155 195 }
igor@155 196