Where can I find JWM's Unmount All Partitions code?
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.
Discussion, talk and tips
https://forum.puppylinux.com/
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.
houndstooth wrote: ↑Thu Jan 11, 2024 3:46 amAs 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
;;
@MochiMoppel then unmount_func can code can be copied?
I am trying to make a standalone script for /root/my-applications/bin.
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
@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
}
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
MochiMoppel wrote: ↑Fri Jan 12, 2024 1:53 amBW64, 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#