View previous topic :: View next topic |
Author |
Message |
Visnu Tux's lil' helper
Joined: 10 Mar 2003 Posts: 93
|
Posted: Wed Oct 01, 2003 4:14 am Post subject: Mounting/Unmounting Script. |
|
|
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.
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 |
|
|
delta407 Bodhisattva
Joined: 23 Apr 2002 Posts: 2876 Location: Chicago, IL
|
Posted: Wed Oct 01, 2003 5:03 am Post subject: |
|
|
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 |
|
|
GurliGebis Retired Dev
Joined: 08 Aug 2002 Posts: 509
|
Posted: Wed Oct 01, 2003 6:17 am Post subject: |
|
|
Wouldn't supermount be better for this? _________________ Queen Rocks. |
|
Back to top |
|
|
Visnu Tux's lil' helper
Joined: 10 Mar 2003 Posts: 93
|
Posted: Wed Oct 01, 2003 6:25 am Post subject: |
|
|
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.
|
|
Back to top |
|
|
choco n00b
Joined: 10 Jun 2003 Posts: 49 Location: Jackson, MI
|
Posted: Wed Oct 01, 2003 8:09 pm Post subject: |
|
|
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 |
|
|
|
|
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
|
|