Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 17 Dec 2018, 12:59
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
Save-file mount Script HOWTO
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
code_m

Joined: 02 Jul 2008
Posts: 65

PostPosted: Tue 16 Sep 2008, 21:53    Post subject:  Save-file mount Script HOWTO
Subject description: Simplify mounting a save file
 

I made this as my first bash script, and thought someone might find it useful. If you don't like, then don't use it!

This script was written in the idea that you are starting from an unmounted drive. It can work with a mounted drive, but not a drive running your save file in use (/mnt/home drive)... See post below.

Step 1: open a text editor (preferably one with copy&paste ability to avoid typing mistakes) (geany works wonderfully)

Step 2: copy each of the following to a blank document in root folder:

File name: mntsave-2fs.sh
Code:
#!/bin/bash

echo Script written by Cody A. Taylor
echo ' '

if [ -n "$DRIVE" ]
then
 echo Trying to mount "$DRIVE"
 mount /dev/$DRIVE /mnt/$DRIVE
else
 echo You need to set variable '$DRIVE'
 echo For Example
 echo '#export DRIVE=sdb1'
fi

echo ' '

if [ -n "$FILE" ]
then
 echo Making dir '"save"' and mounting "$FILE" there
 cd /mnt
 mkdir save
 mount -t ext2 -o loop /mnt/$DRIVE/$FILE /mnt/save
else
 echo You need to ser variable '$FILE'
 echo For Example
 echo '#export FILE=pup_save-name.2fs'
fi

echo ' '
echo 'Thanks for using the mount script'
echo 'Send questions to codemister99@gmail.com'

exit 0


file name: umntsave-2fs.sh
Code:
#!/bin/bash

echo Written by Cody A. Taylor

umount /mnt/save

if [ -n "$DRIVE" ]
then
 umount /mnt/$DRIVE
 cd /mnt
 rmdir save
else
 echo You must set the variable '$DRIVE' again, sorry.
fi

echo Your now ready to use the mount script again.

exit 0


Step 3: Open a command prompt and make the scripts executable:
Code:
cd /root
chmod +x mntsave-2fs.sh
chmod +x umntsave-2fs.sh


Step 4: Add aliases to .bashrc (geany will work fine again)
Code:
alias mountsave='bash /root/mntsave-2fs.sh'
alias umountsave='bash /root/umntsave-2fs.sh'


Step 5: Attach drive if not already and then "set" the variables:
Code:
export DRIVE=sda1
export FILE=pup_save.2fs


note: make sure to set your variables correctly, if you choose the wrong drive or wrong file, the script won't know that and you will likely get an error. I will not respond to errors due to incorrect variables.

Step 6: Finally run the mount script using the alias mountsave.

Step 7: Now you can cd /mnt/save and should be able to use the file

Step 8: Now that your done, clean up what your doing by running the second script with the alias umountsave.

I would be happy to answer any questions. This script should work with any linux at all.

note: This may or may not work if you encrypt your save file. Other people will have to verify being able to mount an encrypted save file.

Last edited by code_m on Wed 17 Sep 2008, 22:22; edited 1 time in total
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6867
Location: Auckland, New Zealand

PostPosted: Wed 17 Sep 2008, 01:37    Post subject:  

Puppy must already have a script that does this, as he mounts and unmounts .2fs files when you click on them in rox. Or is there something special about your script?
_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
code_m

Joined: 02 Jul 2008
Posts: 65

PostPosted: Wed 17 Sep 2008, 22:19    Post subject:  

I wasn't aware of that.

The only way this is different is that you start with the drive unmounted, and the script mounts both the drive and the save file.

Which reminds me, this isn't meant to mount save files in the "/mnt/home" directory. It can work with any drive already mounted, just you will get an error saying the drive is already mounted, just ignor it.

Also, if your working from an already mounted drive, then the second script will unmount the drive as well. If you want the drive to stay mounted, then use the normal command:
Code:
umount /mnt/save
Back to top
View user's profile Send private message 
trapster


Joined: 28 Nov 2005
Posts: 2118
Location: Maine, USA

PostPosted: Thu 18 Sep 2008, 06:55    Post subject:  

xfilemount and Edit-SFS Here
_________________
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog
Back to top
View user's profile Send private message Visit poster's website 
code_m

Joined: 02 Jul 2008
Posts: 65

PostPosted: Thu 18 Sep 2008, 22:23    Post subject:  

well I was just trying to learn basic texts for scripting so that I can start to move on to C++ and the like.

I am now thinking that's what I want to go to college for.

It didn't really matter to me if someone had already created something better.

So like I said before, If you don't like it, don't use it!
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0782s ][ Queries: 11 (0.0220s) ][ GZIP on ]