Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Bash Script Help Needed, trying to do some programing here :)
Robert83
post Apr 13 2004, 05:16 AM
Post #1


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

here is my code [did it alone smile.gif, and aint working smile.gif] :

CODE
I modified the wrong post, so this one is lost , sorry


the problem is that I don't know how to check ther kernel-source version, and only read the version number, not like kernel-source-2.4[blablabla] only 2.4[blablabla] and compare it to kernel_version [if that is a correct way to do it]

another problem is when I download with apt-get install kernel-source#$kernel_version , how do I put in that # ?

also is there a way to somehow download with wget files like this NVIDIA-Linux--x86-1.0-****-pkg1.run
so that it would always download the latest ?

please help me...

Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 05:31 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

well I solved the apt-get install kernel-source stuff...like this

kernel_version2="#"$kernel_version

apt-get install kernel_version2

but I still don't know how to check only the version number of the kernel source



Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 13 2004, 06:03 AM
Post #3


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



Good Job!

change the line:

kernel_source_version=`rpm -q kernel-source`

to

kernel_source_version=`rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}'`


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 13 2004, 06:11 AM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



That doesn't prepare the kernel source and do make dep ... but it should work for the majority of cases for RedHat distro's (RedHat 7.3-9, FedoraCore) ... (use apt-get install vice apt-get download)


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 06:12 AM
Post #5


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Thank you ! smile.gif

WoooooooW, that is some complex line ohmy.gif

[well I'm still at the beggining of this stuff, reading that Advenced Bash-Scripting Guide, seems long enough to actualy learn something from it...after this (1year probably), I'll move to C]

yes I know, but the problem is that I still don't know how to change stuff in files, ...like remove the custom in line 3 or 4 [?], etc... modify nv to nvidia etc... I'm doing this only to do something more complex, after I can do everything with this, I'll create a script that will download nvidia and ati drivers do everything, and you'll need to reboot, and everything is working [hopefully]

Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 13 2004, 06:23 AM
Post #6


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



You also want to take into account smp and athlon kernel types. For example, the command uname -r might be:

2.4.21-9.0.1.ELsmp

or

2.4.21-9.0.1.ELalthon

instead of

2.4.21-9.0.1.EL

but they all use the same kernel source.....of 2.4.21-9.0.1.EL

so change:

kernel_version=`uname -r`

to

kernel_version=`uname -r | awk '{split($1,a,"smp");print a[1];}' | awk '{split($1,a,"athlon");print a[1];}'`

(in case it wraps, the the new kernel_version is all one line)

That should return

2.4.21-9.0.1.EL

for 2.4.21-9.0.1.ELsmp, 2.4.21-9.0.1.ELalthon, or 2.4.21-9.0.1.EL


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 06:30 AM
Post #7


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

thank you...

but I'll still need to use that previous

rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}` to rigth?

like this

rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}` awk '{split($1,a,"smp");print a[1];}' awk '{split($1,a,"athlon");print a[1];}' ?


Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 06:37 AM
Post #8


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

could you please tell me how to use colors with echo ? , or is it possible, to write out NVIDIA in red , or some other text in blue, green etc. ?

Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 13 2004, 06:41 AM
Post #9


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



QUOTE (Robert83 @ Apr 13 2004, 06:30 AM)
Hi,

thank you...

but I'll still need to use that previous

rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}` to rigth?

like this

rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}` awk '{split($1,a,"smp");print a[1];}' awk '{split($1,a,"athlon");print a[1];}'  ?


Sincerely
Robert B

Nope ... the kernel_source_version is:

kernel_source_version=`rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}'`

AND kernel_version is:

kernel_version=`uname -r | awk '{split($1,a,"smp");print a[1];}' | awk '{split($1,a,"athlon");print a[1];}'`


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 13 2004, 06:46 AM
Post #10


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



