LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   a newbie trying to go further (https://www.linuxquestions.org/questions/linux-newbie-8/a-newbie-trying-to-go-further-336674/)

jacktheripperis 06-24-2005 03:34 AM

a newbie trying to go further (VMWARE_GSX & KERNEL)
 
I present you the problem i'd like to resolve:

I've got Suse9.2 but unfortunately I need to work on Windows every now and then. So I use the Vmware GSX server for this (and for testing net stuff & all).
Upon installing VmwareGSX I realised that it cannot run with the kernel(2.6.8-24-default) that comes with this distribution of SuSe, so i configured and compiled the kernel(2.6.4-52-default) on which it runs perfecly. Now, i've got GRUB with wich I can boot with one or the other. And 'till here all is OK.
What happens? GSX, unlike the Vmware Workstation, is a system service that loads at boot time. If I boot with the original kernel (2.6.8-24-default) it does not start up - which is OK - but on the next reboot with the 'older' kernel (2.6.4-52-default) with witch it should work it asks me to reconfigure vmware running the vmware-config.pl & I want to avoid this. I want to make sure that my GSXserver starts up ONLY with the working kernel and with nothing else.

Lots of words for a simple question: How do I restrict the startup of a system service (in my case it should be /etc/rc.d/vmware) depending on the kernel i am using? what file/variable tells me the version of my running kernel?

Thanks in advance,
Adam

zackarya 06-24-2005 03:59 AM

I can help on the last question. To find out the current kernel version you can use

uname -r

uname has a few different options on what it can display to you. Not sure about the
vmware thing though as I don't use it.

Hope that helps.

Zack

jacktheripperis 06-24-2005 04:51 AM

uname -r
 
Thanks, this is the first bit i was missing. With my ok kernel
Code:

uname -r
gives me: 2.6.4-52-default
This is exactly what i need.

So now i shoud construct a condition something like

If uname -r == "2.6.4-52-default" Then
...start up the service...
EndIf


As you can tell I don't know very well bash scripting... do you know the exact syntax to make this condition???


LINUX RULES!
adam

jacktheripperis 06-24-2005 06:21 AM

I've got it!
 
I resolved it and i post it for anyone who might have a similar problem to resolve.

Code:

#!/bin/sh
myKernelVersion=`uname -r`
if [ $myKernelVersion = "2.6.4-52-default" ]; then
        echo OK - starting sevice...
        #start vmware script
fi
exit 0

I also found where to insert this piece of code in order to make it work. The vmware GSX server has a script file in /etc/init.d/ called vmware. You can use this script to start/stop/restart the vmware service by issuing the commands:
Code:

/etc/init.d/vmware start
/etc/init.d/vmware stop
/etc/init.d/vmware restart

It is here (in my case @ line #813) that I inserted my code in order to start up the service only with the working kernel...here it goes:
Code:

# See how we were called.
case "$1" in
  start)
        #checking KERNEL VERSION -> ALLOW STARTUP ONLY FOR: "2.6.4-52-default"
        myKernelVersion=`uname -r`
        if [ $myKernelVersion != "2.6.4-52-default" ]; then
            echo JACK PROHIBITED TO RUN VMWARE SERVICE ON KERNEL: $myKernelVersion
            exit 1
        else
            echo STARTING TO RUN VMWARE SERVICE ON KERNEL: $myKernelVersion
        fi       
        #checking finished - the rest remains untouched

I don't know if this is the best way of doing it but I tested this and for me it works fine!
ciao a tutti!



All times are GMT -5. The time now is 09:31 PM.