Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ [1] 2 3 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Script help needed please< Next Oldest | Next Newest >
clivesay Offline





Group: Guests
Posts: 935
Joined: Dec. 2003
Posted: Dec. 28 2004,16:02 QUOTE

I need some script help if possible. For my NFP machines I am going to run frugal with a MyDocuments symlink to another partition for file storage. This will keep files from being loaded into RAM.

Currently I have a simple command in bootlocal.sh that mounts the partition and creates a symbolic link to to a MyDocuments folder on the hda5 partition.

Since I am doing many installs I want to automate as much as possible, what I really need are commands in bootlocal similar to the following......

mount hda5 and check to see if there is a MyDocuments folder, if there is then just create the symlink to /home/dsl. If there is not a MyDocuments folder on hda5 then create one and then create the symlink.

I have done some very simple bash scripting but I am clueless when it comes to if/then statements. Can someone help me with this one? Thanks

Chris
Back to top
Profile PM MSN YIM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Dec. 28 2004,17:03 QUOTE

i think this is kinda like what you need (untested):
Code Sample

link_docs() {
DOC_DIR="/mnt/hda5/MyDocuments"
if [ ! -d "$DOC_DIR" ]; then
mkdir -p "$DOC_DIR"
fi
ln -s  "$DOC_DIR"  $HOME/MyDocs
}
mount /dev/hda5 && link_docs


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
clivesay Offline





Group: Guests
Posts: 935
Joined: Dec. 2003
Posted: Dec. 28 2004,17:16 QUOTE

Thank you, mikshaw. I will give this a try.

Edit:

It appears that it creates a MyDocs link in /home/dsl but there is nothing in /hda5. Ideally there would be a /MyDocuments folder on /dev/hda5 and a /MyDocuments link in /home/dsl

Chris
Back to top
Profile PM MSN YIM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Dec. 28 2004,19:41 QUOTE

Is /mnt/hda5 writeable by the user running the script?  Is the partition mounted successfully?
How about this...
Code Sample

link_docs() {
DOC_DIR="/mnt/hda5/MyDocuments"
if [ -d "$DOC_DIR" ]; then
ln -s  "$DOC_DIR"  $HOME/MyDocuments
else
mkdir -p "$DOC_DIR" && ln -s  "$DOC_DIR"  $HOME/MyDocuments
fi
}
mount /mnt/hda5 && link_docs


This one will attempt to create the directory on /mnt/hda5 if it doesn't exist, and if mkdir is successful it will link.  If the mkdir command fails the link will not be created.

NOTE:  I've noticed that 'if' tests sometimes work differently with DSL than they do on my workstation.  I think my 'if' is a Tcl built-in command and DSL's might be part of a different package.
I'll check it out in a few minutes.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
clivesay Offline





Group: Guests
Posts: 935
Joined: Dec. 2003
Posted: Dec. 28 2004,20:22 QUOTE

mikshaw -

Thank you so much that seems to do what I want! That will save me some setup time.

Thanks again. I'll continue to test.

Chris
Back to top
Profile PM MSN YIM 
12 replies since Dec. 28 2004,16:02 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ [1] 2 3 >/
reply to topic new topic new poll
Quick Reply: Script help needed please

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code