Auto Symlink from /root to host drive in frugal installs

What features/apps/bugfixes needed in a future Puppy
Post Reply
Message
Author
User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

Auto Symlink from /root to host drive in frugal installs

#1 Post by ecomoney »

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 [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#2 Post by Pizzasgood »

Code: Select all

#!/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.
Last edited by Pizzasgood on Sat 28 Feb 2009, 02:07, edited 2 times in total.
[size=75]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[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#3 Post by jrb »

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.

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#4 Post by Pizzasgood »

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.
[size=75]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[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#5 Post by ecomoney »

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 [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#6 Post by Pizzasgood »

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.
[size=75]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[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
esmourguit
Posts: 1410
Joined: Fri 17 Nov 2006, 14:45
Location: Entre l'ile aux oiseaux.et l'ile de sainte Lucie

#7 Post by esmourguit »

Bonjour,
@Ecomoney,
Can this be able to help you?
Cordialement ;)
[url=http://moulinier.net/][color=blue][b]Toutou Linux[/b][/color][/url] - [url=http://toutoulinux.free.fr/pet.php][color=blue][b]Paquets français[/b][/color][/url]

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#8 Post by ecomoney »

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 [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#9 Post by Pizzasgood »

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.
[size=75]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[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#10 Post by Pizzasgood »

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.
[size=75]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[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#11 Post by ecomoney »

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 :D
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#12 Post by Pizzasgood »

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.

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.
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.
Attachments
create_hd_link.pet
(356 Bytes) Downloaded 541 times
Last edited by Pizzasgood on Mon 02 Mar 2009, 02:07, edited 1 time in total.
[size=75]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[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
WhoDo
Posts: 4428
Joined: Wed 12 Jul 2006, 01:58
Location: Lake Macquarie NSW Australia

#13 Post by WhoDo »

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. :roll:
[i]Actions speak louder than words ... and they usually work when words don't![/i]
SIP:whodo@proxy01.sipphone.com; whodo@realsip.com

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#14 Post by ecomoney »


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! :D

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 [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#15 Post by technosaurus »

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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#16 Post by Flash »

In an attempt to minimize confusion and keep discussions on-topic, I moved my off-topic posts (about Archiving on a multisession DVD) to the Multisession DVD section of the forum.

Post Reply