Finding Puppy's boot file directory using bash (SOLVED)

interpretive language scripts


Moderator: Forum moderators

Post Reply
User avatar
wizard
Posts: 1934
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2592 times
Been thanked: 662 times

Finding Puppy's boot file directory using bash (SOLVED)

Post by wizard »

Edit: changed the post subject from: What is Puppy's boot file location variable?

The object was to find the boot file directory, here is the code I used to do it. The find command looks for an exact file name with an exact file size, so it should be pretty accurate. If there's a better method, please post.

Code: Select all

#calculate file size in bites /1048576
finddir=$(find /mnt/home/ -type f -name "puppy_fossapup64_9.5.sfs" -size 487M)
  echo "$finddir"
 pupdir=$(dirname "$finddir")
  echo "$pupdir"

Thanks
wizard

Last edited by wizard on Fri Jan 07, 2022 7:48 pm, edited 2 times in total.

Big pile of OLD computers

Clarity
Posts: 3777
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1597 times
Been thanked: 512 times

Re: What is Puppy's boot file location variable?

Post by Clarity »

Not sure if this will help but environment variables are shown via this terminal command: 'printenv'

Some/Much of what you may want could be in a boot log.

Hope this is helpful.

User avatar
wizard
Posts: 1934
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2592 times
Been thanked: 662 times

Re: Finding Puppy's boot file directory using bash

Post by wizard »

@Clarity

Good info to know, but didn't find any that pointed to the directory

Thanks
wizard

Big pile of OLD computers

User avatar
MochiMoppel
Posts: 1222
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 20 times
Been thanked: 435 times

Re: Finding Puppy's boot file directory using bash

Post by MochiMoppel »

@wizard You can find the information you need in /etc/rc.d/PUPSTATE. Just source this file and use its variables. In my case $PSUBDIR holds the requested directory (may depend on your boot parameters). The variable $PUPSFS may be more suited, but you would need to extract the directory from it.
If $PSUBDIR is what you are looking for, then try

Code: Select all

source /etc/rc.d/PUPSTATE
pupdir="/mnt/home$PSUBDIR"
echo  "$pupdir"

If you need the path for your main sfs file:

Code: Select all

source /etc/rc.d/PUPSTATE
pupfile="/mnt/home/${PUPSFS#*/}"
echo "$pupfile"
Clarity
Posts: 3777
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1597 times
Been thanked: 512 times

Re: Finding Puppy's boot file directory using bash

Post by Clarity »

YES!

Code: Select all

# geany /etc/rc.d/PUPSTATE
User avatar
wizard
Posts: 1934
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2592 times
Been thanked: 662 times

Re: Finding Puppy's boot file directory using bash

Post by wizard »

@MochiMoppel

Used your code and works perfect. Much better than mine since it will never have to be edited for a change in file size.

Thanks
wizard

Big pile of OLD computers

Post Reply

Return to “Scripts”