command-line sfsloader/unloader

Filemanagers, partitioning tools, etc.
Post Reply
Message
Author
User avatar
maxerro
Posts: 53
Joined: Sun 10 Oct 2010, 16:11

command-line sfsloader/unloader

#1 Post by maxerro »

Here's a small command-line SFS loading/unloading script that works on aufs-based Puppies.
Not meant to compete with the currently wide-accepted shinobar's SFS-Load.
Written without grep/sed/awk/cat/df/losetup with hard-coded sfsfile paths to be easily-readable, and to test if many of the system-checks can be avoided and at what price.

Usage: sfsload (you can rename it to whatever) /drive[/path]/sfsfile
In this case "drive" is considered to be anything down your /mnt branch.

e.g. sfsload /sda1/* /sdb5/Libr* /home/OOo* /sr1/db???

Accepts up to 9 arguments and assumes an sfs extension (hardcoded), so do not type an extension. Use wildcards to load much more SFSs.

'sfsload -u' will unload all SFSs that it loaded up until that point (intentionally), if no other process complains about it. It won't mess-up conventionally loaded SFSs (or at least is not supposed to).

Unionfs-unmount-testing was unsatisfactory (not always 1st attempt and too slow in ms), so support for Racy is dropped and will be on hold for a while, but I'm very happy with its behavior in Slacko and hope it goes as well in Lucid/Wary.
Feel free to improve the script (modify/post-your-version/point-to-overlooked-disaster-scenario) and help someone find their potentially perfect cli-sfsloader.

Code: Select all

#!/bin/sh

case "$1" in 
"")		echo "Command-line SFS loader/unloader for Puppy Linux.
Usage: ${0##*/} [-u] /drive[/path]/sfsfile
e.g. ${0##*/} /sda1/* /sdb5/Libr* /sdc2/db??? (up to 9 args)" ;;
		
"-u")	set /initrd/sfse* 
		i=1
		while [ "${!i}" ] ; do
			if [ -d "${!i}" ] ; then
				busybox mount -o remount,del:"${!i}" / 2>/dev/null
				busybox umount -d "${!i}" 2>/dev/null 
				[ $? -ne 0 ] && echo "${!i##*sfse} won't unload." || echo "${!i##*sfse} unloaded."
				rmdir "${!i}" 2>/dev/null
			fi 
			i=$(($i+1))
		done;;
		
*)		set /mnt$1.sfs /mnt$2.sfs /mnt$3.sfs /mnt$4.sfs /mnt$5.sfs /mnt$6.sfs /mnt$7.sfs /mnt$8.sfs /mnt$9.sfs
		i=1
		while [ "${!i}" ]; do
			if [ -f "${!i}" ]; then
				mkdir -p "/initrd/sfse${!i##*/}"
				busybox mount -t squashfs "${!i}" "/initrd/sfse${!i##*/}" 2>/dev/null
				busybox mount -o remount,append:"/initrd/sfse${!i##*/}" / 2>/dev/null
				if [ $? -ne 0 ]; then 
					echo "${!i##*/} won't load."
					rmdir "/initrd/sfse${!i##*/}" 2>/dev/null
				else 
					echo "${!i##*/} loaded."
					if [ -d "/initrd/sfse${!i##*/}/usr/share/applications" ];then
						for PROG in "/initrd/sfse${!i##*/}"/usr/share/applications/*.desktop; do
							while read LINE || [ "$LINE" ]; do
								case $LINE in Exec=*)echo "	${LINE#*=}";; esac 
							done <${PROG}
						done
					fi
				fi
			fi
			i=$(($i+1))
		done;;
esac
Also prints menu-entry-command-lines (if any), below every successfully loaded SFS.
Combine it with other commands if you like. To refresh menu try:

sfsload /sda1/* && fixmenus && jwm -restart

or, to simulate load-execute-unload behavior, type:

sfsload /sdb5/OOo* && soffice && sfsload -u

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

#2 Post by technosaurus »

the shabang should be !#/bin/bash (due to bashisms) or you could check out my sfs linker in jwm_tools if you want to make it compatible with non-bash shells (its is a similar concept but uses symlinks instead of a layered filesystem and can do files other than sfs and isn't dependant on non-vanilla kernel modules like unionfs/aufs in order to go with jwm to other distros)
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
maxerro
Posts: 53
Joined: Sun 10 Oct 2010, 16:11

#3 Post by maxerro »

:D well, i don't like your shabang either... :D
i'm not even gonna change that.

seriously techno, i'm complaining about unionfs .1s delays, and you're porting me to the versatile 2minute-mount approach? did you clock the devx-linking? and it needs recursion in the unmounting part too, if you wanna do it like that.

now, come up with a blazing unionfs-unmount solution.

Post Reply