Register
It is currently Fri Oct 24, 2014 9:32 pm

need some help editing a script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Thu May 11, 2006 3:49 pm   
User avatar

Joined: Tue May 17, 2005 12:55 am
Posts: 86
Location: Big Easy, Louisiana
i would like to take this script that comes with slax and tweak it to ask me which directory i would like to make an iso.

crouse...here is a place that i am attempting to learn about bash ;)

Code:
#!/bin/bash
# ---------------------------------------------------
# Script to create bootable ISO in Linux
# usage: make_iso.sh [ /tmp/slax.iso ]
# author: Tomas M. <http://www.linux-live.org>
# ---------------------------------------------------

if [ "$1" = "--help" -o "$1" = "-h" ]; then
  echo "This script will create bootable ISO from files in curent directory."
  echo "Current directory must be writable."
  echo "example: $0 /mnt/hda5/slax.iso"
  exit
fi

CDLABEL="SLAX"
ISONAME="$1"

if [ "$ISONAME" = "" ]; then
   SUGGEST="../`basename \`pwd\``.iso"
   echo -ne "Target ISO file name [ Hit enter for $SUGGEST ]: "
   read ISONAME
   if [ "$ISONAME" = "" ]; then ISONAME="$SUGGEST"; fi
fi

# isolinux.bin is changed during the ISO creation,
# so we need to restore it from backup.
cp -f boot/isolinux.bi_ boot/isolinux.bin
if [ $? -ne 0 ]; then
   echo "Can't recreate isolinux.bin, make sure your current directory is writable!"
   exit 1
fi

mkisofs -o "$ISONAME" -v -J -R -D -A "$CDLABEL" -V "$CDLABEL" \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b boot/isolinux.bin -c boot/isolinux.boot .


Top
 Profile YIM  
 PostPosted: Fri May 12, 2006 10:14 am   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
coastie wrote:
i would like to take this script that comes with slax and tweak it to ask me which directory i would like to make an iso.

crouse...here is a place that i am attempting to learn about bash ;)

Code:
#!/bin/bash
# ---------------------------------------------------
# Script to create bootable ISO in Linux
# usage: make_iso.sh [ /tmp/slax.iso ]
# author: Tomas M. <http://www.linux-live.org>
# ---------------------------------------------------

if [ "$1" = "--help" -o "$1" = "-h" ]; then
  echo "This script will create bootable ISO from files in curent directory."
  echo "Current directory must be writable."
  echo "example: $0 /mnt/hda5/slax.iso"
  exit
fi

CDLABEL="SLAX"
ISONAME="$1"

if [ "$ISONAME" = "" ]; then
   SUGGEST="../`basename \`pwd\``.iso"
   echo -ne "Target ISO file name [ Hit enter for $SUGGEST ]: "
   read ISONAME
   if [ "$ISONAME" = "" ]; then ISONAME="$SUGGEST"; fi
fi

# isolinux.bin is changed during the ISO creation,
# so we need to restore it from backup.
cp -f boot/isolinux.bi_ boot/isolinux.bin
if [ $? -ne 0 ]; then
   echo "Can't recreate isolinux.bin, make sure your current directory is writable!"
   exit 1
fi

mkisofs -o "$ISONAME" -v -J -R -D -A "$CDLABEL" -V "$CDLABEL" \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b boot/isolinux.bin -c boot/isolinux.boot .


i would do something more like this:
Code:
#!/bin/bash
# ---------------------------------------------------
# Script to create bootable ISO in Linux
# usage: make_iso.sh [ /tmp/slax.iso ]
# author: Tomas M. <http://www.linux-live.org>
# ---------------------------------------------------

if [ "$1" = "--help" -o "$1" = "-h" ]; then
  echo "This script will create bootable ISO from files in curent directory."
  echo "Current directory must be writable."
  echo "example: $0 /mnt/hda5/slax.iso"
  exit
fi

CDLABEL="SLAX"
ISONAME="$1"
echo "Please enter the directory where you would like the iso created"
read -p ": " to_dir
if [ "${to_dir:${#to_dir}-1}" = "/" ]
then
   to_dir="${to_dir:0:${#to_dir}-1}"
fi

if [ ! -w "${to_dir}" ]
then
   echo "That directory either doesn't exist, or is not writtable!"
   exit
fi

if [ "$ISONAME" = "" ]; then
   SUGGEST="../`basename \`pwd\``.iso"
   echo -ne "Target ISO file name [ Hit enter for $SUGGEST ]: "
   read ISONAME
   if [ "$ISONAME" = "" ]; then ISONAME="$SUGGEST"; fi
fi

# isolinux.bin is changed during the ISO creation,
# so we need to restore it from backup.
cp -f boot/isolinux.bi_ "${to_dir}"/boot/isolinux.bin
if [ $? -ne 0 ]; then
   echo "Can't recreate isolinux.bin, make sure your current directory is writable!"
   exit 1
fi

mkisofs -o "$ISONAME" -v -J -R -D -A "$CDLABEL" -V "$CDLABEL" \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b boot/isolinux.bin -c boot/isolinux.boot "${to_dir}"


let me know if that works... can't say i have ever tried doing what you are talking about, but it seems it would work this way :)


Top
 Profile  
 PostPosted: Thu May 18, 2006 2:04 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
I have also edited that script to suit me, as I maintain 2 version of my slax distro (based on normal and frodo) I have two different slax locations, /home/rob/slax and /home/rob/slax-frodo.
Code:
#!/bin/bash
function ifslaxd ()
{
read -p "Where are your slax files located (no trailing slash): " slaxdir
if [[ -d $slaxdir/base ]]
then
echo " "
else
echo "either $slaxdir does not exist or it does not contain the right files, please try again." &&
ifslaxd
fi
}
ifslaxd
read -p "what would you like the name of the disc to be : " discname
read -p "What would you like the iso to be called (no .iso needed) : " isoname
mkisofs -o /home/$USER/$isoname.iso -v -J -R -D -A $discname -V $discname \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b boot/isolinux.bin -c boot/isolinux.boot $slaxdir
cd /home/$USER
chmod 777 $isoname.iso


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP