set environment variable through config file

Help
Jing Liu
2009-01-04
2013-05-09
  • Jing Liu
    Jing Liu
    2009-01-04

    Hi,

    I have a "Ubuntu 8.10 - WindowsXP" dual boot system. I am trying to follow this documentation:

    http://colinux.wikia.com/wiki/Dualbootscript

    to use Ubuntu through colinux 0.7.3 in WindowsXP. In my colinux configuration file I have

    # This parameter will be forward to Linux kernel.
    root=/dev/cobd0 COLINUX=1

    And in ubuntu I have created /etc/ini.d/colinux with the contents:

    if [[ "x$COLINUX" = "x1" ]]; then
        SUFFIX=colinux
    else
        SUFFIX=ubuntu
    fi

    for conf_file in \     "/etc/fstab" \     "/etc/network/interfaces"
    do
        ln -s -f $conf_file-$SUFFIX $conf_file
    done

    if [[ "x$COLINUX" = "x1" ]]; then
        touch /var/local/colinux
    else
        rm -f /var/local/colinux
    fi

    : exit 0

    Then I have created a link to this script in /etc/rcS.d/ with the name "S21colinux.sh"

    When I booted colinux, this script was executed. However, /var/local/colinux was removed instead of being created. The output of the command "echo $COLINUX" gave empty entry. Obviously the environment variable "$COLINUX" was not set. I checked the output in Windows command window and saw the following lines:

    ...
    Built 1 zonelists.  Total pages: 65024
    Kernel command line: root=/dev/cobd0 COLINUX=1
    Enabling fast FPU save and restore... done.
    ...

    Seems the parameters I setup in the configuration file was passed to colinux. But why wasn't it set in ubuntu?

    Thanks for your help in advance!

    Cheers, Jing

     
    • Henry N.
      Henry N.
      2009-01-04

      Not all distributions set any unhandled kernel parameters to the start script environment.

      An other all times working test for running colinux is this:
      if uname -r | grep -qe "-co-"
         touch /var/local/colinux
      else
         rm -f /var/local/colinux
      fi

       
    • Jing Liu
      Jing Liu
      2009-01-04

      Thanks Henry,

      It works for me with a little modification:

      if `uname -r | grep -qe "-co-"`; then
      touch /var/local/colinux
      else
      rm -f /var/local/colinux
      fi

      Cheers, Jing

       
      • Henry N.
        Henry N.
        2009-01-04

        Oh, yes. Sorry. I have forgotten a 'then' on copy & paste.
        This was my test script:

        if uname -r | grep -qe "-co-"
        then
           echo "I'm in coLinux"
        else 
           echo "I'm in native Linux"
        fi

        You not need the backtics for subshell.

         
        • Jing Liu
          Jing Liu
          2009-01-05

          Thanks again Henry. It works for me. Cheers, Jing