devi@23: package l3config; devi@23: devi@89: use utf8; devi@23: use Exporter; devi@30: use vars qw(@ISA @EXPORT $VERSION); devi@23: use Getopt::Long; devi@23: devi@23: @ISA = ('Exporter'); devi@23: @EXPORT = qw(%Config &init_config); devi@23: devi@32: our $System_Config_File = "/etc/lilalo.conf"; devi@98: our $User_Config_File = "$ENV{HOME}/.l3rc"; devi@32: $ENV{HOME} ||= "/tmp"; devi@32: devi@32: devi@23: our %Config = ( devi@69: "skip_empty" => "yes", devi@69: "skip_interrupted" => "no", devi@69: "skip_wrong" => "no", devi@69: "editors" => ["vi", "pico", "ee", "vim", "nano"], devi@69: "pagers" => ["more", "less", "zmore", "zless", "info", devi@69: "man", "mc", "trafshow", "screen", "cfdisk", devi@69: "trafshow-bsd", "yes", "lynx", "links", "centericq" devi@69: ], devi@69: "full_output_commands" => ["cat"], devi@69: "terminal" => ["mc"], devi@69: "suppress_editors" => "yes", devi@69: "suppress_pagers" => "yes", devi@69: "suppress_terminal" => "yes", devi@23: devi@69: "terminal_width" => 400, igor@152: "terminal_height" => 1000, devi@69: "verbose" => "yes", devi@23: devi@82: "head_lines" => 10, devi@82: "tail_lines" => 10, igor@152: "cache_head_lines" => 2500, igor@152: "cache_tail_lines" => 2500, devi@69: "skip_text" => "...", devi@69: "show_time" => "yes", devi@69: "show_diffs" => "yes", devi@81: "show_screenshots" => "yes", devi@69: "show_comments" => "yes", devi@69: "show_notes" => "yes", devi@23: devi@69: "input" => "$ENV{HOME}/.lilalo", devi@69: "diffs" => "", devi@69: "input_mask" => "*.script", devi@69: "encoding" => "utf-8", devi@23: devi@69: "cache" => "$ENV{HOME}/.lilalo/report.xml", devi@69: "cache_stat" => "$ENV{HOME}/.lilalo/.report.dat", devi@23: devi@69: "output" => "/tmp/report.html", devi@69: "output_mask" => "INDEX", devi@69: "output_format" => "html", devi@101: "cgi_path" => "/l3", devi@101: "frontend_files" => "/l3files", devi@101: "frontend_css" => "/l3files/l3.css", devi@81: "l3shot_path" => "/l3shot/", devi@81: "l3shot_suffix" => ".png", devi@69: "frontend_google_ico" => "/l3/google.ico", devi@69: "frontend_linux_ico" => "/l3/linux.ico", devi@69: "frontend_freebsd_ico" => "/l3/freebsd.ico", devi@69: "frontend_opennet_ico" => "/l3/opennet.ico", devi@69: "frontend_local_ico" => "/l3/freebsd.ico", devi@23: devi@69: "mywi_server" => "127.0.0.1", devi@69: "mywi_port" => "19801", devi@31: devi@69: "stat_inactivity_interval" => "1800", devi@23: devi@69: "signature" => "#lm:", devi@69: "from" => "", devi@69: "to" => "", devi@69: "lab" => "", devi@69: "keywords" => "linux command", devi@69: "files_keywords" => "linux file", devi@27: devi@69: comment_width => "300", devi@85: note_width => "500", devi@85: time_width => "6em", devi@30: devi@85: "mode" => "daemon", # daemon | normal devi@69: "daemon_sleep_interval" => "10", devi@85: "detach" => "yes", devi@69: "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid", devi@30: devi@106: "backend_address" => "xgu.ru", devi@69: "backend_port" => "18030", devi@69: "backend_pidfile" => "/tmp/l3-backend.pid", devi@69: "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml", devi@98: "backend_datadir" => "/var/lilalo/lablogs-xml/", igor@135: "upload_dir" => "/var/www/l3shot", devi@30: devi@85: "l3-agent" => "l3-agent", devi@69: "l3-backend" => "l3-backend", devi@30: devi@69: "course-name" => "", devi@69: "course-code" => "", devi@85: "course-date" => "", devi@69: "course-center" => "", devi@69: "course-trainer" => "", devi@69: "course-student" => "", devi@30: devi@85: "filter" => "", devi@58: #lm devi@69: "show_host" => "no", devi@30: devi@98: "l3cd" => "", # Текущий контекст перехваченных команд devi@98: # Возможные варианты: devi@98: # КУРС/ДАТА-НАЧАЛА/МАШИНА/ПОЛЬЗОВАТЕЛЬ devi@98: # ДАТА-НАЧАЛА/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ devi@98: # УНИКАЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ/КУРС/МАШИНА/ПОЛЬЗОВАТЕЛЬ devi@98: devi@58: # Вспомогательные программы devi@69: #"l3-report" => "./lm-report", devi@85: "l3-report" => "./l3-report", devi@40: devi@58: # Каталоги devi@69: "path_lilalo" => "/var/lilalo/", devi@69: "path_classes" => "/var/lilalo/classes/", devi@69: "path_lablogs" => "/var/lilalo/lablogs/", devi@69: "courses_path" => "/var/lilalo/courses/", devi@85: "outpath" => "/var/lilalo/out/", devi@85: "path_web" => "/var/www/l3", # Путь к web-отчётам devi@69: "path_share" => "./share/", # Путь к web-отчётам devi@48: devi@58: # Файлы devi@85: "runfile" => "lm.run", devi@85: "logfile" => "lm.log", devi@58: devi@85: "class" => "class", # Имя файла класса devi@69: "class_suffix" => ".xml", # Cуффикс файла класса devi@85: "classfile" => "", devi@58: devi@85: "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub", devi@85: "lmssh" => "./lm-ssh", devi@85: "lminstall" => "./lm-install", devi@96: "ssh_user" => "root", devi@58: devi@85: "l3scripts" => "l3scripts", devi@58: devi@58: devi@69: "cgi_path_info" => "", devi@85: "cgi2file" => "", devi@58: devi@85: "year" => "2006", igor@109: "commands_to_show_at_a_go" => "100", igor@109: "start_from_command" => "0", devi@58: ); devi@23: devi@23: sub read_config_file devi@23: { devi@23: my $config = $_[0]; devi@23: my $filename = $_[1]; devi@23: open(CONFIG, "$filename") devi@23: or return; devi@23: while () { devi@98: chomp; devi@23: s/#.*//; devi@23: next if /^\s*$/; devi@23: my ($var, $val) = split /\s*=\s*/, $_, 2; devi@23: $var =~ s/\s*//; devi@23: $config->{$var} = $val; devi@23: } devi@23: close(CONFIG); devi@23: } devi@23: devi@23: devi@23: sub init_config devi@23: { devi@23: my %argv_config; devi@23: my %file_config; devi@32: read_config_file(\%file_config, $System_Config_File); devi@32: read_config_file(\%file_config, $User_Config_File); devi@23: GetOptions(\%argv_config, map "$_=s", keys %Config); devi@23: %Config = (%Config, %file_config, %argv_config); devi@89: for my $key (keys %Config) { devi@89: utf8::decode($Config{$key}); devi@89: } devi@23: } devi@23: