Page 1 of 1

Where can I find JWM's Unmount All Partitions code?

Posted: Thu Jan 11, 2024 3:46 am
by houndstooth

As a non-coder I was trying to hack a standalone script, manually looking for the existence of any mountpoint in /mnt with the test command. I suspect the one we all use is more elegant.


Re: Where can I find JWM's Unmount All Partitions code?

Posted: Thu Jan 11, 2024 4:43 am
by MochiMoppel
houndstooth wrote: Thu Jan 11, 2024 3:46 am

As a non-coder I was trying to hack a standalone script, manually looking for the existence of any mountpoint in /mnt with the test command. I suspect the one we all use is more elegant.

In /usr/local/pup_event/frontend_rox_funcs find

Code: Select all

unmountall)
	# "Unmount ALL mounted partitions"
	for MNTPT in `mount | grep '^/dev/' | grep -vE '^/dev/loop|^/dev/ram' | cut -f 3 -d ' ' | grep -v '^/initrd/' | grep -v '^/$' | tr '\n' ' '`
	do
		unmount_func
	done
	exit
	;;

Re: Where can I find JWM's Unmount All Partitions code?

Posted: Thu Jan 11, 2024 6:31 am
by houndstooth

@MochiMoppel then unmount_func can code can be copied?

I am trying to make a standalone script for /root/my-applications/bin.


Re: Where can I find JWM's Unmount All Partitions code?

Posted: Thu Jan 11, 2024 9:02 am
by MochiMoppel
houndstooth wrote: Thu Jan 11, 2024 6:31 am

@MochiMoppel then unmount_func can code can be copied?

Why not? What should stop you?
It doesn't mean that you have to manually copy. You could just source the file containing the function at the beginning of your script, like this:

Code: Select all

#!/bin/sh
source  /usr/local/pup_event/frontend_rox_funcs

for MNTPT in `mount | grep '^/dev/' | grep -vE '^/dev/loop|^/dev/ram' | cut -f 3 -d ' ' | grep -v '^/initrd/' | grep -v '^/$' | tr '\n' ' '`
do
  unmount_func
done

Re: Where can I find JWM's Unmount All Partitions code?

Posted: Fri Jan 12, 2024 1:40 am
by houndstooth

@MochiMoppel which distro is your example? 64 Xenial is a little different. The file is named frontend_funcs and the code reads:

Code: Select all

#v424 experiment, automatic unmounting...
auto_unmount_func() {
 for ONEMNTPT in `mount | grep '^/dev/' | grep -vE '^/dev/loop|^/dev/ram' | cut -f 3 -d ' ' | grep -v '^/initrd/' | grep -v '^/$' | tr '\n' ' '`
 do
  if [ "`fuser -v -m $ONEMNTPT`" = "" ];then
   sync
   umount $ONEMNTPT ; umVAL=$?
   #code from pmount: fix zombie process prevents partition unmount, invisible to fuser...
   if [ $umVAL -ne 0 ];then
    #120129 karl godt: fix ZOMBIES, see http://murga-linux.com/puppy/viewtopic.php?t=71767&start=420 ...
    ZOMBIES="`ps -H -A | grep '<defunct>' | sed 's/^[[:blank:]]*//;s/  /|/g' | grep -v '|||' | cut -f 1 -d ' ' | tr '\n' ' '`"
    for ONEZOMBIE in $ZOMBIES
    do
     kill $ONEZOMBIE 2>/dev/null
    done
    umount $ONEMNTPT ; umVAL=$?
   fi
  fi
 done
}

Re: Where can I find JWM's Unmount All Partitions code?

Posted: Fri Jan 12, 2024 1:53 am
by MochiMoppel
houndstooth wrote: Fri Jan 12, 2024 1:40 am

@MochiMoppel which distro is your example? 64 Xenial is a little different. The file is named frontend_funcs and the code reads:

BW64, but I would be surprised if 64 Xenial were different. frontend_funcs and frontend_rox_funcs should both be contained in folder /usr/local/pup_event


Re: Where can I find JWM's Unmount All Partitions code?

Posted: Fri Jan 12, 2024 2:00 am
by houndstooth
MochiMoppel wrote: Fri Jan 12, 2024 1:53 am

BW64, but I would be surprised if 64 Xenial were different. frontend_funcs and frontend_rox_funcs should both be contained in folder /usr/local/pup_event

Code: Select all

root# pwd
/usr/local/pup_event
root# ls -lh
total 87K
-rwxr-xr-x 1 root root 7.0K Nov 23  2017 frontend_change
-rwxr-xr-x 1 root root  25K Nov 23  2017 frontend_funcs
-rwxr-xr-x 1 root root 4.1K Nov 23  2017 frontend_startup
-rwxr-xr-x 1 root root 4.5K Nov 23  2017 frontend_timeout
-rwxr-xr-x 1 root root  19K Nov 23  2017 pup_event_frontend_d
-rw-r--r-- 1 root root  27K Nov 23  2017 pup_event_ipc-README.htm
root# cat /etc/*-release
NAME=Puppy
VERSION="7.5"
ID=puppy_xenialpup64
VERSION_ID=7.5
PRETTY_NAME="xenialpup64 7.5"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:puppy:puppy_linux:7.5"
HOME_URL="http://puppylinux.com/"
SUPPORT_URL="http://www.murga-linux.com/puppy/index.php"
BUG_REPORT_URL="https://github.com/puppylinux-woof-CE/woof-CE"
root#