From: W. Trevor King Date: Mon, 22 Mar 2010 22:58:13 +0000 (-0400) Subject: Added commandline options to portage-overlay/.../sysresccd-usbstick X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e99ce0e7a91e2cb5ec1fefa3d0d83c81dacf5f02;p=systemrescuecd.git Added commandline options to portage-overlay/.../sysresccd-usbstick --- diff --git a/portage-overlay/sys-apps/sysresccd-scripts/Manifest b/portage-overlay/sys-apps/sysresccd-scripts/Manifest index 577c292..e280445 100644 --- a/portage-overlay/sys-apps/sysresccd-scripts/Manifest +++ b/portage-overlay/sys-apps/sysresccd-scripts/Manifest @@ -4,7 +4,7 @@ AUX mountsys 15271 RMD160 8d3138fc2d63edfd99d000db64247d71c2282f6a SHA1 e51188d2 AUX sysreport 5282 RMD160 0f2adae1d510c433eb5c69e26c77be210b3f8a13 SHA1 242f837d34d09a05bf5cff585a020c1f666eab20 SHA256 277aad5c858005ce25c6636f61db4f1693a662f89f6a8b5103117d16d71aa595 AUX sysresccd-backstore 5402 RMD160 af8e40dfc4015d3484ebbf4c628be5cf8e866f4f SHA1 a188e01a1cdec73d21f336603a877fd0b73de738 SHA256 4382e98a63627263e4fab6ca1a5a86da821f7005b4f71b2f14cbdaf218335031 AUX sysresccd-cleansys 3066 RMD160 ed0f5745bcc7686c9404f09b588a101de3ff0e47 SHA1 9fd2f1c219d981f5bbe6b951d085a27a1434aab8 SHA256 799ea4a5f9c3d08d31602107e7d00ea4df64d55e6aad49d38c36450dfe8f7b34 -AUX sysresccd-custom 8463 RMD160 34edac90b41f4f7c45f9b4c662008636d17dd11a SHA1 324390faf595ccecc9348f2747e08322721dbb16 SHA256 90a0854d917a0e79e9acc36ea7d57678dd31c650d42ce1bd7606763f3bbe87b6 +AUX sysresccd-custom 8412 RMD160 136271d522f91fdd27d52ffff21ebacec9a67e11 SHA1 64b18a90ad86ebc622017fbf82cda73692f999cd SHA256 064833bdea5238b0dc12eabdf3dbfeea4b8267f947d021e3ec7427463c5686d4 AUX sysresccd-pkgstats 2401 RMD160 8491162fefe3a0029773d493090732816b651722 SHA1 7ef5b0dcc07b151376eb82c5d6f94892a7a9010d SHA256 e9225a832fc33d85d4790c57784392f12754998de2455efa6add25650113a3a0 -AUX sysresccd-usbstick 11756 RMD160 a3dcbbfa2973ea92c6ffb94079b2e75231d8a65d SHA1 acb6c980cc57adf71fd32754f8a41003da92c50c SHA256 002137b9069267545a3804ee921e8686fb1429835ad52ee59d85c66067a100ac +AUX sysresccd-usbstick 12184 RMD160 76b806d0b24fe0f73ad681ea4a0815c2db55314c SHA1 0ae48122912ca53fa5cc08b5cd7aa7b4305c82d5 SHA256 ee5ac43111452ec8c43656916949e8b6e0868f6c37b4d576e2e2b47193eebc1e EBUILD sysresccd-scripts-1.5.0.ebuild 696 RMD160 35e443b4790bd55cb562d33a5acb4e3be1ec00fe SHA1 8fe54c95f9eb35c3f1a841bc23d851a87e02887f SHA256 50424009b7176e01b0feb9a2565b02a59022ce390fee9c7252b4b51930b0bf66 diff --git a/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-custom b/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-custom index 7995711..7ce4186 100755 --- a/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-custom +++ b/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-custom @@ -242,8 +242,7 @@ do_isogen() ## MAIN SHELL FUNCTION ######################################################## -## Main -########################################### + if [ $# -eq 0 ] # Script invoked with no command-line args? then usage diff --git a/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-usbstick b/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-usbstick index d87a8eb..947bda8 100755 --- a/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-usbstick +++ b/portage-overlay/sys-apps/sysresccd-scripts/files/sysresccd-usbstick @@ -9,8 +9,14 @@ ## HELP AND BASIC ARGUMENT PROCESSING ##################################### -# minimal size required for sysresccd in mega-bytes +PROG="${0}" +ISODIR="/livemnt/boot" +USBDIR="/mnt/usbstick" +SYSLINUX="sylinux" MINSIZEMB=300 +cdfiles=('sysrcd.dat' 'sysrcd.md5' 'version' 'isolinux/initram.igz' + 'isolinux/rescuecd' 'isolinux/rescue64' 'isolinux/f1boot.msg' + 'isolinux/isolinux.bin' 'isolinux/isolinux.cfg') usage() { @@ -30,16 +36,16 @@ Commands (execute in that order): 5) syslinux Make the device bootable -h|--help Display this screen + -i ISODIR Set the mount directory for the stock SysRescCD iso ($ISODIR) + -u USBDIR Set the directory for mounting the USB stick ($USBDIR) + -m SYSLINUX Set the syslinux program ($SYSLINUX) + -s MINSIZEMB Minimal size required for SysRescCD in mega-bytes dialog Dialog to make SystemRescueCD-USB-Sticks Distributed under the GNU Public License version 2 - http://www.sysresccd.org EOF } -cdfiles=('sysrcd.dat' 'sysrcd.md5' 'version' 'isolinux/initram.igz' - 'isolinux/rescuecd' 'isolinux/rescue64' 'isolinux/f1boot.msg' - 'isolinux/isolinux.bin' 'isolinux/isolinux.cfg') - ## MISC FUNCTIONS: Many utilities functions ########################################### @@ -52,28 +58,6 @@ help_readman() exit 1 } -## Main -########################################### - -if [ "$1" = "-h" ] || [ "$1" = "--help" ] -then - usage - exit 1 -fi - -if [ "$(whoami)" != "root" ] -then - help_readman "$0: This script requires root privileges to operate." -fi - -if ! cat /proc/mounts | awk '{print $2}' | grep -q -F '/memory' -then - help_readman "$0: This script must be executed from SystemRescueCd" - exit 1 -fi - -PROG=${0} - ## ERROR HANDLING ##################################### @@ -170,7 +154,7 @@ check_valid_blkdevname() check_sysresccd_files() { rootdir="$1" - [ -z "${rootdir}" ] && rootdir="/livemnt/boot" + [ -z "${rootdir}" ] && rootdir="${ISODIR}" for curfile in ${cdfiles[*]} do curcheck="${rootdir}/${curfile}" @@ -312,55 +296,55 @@ do_copyfiles() partname="$1" check_valid_partname "${partname}" - # check the important files are available in /livemnt/boot - check_sysresccd_files "/livemnt/boot" + # check the important files are available in ${ISODIR} + check_sysresccd_files "${ISODIR}" check_sizeof_dev "${partname}" - mkdir -p /mnt/usbstick 2>/dev/null - if ! mount -t vfat ${partname} /mnt/usbstick + mkdir -p ${USBDIR} 2>/dev/null + if ! mount -t vfat ${partname} ${USBDIR} then - die "cannot mount ${partname} on /mnt/usbstick" + die "cannot mount ${partname} on ${USBDIR}" fi - echo "${partname} successfully mounted on /mnt/usbstick" + echo "${partname} successfully mounted on ${USBDIR}" - check_disk_freespace "/mnt/usbstick" + check_disk_freespace "${USBDIR}" - if cp -r --remove-destination /livemnt/boot/* /mnt/usbstick/ && sync + if cp -r --remove-destination ${ISODIR}/* ${USBDIR}/ && sync then echo "Files have been successfully copied to ${partname}" else echo "Cannot copy files to ${partname}" fi - for curfile in '/mnt/usbstick/isolinux/isolinux.cfg' + for curfile in '${USBDIR}/isolinux/isolinux.cfg' do if [ ! -f "${curfile}" ] then - umount /mnt/usbstick + umount ${USBDIR} die "${curfile} not found, cannot continue" fi done # check the important files have been copied - check_sysresccd_files "/mnt/usbstick" + check_sysresccd_files "${USBDIR}" # move isolinux files to syslinux files - rm -rf /mnt/usbstick/syslinux - if ! mv /mnt/usbstick/isolinux/isolinux.cfg /mnt/usbstick/isolinux/syslinux.cfg \ - || ! mv /mnt/usbstick/isolinux /mnt/usbstick/syslinux + rm -rf ${USBDIR}/syslinux + if ! mv ${USBDIR}/isolinux/isolinux.cfg ${USBDIR}/isolinux/syslinux.cfg \ + || ! mv ${USBDIR}/isolinux ${USBDIR}/syslinux then - umount /mnt/usbstick + umount ${USBDIR} die "cannot move isolinux to syslinux, failed" fi # remove the last lines which produces error messages 'bad keyword' with syslinux - sed -i -e '/label disk[1-2]$/d' -e '/label floppy$/d' -e '/label nextboot$/d' -e '/localboot/d' /mnt/usbstick/syslinux/syslinux.cfg + sed -i -e '/label disk[1-2]$/d' -e '/label floppy$/d' -e '/label nextboot$/d' -e '/localboot/d' ${USBDIR}/syslinux/syslinux.cfg # add scandelay option which allows the usb devices to be detected - sed -i -e 's!initrd=initram.igz!initrd=initram.igz scandelay=5!g' /mnt/usbstick/syslinux/syslinux.cfg + sed -i -e 's!initrd=initram.igz!initrd=initram.igz scandelay=5!g' ${USBDIR}/syslinux/syslinux.cfg - umount /mnt/usbstick + umount ${USBDIR} } do_syslinux() @@ -368,16 +352,16 @@ do_syslinux() partname="$1" check_valid_partname "${partname}" - if [ -z "$(which syslinux)" ] + if [ -z "$(which ${SYSLINUX})" ] then - die "syslinux not found on your system, please install syslinux first." + die "${SYSLINUX} not found on your system, please install syslinux first." fi - if syslinux ${partname} && sync + if ${SYSLINUX} ${partname} && sync then - echo "syslinux has successfully prepared ${partname}" + echo "${SYSLINUX} has successfully prepared ${partname}" else - echo "syslinux failed to prepare ${partname}" + echo "${SYSLINUX} failed to prepare ${partname}" fi } @@ -492,8 +476,37 @@ do_listdev() ## MAIN SHELL FUNCTION ######################################################## +if [ $# -eq 0 ] # Script invoked with no command-line args? +then + usage + exit 1 +fi + +while getopts ":ui:r:w:m:" Option +do + case $Option in + i ) ISODIR="$OPTARG";; + r ) ROOTDIR="$OPTARG";; + w ) WORKDIR="$OPTARG";; + * ) usage; exit 1;; # Default, handles -h + esac +done +shift $(($OPTIND - 1)) + COMMAND="${1}" shift + +if [ "$(whoami)" != "root" ] +then + help_readman "$0: This script requires root privileges to operate." +fi + +if ! cat /proc/mounts | awk '{print $2}' | grep -q -F '/memory' +then + help_readman "$0: This script must be executed from SystemRescueCd" + exit 1 +fi + case "${COMMAND}" in listdev) do_listdev