Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 23rd, 2005, 10:57 PM   #1
kdepfyffer
Newbie
 
Join Date: May 2005
Posts: 2
Rep Power: 0 kdepfyffer is on a distinguished road
fedora USB create boot image script

I'm sure I'm going to get an rtfm but what the heck. First of all I'm a total noob.
I don't have a dedicated machine to test fedora betas so I run it on my USB drive.
after getting tired of typing everything in to create a kernel image i decided to create a script.
my script works but I want it to be even easier than it is now. Here's what I'm using.
#!/bin/sh
# writen by Kevin dePfyffer - kdepfyffer@depfyffer.com
# because I was tired of typing it all in :-)
ls /lib/modules
echo "enter the kernel version you would like to use"
read kernel
/sbin/mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod /boot/initrd.''$kernel''.usb.img ''$kernel''
echo "please update your /boot/grub/grub.conf before you reboot"
yes I know its simple and lame but hey I'm new to the whole shell stuff.
Is there any way for me to create a menu (1. 2. 3. etc) from the ls command then use read
and an if statement to get $kernel.
bonus question,
how can I pipe something like this to the end of grub.conf (without overwriting of course)
title Fedora Core ("$kenel"-usb)
root (hd0,0)
kernel /vmlinuz-"$kernel" ro root=LABEL=/ rhgb quiet
initrd /initrd.''$kernel''.usb.img
kdepfyffer is offline   Reply With Quote
Old May 25th, 2005, 12:11 AM   #2
kdepfyffer
Newbie
 
Join Date: May 2005
Posts: 2
Rep Power: 0 kdepfyffer is on a distinguished road
[solved]

I was able to solve the first part by reading about 5 different how-to's and lifting a few portions of other scripts. I can tell I'll never be a programmer but thats ok, I get by :-)
I would still like some help on piping some text to grub.conf if anyone can help me out with that.
Here's the final code that is working.
#!/bin/bash
# easy way to create a initrd image to boot a USB drive in Fedora Core 3 or 4
# has not been tested on any other OS
# Written by kevin dePfyffer - kdepfyffer@depfyffer.com
ls -1 /lib/modules > /tmp/kernel.lst # populate the kernel list

kernel_list="/tmp/kernel.lst" # set Kernel list

n=0		# make sure the counter doesn't contain randome values.
while read; do
	Kernel[$n]=$REPLY 		# Put the directories in an array
	echo "$n) ${Kernel[$n]}"	# create the menu
	n=$(( n + 1 ))			# increment the menu
	done < $kernel_list		# input the read statement
echo "Enter the number of the kernel you would like to use"
read
if [ ! -z $REPLY ]; then
	Choice="${Kernel[$REPLY]}"
echo "you chose to use $Choice"
fi
/sbin/mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod /boot/initrd-''$Choice''.usb.img ''$Choice''
rm /tmp/kernel.lst
echo "please update your /boot/grub/grub.conf before you reboot"

If you see any problems with the script/format please let me know.
kdepfyffer is offline   Reply With Quote
Old May 25th, 2005, 8:31 AM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
echo $DATA >> /boot/grub/grub.conf

cat $DATA >> /boot/grub/grub.conf


The >> is used to append to the end of a file.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC