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 20 Oct 2014, 09:14
All times are UTC - 4
 Forum index » Taking the Puppy out for a walk » Suggestions
Auto Symlink from /root to host drive in frugal installs
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [16 Posts]   Goto page: 1, 2 Next
Author Message
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Wed 25 Feb 2009, 21:12    Post subject:  Auto Symlink from /root to host drive in frugal installs
Subject description: Big improvement in useability noted in testing
 

I provide I.T. support on recycled computers for about 200 computers in my local town. When installing ecopup linux (a pre-configured "frugal" install) for new users, I now as a matter of course make a symlink from inside the /root folder to the host drive. Ive found this can be name /initrd/mnt/dev_save , /mnt/home or sometimes even /initrd/mnt/dev_ro2 . Im not sure if there is any method to how it names things differently, I think it has something to do with the type of machine or disk puppy is running frugally on. I also include links to the home folder from an icon on the desktop, in the rox bookmarks and from the icewm quickstart menu.

Ive found that since introducing it, users have been able find, edit and save their files a LOT more easily. Many of my users run a frugal install on a NTFS Windows xp partition and this also helps them find and work with files in their windows partition that the pup_save.2fs file is on. Before this, users had a great deal of difficulty navigating linux's standard directory structure to find where their files were kept. Such a symlink would also appear in the save file dialogs from puppy's applications. Root would seem the obvious place to put it, considering it also contains directories for shared network locations, ftp file serving and scripts to be run at startup.

What I would like to ask, is how I would automatically create a link to the host drive from within the /root folder. This I imagine would be done during the puppy boot, as the location the symlink would point to might change depending on what machine the frugal install was booted from.

Also, would this cause any problems in terms of breaking existing code. I cant imagine that it would (it hasnt since I started doing it in ecopup/2.15ce over the last year or so Ive been doing it), but it is better to be on the safe side.

Bash code to insert into a startup script would be very welcome.

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Thu 26 Feb 2009, 00:28    Post subject:  

Code:
#!/bin/sh
. /etc/rc.d/PUPSTATE
LINK_NAME="$HOME/hard-drive"
[ "$PUP_HOME" != "/" ] && [ "$PUP_HOME" != "" ] && [ -e "/initrd$PUP_HOME" ] && [ ! -e "$LINK_NAME" ] && [ ! -L "$LINK_NAME" ] && ln -s "/initrd$PUP_HOME" "$LINK_NAME"

That would create the link at $HOME/hard-drive (so for most Puppy users, /root/hard-drive), but since it uses $HOME rather than /root it is also multi-user friendly.

It will only attempt to create the link if /etc/rc.d/PUPSTATE has the PUP_HOME variable defined, and will get the path from that. I haven't tested this on anything but a frugal install, so I'm not certain it will work properly for USB installs (should though). Live-CD should work, since they're identical to Frugal installs, besides the booting originating from a CD rather than harddrive. On full installs, I believe it will not create the link (which is proper as the drive is right there at /). Not sure what it will do for multisession.


EDIT: Corrected a logical error and an oversight in code.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib


Last edited by Pizzasgood on Fri 27 Feb 2009, 22:07; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
jrb


Joined: 11 Dec 2007
Posts: 1040
Location: Smithers, BC, Canada

PostPosted: Thu 26 Feb 2009, 00:43    Post subject:  

ecomoney and Pizzasgood,
Why not just symlink from /mnt/home to /root and then remaster that in? When there is no /mnt/home the link won't work but when there is it will work no matter where /mnt/home is.
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Thu 26 Feb 2009, 01:16    Post subject:  

A broken symlink makes a nasty error-icon, and doesn't work. Not very refined. Refinement is important. If you boot an operating system and are greeted by an obvious error, it doesn't make a good impression at all.


If that script is implemented such that it runs each boot, it should be done in a way that lets the user easily disable it if they don't want the symlink.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Thu 26 Feb 2009, 01:39    Post subject:  

Pizzasgood, thanks for your response, which file should that statement be inserted into. Given the uncertainty of whether it will work for different types of installs, could the statement to create the symlink be enclosed in a conditional"if" statement for PUPMODES that relate to usb and hard drive installs for now, the ones you can say with some certainty will work. As I mentioned, the most common type will be a frugal install on a windows partition for first-time puppy users that will need it. I am happy to do some testing if it will get this feature developed in time.

I cant see that anyone would not want this small symlink, only that they would find it useful to varying degrees. Would you confirm whether simply adding this symlink would break any existing code or cause puppy not to boot if there is an error?

jrb, I have noticed that the mountpoint of the host drive does change between setups, it is not always /mnt/home.

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Thu 26 Feb 2009, 02:19    Post subject:  

No, it wouldn't break anything.

I would probably place it inside /etc/profile, since it deals with the user's home directory. It should go somewhere before the part that runs the scripts in /etc/profile.d/.

All we need to know to know how it behaves in other installations of Puppy is the contents of /etc/rc.d/PUPSTATE, specifically the PUP_HOME variable. If I understand properly, that should be empty in Full and Multisession, and should list the path to the mountpoint of the partition holding pup_save.2fs in any other case (the path is relative to /initrd, however, not to /). If that's the case, it will work fine as-is.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
esmourguit


Joined: 17 Nov 2006
Posts: 1288
Location: Sur l'ile aux oiseaux.

PostPosted: Thu 26 Feb 2009, 06:20    Post subject:  

Bonjour,
@Ecomoney,
Can this be able to help you?
Cordialement Wink

_________________
Toutou Linux - Pets francisés
Back to top
View user's profile Send private message 
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Thu 26 Feb 2009, 07:22    Post subject:  

Many thanks for replying. I think its important to get this out quickly so it will benefit the most users. The "rarer" install methods I think we could add this feature too later, for now what would be the code needed to only insert this link into "frugal" installs?

WhoDo has indicated to me that if this feature would DEFINETELY not break any existing code, he would be adding it to the soon to be release puppy 4.2 . I think frugal installs are used by the great many new users, and we should just concentrate on getting that part going for this, and leave the other methods until later.

Thanks again for your help PizzasGood

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Fri 27 Feb 2009, 19:36    Post subject:  

I don't like partial solutions like that. So I'll just check them all. I'll get back to you later tonight (morning for you I suppose). I highly doubt that there will be issues, but this will also give me an excuse to do some testing of 4.20 RC1.
_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Fri 27 Feb 2009, 22:23    Post subject:  

Alright, ready to go. Well, except that I didn't burn a disk to test Multisession but I did read the init script, so that should be fine. I found one logical error (I had accidentally merged two conditionals into one) and an oversight: full-hd installs don't leave the PUP_HOME variable blank like I thought - they set it to /. Which is technically fine because the corrected code would have still filtered that out, but it would have happened in a round-about manner, so I added an explicit check for it.

The simplest way to install that code is to create a script in /etc/profile.d/ containing that code and named create_hd_link.sh. The name is mostly arbitrary, but the .sh extension is manditory - without that, /etc/profile will not automatically run the code.

By placing it in the directory as its own script, we allow the user to easily disable it by simply renaming or deleting the script, or by removing the execute bit.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Sat 28 Feb 2009, 09:53    Post subject:  

Your right, I like the idea of "encapsulating" the code in a separate script to do that. Im assuming that it can be called to run parellel to the /etc/profile.d (i.e. call that function and carry on running the script. This is safest too because it would mean that for whatever reason this piece of code "locked up" it would mean that puppy would carry on booting normally, just without the link.

I would still be inclined just to have it create a link for frugal hard drive installs for the time being, and add the functionality for the other install types later when we have had time to test things thoroughly, we are quite late in the testing/release cycle for 4.2 now. The hard disk/frugal method would make this available to the most number of people with the least possible risk. The other types will need it eventually though.

Have you amended the code you put above? would this be simply be the contents of the new script create_hd_link.sh ? Then all that would be needed would be a call from /etc/profile.d?

Considering the lateness of this feature, and the workload of whodo at the moment, would you spell it out for us what to put where just to make sure there are no oversights.

Many thanks Pizzasgood Very Happy

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Sun 01 Mar 2009, 17:24    Post subject:  

Yeah, the code up there is complete, you just add it to a script named /etc/profile.d/create_hd_link.sh and make sure it's set to be executable.

That's all you do. /etc/profile doesn't need any modification at all. It already runs any scripts in /etc/profile.d/ that end in .sh.

One thing to note: It seems that one line of that code is so long that the forum is word-wrapping it. There are only really four lines. Everything following the [ "$PUP_HOME" != "/" ] belongs on the same line.

For simplicity's sake, I attached a .pet with it.

That code is only four lines long. It's simple enough that running it in parallel would make no difference. And it can't hurt anything else, because the worst it can do is crash, in which case control returns to /etc/profile and things keep on rolling.

As for other methods than frugal, the absolute worse thing that can happen is that it does nothing. I have it set up to check in advance whether the location it's creating the link to exists. If that location does not exist, it won't even try to create the symlink, meaning that it won't place a broken symlink in /root. It also checks if a file already exists named the same thing as the symlink, and if so, it aborts rather than attempt to overwrite it.


Quote:
I'm not at all sure what this feature might be good for,
Well, IMHO it's somewhat redundant, but I can certainly see why new users wouldn't know about or understand /mnt/home. They probably think it's quite strange to open the file manager, go "up", then into a weird location named "mnt", then to "home", just to get to their good old C:\ drive. This makes it simpler.

Quote:
So it seems like all that is needed is an Archives directory, into which I would put anything I want to archive, and which is then saved to the DVD as a special session. I'm not sure how implementing this might affect the existing Puppy filesystem and whatnot. Any thoughts?
Isn't that what already happens with the /archive directory already in Puppy? I don't use multisession, but I was under the impression that that was exactly what /archive was there for. According to /archive/README-archive.txt, anything placed there will be stored on the disk without being loaded into ram next time. And the CD can be viewed by simply clicking the CD icon on the desktop, now that we have those drive icons in Puppy.


EDIT: Moved a dislocated paragraph into the proper place.
create_hd_link.pet
Description 
pet

 Download 
Filename  create_hd_link.pet 
Filesize  356 Bytes 
Downloaded  358 Time(s) 

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib


Last edited by Pizzasgood on Sun 01 Mar 2009, 22:07; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
WhoDo


Joined: 11 Jul 2006
Posts: 4441
Location: Lake Macquarie NSW Australia

PostPosted: Sun 01 Mar 2009, 19:06    Post subject:  

Pizzasgood wrote:
For simplicity's sake, I attached a .pet with it.

Thanks, PG. I wouldn't have noticed the line break and so the script I made from your instructions would probably have been worthless. Rolling Eyes

_________________
Actions speak louder than words ... and they usually work when words don't!
SIP:whodo@proxy01.sipphone.com; whodo@realsip.com
Back to top
View user's profile Send private message 
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Sun 01 Mar 2009, 19:43    Post subject:  

Quote:


Quote:

I'm not at all sure what this feature might be good for,



Well, IMHO it's somewhat redundant, but I can certainly see why new users wouldn't know about or understand /mnt/home. They probably think it's quite strange to open the file manager, go "up", then into a weird location named "mnt", then to "home", just to get to their good old C:\ drive. This makes it simpler.

[/quote]

It just goes to show there is no substitute for end user testing Developers often cant see what users need just as much as users often dont appreciate its the differences between linux and windows that makes linux so much better! Very Happy

Im over the moon this feature looks like it is going to be included. Its really helped the many people I support puppy understand a proper linux file structure, rather than arbitarily assigning some letter. Now it will benefit a whole load more first time linux users too.

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Mon 02 Mar 2009, 19:36    Post subject:  

try this:

drag any folder to your root folder and select link in the dialog box - then you can rename it whatever you want

that is probably the best way for individual machines - the hard way (but maybe better for mass installs) would be to edit the universal installer to do it for you depending on the type of install selected

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [16 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Taking the Puppy out for a walk » Suggestions
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.1157s ][ Queries: 12 (0.0210s) ][ GZIP on ]