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@23: our $Config_File = "labmaker.conf"; devi@23: our %Config = ( devi@23: "skip_empty" => "yes", devi@23: "skip_interrupted" => "no", devi@23: "skip_wrong" => "no", devi@28: "editors" => ["vi", "pico", "ee", "vim", "nano"], devi@23: "pagers" => ["more", "less", "zmore", "zless", "info", devi@23: "man", "mc", "trafshow", "screen", "cfdisk", devi@23: "trafshow-bsd", "yes", "lynx", "links", "centericq" devi@23: ], devi@23: "terminal" => ["mc"], devi@23: "suppress_editors" => "yes", devi@23: "suppress_pagers" => "yes", devi@23: "suppress_terminal" => "yes", devi@23: devi@31: "terminal_width" => 400, devi@23: "terminal_height" => 100, devi@23: "verbose" => "yes", devi@23: devi@23: "head_lines" => 5, devi@23: "tail_lines" => 5, devi@31: "cache_head_lines" => 50, devi@31: "cache_tail_lines" => 50, devi@23: "skip_text" => "...", devi@23: "show_time" => "yes", devi@23: "show_diffs" => "yes", devi@23: "show_comments" => "yes", devi@31: "show_notes" => "yes", devi@23: devi@23: "input" => "/root/.labmaker", devi@23: "diffs" => "", devi@23: "input_mask" => "*.script", devi@23: "encoding" => "utf-8", devi@23: devi@23: "cache" => "/tmp/report.xml", devi@25: "cache_stat" => "/tmp/.report.dat", devi@23: devi@23: "output" => "/tmp/report.html", devi@23: #"output" => "report.xml", devi@23: "output_mask" => "INDEX", devi@23: "output_format" => "html", devi@27: "frontend_css" => "/l3/l3.css", devi@27: "frontend_google_ico" => "/l3/google.ico", devi@27: "frontend_linux_ico" => "/l3/linux.ico", devi@27: "frontend_freebsd_ico" => "/l3/freebsd.ico", devi@27: "frontend_opennet_ico" => "/l3/opennet.ico", devi@27: "frontend_local_ico" => "/l3/freebsd.ico", devi@23: devi@31: "mywi_server" => "127.0.0.1", devi@31: "mywi_port" => "19800", devi@31: devi@31: "stat_inactivity_interval" => "1800", devi@31: devi@23: "signature" => "#lm:", devi@23: "from" => "", devi@23: "to" => "", devi@23: "lab" => "", devi@23: "keywords" => "linux command", devi@23: "files_keywords" => "linux file", devi@23: devi@23: comment_width => "300", devi@31: note_width => "500", devi@23: time_width => "60", devi@25: devi@25: "mode" => "daemon", # daemon | normal devi@25: "daemon_sleep_interval" => "1", devi@25: "detach" => "yes", devi@25: "agent_pidfile" => "$ENV{HOME}/.labmaker/l3-agent.pid", devi@23: devi@27: "backend_address" => "127.0.0.1", devi@27: "backend_port" => "18030", devi@27: "backend_pidfile" => "/tmp/l3-backend.pid", devi@27: "backend_datafile" => "/tmp/backend.xml", devi@27: devi@25: "l3-agent" => "l3-agent", devi@27: "l3-backend" => "l3-backend", devi@25: devi@23: "course-name" => "", devi@23: "course-code" => "", devi@23: "course-date" => "", devi@23: "course-center" => "", devi@23: "course-trainer" => "", devi@23: "course-student" => "", devi@30: devi@30: devi@30: #lm devi@30: "show_host" => "no", devi@30: devi@30: # Вспомогательные программы devi@30: #"l3-report" => "./lm-report", devi@30: "l3-report" => "./l3-report", devi@30: devi@30: # Каталоги devi@30: "path_lilalo" => "/var/lilalo/", devi@30: "path_classes" => "/var/lilalo/classes/", devi@30: "path_lablogs" => "/var/lilalo/lablogs/", devi@30: "courses_path" => "/var/lilalo/courses/", devi@30: "outpath" => "/var/lilalo/out/", devi@30: "path_web" => "/var/www/l3", # Путь к web-отчётам devi@30: "path_share" => "./share/", # Путь к web-отчётам devi@30: devi@30: # Файлы devi@30: "runfile" => "lm.run", devi@30: "logfile" => "lm.log", devi@30: devi@30: "class" => "class", # Имя файла класса devi@30: "class_suffix" => ".xml", # Cуффикс файла класса devi@30: "classfile" => "", devi@30: devi@30: "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub", devi@30: "lmssh" => "./lm-ssh", devi@30: "lminstall" => "./lm-install", devi@30: "ssh_user" => "root", devi@30: devi@23: ); 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@23: read_config_file(\%file_config, $Config_File); devi@23: GetOptions(\%argv_config, map "$_=s", keys %Config); devi@23: %Config = (%Config, %file_config, %argv_config); devi@23: } devi@23: