Contributions Thread

Installation issues, feature requests, help, etc.

Moderators: Curtis8, A_Null

User avatar
Curtis8
Site Janitor
Posts: 985
Joined: Thu Mar 01, 2007 3:22 pm
Location: Canada
Contact:

Postby Curtis8 » Fri Apr 25, 2008 7:53 pm

I understand about the "one more thing to do to the share" idea. I actually agree with you. However, upon further thought, I wondered if some system techs wish to not have that option to prevent users from accidently making a new image. Of course, we could have the options added by PING in the script (like you did) and then use kernel args to remove the unwanted ones. That would help several of the new users that did forget to add that PartImage.zip file like you did. I think that this other way (having PING add like you did, but use kernel args to remove options) would cover the most ground and work the best for all. What do you think?
Curtis

If you can read this, help me by going to the following link (can only go once per day)
http://s13.bitefight.org/c.php?uid=32058

Thank you

DevX
Posts: 22
Joined: Tue Jan 08, 2008 11:05 pm
Contact:

Postby DevX » Fri Apr 25, 2008 7:57 pm

Yeah, I also like the aproch you have used for the antivirus, and make it configurable in the ping.conf. I think that would make it better.

boricacid
Posts: 2
Joined: Fri Apr 25, 2008 8:14 pm

Postby boricacid » Fri Apr 25, 2008 10:40 pm

Hi,

I've been experimenting with PING on and off at work to duplicate a drive's content to multiple computers.

PING doesn't correctly support extended partitions when using a .part file and restoring to a blank unpartitioned drive. I really needed this, so I added partial support for that. It is an ugly hack because it only recognizes Windows Extended type partitions (W95 Ext'd (LBA), of ID "f") and likely also because I'm a total perl newbie.

There are two bits of code in rc.ping that looked like this originally:

