3

We have an ancien server (Fedora Core 4) installed in 2005. This server had never been updated. It runs a special software allowing to monitor a production line without being connected directly to the outside world.

It is out of question to upgrade the system.

Some utilities have bugs or missing options. Some other utilities are missing.

I have to install some script on this server. The main problem is Bash is really too old and lacks some usefull stuff. I don't like the idea to hack those well tested scripts.

Is there a way to run a newer Bash, and install new programs while letting the system untouched ?

Maybe something like BusyBox does ? Or within a chroot ? The problem of a chroot is the difficulty to access the real system. For example my backup script won't work.

  • 2
    Bash 3.0 shouldn't be difficult to target at all. It would be the same as targeting RHEL 5, which is still a very relevant OS. What shiny bash 4 features are you using? – jordanm May 12 '13 at 15:43
  • 1
    The question is about how to install recent programs, not how to modify well tested scripts. Old Bash have bugs with arrays. Doesn't support support ++ incrementation style, and other things leading to lots and lots modifications into scripts. – Gregory MOUSSAT May 12 '13 at 16:04
  • (( foo++ )) works in bash 3, and I don't know what array bugs you are talking about. It doesn't support associative arrays. What OS do your scripts target? – jordanm May 12 '13 at 16:15
  • THE QUESTION IS ABOUT INSTALLING RECENT PROGRAMS, NOT SPECIFICALLY ABOUT BASH. Yes foo++ works, my mistake. But not foo+=3 and other things. – Gregory MOUSSAT May 12 '13 at 16:24
  • You may be asking the wrong question. – jordanm May 12 '13 at 16:26

4 Answers4

3

You can compile and install the needed tools in the home directory of a dedicated user.

Environment variables of this dedicated user should be set to prefer local version of executables and libraries, e.g. PATH and LD_LIBRARY_PATH.

The needed steps are something like:

  1. create a new user: cooluser
  2. create a ~cooluser/Local directory
  3. edit ~cooluser/.profile to set environment as needed:
    • PATH=${HOME}/Local/bin:${PATH}
    • LD_LIBRARY_PATH=${HOME}/Local/lib:${LD_LIBRARY_PATH}
  4. download sources of needed tools
  5. configure the tool so that it installs intself in ~cooluser/Local
    • e.g. ./configure --prefix=~cooluser/Local
  6. compile and install

Obviously you need gcc and many other developer tools on the machine. If you do not have them, you can compile the tools on another (virtual?) machine running the some os version and transfer the ~cooluser/Local directory when ready.

andcoz
  • 17,130
3

I think the easiest way is to bulk copy programs and libraries from another installation into a separate directory. For example from a live-cd like systemrescuecd which may contains everything you need for only hundred megabytes, copied into /opt/new/. This allow you to copy without having to search/find/guess/test which libraries are needed.

You can then run those programs with LD_LIBRARY_PATH=/opt/new/lib/ ; /opt/new/bin/diff or LD_LIBRARY_PATH=/opt/new/lib/ ; /opt/new/bin/bash This should work flawlessly until the utilities don't read old configuration files they no longer understand. Or worse, until they don't write into them.

Once this works, you can copy the new libraries into /lib/ in order to forget about the LD_LIBRARY_PATH trick. As long as the filenames don't collide this is safe (I think, other advice welcome).

And even replace old binaries with new ones (only for selected ones) if you dare, but maybe not a good idea for a production server.

  • Question flagged as solved with your answer. I tested and this works perfectly. The programs are still in a separate folder and I change PATH when executing the scripts. – Gregory MOUSSAT May 12 '13 at 21:07
1

If you're going to install a lot of programs, maintaining them manually will be a pain. I recommend installing a newer distribution in a chroot.

You can install Fedora if you're used to it. I don't know if it has facilities to help installing in a chroot. If it doesn't, Debian and derivatives do, with Debootstrap. This guide may help. Such an old version of Fedora doesn't have schroot, but you may be able to install the rpm anyway.

If you can't get schroot to work, populate the chroot with bind mounts manually. If you have a distribution installed on /new, and you aren't using schroot, add these entries to /etc/fstab:

/           /new/old      rbind   rbind
/dev        /new/dev      rbind    rbind
/home       /new/home     rbind    rbind
/tmp        /new/tmp      rbind    rbind
proc        /new/proc     proc    defaults
sysfs       /new/sys      sysfs   defaults

As you'll be using bind mounts, make sure to configure your backup script not to traverse any of the bind-mounted directories, or you'll be backing them twice, once in the original location and once in the new location.

-1

Bash depends on libc, which is so old the chances of a successful compilation are very limited. Perhaps telling us what is the stuff your bash version is lacking would help.

schaiba
  • 7,631
  • 4
    libc6 hasn't changed that much in 8 years. – jordanm May 12 '13 at 15:44
  • I don't see anywhere in the question the word "compilation". So I don't understand your answer. – Gregory MOUSSAT May 12 '13 at 15:59
  • @schaiba you are right, probably the latest version of bash would require to recompile a lot of prerequisite libraries but he can try with some older version (better than the antique one he has). – andcoz May 12 '13 at 16:28