devi@32: devi@23: package l3config; devi@23: 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@32: our $User_Config_File = "$ENV{HOME}/.lilalo.conf"; 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, devi@81: "terminal_height" => 300, devi@69: "verbose" => "yes", devi@23: devi@69: "head_lines" => 5, devi@69: "tail_lines" => 5, devi@81: "cache_head_lines" => 150, devi@81: "cache_tail_lines" => 150, 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@69: "frontend_css" => "/l3/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@69: note_width => "500", devi@75: time_width => "6em", devi@30: devi@69: "mode" => "daemon", # daemon | normal devi@69: "daemon_sleep_interval" => "10", devi@69: "detach" => "yes", devi@69: "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid", devi@30: devi@79: "backend_address" => "192.168.15.254", devi@69: "backend_port" => "18030", devi@69: "backend_pidfile" => "/tmp/l3-backend.pid", devi@69: "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml", devi@30: devi@69: "l3-agent" => "l3-agent", devi@69: "l3-backend" => "l3-backend", devi@30: devi@69: "course-name" => "", devi@69: "course-code" => "", devi@69: "course-date" => "", devi@69: "course-center" => "", devi@69: "course-trainer" => "", devi@69: "course-student" => "", devi@30: devi@69: "filter" => "", devi@58: #lm devi@69: "show_host" => "no", devi@30: devi@58: # Вспомогательные программы devi@69: #"l3-report" => "./lm-report", devi@69: "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@69: "outpath" => "/var/lilalo/out/", devi@69: "path_web" => "/var/www/l3", # Путь к web-отчётам devi@69: "path_share" => "./share/", # Путь к web-отчётам devi@48: devi@58: # Файлы devi@69: "runfile" => "lm.run", devi@69: "logfile" => "lm.log", devi@58: devi@69: "class" => "class", # Имя файла класса devi@69: "class_suffix" => ".xml", # Cуффикс файла класса devi@69: "classfile" => "", devi@58: devi@69: "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub", devi@69: "lmssh" => "./lm-ssh", devi@69: "lminstall" => "./lm-install", devi@79: "ssh_user" => "r", devi@58: devi@69: "l3scripts" => "l3scripts", devi@58: devi@58: devi@69: "cgi_path_info" => "", devi@69: "cgi2file" => "", devi@58: devi@58: "year" => "2006", 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@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@23: } devi@23: