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