Code: Select all

      LOG("  * Found [$F] => partitioning instructions.\n");
      my @fdisk = ('d', 1, 'd', 2, 'd', 3, 'd', 4, 'd', 5, 'd', 6);
      my $cnt = 0;
      open(DB, "$SRC/$Entity/$F");
      while(<DB>)
      {
          s/^\s*//;
          s/\s*$//;
          s/\s/ /g;
          while(m/  /)
          {
         s/  / /g;
          }
          next if(m/^\;/);
          my @fields = split(/ /, $_);
          next unless($#fields >= 2);
          my($PNumber, $PSize, $PType, $PLabel, $PBoot) = @fields;

          push(@fdisk, 'n', 'p', $PNumber, '');
          if($PSize eq "+")
          {
         push(@fdisk, '');
          }
          else
          {
         push(@fdisk, "+$PSize");
          }
          push(@fdisk, 't');
          if($cnt > 0)
          {
         push(@fdisk, $PNumber);
          }
          push(@fdisk, $PType);
          if($PBoot eq "*")
          {
         push(@fdisk, 'a', $PNumber);
          }
          if($PLabel)
          {
         $CMD_Label .= ";ntfslabel -f /dev/$Dev$PNumber ".
             substr($PLabel, 0, 8);
          }
          ++ $cnt;
      }
      close(DB);
      push(@fdisk, 'w');

Which I changed to:

Code: Select all

      LOG("  * Found [$F] => partitioning instructions.\n");
      my @fdisk = ('u', 'd', 1, 'd', 2, 'd', 3, 'd', 4, 'd', 5, 'd', 6);
      my $cnt = 0;
      open(DB, "$SRC/$Entity/$F");
      while(<DB>)
      {
         s/^\s*//;
         s/\s*$//;
         s/\s/ /g;
         while(m/  /)
         {
         s/  / /g;
         }
         next if(m/^\;/);
         my @fields = split(/ /, $_);
         next unless($#fields >= 2);
         my($PNumber, $PSize, $PType, $PLabel, $PBoot) = @fields;
            # Partitions numbers > 4 are logical and contained within an extended partition
            if($PNumber > 4)
            {
                push(@fdisk, 'n', 'l', '');
            }
            else
            {
                if($PType eq "f") # We may want to check for more than one partition type ID to decide it is extended.
                {
                push(@fdisk, 'n', 'e', $PNumber, '');
                }
                else
                {
             push(@fdisk, 'n', 'p', $PNumber, '');
             }
          }
         if($PSize eq "+")
         {
         push(@fdisk, '');
         }
         else
         {
         push(@fdisk, "+$PSize");
         }
         push(@fdisk, 't');
         if($cnt > 0)
         {
         push(@fdisk, $PNumber);
         }
         push(@fdisk, $PType);
         if($PBoot eq "*")
         {
         push(@fdisk, 'a', $PNumber);
         }
         if($PLabel)
         {
         $CMD_Label .= ";ntfslabel -f /dev/$Dev$PNumber ".
            substr($PLabel, 0, 8);
         }
         ++ $cnt;
      }
      close(DB);
      push(@fdisk, 'w');

This works fine for the systems I need to restore but I am pretty sure that my assumptions when I coded this will be wrong for some other setups.. but I wanted to contribute this so someone else might use it as a building block to go further. I can send the full rc.ping if anyone is interested.

DevX
Posts: 22
Joined: Tue Jan 08, 2008 11:05 pm
Contact:

Postby DevX » Sun Apr 27, 2008 3:17 pm

I had simillar problems, but i fixed that by doing other modifications to rc.ping. If you want you can give the version i modified a try and see if tat solves your issues with extended partitions.



On another note, I was thinking of a way to automate backup of partitions and options and I was thinking to use the ping.conf and set some variables there. Any thoughs?

boricacid
Posts: 2
Joined: Fri Apr 25, 2008 8:14 pm

Postby boricacid » Tue Apr 29, 2008 5:25 pm

I tried your version and it almost worked right away. I had to add the --force option when restoring the partition table with sfdisk or else it complains that my partition table is incorrect even though it was dumped directly from the drive I am creating a backup from.

Since the script automatically saved that .sf file from a working drive and we are not supposed to need to tamper with it, I don't have a problem adding --force.

I'll keep your solution, it is a more general solution than mine.

Thanks!

DevX
Posts: 22
Joined: Tue Jan 08, 2008 11:05 pm
Contact:

Postby DevX » Tue Apr 29, 2008 7:04 pm

Thanks, for the feedback. Not really sure at this moment on how to tackle that case senario I'll think about it. If you have any ideas I would aprreciate them.

User avatar
Natan
Site Admin
Posts: 1722
Joined: Sun Nov 20, 2005 12:29 am

Postby Natan » Wed Apr 30, 2008 10:38 am

Hi people,
I've been off for some time and feel really amazed by what I read... Great ideas out here !
Natan

jhurd8025
Posts: 92
Joined: Mon Apr 28, 2008 2:50 pm
Location: Dallas, Texas
Contact:

IPAPPEND 1

Postby jhurd8025 » Sun May 18, 2008 9:32 pm

I think this should be recommended for users to use.


in the default file,

use the IPAPPEND 1 statement.
example:

Code: Select all

LABEL PING
   MENU LABEL PING
   KERNEL kernel
   APPEND vga=normal devfs=nomount pxe ramdisk_size=33000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0
initrd=initrd.gz root=/dev/ram0 rw noacpi noapm pci=noacpi lba acpi=off apm=off
   IPAPPEND 1


This adds the statement to be like:
vga=normal devfs=nomount pxe ramdisk_size=33000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw noacpi noapm pci=noacpi lba acpi=off apm=off ip=x.x.x.x:x.x.x.x:x.x.x.x:x.x.x.x

The actualy layout is:
ip=Ip:Bootserver:Gateway:NetMask

The problem is you need something in the rc.ping that can split this up so that it's
IP=IP
Server=bootserver
Gateway=gateway
NetMask=subnetmask

I think something like this would work, but I'm not really familiar with perl scripting:

Code: Select all

($IP,$Server,$Gateway,$Netnask)=split/:/



In the end if we can get this to work. The client doesn't have to request an IP again, and rather its set by default from the PXE command line.

User avatar
Curtis8
Site Janitor
Posts: 985
Joined: Thu Mar 01, 2007 3:22 pm
Location: Canada
Contact:

Postby Curtis8 » Sun May 18, 2008 9:41 pm

Interesting. Will need to look at that. It may work.
Curtis

If you can read this, help me by going to the following link (can only go once per day)
http://s13.bitefight.org/c.php?uid=32058

Thank you

jhurd8025
Posts: 92
Joined: Mon Apr 28, 2008 2:50 pm
Location: Dallas, Texas
Contact:

Postby jhurd8025 » Mon May 19, 2008 11:43 pm

Curtis I got it to work:

Right after this code:

Code: Select all

   if(-e "/proc/cmdline")
   {
       LOG("  Parsing the [/proc/cmdline] file for arguments possibly\n");
       LOG("    passed to the kernel\n");

       open(DB, "/proc/cmdline");
       while(<DB>)
       {
      s/^\s*//;
      s/\s*$//;
      while(m/\"([^\"]+)\"/)
      {
          my $tmp = $1;
          $tmp =~s/\s/£££/g;
          s/\"([^\"]+)\"/$tmp/;
      }
      my(@Params) = split(/ /, $_);

      foreach my $Param (@Params)
      {
          $Param =~s/£££/ /g;
          my(@fields) = split(/=/, $Param);
          if($#fields > 0)
          {
         my $Key = $fields[0];
         my $Value = join("=", @fields[1..$#fields]);


I inserted:

Code: Select all

if($Key =~ m/IP/i)
         {
            my ($p_ip, undef, $p_gw, $p_netmask) = split(/:/, $Value);
            $P{'IP'} = $p_ip;
            $P{'Netmask'} = $p_netmask;
            $P{'Gateway'} = $p_gw;
            $P{'Server'} = $p_gw;
            $flag = 1;
            next;
         }


Again you have to use IPAPPEND 1 or 3, I also use the GW as my 'Server'. Most people could use the broadcast address as their 'Server'. Works great, and no longer have to make a second dhcp request.

jhurd8025
Posts: 92
Joined: Mon Apr 28, 2008 2:50 pm
Location: Dallas, Texas
Contact:

Postby jhurd8025 » Tue Jun 17, 2008 4:32 pm

BTW this works good. No longer have to request a second IP. And I can lock down the DHCP server to only accept pxe requests.

User avatar
Natan
Site Admin
Posts: 1722
Joined: Sun Nov 20, 2005 12:29 am

Postby Natan » Tue Jun 17, 2008 5:08 pm

Hi JHurd,

I don't understand the problem you had, in fact. There is a possibility to pass params called IP, Gateway, Netmask -- this is for the NIC config, if no DHCP is wanted -- and params called Server, Share, User, Passwd, Directory -- which are for the server config.

Hence my wondering, or misunderstanding.

Natan

jhurd8025
Posts: 92
Joined: Mon Apr 28, 2008 2:50 pm
Location: Dallas, Texas
Contact:

Postby jhurd8025 » Tue Jun 17, 2008 5:54 pm

The case was I didnt want to pass manualy. I wanted to pass the same IP given to the host durning the PXE process. By using IPAPPEND 1,2,3 you can pass to the kernel the ip and gw info from that session. So I had to modify the ping.conf to accept the format that IPAPPEND outputs.

User avatar
Natan
Site Admin
Posts: 1722
Joined: Sun Nov 20, 2005 12:29 am

Postby Natan » Wed Jun 18, 2008 1:29 am

I didn't even know this existed... Certainly worth being implemented.

Thanks!
Natan

jhurd8025
Posts: 92
Joined: Mon Apr 28, 2008 2:50 pm
Location: Dallas, Texas
Contact:

Postby jhurd8025 » Wed Jun 18, 2008 3:20 pm

Granted before anyone was to use this...


My GW is the same as my smb server.

So Gateway = Server

That won't be the case with 70% of the people here I'm guessing. So a modify of what I wrote above would be needed.


Return to “PING / General Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest