#!/bin/sh #!/usr/local/bin/perl #File: /u/kscott/work/src/putdisk #Author: K. Scott Rowe #Time-stamp: <04/27/1998 11:16:25 kscott@pescado.tcct.nmt.edu> # # Future Improvements # # need to be able to dd mac floppies # if the image fails, remove it # if there is a README have view/edit if not just edit # hide ~ files # add a remove funcion # needs more error checking # allow editing a README file #kscott Apr 23 1998: done # # SetUp() { HOME=/fs/holmium/disks # HOME=/tmp/disks cd ${HOME} CWD="/" TMPFILE=/tmp/putdisk.$$ touch ${TMPFILE} } DisplayDirs() { DIRS=".. .. NewDirectory NewDirectory NewImage NewImage EditReadme EditReadme ---- ----" for x in * ; do DIRS="${DIRS} $x $x" done dialog --title "$CWD" --clear --menu "pick one" 24 80 18 ${DIRS} 2> ${TMPFILE} } EditReadme() { if [ "${EDITOR}" = "" ] ; then emacs -nw ${PWD}/README else ${EDITOR} ${PWD}/README fi } MakeNewDir() { DIRS="" for x in * ; do DIRS="${DIRS}$x\n" done dialog --title "New Dir in $CWD" --inputbox "Existing directories\n${DIRS}\nPlease enter a new one" 24 80 2> ${TMPFILE} mkdir ${PWD}/`cat ${TMPFILE}` 2> /dev/null } MakeNewImage() { IMAGES="" for x in * ; do IMAGES="${IMAGES}$x\n" done dialog --title "New Image in $CWD" --inputbox "Existing Images\n${IMAGES}\nPlease enter a new one" 24 80 2>${TMPFILE} new_image="`cat ${TMPFILE}`" dialog --title "Question" --inputbox "How many disks are in this image?" 10 40 "1" 2> ${TMPFILE} current_disk="1" num_of_disks="`cat ${TMPFILE}`" while [ "$current_disk" -le "$num_of_disks" ] ; do dialog --title "Makeing Disk Images" --yesno "Insert disk ${current_disk} of ${num_of_disks} and press Return" 10 40 dd if=/dev/fd0 of=${PWD}/${new_image}.dd-${current_disk} bs=8192 if [ "$?" != "0" ] ; then dialog --title "ERROR" --yesno "There was a problem reading disk ${current_disk}. Do you want to try and read it again?" 10 40 2> ${TMPFILE} if [ "$?" = "1" ] ; then # keep going current_disk=`expr ${current_disk} + 1` fi else current_disk=`expr ${current_disk} + 1` fi done } ChangeDir() { cd `cat $TMPFILE` CWD="`echo $PWD | sed -e 's#'$HOME'##'`" } ShowImages() { for x in * ; do IMAGES="${IMAGES}$x\n" done dialog --title "Images in ${CWD}" --msgbox ${IMAGES} 24 60 dialog --title "Enter a New Image" --clear --inputbox "" 12 40 2> ${TMPFILE} } CleanUp() { rm ${TMPFILE} 2> /dev/null } SetUp while [ 1 ] ; do DisplayDirs [ "$?" = "1" ] && break choice="`cat ${TMPFILE}`" if [ "${choice}" = "NewDirectory" ] ; then MakeNewDir elif [ "${choice}" = "EditReadme" ] ; then EditReadme elif [ "${choice}" = "NewImage" ] ; then MakeNewImage elif [ "${choice}" != "----" ] ; then ChangeDir fi done CleanUp