Contributions Thread

Installation issues, feature requests, help, etc.

Moderators: Curtis8, A_Null

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

Postby Natan » Sun Jun 03, 2007 6:35 pm

Hi Crulie !
Thanks for your feedback. The 1.12 is still being developed. In fact, I always prefer let people test a lot before declaring a new version stable. So, there might be a bug like this, and I'll be interested in feedback and / or a patch.

Currently, I'm rather working hard on the making of a 100%-LFS (Linux From Scratch) image, to replace the current one. I'm doing it so to gain more autonomy, more ease for the compilation of new tools, and as well so to be able to share the making of PING with others. Currently, to do this, I'd have to share a 10-Gigabyte virtual machine... whereas the sources of a LFS system would not exceed 300 or 400 Mo.

Regards
Natan

ampster
Posts: 14
Joined: Wed Jun 06, 2007 4:59 pm
Location: California

Postby ampster » Thu Jul 12, 2007 4:20 pm

Any chance you could share your working LFS environment?
I just posted a suggestion about splash screens:
http://ping.windowsdream.com/forum/view ... c&start=35
and would be happy to do the work to incorporate the idea.

I hate to have to start from "scratch"

Anthony

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

Postby Natan » Thu Jul 12, 2007 5:06 pm

Hi Anthony,

sure I'll share the fromscratch ! Could only help making PING better.
I'll upload it tonight, I think.

As a prerequisite, you need a Linux box -- even a VM --, with development tools installed (gcc, libs and friends). You probably already have this. Elsewhere, any Fedora installed with all dev packages will be OK.

What I'll share will be... a lot of shell scripts, easy enough to run, with used LFS and non-LFS packages (tarballs to compile).

Your feedback will be greatly appreciated.
Regards
Natan

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

Postby Natan » Thu Jul 12, 2007 6:03 pm

Anthony,

Go and get it here: http://www.windowsdream.com/dl/PING_2.00/
The file is called LFS-6.2-PING.20070712.tar.bz2.

You'll have to adjust a couple of shell scripts, but it should be OK.

Regards
Natan

ampster
Posts: 14
Joined: Wed Jun 06, 2007 4:59 pm
Location: California

Postby ampster » Thu Jul 12, 2007 10:50 pm

Natan
Thanks for the LFS gz file.
Give me a little time to digest the 265MB and get my arms around it. :shock:

Anthony

ampster
Posts: 14
Joined: Wed Jun 06, 2007 4:59 pm
Location: California

Postby ampster » Thu Jul 12, 2007 10:56 pm

I am currently an UBUNTU fan and also have a bunch
of Asterisk systems on CENTOS aka trixbox.
Do you think I should install Fedora ? and if so what version?

Anthony

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

Postby Natan » Thu Jul 12, 2007 11:22 pm

Any flavor will do !

bhenry
Posts: 7
Joined: Wed Nov 07, 2007 5:26 pm

Postby bhenry » Wed Dec 26, 2007 9:51 pm

We're in the middle of a PING implementation at the college I work for. We wanted a way we could turn TFTP off and easily check the status of the service. So I bashed up this script:

Code: Select all

<html>
<head><title>PING Web Control</title></head>
<body>
<form action="index.php" method=post>

<?php
        # This if/elseif statement reviews to see if the ON or OFF commands have been given to the script.
        #
        if($_POST['command'] == "on") {                         # If the command to turn TFTP on is issued...
                exec('sudo /sbin/chkconfig tftp on');           # Turn TFTP on
                exec('touch /var/www/html/ping/tftp_mod');      # and touch the tftp_mod file to update the date
        } elseif ($_POST['command'] == "off") {                 # If the command to turn TFTP off is issued
                exec('sudo /sbin/chkconfig tftp off');          # Then turn it off
        }                                                       # Note no "else" command

        $status = exec('sudo /sbin/chkconfig --list tftp');     # Get the status of the TFTP server

        #Based on the status of the TFTP server, set the variables $tftpstat, $tftpnext, and $color to the needed values.
        if($status == "tftp             on") {
                $tftpstat = "on";
                $tftpnext = "off";
                $color = "green";
        } elseif ($status == "tftp              off") {
                $tftpstat = "off";
                $tftpnext = "on";
                $color = "red";
        } else {                                                # Because you never know when something will fubar
                echo "There has been some sort of problem.<br>" . $status;
                $tftpstat = "error";
        }
        if($tftpstat != "error") {                              # Assuming we didn't fubar
                echo "<h1><font color=\"" . $color . "\">PING is currently " . $tftpstat . "</font></h1>\n\n";  # Display TFTP status as the PING status
                echo "<input type=hidden name=command value=" . $tftpnext . ">\n";                      # Set up the hidden input field for what we do next
                echo "<input type=submit value =\"Turn " . $tftpnext . " PING\">\n";                    # and create a button.

#I push the button! Not you push the button I push the button.  Is my turn not your turn.
        }
?>
</form>
<p><a href="..">Return to main page</a></p>
</body>
<html>


which will simply check the status of tftp and enable you to turn it on or off.

(the last comment comes from an Animaniacs marathon the weekend before I coded it)

And because we don't want tftp on too long, we have an accompanying shell script which will turn it off, set to run every 15 minutes to see if tftp has been on for over an hour and if it has, then turn it off:

Code: Select all

#!/bin/sh

#get the current status of tftp server
tftp_status=`/sbin/chkconfig --list tftp | awk '{print $2}'`

#check that the tftp_mod file exists, if not touch it and kill tftp just in case
if [ ! -f /var/www/html/ping/tftp_mod ]
then
        touch /var/www/html/ping/tftp_mod
        sudo /sbin/chkconfig tftp off
fi

#if the server is off, don't bother with the rest of the script
if test $tftp_status != "off"
then

        #set the tftp_off flag to 0.  Will be used (0 means don't turn it off yet)
        tftp_off=0

        #get the date and time the file was last modified
        file_modf_time=`ls -l /var/www/html/ping/tftp_mod`
        #get the current date and time
        curr_modf_time=`date`

        #slice the dates and times into something usable
        file_time_month=`echo $file_modf_time | awk '{print $6}'`
        file_time_day=`echo $file_modf_time | awk '{print $7}'`
        file_time_hrmin=`echo $file_modf_time | awk '{print $8}'`
        file_time_hr=`echo $file_time_hrmin | cut -d ':' -f1`
        file_time_min=`echo $file_time_hrmin | cut -d ':' -f2`

        curr_time_month=`echo $curr_modf_time | awk '{print $2}'`
        curr_time_day=`echo $curr_modf_time | awk '{print $3}'`
        curr_time_hrmin=`echo $curr_modf_time | awk '{print $4}'`
        curr_time_hr=`echo $curr_time_hrmin | cut -d ':' -f1`
        curr_time_min=`echo $curr_time_hrmin | cut -d ':' -f2`

        #change the month to a numeric
        case "$file_time_month" in
                'Jan')
                        file_time_month=1
                        ;;
                'Feb')
                        file_time_month=2
                        ;;
                'Mar')
                        file_time_month=3
                        ;;
                'Apr')
                        file_time_month=4
                        ;;
                'May')
                        file_time_month=5
                        ;;
                'Jun')
                        file_time_month=6
                        ;;
                'Jul')
                        file_time_month=7
                        ;;
                'Aug')
                'Aug')
                        file_time_month=8
                        ;;
                'Sep')
                        file_time_month=9
                        ;;
                'Oct')
                        file_time_month=10
                        ;;
                'Nov')
                        file_time_month=11
                        ;;
                'Dec')
                        file_time_month=12
                        ;;
        esac

        case "$curr_time_month" in
                'Jan')
                        curr_time_month=1
                        ;;
                'Feb')
                        curr_time_month=2
                        ;;
                'Mar')
                        curr_time_month=3
                        ;;
                'Apr')
                        curr_time_month=4
                        ;;
                'May')
                        curr_time_month=5
                        ;;
                'Jun')
                        curr_time_month=6
                        ;;
                'Jul')
                        curr_time_month=7
                        ;;
                'Aug')
                        curr_time_month=8
                        ;;
                'Sep')
                        curr_time_month=9
                        ;;
                'Oct')
                        curr_time_month=10
                        ;;
                'Nov')
                        curr_time_month=11
                        ;;
                'Dec')
                        curr_time_month=12
                        ;;
        esac

        #If it's a differnet month, kill tftp
        if test $curr_time_month -ne $file_time_month
        then
                tftp_off=1
        fi

        #If it's a different day, kill tftp
        if test $curr_time_day -ne $file_time_day
        then
                tftp_off=1
        fi

        #convert the current time to minutes
        curr_time_hrmin=`expr $curr_time_hr \* 60 + $curr_time_min`

        #convert the file time to minutes and add an hour
        file_time_check=`expr $file_time_hr \* 60 + $file_time_min + 60`

        #if the time differs by over an hour, kill tftp
        if test $curr_time_hrmin -gt $file_time_check
        then
                tftp_off=1
        fi

        #if any of the previous ifs said to kill tftp, here's where we kill it
        if test $tftp_off -eq 1
        then
                sudo /sbin/chkconfig tftp off
        fi
fi

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

Postby Natan » Thu Dec 27, 2007 12:18 am

Thank you for this contrib.
Natan

bwkaz
Posts: 8
Joined: Sun Jan 20, 2008 11:16 pm

Postby bwkaz » Mon Jan 21, 2008 12:02 am

Request: Use an initramfs instead of an initrd. I'm sure an initrd will continue to work for a very long time, but the initramfs setup seems to be the way the kernel developers want everyone to move eventually.

Explanation and probably way too many details:

An initrd is a gzipped image of an ext2 filesystem (well, any particular filesystem that the kernel supports, but usually ext2 because it's tiny and simple). An initramfs is a gzipped CPIO archive of a group of files. When the kernel interprets an initrd, it gunzips it and treats it like a ramdisk (uses the ramdisk's own filesystem); when the kernel interprets an initramfs, it creates a tmpfs (basically), gunzips the initramfs image, and un-cpio-s its structure into the new tmpfs.

An initrd's "main" executable is /linuxrc. An initramfs's "main" executable is /init. (Simply renaming /linuxrc to /init should work for PING, with a few other changes to /init itself given below.)

When an initramfs hands control off to the real root filesystem, it's a single step instead of two. An initrd runs pivot_root and then executes the new shell, but an initramfs executes run-init (see klibc for the sources). run-init does a bunch of sanity checks to make sure it doesn't run when a non-initramfs is the root FS, then deletes all the files off the root FS (to free up RAM). Then it effectively does a "mount --move" on the new root directory (/tmpfs in the case of PING), moving it to /. Then it does a chroot to the new /, opens the new /dev/console device, and execs the new init with whatever arguments.

Syntax on run-init is:

run-init [ -c consolefile ] new-root init-file [ init-args ]

where consolefile is the new console file (defaults to /dev/console, shouldn't need to be changed), new-root is the /tmpfs directory in PING, init-file is /sbin/init in PING, and init-args are any arguments to pass to the new init. (I've been able to get away with skipping them, but most initramfs images pass "$@", to be sure everything gets through.)

What I used in my testing was the following:

Code: Select all

exec /bin/run-init /tmpfs /sbin/init
wherever the initrd ran "pivot_root blah" then "exec /sbin/init blah".

which worked OK. But I built my own run-init using glibc (so I had to copy /lib/libc.so.6 and /lib/ld-linux.so.2 into the initramfs as well); rebuilding it using whatever crunchbox method will probably make a much smaller ISO. (In fact crunchbox may already have a run-init option? If not, klibc should provide usable sources; I used klibc-1.5.)

