/[pxelator]/lib/PXElator/config.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/config.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 135 - (show annotations)
Tue Aug 4 13:19:08 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 1824 byte(s)
implement mirror and configuration creation for webconverger

1 package config;
2
3 use warnings;
4 use strict;
5 use autodie;
6
7 use server;
8 use pxelinux;
9 use File::Slurp;
10
11 sub shared {
12 my ($name, $value) = @_;
13
14 my $path ="$server::base_dir/conf/$server::ip/$name";
15 if ( defined $value ) {
16 write_file $path, $value;
17 } else {
18 $value = read_file $path if -e $path;
19 }
20 return $value;
21 }
22
23 sub debian_live {
24 $dhcpd::file = "pxelinux.0";
25 $pxelinux::path_prefix = 'live-helper/tftpboot/';
26 $pxelinux::config_file = 'pxelinux.cfg/default';
27 }
28
29 use LWP::Simple qw/mirror RC_NOT_MODIFIED/;
30 sub webconverger {
31 $dhcpd::file = "pxelinux.0";
32 $pxelinux::path_prefix = 'webconverger/';
33
34 my $dir = "$server::base_dir/tftp/$pxelinux::path_prefix";
35
36 mkdir $dir unless -d $dir;
37
38 my $cfg = "$dir/pxelinux.cfg";
39 return 1 if -e $cfg;
40
41 mkdir $cfg;
42
43 my $iso = '/srv/pxelator/iso/webc-5.2.iso';
44 my $url = 'http://download.webconverger.com/webc-5.2.iso';
45
46 print STDERR "mirror $url";
47 mirror( $url, $iso)
48 == RC_NOT_MODIFIED
49 && warn(" not modified\n")
50 || warn(" done ", -s $iso, " bytes\n")
51 ;
52
53 mkdir "$dir/iso" unless -e "$dir/iso";
54
55 system "mount -t iso9660 | grep webc-5.2 || sudo mount $iso $dir/iso/ -o loop -t iso9660 -v";
56
57 symlink "/usr/lib/syslinux/pxelinux.0", "$dir/$dhcpd::file";
58
59 $cfg .= '/default';
60
61 write_file $cfg, qq{
62 label webconverger
63 kernel iso/live/vmlinuz-2.6.30-backports.1-486
64 append initrd=iso/live/initrd.img-2.6.30-backports.1-486 fetch=http://172.16.10.1/pxelator/webconverger/iso/live/filesystem.squashfs boot=live quiet homepage=http://172.16.10.1:7777/ nonetworking nosudo splash video=vesa:ywrap,mtrr vga=788 nopersistent username=webc hostname=webconverger union=aufs
65 };
66
67 # $pxelinux::config_file = $cfg;
68 }
69
70 sub for_ip {
71 my $ip = shift;
72 # debian_live();
73 webconverger();
74 # $tftp::dir = "$server::base_dir/tftp/$pxelinux::path_prefix";
75 }
76
77 warn 'loaded';
78
79 1;

  ViewVC Help
Powered by ViewVC 1.1.26