Page 1 of 1
dir2sfs - Yad version
Posted: Tue Aug 11, 2020 9:47 am
by stemsee
Here is dir2sfs yad version. Contributors to this updated version include rg66, fredx181, misko_2083, stemsee, step, belham2, rufwoof and technosaurus.
topic on murga http://murga-linux.com/puppy/viewtopic.php?t=111674
- dir2sfs.png (86.47 KiB) Viewed 2093 times
Code: Select all
#!/bin/bash
#
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$@"
[ ! -d "$1" ] && exit
if [ "$(echo "$1" | wc -w)" -gt 1 ]; then
yad --window-icon="application-x-squashfs-image" --title="Rename Folder" \
--text="Remove blank spaces from\n<b>$(basename "$1")</b> \
and try again." --text-align="center" --borders="10" --width="220" \
--no-buttons --timeout="3" --center
exit
fi
if [ -f "$1.sfs" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" \
--text="<b>$(basename $1).sfs</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" \
--button="Yes:1" --button="No:0" --center --timeout-indicator=top \
--timeout 7
case $? in
0|252) exit ;;
70|1) [[ -f "$1.sfs" ]] && rm -f $1.sfs
[[ -f "$1.sfs-md5.txt" ]] && rm -f "$1.sfs-md5.txt";;
esac
fi
yad --window-icon="application-x-squashfs-image" \
--title "Choose Compression Type" \
--text="LZ4 is fastest; GZIP for older machines
XZ-HC is the highest compression; ZSTD is latest tech." \
--text-align="center" --borders="10" --buttons-layout="center" \
--columns=2 --button="GZIP:0" --button="XZ:1" --button="XZ-HC:2" \
--button="LZ4:3" --button="LZ4-HC:4" --button="ZSTD:5" --center \
--timeout-indicator=top --timeout 7
case $? in
0) COMP="-comp gzip" ;;
1) COMP="-comp xz" ;;
2) COMP="-comp xz -b 1024k -Xbcj x86" ;;
3) COMP="-comp lz4" ;;
4) COMP="-comp lz4 -Xhc" ;;
5) COMP="-comp zstd" ;;
*) COMP="-comp xz" ;;
esac
( sleep 0.5; pgrep -n mksquashfs >/tmp/$$ ) &
(script -q -c "stty rows 40 cols 100; mksquashfs "$1" "$1.sfs" $COMP" | \
while read -n 100 LINE; do echo $LINE | busybox strings | egrep '[0-9]\%' | \
awk '{print $NF}'; done ) | yad --progress --center --undecorated --on-top \
--skip-taskbar --progress-text="Building $1.sfs $COMP" --borders="10" \
--text-align="center" --button="Stop:1" \
--buttons-layout="center" --auto-close
case $? in
1) kill $(cat /tmp/$$)
[[ -f "$1.sfs" ]] && rm -f $1.sfs
[[ -f "$1.sfs-md5.txt" ]] && rm -f "$1.sfs-md5.txt";;
esac
[[ -f "$1.sfs" ]] && md5sum "$1.sfs" > "$1.sfs-md5.txt"
rm -f typescript
rm -f /tmp/$$
sync
rename as dir2sfs and place in /usr/local/bin, then
Re: dir2sfs
Posted: Tue Dec 27, 2022 9:29 am
by Jasper
@stemsee
Thanks for this script
My version in FossaPup64-95 appeared to have stopped functioning and I would receive error messages informing me that the directory was locked/unavailable (?)
For my build the file needs to be placed in
/sbin
**EDIT**
When I run the application the GUI remains on-screen for a few seconds before it counts down and gives little opportunity to make a selection.
Is it possible for the application not to execute until a user makes their decision?
Also, my progress bar seems to run right to left. To me that feels like a countdown instead of progress.
Re: dir2sfs
Posted: Wed Dec 28, 2022 12:34 pm
by stemsee
Hi Jasper
Just remove "--timeout 7" ....
For the progress indicator to move from left to right there is the --bar=LABEL[:TYPE], type can be norm, rtl, pulse, or perm .... but when i tested --bar option the script hung! I am using the gtk2 yad version by step, I expect gtk3 version should be ok! Experiment and let us know.
cheers
Re: dir2sfs
Posted: Wed Dec 28, 2022 3:16 pm
by Jasper
@stemsee
Thanks for getting back to me.
I did remove the Timeout entry and that allowed the dialog box to remain onscreen until I made my decision.
I could not locate the --bar term. However, when I did another test, the progress bar did run left to right
Re: dir2sfs
Posted: Fri Dec 30, 2022 7:56 pm
by stemsee
Yes, the timeout indicator always runs right to left.
Im glad its resolved.
stemsee
Re: dir2sfs
Posted: Sat Jun 01, 2024 11:44 pm
by AntonioPt
Hello guys this script has a small but that i still don't how to fix it
so i run it, then i stop it in the middle of the operation, gui close right but mksquashfs still working in background
Re: dir2sfs - Yad version
Posted: Sun Jun 02, 2024 2:17 am
by sonny
@radky, @stemsee
In BookwormPup64, the 'progress (%)' indicator no longer appears in the terminal.
You can only tell it's done when the text file pops up.
Re: dir2sfs
Posted: Fri Jun 07, 2024 11:02 am
by stemsee
AntonioPt wrote: ↑Sat Jun 01, 2024 11:44 pm
Hello guys this script has a small but that i still don't how to fix it
so i run it, then i stop it in the middle of the operation, gui close right but mksquashfs still working in background
This is the line to work on. Maybe test your kill command or pkill. See if /tmp/$$ contains the correct process id. Maybe increase the sleepto 1 in this line
Code: Select all
( sleep 0.5; pgrep -n mksquashfs >/tmp/$$ ) &
Re: dir2sfs - Yad version
Posted: Fri Jun 07, 2024 11:04 am
by stemsee
sonny wrote: ↑Sun Jun 02, 2024 2:17 am
@radky, @stemsee
In BookwormPup64, the 'progress (%)' indicator no longer appears in the terminal.
You can only tell it's done when the text file pops up.
This is a GUI version of dir2sfs, depends on yad.
Re: dir2sfs
Posted: Fri Jun 07, 2024 11:56 am
by AntonioPt
Gonna test it and see what is the Result thxx
stemsee wrote: ↑Fri Jun 07, 2024 11:02 am
AntonioPt wrote: ↑Sat Jun 01, 2024 11:44 pm
Hello guys this script has a small but that i still don't how to fix it
so i run it, then i stop it in the middle of the operation, gui close right but mksquashfs still working in background
This is the line to work on. Maybe test your kill command or pkill. See if /tmp/$$ contains the correct process id. Maybe increase the sleepto 1 in this line
Code: Select all
( sleep 0.5; pgrep -n mksquashfs >/tmp/$$ ) &
Re: dir2sfs - Yad version
Posted: Fri Jun 07, 2024 12:13 pm
by AntonioPt
hello @stemsee i add it more time and still nutting i all so add in the case killall mksquashfs
Re: dir2sfs - Yad version
Posted: Fri Jun 07, 2024 1:15 pm
by AntonioPt
Found the anser @stemsee
New code should look like this or at least in LunarPup its working since now i can grab real info
Code: Select all
( sleep 0.5; pgrep -n mksquashfs >/tmp/$$ ) &
(script -q -c "stty rows 40 cols 100; mksquashfs "$1" "$1.sfs" $COMP" | \
while read -n 100 LINE; do echo $LINE | busybox strings | egrep '[0-9]\%' | \
awk '{print $NF}'; done & ) | result=($( yad --progress --center --undecorated --on-top \
--skip-taskbar --progress-text="$(gettext 'Building') $1.sfs $COMP" --borders="10" \
--text-align="center" --button="$(gettext 'Stop'):1" \
--buttons-layout="center" --auto-close ))
ret=$?
# kill $(cat /tmp/$$)
case $ret in
1) killall mksquashfs
[[ -f "$1.sfs" ]] && rm -f $1.sfs
[[ -f "$1.sfs-md5.txt" ]] && rm -f "$1.sfs-md5.txt";;
esac
Re: dir2sfs - Yad version
Posted: Sat Jun 08, 2024 12:49 pm
by stemsee
that's not the best solution, because you might have another mksquashfs in progress!
Does your system have pgrep installed?
Re: dir2sfs - Yad version
Posted: Wed Jun 12, 2024 4:59 am
by AntonioPt
stemsee wrote: ↑Sat Jun 08, 2024 12:49 pm
that's not the best solution, because you might have another mksquashfs in progress!
Does your system have pgrep installed?
Sorry just Saw your post now and yes i have pgrep.
By the way since this machine is too slow i just can Run one mksquashsf at time but tell me a better way then
Re: dir2sfs - Yad version
Posted: Wed Jun 12, 2024 6:10 am
by stemsee
yes, your machine is slow so the mksquashfs command takes much longer to begin, so increase the sleep value to 4 or more seconds, so that mksquashfs is actually squashing files and has a process id to grab. But the script will never be changed for general use to 'killall mksquashfs'....of course you can make that change locally.
Re: dir2sfs - Yad version
Posted: Wed Jun 12, 2024 4:15 pm
by AntonioPt
OK small update
from my final code i change killall mksquashfs to original code kill $(cat /tmp/$$) in order to kill only this mksquashfs process and thxx for the Tip @stemsee
Code: Select all
case $ret in
1) kill $(cat /tmp/$$)
[[ -f "$1.sfs" ]] && rm -f $1.sfs
[[ -f "$1.sfs-md5.txt" ]] && rm -f "$1.sfs-md5.txt";;
esac