The one other thing to be careful of is that I believe the initramfs image file needs to have its pathnames start with a / character. I can't figure out any way to get the cpio command to do this, so I built a file and ran it through the kernel's usr/gen_init_cpio program to generate the cpio file instead. (gen_init_cpio can put any arbitrary file from the host at any arbitrary path in the cpio image.) This also requires a bit of a hack to fix an issue with the stat program (it won't print the decimal major/minor number of device nodes); the script to do that is named ~/replace_0x, and is given below:

Code: Select all

#!/bin/bash

while read line ; do
   set -- $line

   for i in "$@" ; do
      case "$i" in
         0x*)
         echo -n "$(($i)) "
         ;;
         *)
         echo -n "$i "
      esac
   done

   echo ""
done
Apart from that, the commands to actually generate an initramfs image are below (of course the kernel needs to be built first, to generate the gen_init_cpio binary):

Code: Select all

( find . -type d -not -name . -printf "dir /%P %m %U %G\n"
  find . -type f -printf "file /%P %p %m %U %G\n"
  find . -type l -printf "slink /%P %l 0777 0 0\n"
  find . -type c -exec stat --format="nod %n %a %u %g c 0x%t 0x%T" {} \;
  find . -type b -exec stat --format="nod %n %a %u %g b 0x%t 0x%T" {} \;
) | sed -e 's/^nod \./nod /' | ~/replace_0x >../file_list

<kernel_source_path>/usr/gen_init_cpio ../file_list | gzip -c >../initramfs.cpio.gz
The first find generates commands to create the directory tree in the cpio archive. The second generates commands to copy all the files into the cpio archive. The third generates commands to create all the symbolic links (critical given the crunchbox architecture in the initramfs). The fourth and fifth generate commands to create the character and block devices, respectively. The sed is needed to get rid of the "." at the start of the device-node command paths; the pipe through replace_0x changes the 0x%t and 0x%T items (from stat) from hex into decimal. This all gets dumped into ../file_list for gen_init_cpio to work on.

Then gen_init_cpio is called, which dumps the cpio archive to stdout; this is piped through gzip and written to the cpio.gz file. It's critical that gen_init_cpio be called from the same directory as was current when the ../file_list was generated (otherwise the relative paths from find won't be correct in ../file_list).

Of course the initramfs image can be called anything; initrd.gz would work fine if you don't want to change the syslinux.cfg file. However, I was able to remove all of the following from the kernel command line in syslinux.cfg:

ramdisk_size=33000
load_ramdisk=1
init=/linuxrc
prompt_ramdisk=0

and the image still worked fine. I'm not sure if these are kernel options or syslinux options, but if they're kernel options, then they can go away, and the system will still at least boot and be able to run partimage. :)

Thanks!

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

Postby Natan » Thu Jan 24, 2008 11:37 am

Hi there!
Back from holidays... and reading all new messages.

Thanks Bwcaz for this contrib. I must admit I'm not very aware of this initrd vs. initramfs topic, but am interested in any way that will improve PING, making it as small as possible, and consume as little RAM as possible too. Crunchbox is a good thing that I have not used so far.

The whole PING OS is made through shell scripts, that compile each source and build the OS from scratch (mostly inspired from LFS, Linux from scratch). The scripts and the used sources are available, yet not in the download section because they often change and hardly no one is interested in them.

Would you like to take care of the switch from initrd to initramfs ? This would lead us to PING 3.00.00, I guess. The idea is in the TODO-list now, anyway.

Regards
Natan

bwkaz
Posts: 8
Joined: Sun Jan 20, 2008 11:16 pm

Postby bwkaz » Fri Jan 25, 2008 1:15 am

Natan wrote:I must admit I'm not very aware of this initrd vs. initramfs topic, but am interested in any way that will improve PING, making it as small as possible, and consume as little RAM as possible too.
I'm not sure whether using an initramfs (rather than an initrd) will make it smaller or make it use any less RAM. It'll probably be very similar as far as memory usage goes.

What it does get you is a simpler file (instead of a gzipped file with an ext2 FS on it, containing files, it's just a gzipped cpio archive containing files), but I don't think it saves a ton of space. It certainly doesn't after adding glibc's libc.so.6 and ld-linux.so.2 to the image (but those wouldn't be needed if run-init could be compiled against crunchbox; maybe it can? I need to look into crunchbox, I think).

I'm just a lot more familiar with an initramfs (having put together a pre-beta of an initramfs-generator for LFS; I hope to get something like it into either LFS or BLFS before 7.0), so when I needed to make a few changes to the embedded rootfs.tar.bz2 file, I converted it to an initramfs. Then I figured it'd be good to share that too.

(The changes I made to rootfs.tar.bz2 are pretty specific to the environment that we'll be using PING in. We can rely on DHCP being available, for instance, so I ripped out the whole LFS bootscript /etc/sysconfig/network-devices tree, and just changed /etc/rc.d/init.d/network to fire up dhcpcd on each eth* NIC in /sys/class/net/ instead. Then I killed the code that ran PING's Perl script, and instead I added some code to rc.local to prompt for server, username, and password, then automatically mount.cifs our image share. Then it automatically starts up partimage in interactive mode. We used to use a DOS-based CD with network support and Ghost on it, which is why I set it to prompt for this stuff; that's how the old CD did it too. We can't use that CD anymore because we can't get SATA CD drivers for DOS, I like Linux a lot more anyway, and PING is tiny. ;))

Thanks for doing this, by the way. :)

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

Postby DevX » Fri Apr 25, 2008 2:34 pm

I've been working with ping for a while, and i'm trying to automate the process and make it so it writes directly to a DVD. Once i get that completed or to a working stage I will share my findings. For the time being i wanted to share something.

When i was working with ping and trying to back up to a samba share i wouldn't be able to create a new image because simple the options was not there. Here is the patch diff.

Code: Select all


-- rc.ping     2008-04-25 09:22:08.000000000 -0400
+++ rc.ping.2.0.12.RW.samba     2008-04-25 09:21:58.000000000 -0400
@@ -2215,7 +2215,9 @@
 # able to create a new image etc. So, let's add the special directories
 # if he has forgotten to create them.
 #
-if($SRC =~/dos/)
+# Also give the user the option to create a new image on SMBFS share
+#
+if($SRC =~/smbfs/ || $SRC =~/dos/)
 {
     foreach my $S ("Blank_Local_Admin_Passwd", "Create_New_Image")
     {


Also another issue i encounter was dealing with extended partitions. I manage to get arround that by adding something like the following to export the extended partition table information. The following code is not tested thoroughly.



Code: Select all

             LOG("  * Backuping extended Partition table [/dev/$P]\n");
             if(! -e "$SRC/$New_Image/$HDD.sf")
             {
                 my $cmd = "sfdisk -d /dev/$HDD > $SRC/$New_Image/$HDD.sf";
                 LOG("    Cmd: [$cmd]\n");
                 my $out = `$cmd`;
                 LOG("    Out: [$out]\n");

             }


Due to lack of time i had to implement an ugly hack to have this work for me.

Code: Select all


               LOG(" * Restore Extended Partitions [/dev/$F]\n");
               my $cmd = "sfdisk /dev/$F < $FF.sf";
               LOG("     Cmd: [$cmd]\n");
               my $out = `$cmd`;
               LOG("    Out: [$out]\n");


I hope this is helpfull to someone, any feedback or questions are appreciated.

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

Postby Curtis8 » Fri Apr 25, 2008 5:54 pm

DevX wrote:When i was working with ping and trying to back up to a samba share i wouldn't be able to create a new image because simple the options was not there. Here is the patch diff.
You can simply extract the PartImage.zip file to the share dir like you are told in the How-To :P

The other things you have added look promising and will need to be tested further :D
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:07 pm

Thanks for the feedback. I didn't see that part in the readme, but it's just one extra thing you have to do on the samba share. So that's why i chose to add those options.

I've incorporated the code i suggested to a version of PING that I'm ussing. I also fixed a bug i had encounter where it wouldn't restore different drive partition tables. I hope someone finds it usefull, and hope some of it makes it to the main distribution.


http://www.desmind.org/ping/rc.ping

any feedback is welcome

Regards

Vic


Return to “PING / General Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests