Fedora Linux Support Community & Resources Center
  #1  
Old 25th June 2010, 11:17 AM
snoopo71 Offline
Registered User
 
Join Date: Jun 2010
Location: Llívia, Cerdanya
Age: 26
Posts: 10
linuxfedorafirefox
bash script help needed please

Hi everibody!

First of all, I'm new to Fedora and i'm very happy with it, it's a great distribution!

Let's start, im writting a script to auto-install my programs and do some actions like auto-put my user in the sudoers file and so on, and I need some help in the nvidia drivers part of the code.
I've made a little function to install de akmod an drivers files, but now I want to disable the nouveau driver, I can do it manually by adding this expression " rdblacklist=nouveau " to the kernel load o0ptions in boot.conf, but I don't know how to do it automatically. Can anybody help me?

drivers_grafica(){
echo "Drivers grafica:"
yum install -y akmod-nvidia.x86_64 xorg-x11-drv-nvidia.x86_64 xorg-x11-drv-nvidia-devel.x86_64 xorg-x11-drv-nvidia-libs.x86_64

#rdblacklist=nouveau #I want to add this expression to the kernel load options!!
}

here is my line in grub.conf must look:

kernel /vmlinuz-2.6.33.5-124.fc13.x86_64 ro root=UUID=13671202-41e0-40d2-9e5b-0f775340d8c5 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=ca_AD.UTF-8 KEYBOARDTYPE=pc KEYTABLE=es rhgb quiet rdblacklist=nouveau



If someone want the entire script say it!!

---------- Post added at 12:17 PM CDT ---------- Previous post was at 11:39 AM CDT ----------

There is the complete script (not finished yet)

Code:
#!/bin/bash
#script per a instal·lar tot el necessari

main(){
echo "Que vols instal·lar ?"
echo "0)Tot"
echo "1)Repos:"
echo "2)Accions:"
echo "3)Drivers grafica:"
echo "4)Plugins:"
echo "5)Apps:"
echo "6)Dev tools:"
echo "7)test"
echo "8)sortir"

read opt

	case $opt in

	0) repos; accions; drivers_grafica; plugins; apps; dev_tools;;	

	1) repos;;
	
	2) accions;;
	
	3) drivers_grafica;;

	4) plugins;;
		
	5) apps;;
		
	6) dev_tools;;	
	
	7) testing; testing_2;;

	8) sortir;;
		
esac
}

sortir(){
exit 0
}

testing(){
	echo "estem testejant"
}

testing_2(){
	echo "continuem testejant"
}

repos(){ 
	echo "Repos:"
		rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm  http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
	}

accions(){ 
	echo "Accions:"
		echo 'user  ALL=(ALL)  ALL'  >> /etc/sudoers
	}

drivers_grafica(){
	echo "Drivers grafica:"
		yum install -y akmod-nvidia.x86_64 xorg-x11-drv-nvidia.x86_64 xorg-x11-drv-nvidia-devel.x86_64 xorg-x11-drv-nvidia-libs.x86_64 
		uname -a
		#cd /boot/grub/grub.conf
		#Y agregaremos al final de la línea (la más larga de todo el archivo) 			donde se encuentra el Kernel booteable lo siguiente:
		#rdblacklist=nouveau
	}

plugins(){
	echo "Plugins:"
		echo "gnome appearence tweak:"
			yum -y install gtweakui
		echo "ntfs support:"
			yum -y install ntfs-3g
		echo "multimedia:"
			yum -y install gstreamer-plugins-bad gstreamer-plugins-bad-free-extras gstreamer-plugins-bad-nonfree gstreamer-plugins-ugly gstreamer-ffmpeg xine-lib-extras xine-lib-extras-freeworld
		echo "flash:"
			yum erase flash-plugin nspluginwrapper*
			cd /etc/yum.repos.d/
			curl -O http://www.dfm.uninsubria.it/compiz/fusion-testing/flashplayer.x86_64/flash.repo
			rpm --import http://www.dfm.uninsubria.it/compiz/fusion-testing/flashplayer.x86_64/RPM-GPG-KEY-leigh123linux
			yum install flash-plugin
		echo "rar:"
			yum -y install rar unrar p7zip p7zip-plugins
		echo "java:"
			yum -y install java-1.6.0-openjdk
		echo "murrine engine gtk help:"
			yum -y install gtk-murrine-engine
	}

apps(){
	echo "Apps:"
		echo "awn:"
			yum -y install avant-window-navigator.x86_64 awn-extras-applets.x86_64 avant-window-navigator-devel.x86_64
		echo "amarok:"
			yum -y install amarok-utils.x86_64 amarok-libs.x86_64 amarok-utils.x86_64 moodbar.x86_64
		echo "vlc:"
			yum -y install vlc
		echo "OpenOffice:"
			yum -y install openoffice.org-writer openoffice.org-impress openoffice.org-calc

		echo "gparted:"
			yum -y install gparted.x86_64
		echo "compiz-emerald:"
			yum -y install compiz-devel.x86_64 compiz-fusion.x86_64 compiz-fusion-extras.x86_64 compiz-fusion-extras-gnome.x86_64 compiz-fusion-gnome.x86_64 compizconfig-python.x86_64 compiz-fusion-extras-devel.x86_64 libcompizconfig.x86_64 compizconfig-python.x86_64 emerald.x86_64 emerald-themes.noarch fusion-icon.noarch ccsm.noarch
	}

dev_tools(){
	echo "dev tools:"
			yum groupinstall "Development Tools"
	}

main

exit 0
Reply With Quote
  #2  
Old 25th June 2010, 02:28 PM
ultra magnus Offline
Registered User
 
Join Date: Nov 2007
Location: Finland
Age: 31
Posts: 313
linuxfedorafirefox
Re: bash script help needed please

I have been playing around with bash to create something similar myself, here's my nvidia installer function:
Code:
# Nvidia drivers:
app_install_4 ()
{
clear
if [ -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then
echo "yum install -y dkms akmod-nvidia xorg-x11-drv-nvidia-libs.i686" | sh
#blacklist Nouveau:
echo "Blacklisting Nouveau, please wait. . ."

sed -i '/root=/s|$| rdblacklist=nouveau|' /boot/grub/grub.conf
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname   -r)-nouveau.img
dracut /boot/initramfs-$(uname -r).img $(uname -r)

else
    echo "You need to enable the RPMFusion repository first."
    echo "Enable it now?"
    echo "Yes/No" ; read opt ;
	  case $opt in
	  Yes) repo_rpmfusion ;;
	  No)	app_menu ;;
	  esac
fi
}

# grab the rpmfusion.org rpms and install them:
repo_rpmfusion ()
{
clear
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uhv http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

}
entire working (ugly) script below:
Code:
#!/bin/bash
# same as fedset.sh, but using dialog.

version="0.0.2"
title="Fedora Linux Setup Script"
# check for dialog, if Not installed, ask to install it:
deptest ()
{
if [ -e /usr/bin/dialog ]; then welcome
else
    echo "This scripts needs dialog to run,\ninstall dialog?"\
    echo "Yes/No" ; read answer ;
	  
	  case $answer in
	  Yes)	yum_installdeps ;;
	  No)	exit 0 ;;	  
	  esac
fi

}
# A little information
welcome () 
{
dialog	--title " $title - $version "\
	--backtitle " $title - $version"\
	--msgbox "This is an easy setup utility for\
		  Fedora Linux versions 12,13 and above.\
		  \nThis script utilises yum, rpm and dialog.\
		  \nPress a key to continue. . ." 0 0
sel=$?
case $sel in
  0) main_menu;;
  1) exit 0;;
  255) exit 1;;
esac
}

