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 Thu 30 Oct 2014, 13:32
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
command-line sfsloader/unloader
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
maxerro


Joined: 10 Oct 2010
Posts: 65

PostPosted: Sat 12 Nov 2011, 08:31    Post_subject:  command-line sfsloader/unloader
Sub_title: currently aufs-only (Slacko/Lucid/Wary)
 

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:
#!/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
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Sun 13 Nov 2011, 01:01    Post_subject:  

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)
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
maxerro


Joined: 10 Oct 2010
Posts: 65

PostPosted: Sun 13 Nov 2011, 04:33    Post_subject:  

Very Happy well, i don't like your shabang either... Very Happy
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.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0556s ][ Queries: 12 (0.0045s) ][ GZIP on ]