aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/apache/manifests/var.pp5
-rw-r--r--modules/apache/templates/00_default_vhosts.conf10
2 files changed, 13 insertions, 2 deletions
diff --git a/modules/apache/manifests/var.pp b/modules/apache/manifests/var.pp
index 294af458..2c33a23f 100644
--- a/modules/apache/manifests/var.pp
+++ b/modules/apache/manifests/var.pp
@@ -1,9 +1,12 @@
# $httpdlogs_rotate:
# number of time the log file are rotated before being removed
+# $default_vhost_redirect:
+# URL to redirect to in case of unknown vhost
class apache::var(
$httpdlogs_rotate = '24',
$apache_user = 'apache',
- $apache_group = 'apache'
+ $apache_group = 'apache',
+ $default_vhost_redirect = ''
) {
if ($::lsbdistrelease == '1') or ($::lsbdistid == 'MandrivaLinux') {
$pkg_conf = 'apache-conf'
diff --git a/modules/apache/templates/00_default_vhosts.conf b/modules/apache/templates/00_default_vhosts.conf
index a1afe9ca..9a5f586c 100644
--- a/modules/apache/templates/00_default_vhosts.conf
+++ b/modules/apache/templates/00_default_vhosts.conf
@@ -3,5 +3,13 @@
<Location />
Allow from all
</Location>
- Redirect / http://www.<%= @domain %>/
+ <%-
+ default_redirect = scope.lookupvar('apache::var::default_vhost_redirect')
+ if default_redirect == ''
+ -%>
+ Redirect 404 /
+ ErrorDocument 404 "Page Not Found"
+ <%- else -%>
+ Redirect / <%= default_redirect %>
+ <%- end -%>
</VirtualHost>
a id='n68' href='#n68'>68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
package network::thirdparty;

use strict;
use common;
use detect_devices;
use run_program;
use services;
use fs::get;
use fs;
use log;

#- network_settings is an hash of categories (rtc, dsl, wireless, ...)
#- each category is an hash of device settings

#- a device settings element must have the following fields:
#- o matching:
#-     specify if this settings element matches a driver
#-     can be a regexp, array ref or Perl code (parameters: driver)
#- o description:
#-     full name of the device
#- o name: name used by the packages

#- the following fields are optional:
#- o url:
#-     url where the user can find tools/drivers/firmwares for this device
#- o device:
#-     device in /dev to be configured
#- o post:
#-     command to be run after all packages are installed
#-     can be a shell command or Perl code
#- o restart_service:
#-     if exists but not 1, name of the service to be restarted
#-     if 1, specify that the service named by the name field should be restarted
#- o tools:
#-     if exists but not 1, hash of the tools settings
#-     if 1, tools are needed and package name is the name field
#- o kernel_module:
#-     if exists but not 1, hash of the module settings
#-     if 1, kernel modules are needed and use the name field
#-         (name-kernel or dkms-name)
#- o firmware:
#-     if exists but not 1, hash of the firmware settings
#-     if 1, firmware are needed and use the name field
#-         (name-firmware)

#- hash of package settings structure (all fields are optional):
#- o package:
#-     name of the package to be installed for these device
#- o test_file:
#-     file used to test if the package is installed
#- o prefix:
#-     path of the files that are tested
#- o links:
#-     useful links for this device
#-     can be a single link or array ref
#- o user_install:
#-     function to call if the package installation fails
#- o explanations:
#-     additionnal text to display if the installation fails
#- o no_club:
#-     1 if the package isn't available on Mandriva club

my $hotplug_firmware_prefix = "$::prefix/lib/hotplug/firmware";

my %network_settings = (
  rtc =>
  [
   {
    matching => qr/^Hcf:/,
    description => 'HCF 56k Modem',
    url => 'http://www.linuxant.com/drivers/hcf/',
    name => 'hcfpcimodem',
    kernel_module => 1,
    tools =>
    {
     test_file => '/usr/sbin/hcfpciconfig',
    },
    device => '/dev/ttySHSF0',
    post => '/usr/sbin/hcfpciconfig --auto',
   },

   {
    matching => qr/^Hsf:/,
    description => 'HSF 56k Modem',
    url => 'http://www.linuxant.com/drivers/hsf/',
    name => 'hsflinmodem',
    kernel_module => 1,
    tools =>
    {
     test_file => '/usr/sbin/hsfconfig',
    },
    device => '/dev/ttySHSF0',
    post => '/usr/sbin/hsfconfig --auto',
   },

   {
    matching => qr/^LT:/,
    description => 'LT WinModem',
    url => 'http://www.heby.de/ltmodem/',
    name => 'ltmodem',
    kernel_module => 1,
    tools =>
    {
     test_file => '/etc/devfs/conf.d/ltmodem.conf',
    },
    device => '/dev/ttyS14',
    links =>
    [
     'http://linmodems.technion.ac.il/Ltmodem.html',
     'http://linmodems.technion.ac.il/packages/ltmodem/',
    ],
   },

   {
    matching => [ list_modules::category2modules('network/slmodem') ],
    description => 'Smartlink WinModem',
    url => 'http://www.smlink.com/content.aspx?id=135/',
    name => 'slmodem',
    kernel_module => 1,
    tools =>
    {
     test_file => '/usr/sbin/slmodemd',
    },
    device => '/dev/ttySL0',
    restart_service => 1,
   },
  ],

  wireless =>
  [
   {
    matching => 'zd1201',
    description => 'ZyDAS ZD1201',
    url => 'http://linux-lc100020.sourceforge.net/',
    firmware =>
    {
     test_file => 'zd1201*.fw',
    },
   },

   (map {
       {
           matching => "ipw${_}",
           description => "Intel(R) PRO/Wireless ${_}",
           url => "http://ipw${_}.sourceforge.net/",
	   name => "ipw${_}",
           firmware =>
	   {
               url => "http://ipw${_}.sourceforge.net/firmware.php",
               test_file => ($_ == 2100 ? "ipw2100-*.fw" :  "ipw-*.fw"),
           },
       }
   } (2100, 2200)),

   {
    matching => 'prism54',
    description => 'Prism GT / Prism Duette / Prism Indigo Chipsets',
    url => 'http://prism54.org/',
    name => 'prism54',
    firmware =>
    {
     url => 'http://prism54.org/~mcgrof/firmware/',
     test_file => "isl38*",
    },
   },

   {
    matching => qr/^at76c50/,
    description => 'Atmel at76c50x cards',
    url => 'http://thekelleys.org.uk/atmel/',
    name => 'atmel',
    firmware =>
    {
     test_file => 'atmel_at76c50*',
    },
    links => 'http://at76c503a.berlios.de/',
   },
  ],

  dsl =>
  [
   {
    matching => sub { detect_devices::getSpeedtouch() },
    description => N_("Alcatel speedtouch USB modem"),
    url => "http://www.speedtouch.com/supuser.htm",
    name => 'speedtouch',
    tools =>
    {
     test_file => '/usr/sbin/modem_run',
    },
    firmware =>
    {
     package => 'speedtouch_mgmt',
     prefix => '/usr/share/speedtouch',
     test_file => 'mgmt*.o',
     explanations => N_("Copy the Alcatel microcode as mgmt.o in /usr/share/speedtouch/"),
     user_install => \&install_speedtouch_microcode,
    },
    links => 'http://linux-usb.sourceforge.net/SpeedTouch/mandrake/index.html',
   },

   {
    matching => 'eciadsl',
    name => 'eciadsl',
    explanations => N_("The ECI Hi-Focus modem cannot be supported due to binary driver distribution problem.

You can find a driver on http://eciadsl.flashtux.org/"),
    no_club => 1,
    tools => 1,
   },

   {
    matching => 'eagle-usb',
    description => 'Eagle chipset (from Analog Devices), e.g. Sagem F@st 800/840/908',
    url => 'http://www.eagle-usb.org/',
    name => 'eagle-usb',
    tools =>
    {
     test_file => '/sbin/eaglectrl',
    },
   },

   {
    matching => 'bewan',
    description => 'Bewan Adsl (Unicorn)',
    url => 'http://www.bewan.com/bewan/users/downloads/',
    name => 'unicorn',
    kernel_module => 1,
    tools => 1,
   },
  ],
);

sub device_get_package {
    my ($settings, $option, $o_default) = @_;
    $settings->{$option} or return;
    my $package;
    if (ref $settings->{$option} eq 'HASH') {
	$package = $settings->{$option}{package} || 1;
    } else {
	$package = $settings->{$option};
    }
    $package == 1 ? $o_default || $settings->{name} : $package;
}

sub device_get_option {
    my ($settings, $option) = @_;
    $settings->{$option} or return;
    my $value = $settings->{$option};
    $value == 1 ? $settings->{name} : $value;
}

sub find_settings {
    my ($category, $driver) = @_;
    find {
	my $type = ref $_->{matching};
        $type eq 'Regexp' && $driver =~ $_->{matching} ||
	$type eq 'CODE'   && $_->{matching}->($driver) ||
        $type eq 'ARRAY'  && member($driver, @{$_->{matching}}) ||
	$driver eq $_->{matching};
    } @{$network_settings{$category}};
}

sub warn_not_installed {
    my ($in, @packages) = @_;
    $in->ask_warn(N("Error"), N("Could not install the packages (%s)!", @packages));
}

sub warn_not_found {
    my ($in, $settings, $option, @packages) = @_;
    my %opt;
    $opt{$_} = $settings->{$option}{$_} || $settings->{$_} foreach qw(url explanations no_club);
    $in->ask_warn(N("Error"),
		  N("Some packages (%s) are required but aren't available.", @packages) .
		  if_(!$opt{no_club}, N("These packages can be found in Mandriva Club or in Mandriva commercial releases.")) .
		  if_($opt{url}, "\n\n" . N("The required files can also be installed from this URL:
%s", $opt{url})) .
		  if_($opt{explanations}, "\n\n" . translate($opt{explanations})));
}

sub is_file_installed {
    my ($settings, $option) = @_;
    my $file = exists $settings->{$option} && $settings->{$option}{test_file};
    $file && -e "$::prefix$file";
}

sub is_module_installed {
    my ($driver) = @_;
    find { m!/\Q$driver\E\.k?o! } cat_("$::prefix/lib/modules/" . c::kernel_version() . '/modules.dep');
}

sub is_firmware_installed {
    my ($settings) = @_;
    my $wildcard = exists $settings->{firmware} && $settings->{firmware}{test_file} or return;
    my $path = $settings->{firmware}{prefix} || $hotplug_firmware_prefix;
    scalar glob_("$::prefix$path/$wildcard");
}

sub find_file_on_windows_system {
    my ($in, $file) = @_;
    my $source;
    require fsedit;
    my $all_hds = fsedit::get_hds();
    fs::get_info_from_fstab($all_hds);
    if (my $part = find { $_->{device_windobe} eq 'C' } fs::get::fstab($all_hds)) {
	foreach (qw(windows/system winnt/system windows/system32/drivers winnt/system32/drivers)) {
	    -d $_ and $source = first(glob_("$part->{mntpoint}/$_/$file")) and last;
	}