# the MainMenu:
main_menu () 
{
dialog	--backtitle " $title - $version"\
	--title " Main Menu "\
	--menu " Move using [UP] [DOWN], [ENTER] to Select" 0 0 0\
	  Repositories	"Add repositories"\
	  UpdateSystem	"Update system"\
	  Applications 	"Choose applications to install"\
	  QuickInstall	"Install a set of basic apps"\
	  Quit 		"Exit"\
	  2>/tmp/menuitem.$$
	menuitem=`cat /tmp/menuitem.$$`
	opt=$?
	case $menuitem in
	Repositories) repo_menu ;;
	UpdateSystem) yum_update ; main_menu ;;
	Applications) app_menu ;;
	QuickInstall) quickfix_repo ; main_menu ;;
	Quit) exit 0 ;;
	esac

}
# the ReposMenu
repo_menu () 
{
dialog	--backtitle " $title - $version"\
	--title " Repositories "\
	--menu " Move using [UP] [DOWN], [ENTER] to Select" 0 0 0\
          Adobe         "Adobe flash-plugin"\
          Flash64       "64bit flash-plugin"\
	  KDE		"KDE-RedHat.sf.net, KDE-unstable"\
          Magnu5        "Rekonq beta and dropbox-servicemenu"\
          RPMFusion     "RPMFusion.org, multimedia and drivers"\
	  VirtualBox 	"Oracle VirtualBox-PUEL"\
          MainMenu      "Return to Main Menu"\
	  Quit		"Exit"\
	  2>/tmp/menuitem.$$
	menuitem=`cat /tmp/menuitem.$$`
	opt=$?
	case $menuitem in
        Adobe) repo_adobe ; repo_menu ;;
        Flash64) repo_flash64 ; repo_menu ;;
	KDE) repo_kde_redhat ; repo_menu ;;
        Magnu5) repo_magnu5 ; repo_menu ;;
        RPMFusion) repo_rpmfusion ; repo_menu ;;
	VirtualBox) repo_virtualbox ; repo_menu ;;
        MainMenu) main_menu ;;
	Quit) exit 0;;
	esac

}
# the ApplicationsMenu
app_menu ()
{
dialog	--backtitle " $title - $version"\
	--title " Applications "\
	--menu " Move using [UP] [DOWN], [ENTER] to Select" 0 0 0\
          DevelopmentTools      "RPM packagers choice"\
          DropBox       "DropBox client and ServiceMenu"\
	  Flash		"flash-plugin"\
	  Multimedia	"Amarok, Mplayer, codecs & plugins"\
	  Nvidia	"Nvidia drivers"\
          OpenOffice    "Oracle OpenOffice.org"\
	  VirtualBox	"Oracle VirtualBox-PUEL"\
	  MainMenu	"Return to Main Menu"\
	  Quit		"Exit"\
	  2>/tmp/menuitem.$$
	menuitem=`cat /tmp/menuitem.$$`
	opt=$?
	case $menuitem in
        DevelopmentTools) app_install_2 ; app_menu ;;
        DropBox) app_install_3 ; app_menu ;;
	Flash) app_install_7 ; app_menu ;;
	Multimedia) app_install_1 ; app_menu;;
        Nvidia) app_install_4 ; app_menu ;;
        OpenOffice) app_install_6 ; app_menu ;;
	VirtualBox) app_install_5 ; app_menu ;;
	MainMenu) main_menu ;;
	Quit) exit 0;;
	esac

}
# repositories below
#### Begin Repository Setup ####
quickfix_repo ()
{
dialog --msgbox "The following repositories will be enabled: \nVirtualBox\nRPMFusion" 0 0
sel=$?
case $sel in
  0) repo_adobe ; repo_rpmfusion ; repo_magnu5 ; quickfix_apps  ;;
  1) exit 0;;
  255) exit 1;;
esac
}

# Adobe repository:
repo_adobe ()
{
clear
rpm -Uhv http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

}

# grab the rpmfusion.org rpms and install them:
repo_rpmfusion ()
{
clear
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uhv http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

}

# grab the kde.repo and kde-i386.repo from kde-redhat.sf.net:
repo_kde_redhat ()
{
clear
cd /etc/yum.repos.d/
curl -O http://apt.kde-redhat.org/apt/kde-redhat/fedora/kde.repo
curl -O http://apt.kde-redhat.org/apt/kde-redhat/fedora/kde-i386.repo

}

# grab the virtualbox.spec from virtualbox.org:
repo_virtualbox ()
{
clear
cd /etc/yum.repos.d/
curl -O http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo

}

# Set up leigh123linux flash repository for the 64bit flash-plugin:
repo_flash64 ()
{
clear
cd /etc/yum.repos.d/
curl -O http://www.dfm.uninsubria.it/compiz/fusion-testing/flashplayer.x86_64/flash.repo
rpm --import http://www.dfm.uninsubria.it/compiz/fusion-testing/flashplayer.x86_64/RPM-GPG-KEY-leigh123linux

}


repo_magnu5 ()
{
clear
rpm -Uhv http://magnu5.fedorapeople.org/repo/magnu5-1.0-1.fc13.noarch.rpm

}

##### End of Repository Setup ####

#### Begin Application Install ####

# Install a bunch of apps.
quickfix_apps ()
{
dialog --msgbox "The following applications will be installed:\namarok xine-lib-extras xine-lib-extras-freeworld gecko-mediaplayer\nfirefox rekonq nss-mdns p7zip* lynx gimp inkscape digikam kipi-plugins flash-plugin gstreamer-plugins-bad gstreamer-plugins-ugly nspluginwrapper.x86_64 spluginwrapper.i686 alsa-plugins-pulseaudio.i686 libcurl.i686" 0 0
sel=$?
case $sel in
  0) app_install_1 ; app_install_7 ; app_install_6 ;;
  1) exit 0;;
  255) exit 1;;
esac
}

# Amarok, Mplayer, codecs and plugins:
app_install_1 ()
{
clear
if [ -e /etc/yum.repos.d/rpmfusion-free.repo ]; then
echo "yum install -y amarok xine-lib-extras xine-lib-extras-freeworld gecko-mediaplayer \
firefox rekonq nss-mdns p7zip* lynx gimp inkscape digikam kipi-plugins \
gstreamer-plugins-bad gstreamer-plugins-ugly" | sh

else
    echo "You need to enable the RPMFusion repository first."
    echo "Enable it now?"
    echo "Yes/No" ; read opt ;
	  case $opt in
	  Yes)	repo_rpmfusion ;;
	  No)	app_menu ;;
	  esac
fi
}

# Development Tools:
app_install_2 ()
{
clear
echo "yum install -y rpmdevtools fedora-packager rpmfusion-packager mock \
mock-rpmfusion-* kdesdk qt-creator kdebase-workspace-devel @development-tools" | sh

}

# Dropbox with servicemenu:
app_install_3 ()
{
clear
if [ -e /etc/yum.repos.d/magnu5.repo ]; then
echo "Downloading DropBox. . ."

#cd /etc/skel
#curl -O http://dl-web.dropbox.com/u/17/dropbox-lnx.x86_64-0.7.110.tar.gz
#tar xvzf dropbox-lnx.x86_64-0.7.110.tar.gz
#rm dropbox-lnx.x86_64-0.7.110.tar.gz
# Not a good idea, puts files in user dir.

echo "yum install -y dropbox-servicemenu" | sh
echo ". . . Press a key" ; read
else
    echo "You need to enable the Magnu5 repository first."
    echo "Enable it now?"
    echo "Yes/No" ; read opt ;
	  case $opt in
	  Yes)	repo_magnu5 ;;
	  No)	app_menu ;;
	  esac
fi
}

# Nvidia drivers:
app_install_4 ()
{
clear
if [ -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then
echo "yum install -y dkms akmod-nvidia xorg-x11-drv-nvidia-libs.i686" | sh
#blacklist Nouveau:
echo "Blacklisting Nouveau, please wait. . ."

sed -i '/root=/s|$| rdblacklist=nouveau|' /boot/grub/grub.conf
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname   -r)-nouveau.img
dracut /boot/initramfs-$(uname -r).img $(uname -r)

else
    echo "You need to enable the RPMFusion repository first."
    echo "Enable it now?"
    echo "Yes/No" ; read opt ;
	  case $opt in
	  Yes)	repo_rpmfusion ;;
	  No)	app_menu ;;
	  esac
fi
}

# VirtualBox-PUEL:
app_install_5 ()
{
clear
if [ -e /etc/yum.repos.d/virtualbox.repo ]; then
echo "yum install -y kernel-devel dkms VirtualBox-3.2" | sh

else
    echo "You need to enable the VirtualBox repository first."
    echo "Enable it now?"
    echo "Yes/No" ; read opt ;
	  case $opt in
	  Yes)	repo_virtualbox ;;
	  No)	app_menu ;;
	  esac
fi
}

# OpenOffice.org:
app_install_6 ()
{
clear
echo "yum install -y openoffice.org-writer openoffice.org-calc openoffice.org-impress && yum remove -y koffice*" | sh

}

# Flash
app_install_7 ()
{
clear
if [ -e /etc/yum.repos.d/adobe-linux-i386.repo ]; then
echo "yum install -y flash-plugin nspluginwrapper.x86_64 nspluginwrapper.i686 alsa-plugins-pulseaudio.i686 libcurl.i686" | sh

else
    echo "You need to enable the Adobe repository first."
    echo "Enable it now?"
    echo "Yes/No" ; read opt ;
	  case $opt in
	  Yes)	repo_adobe ;;
	  No)	app_menu ;;
	  esac
fi
}

# yum update
yum_update ()
{
yum update -y

}

# Check for dialog
yum_installdeps ()
{
clear
echo "yum install -y dialog" | sh ; deptest
}

deptest
__________________
my blog
my forum
my "art"
my packages
IRC: Magnu5
Reply With Quote
  #3  
Old 25th June 2010, 02:50 PM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,854
linuxfirefox
Re: bash script help needed please

If you would have bothered to look at Leigh's Nvidia driver install guide, you would found the command(s) you are looking for:
Quote:
2. Edit grub.conf ( if you omit this step the driver will fail to work )


this command adds rdblacklist=nouveau option to /boot/grub/grub.conf

Code:

su -
sed -i '/root=/s|$| rdblacklist=nouveau|' /boot/grub/grub.conf
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
dracut /boot/initramfs-$(uname -r).img $(uname -r)


3. Reboot
Reply With Quote
  #4  
Old 25th June 2010, 03:47 PM
vallimar Offline
Registered User
 
Join Date: Jul 2008
Posts: 1,030
windows_xp_2003chrome
Re: bash script help needed please

Nobody else seems to realize this, but you don't have to touch grub at all.
The alternative that I use, and much prefer, is adding dracut options to /etc/cmdline.
Newer versions even allow for having multiple lines, so you can have one option per line.
Reply With Quote
  #5  
Old 27th June 2010, 01:10 PM
snoopo71 Offline
Registered User
 
Join Date: Jun 2010
Location: Llívia, Cerdanya
Age: 26
Posts: 10
linuxfedorafirefox
Thumbs up Re: bash script help needed please

Thanx everybody I finally found a solution using sed, but I prefer yours. Thanx a lot!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script help woodson2 Programming & Packaging 1 5th May 2009 03:29 PM
Bash Script Help Jamwa Using Fedora 5 17th June 2008 05:26 PM
Convert bash script to perl script homey Programming & Packaging 1 2nd September 2006 04:24 AM


Current GMT-time: 03:12 (Sunday, 20-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat