daily pastebin goal
28%
SHARE
TWEET

tmpramdisk

shiftdot515 Jun 14th, 2018 69 in 22 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/sbin/mksh
  2. # make a ramdisk, so I can make use of it.
  3. #change to get disk from mount!!
  4. #set -x
  5. case $1 in
  6.   on|make)
  7.          echo -n "How many megabytes? "
  8. #yes in good time change to a default reply for arg 2 so improve probl.mstatemnt
  9.      read
  10.      (( NUMSEC = $REPLY * 1024 * 2 ))
  11.      echo number of sectors is $NUMSEC
  12.      DISK=$(hdid -nomount ram://$NUMSEC || echo fail)
  13.      case $DISK in
  14.          fail)
  15.          echo failed; exit 1   #trivial ex. of message passing.(isit?)
  16.          ;;
  17.      esac
  18.      echo disk is $DISK
  19.      echo "#DISK# is #${DISK}#"  # help the user avoid stupid pet tricks.
  20.      ## Glad, I know how to code in test-case
  21.      ## w/o some lookyloosyslop over my shoulder!
  22.          ####
  23.      print 'HIT return damn you OR CTRL-C!'
  24.      #####################################
  25.      read           #THEPLANEbosstheplane #snortle
  26.      # newfs_hfs needs an rdisk
  27.      DISK=${DISK##*/} # I'll impress myself later. (Sure, I will ;-)
  28.      echo "after $DISK"
  29.      newfs_hfs -s -v tmp r${DISK} || exit 2
  30.      diskutil mount ${DISK}  || exit 3
  31.      print fin
  32.      ;;
  33.   off|unmake|un-make)
  34.        print 'Do you remember the disk?'
  35.        read DISK
  36.        case $DISK in  # system specfic you will NEED to change this!
  37.        /dev/disk[01]|disk[01]) # as above...
  38.        print "Not allowed!"
  39.            exit 1 ## who should I be impressing if I print rel. line here?
  40.        ;;
  41.        [nN][oO]*)  # not specific
  42.            print "Cancelled."
  43.        exit
  44.        ;;
  45.        "")
  46.            print "maybe I'll do something cute with select here later"
  47.        ;;
  48.        esac
  49.        print '[Enter] to unmount disk, and cleanup'
  50.        read
  51.        echo "#DISK# is #${DISK}#" # help the user avoid stupid pet tricks. #lol
  52.        #unmount $DISK || exit 5
  53.        #hdiutil detach $DISK || exit 5
  54.        diskutil eject $DISK || exit 2 #it's a ramdisk so eject it.
  55.        ;;  
  56.    *)  print 'tmpramdisk [on/make]'
  57.        print '           [off/unmake]'
  58.        exit 0 # not actually, an error imo
  59.        ;;  
  60. esac
  61. exit
  62. # mount a ramdisk at ~/tmp
  63. #mount -t hfs $DISK tmp || exit 4
  64. #cd tmp || exit 3
  65. #open . || exit 4
  66. ## ramdisk is no mounted on ~/tmp with volumename tmp
  67. #find / > /Volumes/tmp/find.out &
  68. #diskutil list
  69. #bin#./tmpramdisk on
  70. #How many megabytes? 121
  71. #number of sectors is 247808
  72. #disk is /dev/disk3
  73. #DISK\# is \#/dev/disk3
  74. #HIT return damn you OR CTRL-C!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top