QUOTE (Robert83 @ Apr 13 2004, 06:37 AM)
could you please tell me how to use colors with echo ? , or is it possible, to write out NVIDIA in red , or some other text in blue, green etc. ?

Go here:

http://ldp.linuxhelp.ca/LDP/abs/html/colorizing.html


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 06:51 AM
Post #11


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

Thank you for your help , very-very much ! smile.gif smile.gif

Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 07:31 AM
Post #12


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

so I think the solution is, that I search with grep for that custom in Makefile, but how do I pass it to the command [which I dont know smile.gif], to remove it... [and what is the command to replace that line with something else ? ]


Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 07:38 AM
Post #13


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

found it out, "replace that file" the command is replace smile.gif smile.gif

so I tried it manualy
touch robi
added the line left
replace left right -- robi robi

and it changed left to right, so I think it will work with the makefile as well, change custom to nothing [that's like removing it right?]

the problem is that it won't work , I mean change robi to "nothing" [remove it] , any ideas?

Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 11:35 AM
Post #14


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

I think I did it, it now fully prepares the kernel-source [download, and preparation is included], then goes to the point where you need to install the nvidia display driver...it even checks your current runlevel and if everything goes acording to plan, sets the system to runlevel 3 reboots, and you can run it again, once it finished it replaces nv or vesa with nvidia, sets the system back to runlevel 5 and tells you to reboot smile.gif

here is the code :

CODE
#!/bin/bash

username=root
current_user=`whoami`
kernel_version=`uname -r | awk '{split($1,a,"smp");print a[1];}' | awk '{split($1,a,"athlon");print a[1];}'`
kernel_version2="#"$kernel_version
blue_color='E[00;34m'
green_color='E[00;32m'
red_color='E[00;31m'
cyan_color='E[00;36m'
norm="tput sgr0"

clear

echo                "                    -------------------------------------------"
echo  -e $blue_color "                    Welcome to the NVIDIA Installer Bash Script"; $norm
echo  -e $green_color"                                   By Robert B"               ; $norm
echo  -e $red_color  "                             Thanks goes to Hughesjr"         ; $norm
echo                "                                       and"
echo  -e $red_color  "                                www.linuxhelp.ca"             ; $norm
echo                "                    -------------------------------------------"

echo "----------------------------"
echo " Checking If Runlevel is 3"
echo "----------------------------"

run_level=`cat /etc/inittab | grep id`
run_level_not_good=id:5:initdefault:

if [ $run_level = $run_level_not_good ]; then

   echo -e $red_color"[INFORMATION] :"; $norm
   echo "Your Runlevel Is Not 3 , I'm Rebooting The System In Runlevel 3"
   cd /etc
   replace id:5:initdefault: id:3:initdefault inittab inittab
   reboot

else

   echo -e $red_color"[INFORMATION] :"; $norm
   echo "Your Runlevel is 3 , Proceeding With Installation"

fi

echo
echo               "------------------------------"
echo  -e $cyan_color"Step 1 : Check If User Is root"; $norm
echo               "------------------------------"
echo

if [ $current_user = $username ]; then

   echo -e  $red_color"[INFORMATION] :"; $norm
   echo "You Are $current_user"
   echo "Please Stand By while I Download The NVIDIA Display Driver"
   
else

   echo  -e $red_color"[INFORMATION] :"; $norm
   echo "You Are Not $username, You Are $current_user , Please Change To $username!"
   echo
   echo  -e $green_color"HOWTO CHANGE TO ROOT ? : Press CTRL-ALT-BACKSPACE And Then Type Username root"
   echo "And Type In Your root Password And Hit Enter, And Then Run This Script Again"; $norm
   echo
   echo "Aborting Installation !"
   exit 0
fi

kernel_source_version=`rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}'`

echo
echo               "---------------------------------------------------------"
echo  -e $cyan_color"Step 2 : Checking If User Has The Kernel Source Installed"; $norm
echo               "---------------------------------------------------------"
echo

if [ $kernel_source_version = $kernel_version ]; then
 
   echo -e $red_color"[INFORMATION :]"; $norm
   echo "You Have The Correct Kernel Source , Please Wait While I Download"
   echo "The NVIDIA Display Driver"
   echo
   echo -e $red_color"There Will Be Lots Of Things Showing Up On The Screen, While The Kernel"
   echo "Source Is Prepared For The NVIDIA Driver Installation"; $norm
   cd /home
   mkdir nvidia
   cd nvidia
   echo -e $green_color
   wget http://download.nvidia.com/XFree86/Linux-x86/1.0-5336/NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   $norm
   cd /usr/src/linux-$kernel_version
   make mrproper
   cp /boot/config-$kernel_version /usr/src/linux-$kernel_version/.config
   replace custom '' -- Makefile Makefile &&
   make oldconfig &&
   make dep &&
   cd /home/nvidia
   chmod 755 NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   ./NVIDIA-Linux-x86-1.0-5336-pkg1.run
   cd /etc/X11
   replace nv nvidia XF86Config XF86Config
   replace vesa nvidia XF86Config XF86Config
   cd /etc
   replace id:3:initdefault: id:5:initdefault: inittab inittab
   echo -e $green_color"Now Reboot, And Your System Has 3D Hardware Acceleration Enabled"; $norm
   
else

   echo -e $red_color"[INFORMATION :]"; $norm
   echo "You Don't Have The Kernel Source Installed, Please Wait While I Download"
   echo "The Kernel Source"
   echo -e $red_color"There Will Be Lots Of Things Showing Up On The Screen, While The Kernel"
   echo "Source Is Prepared For The NVIDIA Driver Installation"; $norm
   apt-get install kernel$kernel_version2 &&
   cd /usr/src/linux-$kernel_version
   make mrproper
   cp /boot/config-$kernel_version /usr/src/linux-$kernel_version/.config
   replace custom '' -- Makefile Makefile &&
   make oldconfig &&
   make dep &&
   echo
   echo -e $red_color"[INFORMATION :]"; $norm
   echo "Kernel Source Downloaded Installed And Prepared, Please Stand By While I Download The NVIDIA"
   echo "Display Driver"
   echo
   cd /home
   mkdir nvidia
   cd nvidia
   echo -e $green_color
   wget http://download.nvidia.com/XFree86/Linux-x86/1.0-5336/NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   $norm
   chmod 755 NVIDIA-Linux-x86-1.0-5336-pkg1.run &&    
   ./NVIDIA-Linux-x86-1.0-5336-pkg1.run
   cd /etc/X11
   replace nv nvidia XF86Config XF86Config
   replace vesa nvidia XF86Config XF86Config
   cd /etc
   replace id:3:initdefault: id:5:initdefault: inittab inittab
   echo -e $green_color"Now Reboot, And Your System Has 3D Hardware Acceleration Enabled"; $norm
fi    
   


what do you think? could it be of any use to people who want a easy way to install the driver?

Sincerely
Robert B

ps.: I think I'll do one for the Ati driver to, just to practice smile.gif


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
Robert83
post Apr 13 2004, 12:44 PM
Post #15


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

I have a little problem tough :

It won't change id:5:initdefault to id:3:initdefault, can someone tell me why?

the problem seems to be this : , hmm... how can I replace strings that have a : between them ?


Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 14 2004, 06:04 AM
Post #16


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



I wouldn't use replace (it is not installed on all RH machines ... I think only those with mysql) ,,, but I would use sed instead ....

Here is how to edit the inittab file with sed:

cd /etc
cp -f inittab inittab.bak
sed '/id:5:initdefault:/s//id:3:initdefault:/g' inittab > inittab.test
cp -f inittab.test inittab
rm -f inittab.test


that should leave you with inittab.bak which is the original inittab .... and a new inittab with a id:3:initdefault: if the original had id:5:initdefault: .... if you have id:3:initdefault: already and want to switch to id:5:initdefault:, just make the sed line look like this:

sed '/id:3:initdefault:/s//id:5:initdefault:/g' inittab > inittab.test

We could also use perl and search and replace directly in the file (or python, or php), but this works without anything else except sed intstalled.


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
hughesjr
post Apr 14 2004, 06:09 AM
Post #17


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



Also .. since you are running this from the command line as root, it isn't super important because you have root's environment, but you should either add PATH statement in the top of the file OR use full pathnames to executables like sed or replace ....


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
Robert83
post Apr 14 2004, 10:34 AM
Post #18


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,439
Joined: 3-January 04
From: Germany
Member No.: 2,069



Hi,

I did what you told me and here is the code :

CODE
#!/bin/bash
PATH={$PATH}:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/sbin:/usr/sbin

username=root
current_user=`whoami`
kernel_version=`uname -r | awk '{split($1,a,"smp");print a[1];}' | awk '{split($1,a,"athlon");print a[1];}'`
kernel_version2="#"$kernel_version
blue_color='E[00;34m'
green_color='E[00;32m'
red_color='E[00;31m'
cyan_color='E[00;36m'
norm="tput sgr0"
run_level=`cat /etc/inittab | grep id`
run_level_not_good=id:5:initdefault:
level_5=id:5
level_3=id:3

clear

echo                "                    -------------------------------------------"
echo  -e $blue_color "                    Welcome to the NVIDIA Installer Bash Script"; $norm
echo  -e $green_color"                                   By Robert B"                ; $norm
echo  -e $red_color  "                             Thanks goes to Hughesjr"          ; $norm
echo                "                                       and"
echo  -e $red_color  "                                www.linuxhelp.ca"              ; $norm
echo                "                    -------------------------------------------"

echo "----------------------------"
echo " Checking If Runlevel is 3"
echo "----------------------------"


if [ $run_level = $run_level_not_good ]; then

   echo -e $red_color"[INFORMATION] :"; $norm
   echo "Your Runlevel Is Not 3 , I'm Rebooting The System In Runlevel 3"
   cd /etc &&
   sed '/id:5:initdefault:/s//id:3:initdefault:/g' inittab > inittab.test &&
   cp -f inittab.test inittab &&
   rm -f inittab.test &&
   reboot
   exit 0
else

   echo -e $red_color"[INFORMATION] :"; $norm
   echo "Your Runlevel is 3 , Proceeding With Installation"

fi

echo
echo               "------------------------------"
echo  -e $cyan_color"Step 1 : Check If User Is root"; $norm
echo               "------------------------------"
echo

if [ $current_user = $username ]; then

   echo -e  $red_color"[INFORMATION] :"; $norm
   echo "You Are $current_user"
   echo "Please Stand By while I Download The NVIDIA Display Driver"
   
else

   echo  -e $red_color"[INFORMATION] :"; $norm
   echo "You Are Not $username, You Are $current_user , Please Change To $username!"
   echo
   echo  -e $green_color"HOWTO CHANGE TO ROOT ? : Press CTRL-ALT-BACKSPACE And Then Type Username root"
   echo "And Type In Your root Password And Hit Enter, And Then Run This Script Again"; $norm
   echo
   echo "Aborting Installation !"
   exit 0
fi

kernel_source_version=`rpm -q kernel-source | awk '{split($1,a,"source-");print a[2];}'`

echo
echo               "---------------------------------------------------------"
echo  -e $cyan_color"Step 2 : Checking If User Has The Kernel Source Installed"; $norm
echo               "---------------------------------------------------------"
echo

if [ $kernel_source_version = $kernel_version ]; then
 
   echo -e $red_color"[INFORMATION :]"; $norm
   echo "You Have The Correct Kernel Source , Please Wait While I Download"
   echo "The NVIDIA Display Driver"
   echo
   echo -e $red_color"There Will Be Lots Of Things Showing Up On The Screen, While The Kernel"
   echo "Source Is Prepared For The NVIDIA Driver Installation"; $norm
   cd /home
   mkdir nvidia
   cd nvidia
   echo -e $green_color
   wget http://download.nvidia.com/XFree86/Linux-x86/1.0-5336/NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   $norm
   cd /usr/src/linux-$kernel_version
   make mrproper &&
   cp /boot/config-$kernel_version /usr/src/linux-$kernel_version/.config
   sed 'custom/s//g' Makefile > Makefile.test
   cp -f Makefile.test Makefile
   rm -f Makefile.test
   make oldconfig &&
   make dep &&
   cd /home/nvidia
   chmod 755 NVIDIA-Linux-x86-1.0-5336-pkg1.run
   ./NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   cd /etc/X11
   sed '/nv/s//nvidia/g' XF86Config > XF86Config.test
   cp -f XF86Config.test XF86Config
   rm -f XF86Config.test
   sed '/vesa/s//nvidia/g' XF86Config > XF86Config.test
   cp -f XF86Config.test XF86Config
   rm -f XF86Config.test
   cd /etc
   sed '/id:3:initdefault:/s//id:5:initdefault:/g' inittab > inittab.test
   cp -f inittab.test inittab
   rm -f inittab.test
   echo -e $green_color"Now Reboot, And Your System Has 3D Hardware Acceleration Enabled"; $norm
   
else

   echo -e $red_color"[INFORMATION :]"; $norm
   echo "You Don't Have The Kernel Source Installed, Please Wait While I Download"
   echo "The Kernel Source"
   echo -e $red_color"There Will Be Lots Of Things Showing Up On The Screen, While The Kernel"
   echo "Source Is Prepared For The NVIDIA Driver Installation"; $norm
   apt-get install kernel$kernel_version2 &&
   cd /usr/src/linux-$kernel_version
   make mrproper &&
   cp /boot/config-$kernel_version /usr/src/linux-$kernel_version/.config
   sed 'custom/s//g' Makefile > Makefile.test
   cp -f Makefile.test Makefile
   rm -f Makefile.test
   make oldconfig &&
   make dep &&
   echo
   echo -e $red_color"[INFORMATION :]"; $norm
   echo "Kernel Source Downloaded Installed And Prepared, Please Stand By While I Download The NVIDIA"
   echo "Display Driver"
   echo
   cd /home
   mkdir nvidia
   cd nvidia
   echo -e $green_color
   wget http://download.nvidia.com/XFree86/Linux-x86/1.0-5336/NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   $norm
   chmod 755 NVIDIA-Linux-x86-1.0-5336-pkg1.run
   ./NVIDIA-Linux-x86-1.0-5336-pkg1.run &&
   cd /etc/X11
   sed '/nv/s//nvidia/g' XF86Config > XF86Config.test
   cp -f XF86Config.test XF86Config
   rm -f XF86Config.test
   sed '/vesa/s//nvidia/g' XF86Config > XF86Config.test
   cp -f XF86Config.test XF86Config
   rm -f XF86Config.test
   cd /etc
   sed '/id:3:initdefault:/s//id:5:initdefault:/g' inittab > inittab.test
   cp -f inittab.test inittab
   rm -f inittab.test
   echo -e $green_color"Now Reboot, And Your System Has 3D Hardware Acceleration Enabled"; $norm
fi    
   


Sincerely
Robert B


--------------------
Robert Becskei
robert83@linuxhelp.net
--------------------
May the source be with us!
--------------------
AMD X2-3800 @ 2400Mhz
2048MB DDR 400Mhz
DFI Lanparty UT4 NF4 ULTRA-D
GeForce 7800GT
250GB+250GB
Pioneer DVD-RW
17inch Samsung Syncmaster 757NF
WinXP Pro (SP2)/ CentOS 4.3
--------------------
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd October 2017 - 11:33 PM