Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mounting/Unmounting Script.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Visnu
Tux's lil' helper
Tux's lil' helper


Joined: 10 Mar 2003
Posts: 93

PostPosted: Wed Oct 01, 2003 4:14 am    Post subject: Mounting/Unmounting Script. Reply with quote

Hola, this is my first submission for something that may be halfway useful to the Linux community, it's also my first script (well, real one anyways). Please enjoy, also I would appreciate comments/improvement ideas. I mainly made it for my own personal use, but figured maybe someone could use it. :D

Code:

#!/bin/bash
# Mounting/Unmounting Menu Script
# Created by Nathan Nill
#
# Change the 'hdb=/mnt/cdrom' and/or 'hdc="/mnt/dvd' to the correct paths.
# Enjoy
#
# P.S. I know it's not commented well/at all, this is my first script. =o)
clear

hdb=/mnt/cdrom
hdc=/mnt/dvd

cdmount ()
{
 clear
 echo "Now mounting $hdb..."
 mount $hdb
 echo ""
 echo "Mounting of $hdb finished, press any key to continue."
 read key
  case $key in
   *) menu
  ;;
 esac
}

dvdmount ()
{
 clear
 echo "Now mounting $hdc..."
 mount $hdc
 echo ""
 echo "Mounting of $hdc finished, press any key to continue."
 read key
  case $key in
   *) menu
  ;;
 esac
}

cdunmount ()
{
 clear
 echo "Now unmounting $hdb..."
 umount $hdb
 echo ""
 echo "Finished unmounting $hdb, press any key to contiue."
 read key
  case $key in
   *) menu
  ;;
 esac
}

dvdunmount ()
{
 clear
 echo "Now unmounting $hdc..."
 umount $hdc
 echo ""
 echo "Finished unmounting $hdc, press any key to continue."
 read key
  case $key in
   *) menu
  ;;
 esac
}

menu ()
{
 clear
 echo "-----------------------------------"
 echo "  Mounting/Unmounting Script v1.0  "
 echo "-----------------------------------"
 echo "-- 1. Mount $hdb                 "
 echo "-----------------------------------"
 echo "-- 2. Mount $hdc                 "
 echo "-----------------------------------"
 echo "-- 3. Unmount $hdb               "
 echo "-----------------------------------"
 echo "-- 4. Unmount $hdc               "
 echo "-----------------------------------"
 echo "-- 5. Exit                       "
 echo "-----------------------------------"
 echo "-----------------------------------"
 echo ""
 echo "Enter your choice."

 read choice

 case $choice in
 1) cdmount
 ;;
 2) dvdmount
 ;;
 3) cdunmount
 ;;
 4) dvdunmount
 ;;
 *) exit
 ;;
esac
}

menu


Just chmod +x whatever name you save it to, I use the name mnt, and then run it.
Enjoy!
Back to top
View user's profile Send private message
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Wed Oct 01, 2003 5:03 am    Post subject: Reply with quote

Why not just `mount /mnt/cdrom` and be done with it?

BTW, if you still want a menu to do something like this (which I, personally, don't understand) try using `dialog`. It'll look more pretty.
_________________
I don't believe in witty sigs.
Back to top
View user's profile Send private message
GurliGebis
Retired Dev
Retired Dev


Joined: 08 Aug 2002
Posts: 509

PostPosted: Wed Oct 01, 2003 6:17 am    Post subject: Reply with quote

Wouldn't supermount be better for this?
_________________
Queen Rocks.
Back to top
View user's profile Send private message
Visnu
Tux's lil' helper
Tux's lil' helper


Joined: 10 Mar 2003
Posts: 93

PostPosted: Wed Oct 01, 2003 6:25 am    Post subject: Reply with quote

delta407 wrote:
Why not just `mount /mnt/cdrom` and be done with it?

BTW, if you still want a menu to do something like this (which I, personally, don't understand) try using `dialog`. It'll look more pretty.


Dunno, I just find that a bit more convinient, I keep the script open on my desktop, it's less characters to type, I guess. I wasn't going for "pretty", I was focusing on usability, besides, if I wanted pretty I could just make a Dock applet for Fluxbox (WM of choice =o).

Is Supermount is the automounter? I've used other distros that had automounting built in, and I much prefer to manually mount than automatically. Personal preference I imagine.

:D
Back to top
View user's profile Send private message
choco
n00b
n00b


Joined: 10 Jun 2003
Posts: 49
Location: Jackson, MI

PostPosted: Wed Oct 01, 2003 8:09 pm    Post subject: Reply with quote

If you're concerned about keystrokes, a way to take this even further is to assign the mount and umount commands to keyboard shortcuts. Of course, to use the shortcuts as a normal user, you need to sudo the commands. While you're at it, you could assign a keyboard shortcut to the command 'xmms -u' to pause and resume xmms while you're doing something else.

Edit: But each device would need its own pair of mount and umount commands, so this would get confusing with a lot of devices.
_________________
Who would win in a fight between Sandman and Clayface?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum