Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 142428 Details for
Bug 208499
Proposed LiveUSB script
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
liveusb script
liveusb.sh (text/plain), 4.28 KB, created by
Nelson
on 2008-02-01 21:03:28 UTC
(
hide
)
Description:
liveusb script
Filename:
MIME Type:
Creator:
Nelson
Created:
2008-02-01 21:03:28 UTC
Size:
4.28 KB
patch
obsolete
>#!/bin/bash > > ># TODO >#-Make a list of available versions of gentoo releases that work with this script ># and make sure the script verifies by the filename it is using an ># appropriate release. >#-Add the option of formatting the pen if necessary > >leaving(){ > [ -d "${cdmnt}" -a "${isomode}" = "1" ] && (umount cdmnt ; rmdir cdmnt) >/dev/null 2>/dev/null > [ -d "${utmp}" ] && (umount utmp ; rmdir utmp) >/dev/null 2>/dev/null >} > >die() { > echo "$1" > leaving > exit 1 >} > >usage() { > echo "$0 [--verify] <iso or cd mount point> <usb device>" > echo "$1" > exit 1 >} > > >filesystem() { > local USBFS=$(/lib/udev/vol_id -t ${USBDEV}) > if [ "$USBFS" != "vfat" -a "$USBFS" != "msdos" ]; then > die "USB filesystem must be vfat or ext[23]" > fi >} > >testing() { > >if [ $(id -u) != 0 ]; then > echo "You need to be root to run this script" > exit 1 >fi > >if [ \( ! -e /usr/lib/syslinux/mbr.bin \) -o \( ! -e /usr/bin/syslinux \) ] >then > die "You must have syslinux-3 installed" >fi > >if [ -z "$ISO" -o -z "$USBDEV" ] >then > usage >elif [ ! -e "$ISO" ] >then > usage "Iso or mount point not found" >elif [ ! -b "$USBDEV" ] >then > usage "USB device not found" >fi > >if [ "${verify}" = "1" ] >then > [ -d "${ISO}" ] && die "You did not provide an ISO file" > [ ! -e "${ISO}".DIGESTS ] && die "You do not have a valid *.DIGESTS in the same directory as the ISO file" > md5sum -c --status "${ISO}".DIGESTS > [ $? -ne 0 ] && die "md5sum check failed" >fi > >filesystem > >} > >getdisk() { > > local p=$(udevinfo -q path -n ${USBDEV}) > if [ -e /sys/$p/device ]; then > device=$(basename /sys/$p) > else > device=$(basename $(readlink -f /sys/$p/../)) > fi > if [ ! -e /sys/block/$device -o ! -e /dev/$device ]; then > die "Error finding block device of $DEV. Aborting!" > fi > > device="/dev/${device}" >} > >#checkMBR() { ># local bs=$(mktemp /tmp/bs.XXXXXX) ># dd if=$device of=$bs bs=512 count=1 2>/dev/null || die "Error checking the MBR" ># ># local mbrword=$(hexdump -n 2 $bs |head -n 1|awk {'print $2;'}) ># rm -f $bs ># if [ "$mbrword" = "0000" ]; then ># echo "MBR appears to be blank." ># echo "Do you want to replace the MBR on this device?" ># echo "Press Enter to continue or ctrl-c to abort" ># read ># resetMBR $1 ># fi ># ># return 0 >#} > >checkPartActive() { > local dev="${USBDEV}" > > # if we're installing to whole-disk and not a partition, then we > # don't need to worry about being active > if [ "$dev" = "$device" ]; then > return > fi > > if [ "$(/sbin/fdisk -l $device 2>/dev/null |grep $dev |awk {'print $2;'})" != "*" ]; then > echo "Partition isn't marked bootable!" > echo "You can mark the partition as bootable with " > echo " # /sbin/parted $device" > echo " (parted) toggle N boot" > echo " (parted) quit" > exit 1 > fi >} > >[ \( $# -ne 2 \) -a \( $# -ne 3 \) ] && usage > >while [ $# -gt 2 ]; do > case $1 in > --verify) > verify=1 > ;; > *) > usage > ;; > esac > shift >done > >ISO=$1 >USBDEV=$2 > >testing >getdisk >#checkMBR >checkPartActive > >echo "LiveUSB creation process started" > >#see if ISO is mounted cd or iso file >if [ -d ${ISO} ] >then > cdmnt=$1 > isomode=0 >elif [ -f ${ISO} ] >then > isomode=1 > cdmnt=$(mktemp -d) || die "Couldn't create temporary ISO dir" > mount -o loop $1 ${cdmnt} || die "ISO not mounted" >else > die "ISO not found" >fi > >echo "Installing new MBR..." >dd if=/usr/lib/syslinux/mbr.bin of=${device} || die "Failed installing MBR in ${device}" > >utmp=$(mktemp -d) || die "Couldn't create directory for the key ${utmp}" > >echo "Unmounting USB device" >umount ${USBDEV} >/dev/null 2>/dev/null > >mount -t auto ${USBDEV} ${utmp} || die "Failed mounting ${USBDEV} in ${utmp}" > >echo "Copying files (may take a long time)..." >cp -R ${cdmnt}/* ${utmp} || die "Failed copying cd contents" >if [ ${isomode} -eq 1 ]; then > umount ${cdmnt} || die "Failed unmounting ${cdmnt}" >fi >mv ${utmp}/isolinux/* ${utmp} || die "Failed moving contents" >mv ${utmp}/isolinux.cfg ${utmp}/syslinux.cfg >rm -rf ${utmp}/isolinux* >mv ${utmp}/memtest86 ${utmp}/memtest \ > || die "Failed moving ${utmp}/memtest86 to ${utmp}/memtest" > > >sed -i \ > -e "s:cdroot:cdroot slowusb:" \ > -e "s:kernel memtest86:kernel memtest:" \ > ${utmp}/syslinux.cfg || die "Failed using sed" > >umount ${utmp} || die "Failed unmounting ${utmp}" >syslinux ${USBDEV} || die "Couldn't install the syslinux bootloader" > >echo "Gentoo LiveUSB created"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 208499
:
142428
|
142445
|
142456
|
142457
|
142469
|
142506
|
142753
|
142770
|
142954
|
144917
|
145227