specify subdirectory for mydsl apps


Forum: Other Help Topics
Topic: specify subdirectory for mydsl apps
started by: mikshaw

Posted by mikshaw on May 20 2005,22:18
So clivesay got me thinking about yet another possibility, and i had to try it out...

You can presently specify a partition to have a collection of myDSL apps automatically load on boot (mydsl=<partition>), so you can have a variety of DSL configurations using a single liveCD or frugal install.  However, the number of variants is currently limited by the number of partitions you have, using the "mydsl=" boot option.

Fortunately, DSL has been configured to save your boot options so that you can use them at any time (sweeeet!).  So here's a way to provide numerous mydsl combinations chosen at boot, with only a single partition, or with no partitions by using a rebuilt CD.

By including a special bit of script in /opt/bootlocal.sh, you can specify on the boot line a path to where mydsl applications are stored.  For example:
mydsldir=hda1/myDSL/xfree
Using this boot option, the mydsl apps in /mnt/hda1/myDSL/xfree will be loaded from bootlocal.sh
If you want multiple configs using some of the same applications, symlinks put in the subdirectories will work just as well as copies, so you can save some space.

Here's what I put in /opt/bootlocal.sh:
Code Sample

. /etc/init.d/dsl-functions
CMDLINE="$(cat /proc/cmdline)"

getmydsl() {
for FILE in `ls $1/* 2>/dev/null`; do
case $FILE in
*.tar.gz)
BASE=$(getbasefile "$FILE" 2)
if [ "$BASE" != "backup" ]; then
echo "${YELLOW}$BASE${NORMAL}"
sudo su dsl -c mydsl-load $FILE
fi
;;
*.dsl|*.uci)
BASE=$(getbasefile "$FILE" 1)
echo "${YELLOW}$BASE${NORMAL}"
sudo su dsl -c mydsl-load $FILE
;;
esac
done
}

MYDSL="$(getbootparam 'mydsldir')"
if [ -n "$MYDSL" ]; then
DEVICE="${MYDSL%%/*}"
MOUNTED=`grep "/dev/$DEVICE" /etc/mtab 2>/dev/null`
if [ -n "$MOUNTED" ]; then
DIR="/cdrom/${MYDSL#*/}"
else
DIR="/mnt/$DEVICE/${MYDSL#*/}"
mount /dev/$DEVICE &>/dev/null
fi
if [ -d "$DIR" ]; then
     getmydsl "$DIR"
fi
fi

It's loosely based on Robert's getmydslapps function in dsl-config

There are some minor issues i need to fix...

It wasn't working with the partition containing KNOPPIX, because it was already mounted.  The code i added to address this is sloppy and probably unreliable, but it does seem to work as long as you haven't booted toram and mounted that drive from bootlocal.  I'll have to work out a better solution.

It hasn't been tested from a rebuilt iso including the mydsl directories, but i'm thinking it should work the same.  Using "mydsldir=cdrom/path/to/files" *should* end up using /cdrom.

This doesn't apply to mydsl apps in /cdrom/optional...you'd still need to use mydsl=whatever to get those.

Posted by WoofyDugfock on May 21 2005,11:38
Really interesting idea - would be handy to be able to point the mydsl boot option at a specific directory path.
Posted by mikshaw on May 21 2005,14:00
Tiny bit more info....

While playing around with it a bit more, i realized what am i gonna do if i need boottime commands specific to one setup?  If you have only one bootlocal.sh for all systems, the file has to be built to accomodate all...
Code Sample

if [ "${MYDSL##*/}" = "xfree" ]; then
do some commands for xfree only
fi

"xfree" is the name of the directory containing the applications related to an XFree86 setup.  If "mydsldir=<partition>/path/to/xfree" was used on the boot line, that piece of code will be run.

Another option...
If you are always going to use the same device and base directory, that can be specified in the script, so all you'd need to put on the boot line is "mydsldir=xfree".
I haven't done anything with that yet, but it will probably end up being a part of the final script.

Posted by mikshaw on May 21 2005,18:00
Updated the script to do both things mentioned in the previous post.
< mydsldir_boot_option.txt >

Posted by roberts on May 21 2005,21:32
This really should not be done in /opt/bootlocal.sh as it is after the restore.
This out of order procedure prevents persisting any data certain apps may require.

It is also unforunate that I too was ask to look at this, and I have it implemented for the next release. where is belongs in the proper order.

I suppose that is why when you, mikshaw, asked me such pointed questions regarding string chopping in IRC i was quick to answer you, little did I know that this is what your efforts were focused on. It is also too bad that you did not communicate with me about this. Anyway, I am sure that you had fun thinking about how this stuff works.

Again, I would not recommend running this procedure from /opt/bootlocal.sh
It belongs before the restore of data thus allowing persistancy of config files. etc.

Posted by mikshaw on May 22 2005,01:38
Actually the string chopping question was unrelated.  This particular project began after i spoke with you on irc.  I had seen the chopping in a couple of your scripts and couldn't quite figure it out.  It was utilized here just because it seemed to work, but was later dropped since chopping was unnecessary.

Thank you very much for your teachings.
Yes, I am enjoying this.  The exploration and learning is my primary reason for using DSL...even if it's learning what not to do.

Edit:  I was pondering what you meant by persitent configs....
i think i understand now.  If a user has made changes to the configuration of a myDSL application, he's not going to appreciate that configuration being overwritten by the default supplied with the application.  The only way to make sure this doesn't happen (without editing all your mydsl apps) is to load the applications before backup is restored, and therefore before bootlocal is run.  It never occured to me because i tend to use only a few extensions on a regualr basis, and those don't have included configs.  I also don't usually use backup/restore.  One of my setups is customized, but that is through the use of a persistent home and opt...all desired applications are already a part of the system.  The others are plain vanilla DSL with the only difference being the myDSL applications that are loaded with each one....so although this mydsldir system may not be suitable for some or most users, it works fine for me.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.